From 03e780c05ec580245c48aaf903deb0e5456bb8ef Mon Sep 17 00:00:00 2001 From: Jannik Pulfer Date: Tue, 5 Nov 2024 14:44:28 +0100 Subject: [PATCH] Shorten timeouts in tabbing tests, fix flaw in tab until method and set fail fast to false for matrix tests --- .github/workflows/frontend-test-action.yml | 1 + frontend/cypress/e2e/tab.cy.ts | 59 +++++++++++----------- frontend/cypress/support/commands.ts | 21 ++++---- 3 files changed, 42 insertions(+), 39 deletions(-) diff --git a/.github/workflows/frontend-test-action.yml b/.github/workflows/frontend-test-action.yml index 40389437eb..6df8c94757 100644 --- a/.github/workflows/frontend-test-action.yml +++ b/.github/workflows/frontend-test-action.yml @@ -41,6 +41,7 @@ jobs: needs: get-e2e-files runs-on: ubuntu-24.04 strategy: + fail-fast: false matrix: file: ${{ fromJSON(needs.get-e2e-files.outputs.file_list) }} steps: diff --git a/frontend/cypress/e2e/tab.cy.ts b/frontend/cypress/e2e/tab.cy.ts index 49b04dda1a..d8abaeb5fa 100644 --- a/frontend/cypress/e2e/tab.cy.ts +++ b/frontend/cypress/e2e/tab.cy.ts @@ -107,7 +107,7 @@ describe('Tab workflow tests', () => { function createNewObjectiveWithTab() { openCreateObjective(); - cy.wait(500); + cy.wait(150); cy.contains('erfassen'); cy.tabForward(); cy.focused().type('Objective by Cypress', { delay: 0 }); @@ -212,6 +212,7 @@ describe('Tab workflow tests', () => { cy.tabForward(); cy.tabForward(); cy.realPress('Enter'); + cy.contains('Objective von').should('not.exist'); cy.contains('Edited by Cypress'); }); @@ -220,7 +221,7 @@ describe('Tab workflow tests', () => { cy.realPress('ArrowDown'); cy.focused().contains('Objective duplizieren'); cy.realPress('Enter'); - cy.wait(500); + cy.wait(150); cy.contains('duplizieren'); cy.tabForward(); editInputFields('Duplicated by Cypress'); @@ -231,7 +232,7 @@ describe('Tab workflow tests', () => { cy.tabForward(); cy.focused().contains('Speichern'); cy.realPress('Enter'); - cy.wait(500); + cy.wait(150); cy.tabBackwardUntil('[data-testId="quarterFilter"]'); cy.focused().contains('GJ'); cy.realPress('ArrowDown'); @@ -244,7 +245,7 @@ describe('Tab workflow tests', () => { cy.realPress('ArrowDown'); cy.focused().contains('Objective abschliessen'); cy.realPress('Enter'); - cy.wait(500); + cy.wait(150); cy.contains('Objective abschliessen'); cy.contains('Objective erreicht'); cy.contains('Objective nicht erreicht'); @@ -272,7 +273,7 @@ describe('Tab workflow tests', () => { it('Delete objective with tab', () => { createNewObjectiveWithTab(); - cy.wait(500); + cy.wait(150); cy.get('.objective').last().focus(); cy.tabForwardUntil('[data-testId="three-dot-menu"]'); cy.focused().realPress('Enter'); @@ -282,7 +283,7 @@ describe('Tab workflow tests', () => { cy.tabForwardUntil('[data-testId="delete"]'); cy.focused().contains('Objective Löschen'); cy.realPress('Enter'); - cy.wait(500); + cy.wait(150); cy.tabForward(); cy.contains('Objective löschen'); cy.focused().contains('Ja'); @@ -303,11 +304,11 @@ describe('Tab workflow tests', () => { it('Edit key result with tab', () => { openKeyresultDetail(); - cy.wait(500); + cy.wait(150); cy.tabForwardUntil('[data-testId="edit-keyResult"]'); cy.focused().contains('Key Result bearbeiten'); cy.realPress('Enter'); - cy.wait(500); + cy.wait(150); cy.tabForward(); editInputFields('This has been edited by Cypress'); cy.tabForwardUntil('[data-testId="descriptionInput"]'); @@ -315,32 +316,32 @@ describe('Tab workflow tests', () => { cy.tabForwardUntil('[data-testId="submit"]'); cy.focused().contains('Speichern'); cy.realPress('Enter'); - cy.wait(500); + cy.wait(150); cy.contains('This has been edited by Cypress'); }); it('Delete key result with tab', () => { openKeyresultDetail(); - cy.wait(500); + cy.wait(150); cy.tabForwardUntil('[data-testId="edit-keyResult"]'); cy.focused().contains('Key Result bearbeiten'); cy.realPress('Enter'); - cy.wait(500); + cy.wait(150); cy.tabForwardUntil('[data-testId="delete-keyResult"]'); cy.focused().contains('Key Result löschen'); cy.realPress('Enter'); - cy.wait(500); + cy.wait(150); cy.tabForward(); cy.focused().contains('Ja'); cy.realPress('Enter'); - cy.wait(500); + cy.wait(150); cy.contains('This has been edited by Cypress').should('not.exist'); }); it('Create new key result metric with checkin and edit checkin with tab', () => { // Create keyresult openCreateKeyResult(); - cy.wait(500); + cy.wait(150); cy.tabForward(); cy.focused().type('KeyResult metric by Cypress', { delay: 0 }); cy.contains('Einheit'); @@ -358,7 +359,7 @@ describe('Tab workflow tests', () => { //Actionplan it('Create new key result with new actionplan', () => { openCreateKeyResult(); - cy.wait(500); + cy.wait(150); cy.tabForward(); cy.focused().type('KeyResult', { delay: 0 }); cy.tabForward(); @@ -391,7 +392,7 @@ describe('Tab workflow tests', () => { it('Edit actionplan of key result and change order of actions', () => { openKeyresultDetail(); - cy.wait(500); + cy.wait(150); cy.tabForwardUntil('[data-testId="edit-keyResult"]'); cy.focused().contains('Key Result bearbeiten'); cy.realPress('Enter'); @@ -409,7 +410,7 @@ describe('Tab workflow tests', () => { it('Edit actionplan of key result and delete action', () => { openKeyresultDetail(); - cy.wait(500); + cy.wait(150); cy.tabForwardUntil('[data-testId="edit-keyResult"]'); cy.focused().contains('Key Result bearbeiten'); cy.realPress('Enter'); @@ -428,7 +429,7 @@ describe('Tab workflow tests', () => { cy.tabForwardUntil('[data-testId="add-check-in"]'); cy.focused().contains('Check-in erfassen'); cy.realPress('Enter'); - cy.wait(500); + cy.wait(150); cy.tabForward(); cy.tabForward(); cy.tabForward(); @@ -442,14 +443,14 @@ describe('Tab workflow tests', () => { cy.tabForward(); cy.focused().contains('Check-in speichern'); cy.realPress('Enter'); - cy.wait(500); + cy.wait(150); // Edit checkin openCheckInHistory(); - cy.wait(500); + cy.wait(150); cy.tabForward(); cy.realPress('Enter'); - cy.wait(500); + cy.wait(150); cy.tabForward(); cy.tabForward(); cy.tabForward(); @@ -463,14 +464,14 @@ describe('Tab workflow tests', () => { cy.tabForward(); cy.focused().contains('Speichern'); cy.realPress('Enter'); - cy.wait(500); + cy.wait(150); cy.contains('Check-in by Cypress (edited)'); }); it('Create new key result ordinal with checkin and edit checkin with tab', () => { // Create keyresult openCreateKeyResult(); - cy.wait(500); + cy.wait(150); cy.tabForward(); // -> title cy.focused().type('KeyResult ordinal by Cypress', { delay: 0 }); cy.tabForward(); @@ -484,7 +485,7 @@ describe('Tab workflow tests', () => { cy.tabForward(); cy.focused().type('Stretch Goal', { delay: 0 }); fillInNewKeyResult(); - cy.wait(500); + cy.wait(150); cy.contains('KeyResult ordinal by Cypress'); // Create checkin @@ -492,24 +493,24 @@ describe('Tab workflow tests', () => { cy.tabForwardUntil('[data-testId="add-check-in"]'); cy.focused().contains('Check-in erfassen'); cy.realPress('Enter'); - cy.wait(500); + cy.wait(150); fillOutOrdinalCheckin('Check-in by Cypress'); cy.tabForward(); cy.focused().contains('Check-in speichern'); cy.realPress('Enter'); - cy.wait(500); + cy.wait(150); // Edit checkin openCheckInHistory(); - cy.wait(500); + cy.wait(150); cy.tabForward(); cy.realPress('Enter'); - cy.wait(500); + cy.wait(150); fillOutOrdinalCheckin('Check-in by Cypress (edited)'); cy.tabForward(); cy.focused().contains('Speichern'); cy.realPress('Enter'); - cy.wait(500); + cy.wait(150); cy.contains('Check-in by Cypress (edited)'); }); diff --git a/frontend/cypress/support/commands.ts b/frontend/cypress/support/commands.ts index 8a75492aba..4040e22dbb 100644 --- a/frontend/cypress/support/commands.ts +++ b/frontend/cypress/support/commands.ts @@ -225,16 +225,17 @@ Cypress.Commands.add( }, ); -function doUntil(selector: string, tab: () => void, limit: number = 100) { - for (let i = 0; i < limit; i++) { - cy.focused().then((element) => { - if (element.get(0).matches(selector)) { - return; - } else { - tab(); - } - }); - } +function doUntil(selector: string, tab: () => void, limit: number = 100, count: number = 0) { + if (count >= limit) return; + + cy.focused().then((element) => { + if (element.get(0).matches(selector)) { + return; + } else { + tab(); + doUntil(selector, tab, limit, count + 1); + } + }); } function setConfidence(confidence: number) {