Skip to content

Commit ecfc59c

Browse files
committed
Modify DeleteWithConfirmButton tests to check dialog is closed
1 parent 357b557 commit ecfc59c

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

packages/ra-ui-materialui/src/button/DeleteWithConfirmButton.spec.tsx

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ describe('<DeleteWithConfirmButton />', () => {
9696

9797
it('should allow to override the resource', async () => {
9898
const dataProvider = testDataProvider({
99-
// @ts-ignore
10099
getOne: () =>
100+
// @ts-ignore
101101
Promise.resolve({
102102
data: { id: 123, title: 'lorem' },
103103
}),
@@ -137,8 +137,8 @@ describe('<DeleteWithConfirmButton />', () => {
137137

138138
it('should allows to undo the deletion after confirmation if mutationMode is undoable', async () => {
139139
const dataProvider = testDataProvider({
140-
// @ts-ignore
141140
getOne: () =>
141+
// @ts-ignore
142142
Promise.resolve({
143143
data: { id: 123, title: 'lorem' },
144144
}),
@@ -182,8 +182,8 @@ describe('<DeleteWithConfirmButton />', () => {
182182

183183
it('should allow to override the success side effects', async () => {
184184
const dataProvider = testDataProvider({
185-
// @ts-ignore
186185
getOne: () =>
186+
// @ts-ignore
187187
Promise.resolve({
188188
data: { id: 123, title: 'lorem' },
189189
}),
@@ -226,13 +226,17 @@ describe('<DeleteWithConfirmButton />', () => {
226226
{ snapshot: [] }
227227
);
228228
});
229+
await waitFor(() => {
230+
// Check that the dialog is closed
231+
expect(screen.queryByText('ra.action.confirm')).toBeNull();
232+
});
229233
});
230234

231235
it('should allow to override the error side effects', async () => {
232236
jest.spyOn(console, 'error').mockImplementation(() => {});
233237
const dataProvider = testDataProvider({
234-
// @ts-ignore
235238
getOne: () =>
239+
// @ts-ignore
236240
Promise.resolve({
237241
data: { id: 123, title: 'lorem' },
238242
}),
@@ -275,12 +279,16 @@ describe('<DeleteWithConfirmButton />', () => {
275279
{ snapshot: [] }
276280
);
277281
});
282+
await waitFor(() => {
283+
// Check that the dialog is closed
284+
expect(screen.queryByText('ra.action.confirm')).toBeNull();
285+
});
278286
});
279287

280288
it('should allow to override the translateOptions props', async () => {
281289
const dataProvider = testDataProvider({
282-
// @ts-ignore
283290
getOne: () =>
291+
// @ts-ignore
284292
Promise.resolve({
285293
data: { id: 123, title: 'lorem' },
286294
}),
@@ -322,8 +330,8 @@ describe('<DeleteWithConfirmButton />', () => {
322330
it('should display success message after successful deletion', async () => {
323331
const successMessage = 'Test Message';
324332
const dataProvider = testDataProvider({
325-
// @ts-ignore
326333
getOne: () =>
334+
// @ts-ignore
327335
Promise.resolve({
328336
data: { id: 123, title: 'lorem' },
329337
}),

0 commit comments

Comments
 (0)