Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test for #9655 #9659

Draft
wants to merge 24 commits into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
0fb4007
Test for #9655
Dreamsorcerer Feb 11, 2024
86d3093
Update BulkUpdateWithConfirmButton.spec.tsx
Dreamsorcerer Feb 11, 2024
e8c4369
Update BulkUpdateWithConfirmButton.spec.tsx
Dreamsorcerer Feb 11, 2024
eb2df6b
Update BulkUpdateWithConfirmButton.spec.tsx
Dreamsorcerer Feb 11, 2024
da327b5
Update BulkUpdateWithConfirmButton.spec.tsx
Dreamsorcerer Feb 11, 2024
13bc7be
Update BulkUpdateWithConfirmButton.spec.tsx
Dreamsorcerer Feb 11, 2024
a942ae2
Update BulkUpdateWithConfirmButton.spec.tsx
Dreamsorcerer Feb 11, 2024
311ef57
Update BulkUpdateWithConfirmButton.spec.tsx
Dreamsorcerer Feb 11, 2024
e611de5
Update BulkUpdateWithConfirmButton.spec.tsx
Dreamsorcerer Feb 11, 2024
d2b0dec
Update BulkUpdateWithConfirmButton.spec.tsx
Dreamsorcerer Feb 11, 2024
6dd1673
Update BulkUpdateWithConfirmButton.spec.tsx
Dreamsorcerer Feb 11, 2024
253a8f9
Update BulkUpdateWithConfirmButton.spec.tsx
Dreamsorcerer Feb 24, 2024
cf61720
Update BulkUpdateWithConfirmButton.spec.tsx
Dreamsorcerer Feb 24, 2024
21770b9
Update BulkUpdateWithConfirmButton.spec.tsx
Dreamsorcerer Feb 24, 2024
87882c8
Update BulkUpdateWithConfirmButton.spec.tsx
Dreamsorcerer Feb 24, 2024
ae5b685
Update BulkUpdateWithConfirmButton.spec.tsx
Dreamsorcerer Feb 24, 2024
f81d292
Update BulkUpdateWithConfirmButton.spec.tsx
Dreamsorcerer Feb 24, 2024
2c2baf6
Update BulkUpdateWithConfirmButton.spec.tsx
Dreamsorcerer Feb 24, 2024
cecb441
Update BulkUpdateWithConfirmButton.spec.tsx
Dreamsorcerer Feb 24, 2024
25523de
Update BulkUpdateWithConfirmButton.spec.tsx
Dreamsorcerer Feb 24, 2024
5cf525c
Update BulkUpdateWithConfirmButton.spec.tsx
Dreamsorcerer Feb 24, 2024
e144f11
Update BulkUpdateWithConfirmButton.spec.tsx
Dreamsorcerer Feb 24, 2024
9485242
Update BulkUpdateWithConfirmButton.spec.tsx
Dreamsorcerer Feb 24, 2024
102c910
Update BulkUpdateWithConfirmButton.spec.tsx
Dreamsorcerer Apr 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -0,0 +1,72 @@
import * as React from 'react';
import {
fireEvent,
render,
screen,
waitFor,
within,
} from '@testing-library/react';
import expect from 'expect';
import {
CoreAdminContext,
ListBase,
ResourceContextProvider,
testDataProvider,
} from 'ra-core';
import { createTheme, ThemeProvider } from '@mui/material/styles';

import { BulkUpdateWithConfirmButton } from './BulkUpdateWithConfirmButton';
import { Datagrid } from '../list';
import { TextField } from '../field';

const theme = createTheme();

describe('<BulkUpdateWithConfirmButton />', () => {
it('should close the confirmation dialog after confirm', async () => {
const record = { id: 123, title: 'lorem' };
const dataProvider = testDataProvider({
getList: () => Promise.resolve({ data: [record], total: 1 }),
getMany: () => Promise.resolve({ data: [record] }),
getOne: () => Promise.resolve({ data: record }),
updateMany: p => {
record.title = p.data.title;
return p.ids;
},
});
const ActionButtons = () => (
<>
<BulkUpdateWithConfirmButton
data={{ title: 'foobar' }}
mutationMode="pessimistic"
/>
</>
);
render(
<ThemeProvider theme={theme}>
<CoreAdminContext dataProvider={dataProvider}>
<ResourceContextProvider value="posts">
<ListBase value={{ selectedIds: [123] }}>
<Datagrid bulkActionButtons={<ActionButtons />}>
<TextField source="title" />
</Datagrid>
</ListBase>
</ResourceContextProvider>
</CoreAdminContext>
</ThemeProvider>
);
expect(await screen.findByText('lorem')).toBeDefined();
const checkContainer = screen.getAllByRole('columnheader')[0];
const check = within(checkContainer).getByRole('checkbox');
fireEvent.click(check);

fireEvent.click(screen.getByLabelText('ra.action.update'));
screen.debug(undefined, Infinity);
expect(await screen.findByText('ra.message.bulk_update_title')).toBeDefined();

Check failure on line 64 in packages/ra-ui-materialui/src/button/BulkUpdateWithConfirmButton.spec.tsx

View workflow job for this annotation

GitHub Actions / typecheck

Replace `await·screen.findByText('ra.message.bulk_update_title')` with `⏎············await·screen.findByText('ra.message.bulk_update_title')⏎········`

Check failure on line 64 in packages/ra-ui-materialui/src/button/BulkUpdateWithConfirmButton.spec.tsx

View workflow job for this annotation

GitHub Actions / typecheck

Replace `await·screen.findByText('ra.message.bulk_update_title')` with `⏎············await·screen.findByText('ra.message.bulk_update_title')⏎········`
fireEvent.click(screen.getByText('ra.action.confirm'));

await waitFor(() => {
expect(screen.queryByText('ra.message.bulk_update_title')).toBeNull();

Check failure on line 68 in packages/ra-ui-materialui/src/button/BulkUpdateWithConfirmButton.spec.tsx

View workflow job for this annotation

GitHub Actions / typecheck

Replace `screen.queryByText('ra.message.bulk_update_title')` with `⏎················screen.queryByText('ra.message.bulk_update_title')⏎············`

Check failure on line 68 in packages/ra-ui-materialui/src/button/BulkUpdateWithConfirmButton.spec.tsx

View workflow job for this annotation

GitHub Actions / typecheck

Replace `screen.queryByText('ra.message.bulk_update_title')` with `⏎················screen.queryByText('ra.message.bulk_update_title')⏎············`
});
expect(screen.getByText('foobar')).toBeDefined();
});
});