Skip to content

Commit

Permalink
Shorten timeouts in tabbing tests, fix flaw in tab until method and s…
Browse files Browse the repository at this point in the history
…et fail fast to false for matrix tests
  • Loading branch information
RandomTannenbaum committed Nov 5, 2024
1 parent ff21a16 commit 03e780c
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 39 deletions.
1 change: 1 addition & 0 deletions .github/workflows/frontend-test-action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
59 changes: 30 additions & 29 deletions frontend/cypress/e2e/tab.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand Down Expand Up @@ -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');
});

Expand All @@ -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');
Expand All @@ -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');
Expand All @@ -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');
Expand Down Expand Up @@ -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');
Expand All @@ -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');
Expand All @@ -303,44 +304,44 @@ 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"]');
editInputFields('Description of Cypress');
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');
Expand All @@ -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();
Expand Down Expand Up @@ -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');
Expand All @@ -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');
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -484,32 +485,32 @@ 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
cy.getByTestId('keyresult').contains('KeyResult ordinal by Cypress').click();
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)');
});

Expand Down
21 changes: 11 additions & 10 deletions frontend/cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 03e780c

Please sign in to comment.