feat: add reusable prompt dialogs for frontend forms

This commit is contained in:
cesnimda
2026-03-22 14:14:29 +01:00
parent 758d2c6a0b
commit abac48847c
6 changed files with 134 additions and 8 deletions
+26
View File
@@ -0,0 +1,26 @@
import React from 'react';
import '@testing-library/jest-dom';
import { render, screen, fireEvent } from '@testing-library/react';
import { ConfirmProvider, useConfirm } from './confirm';
function Demo() {
const { confirm } = useConfirm();
return (
<button onClick={() => void confirm({ title: 'Delete job', message: 'Are you sure?', confirmLabel: 'Delete', destructive: true })}>
Open confirm
</button>
);
}
test('renders app-owned confirmation dialog', async () => {
render(
<ConfirmProvider>
<Demo />
</ConfirmProvider>,
);
fireEvent.click(screen.getByRole('button', { name: /open confirm/i }));
expect(await screen.findByText(/are you sure/i)).toBeInTheDocument();
expect(screen.getByRole('button', { name: /delete/i })).toBeInTheDocument();
});