From ec5767d01023c832de102a80d1045ef07cb75362 Mon Sep 17 00:00:00 2001 From: Simona Domnisoru Date: Tue, 26 Sep 2023 13:26:27 +0200 Subject: [PATCH] fix: flaky custom program stage working list tests --- .../TeiWorkingLists/TeiWorkingListsUser/index.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/cypress/integration/WorkingLists/TeiWorkingLists/TeiWorkingListsUser/index.js b/cypress/integration/WorkingLists/TeiWorkingLists/TeiWorkingListsUser/index.js index dedb6cd458..9e277a8ff0 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'); }); @@ -13,6 +26,7 @@ Given('you open the main page with Ngelehun and WHO RMNCH Tracker context', () = }); Given('you open the main page with Ngelehun and Malaria focus investigation context', () => { + cleanUpIfApplicable(); cy.visit('#/?programId=M3xtLkYBlKI&orgUnitId=DiszpKrYNg8'); }); @@ -42,6 +56,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"]') @@ -740,3 +755,4 @@ Then('the program stage custom working list filters are loaded', () => { .find('[data-test="more-filters"]') .should('have.length', 2); }); +