Skip to content

Commit

Permalink
Try to make driving list test more stable
Browse files Browse the repository at this point in the history
  • Loading branch information
lotorvik committed Nov 28, 2024
1 parent 11f17e0 commit 8810737
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions packages/fyllut/cypress/e2e/components/driving-list.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ describe('DrivingList', () => {
cy.configMocksServer();
});

after(() => {
cy.mocksRestoreRouteVariants();
});

describe('paper', () => {
beforeEach(() => {
cy.defaultIntercepts();
Expand All @@ -40,8 +36,9 @@ describe('DrivingList', () => {
cy.clickNextStep();

// Unstable test. Try and solve this with dirty timeout...
cy.get('[data-cy=error-summary]', { timeout: 10000 })
cy.findByRole('heading', { name: 'For å gå videre må du rette opp følgende:' })
.should('exist')
.parent()
.within(() => {
cy.findByRole('link', { name: `Du må fylle ut: ${DATE_PICKER_LABEL}` })
.should('exist')
Expand All @@ -57,16 +54,17 @@ describe('DrivingList', () => {
cy.findByRole('textbox', { name: PARKING_EXPENSES_LABEL }).clear();
cy.findByRole('textbox', { name: PARKING_EXPENSES_LABEL }).type('text');
cy.clickNextStep();
cy.get('[data-cy=error-summary]')
cy.findByRole('heading', { name: 'For å gå videre må du rette opp følgende:' })
.should('exist')
.parent()
.within(() => {
cy.findByRole('link', { name: 'Parkeringsutgiftene for 15.05.2023 må være et gyldig beløp' })
.should('exist')
.click();
});

cy.findByRole('textbox', { name: PARKING_EXPENSES_LABEL }).should('have.focus').type('{selectall}78');
cy.get('[data-cy=error-summary]').should('not.exist');
cy.findByRole('heading', { name: 'For å gå videre må du rette opp følgende:' }).should('not.exist');

// Parking expenses should not show even with value over 100
cy.findByRole('textbox', { name: PARKING_EXPENSES_LABEL }).should('exist').type('101');
Expand Down Expand Up @@ -139,15 +137,12 @@ describe('DrivingList', () => {

describe('digital', () => {
beforeEach(() => {
cy.mocksRestoreRouteVariants();
cy.defaultInterceptsMellomlagring();
cy.defaultInterceptsExternal();
cy.defaultIntercepts();
});

afterEach(() => {
cy.mocksRestoreRouteVariants();
});

it('should fill out form and show data in summary', () => {
cy.visit(`/fyllut/testdrivinglist?sub=digital`);
cy.defaultWaits();
Expand Down

0 comments on commit 8810737

Please sign in to comment.