Skip to content

Commit

Permalink
Merge pull request #7136 from thdk/fix/admin-test
Browse files Browse the repository at this point in the history
Fix failing admin test when running all tests together
  • Loading branch information
fzaninotto committed Jan 25, 2022
2 parents a1c602c + c53e214 commit a03108f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 16 deletions.
32 changes: 17 additions & 15 deletions packages/ra-no-code/src/Admin.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,35 @@ import { ApplicationContext } from './ApplicationContext';

describe('Admin', () => {
it('should be functional', async () => {
const customers = fs.readFileSync(
const customersPromise = fs.promises.readFile(
path.resolve(__dirname, '../assets/ra-customers.csv'),
{
encoding: 'utf-8',
}
);
const orders1 = fs.readFileSync(
const orders1Promise = fs.promises.readFile(
path.resolve(__dirname, '../assets/ra-orders-1.csv'),
{
encoding: 'utf-8',
}
);
const orders2 = fs.readFileSync(
const orders2Promise = fs.promises.readFile(
path.resolve(__dirname, '../assets/ra-orders-2.csv'),
{
encoding: 'utf-8',
}
);

const [customers, orders1, orders2] = await Promise.all([
customersPromise,
orders1Promise,
orders2Promise,
]);

let file = new File([customers], 'customers.csv', {
type: 'text/csv',
});
const { getByLabelText, getByText, getByDisplayValue } = render(
const { getByLabelText, getByText, findByDisplayValue } = render(
<ApplicationContext.Provider
value={{
application: { name: 'test', created_at: new Date() },
Expand All @@ -43,9 +49,7 @@ describe('Admin', () => {

userEvents.upload(getByLabelText('CSV File'), file);

await waitFor(() => {
getByDisplayValue('customers');
});
await findByDisplayValue('customers');

fireEvent.click(getByText('Import'));

Expand Down Expand Up @@ -79,9 +83,8 @@ describe('Admin', () => {
});
userEvents.upload(getByLabelText('CSV File'), file);

await waitFor(() => {
getByDisplayValue('orders');
});
await findByDisplayValue('orders');

fireEvent.click(getByText('Import'));

await waitFor(() => {
Expand All @@ -108,10 +111,9 @@ describe('Admin', () => {
});
userEvents.upload(getByLabelText('CSV File'), file);

await waitFor(() => {
getByDisplayValue('orders2');
});
fireEvent.change(getByDisplayValue('orders2'), {
const order2El = await findByDisplayValue('orders2');

fireEvent.change(order2El, {
target: { value: 'orders' },
});
fireEvent.click(getByText('Import'));
Expand All @@ -120,5 +122,5 @@ describe('Admin', () => {
getByText('Orders', { selector: '#react-admin-title *' });
getByText('1-10 of 12');
});
});
}, 10000);
});
6 changes: 5 additions & 1 deletion packages/ra-no-code/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
"rootDir": "src",
"declaration": true,
"declarationMap": true,
"allowJs": false
"allowJs": false,
"types": [
"jest",
"@types/node"
]
},
"exclude": ["**/*.spec.ts", "**/*.spec.tsx", "**/*.spec.js"],
"include": ["src"]
Expand Down

0 comments on commit a03108f

Please sign in to comment.