From ebe67c26df7ba4a7a4162816b881ac003f140526 Mon Sep 17 00:00:00 2001 From: Simona Domnisoru Date: Wed, 27 Sep 2023 10:49:54 +0200 Subject: [PATCH] chore: [TECH-1644] flaky custom program stage working list tests (#3420) --- .../TeiWorkingListsUser.feature | 2 +- .../TeiWorkingListsUser/index.js | 20 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/cypress/integration/WorkingLists/TeiWorkingLists/TeiWorkingListsUser.feature b/cypress/integration/WorkingLists/TeiWorkingLists/TeiWorkingListsUser.feature index fe69bbc858..d3f07adfe2 100644 --- a/cypress/integration/WorkingLists/TeiWorkingLists/TeiWorkingListsUser.feature +++ b/cypress/integration/WorkingLists/TeiWorkingLists/TeiWorkingListsUser.feature @@ -233,7 +233,7 @@ And the Custom Program stage list is deleted @v>=40 Scenario: The user can save a program stage working list, based on a TEI working list configuration -Given you open the main page with Ngelehun and Malaria focus investigation context +Given you open a clean main page with Ngelehun and Malaria focus investigation context Then you see the custom TEI working lists And you can load the view with the name Ongoing foci responses And you open the program stage filters from the more filters dropdown menu diff --git a/cypress/integration/WorkingLists/TeiWorkingLists/TeiWorkingListsUser/index.js b/cypress/integration/WorkingLists/TeiWorkingLists/TeiWorkingListsUser/index.js index dedb6cd458..974685a855 100644 --- a/cypress/integration/WorkingLists/TeiWorkingLists/TeiWorkingListsUser/index.js +++ b/cypress/integration/WorkingLists/TeiWorkingLists/TeiWorkingListsUser/index.js @@ -2,6 +2,19 @@ import { v4 as uuid } from 'uuid'; import '../../sharedSteps'; import '../../../sharedSteps'; +const cleanUpIfApplicable = () => { + cy.buildApiUrl('programStageWorkingLists?filter=program.id:eq:qDkgAbB5Jlk&fields=id,displayName') + .then(url => cy.request(url)) + .then(({ body }) => { + const workingList = body.programStageWorkingLists?.find(e => e.displayName === 'Custom Program stage list'); + if (!workingList) { + return null; + } + return cy + .buildApiUrl('programStageWorkingLists', workingList.id) + .then(workingListUrl => cy.request('DELETE', workingListUrl)); + }); +}; Given('you open the main page with Ngelehun and child programme context', () => { cy.visit('#/?programId=IpHINAT79UW&orgUnitId=DiszpKrYNg8'); }); @@ -42,6 +55,7 @@ Given('you open the main page with Ngelehun and Malaria case diagnosis context', }); Given('you open the main page with Ngelehun and Malaria case diagnosis and Household investigation context', () => { + cleanUpIfApplicable(); cy.visit('#/?programId=qDkgAbB5Jlk&orgUnitId=DiszpKrYNg8'); cy.get('[data-test="tei-working-lists"]') @@ -60,6 +74,11 @@ Given('you open the main page with Ngelehun and Malaria case diagnosis and House .click(); }); +Given('you open a clean main page with Ngelehun and Malaria focus investigation context', () => { + cleanUpIfApplicable(); + cy.visit('#/?programId=M3xtLkYBlKI&orgUnitId=DiszpKrYNg8'); +}); + Then('the default working list should be displayed', () => { const names = [ 'Filona', @@ -740,3 +759,4 @@ Then('the program stage custom working list filters are loaded', () => { .find('[data-test="more-filters"]') .should('have.length', 2); }); +