Skip to content

Commit

Permalink
fix e2e tests (slow because of the numerous calls to getManyReference)
Browse files Browse the repository at this point in the history
  • Loading branch information
slax57 committed Jun 28, 2024
1 parent 56bae46 commit c1a124a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
27 changes: 19 additions & 8 deletions cypress/e2e/lists.cy.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { login } from './login';

const getPaginationText = () => cy.findByText(/\d+-\d+ of \d+/);
const getPaginationText = () =>
cy.findByText(/\d+-\d+ of \d+/, { timeout: 10000 });

describe('Lists', () => {
it('should render a list', () => {
Expand All @@ -17,7 +18,7 @@ describe('Lists', () => {
getPaginationText().then(el => {
const count = parseInt(el.text().split('of')[1].trim());

cy.findByText('Before last month').click();
cy.findByText('Earlier').click();
// Use should here to allow built-in retry as it may take a few ms for the list to update
getPaginationText().should(el => {
const countFiltered = parseInt(el.text().split('of')[1].trim());
Expand Down Expand Up @@ -65,8 +66,6 @@ describe('Lists', () => {
cy.visit('/');
login();
cy.findByText('Contacts').click();
cy.findByRole('button', { name: /rows per page/i }).click();
cy.findByRole('option', { name: '10' }).click();
getPaginationText().then(el => {
const page = parseInt(el.text().split('-')[0].trim());
cy.findByLabelText('Go to page 4').click();
Expand All @@ -93,11 +92,23 @@ describe('Lists', () => {
cy.visit('/');
login();
cy.findByText('Contacts').click();
cy.findAllByText(/\d+ days? ago/).should('have.length.greaterThan', 0);
cy.findAllByText(/\d+ years? ago/).should('have.length', 0);
cy.findAllByText(/\d+ days? ago/, { timeout: 10000 }).should(
'have.length.greaterThan',
0
);
cy.findAllByText(/\d+ years? ago/, { timeout: 10000 }).should(
'have.length',
0
);
cy.findByText('Sort by Last seen descending').click();
cy.findByText('Last seen ascending').click();
cy.findAllByText(/\d+ days? ago/).should('have.length', 0);
cy.findAllByText(/\d+ years? ago/).should('have.length.greaterThan', 0);
cy.findAllByText(/\d+ days? ago/, { timeout: 10000 }).should(
'have.length',
0
);
cy.findAllByText(/\d+ years? ago/, { timeout: 10000 }).should(
'have.length.greaterThan',
0
);
});
});
2 changes: 1 addition & 1 deletion packages/demo/src/contacts/ContactList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export const ContactList = () => {
<RaList
actions={<ContactListActions />}
aside={<ContactListFilter />}
perPage={25}
perPage={10}
pagination={<Pagination rowsPerPageOptions={[10, 25, 50, 100]} />}
filterDefaultValues={{ sales_id: identity?.id }}
sort={{ field: 'last_seen', order: 'DESC' }}
Expand Down

0 comments on commit c1a124a

Please sign in to comment.