From 01a2705f82fb43f14d08fde760b742e79c3ddfb2 Mon Sep 17 00:00:00 2001 From: Simona Domnisoru Date: Mon, 2 Oct 2023 10:49:42 +0200 Subject: [PATCH 1/3] fix: navigation with program stage filter --- .../TeiWorkingListsReduxProvider.container.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/core_modules/capture-core/components/WorkingLists/TeiWorkingLists/ReduxProvider/TeiWorkingListsReduxProvider.container.js b/src/core_modules/capture-core/components/WorkingLists/TeiWorkingLists/ReduxProvider/TeiWorkingListsReduxProvider.container.js index 1017f47dcd..2516e630a1 100644 --- a/src/core_modules/capture-core/components/WorkingLists/TeiWorkingLists/ReduxProvider/TeiWorkingListsReduxProvider.container.js +++ b/src/core_modules/capture-core/components/WorkingLists/TeiWorkingLists/ReduxProvider/TeiWorkingListsReduxProvider.container.js @@ -47,9 +47,11 @@ export const TeiWorkingListsReduxProvider = ({ }, [dispatch, programId, storeId, selectedTemplateId]); useEffect(() => { - selectedTemplateId && onSelectTemplate && onSelectTemplate(selectedTemplateId); - // eslint-disable-next-line react-hooks/exhaustive-deps - }, []); + selectedTemplateId && + selectedTemplateId !== `${programId}-default` && + onSelectTemplate && + onSelectTemplate(selectedTemplateId); + }, [selectedTemplateId, programId, onSelectTemplate]); const onSelectListRow = useCallback(({ id }) => { const record = records[id]; From 814e99ea14fe0febfbdb95f72edaddb539713596 Mon Sep 17 00:00:00 2001 From: Simona Domnisoru Date: Wed, 4 Oct 2023 08:10:55 +0200 Subject: [PATCH 2/3] test: [DHIS2-15782] add scenario for navigation --- .../TeiWorkingListsUser.feature | 7 ++++ .../TeiWorkingListsUser/index.js | 39 +++++++++++++++++++ .../TeiWorkingListsReduxProvider.container.js | 3 +- 3 files changed, 48 insertions(+), 1 deletion(-) diff --git a/cypress/integration/WorkingLists/TeiWorkingLists/TeiWorkingListsUser.feature b/cypress/integration/WorkingLists/TeiWorkingLists/TeiWorkingListsUser.feature index d3f07adfe2..b0bdfef1e0 100644 --- a/cypress/integration/WorkingLists/TeiWorkingLists/TeiWorkingListsUser.feature +++ b/cypress/integration/WorkingLists/TeiWorkingLists/TeiWorkingListsUser.feature @@ -186,6 +186,13 @@ And you select the events scheduled today And you apply the current filter Then you see the selected option in the scheduledAt filter +@v>=39 +Scenario: The program stage working list configureation is kept when navigating +Given you open the main page with Ngelehun and WHO RMNCH Tracker context and configure a program stage working list +When you open an enrollment event from the working list +And you go back using the browser button +Then the program stage working list is loaded + @v>=40 Scenario: The user creates, updates and deletes a Program stage custom working list Given you open the main page with Ngelehun and Malaria case diagnosis and Household investigation context diff --git a/cypress/integration/WorkingLists/TeiWorkingLists/TeiWorkingListsUser/index.js b/cypress/integration/WorkingLists/TeiWorkingLists/TeiWorkingListsUser/index.js index 7e5825c8a1..760319bfba 100644 --- a/cypress/integration/WorkingLists/TeiWorkingLists/TeiWorkingListsUser/index.js +++ b/cypress/integration/WorkingLists/TeiWorkingLists/TeiWorkingListsUser/index.js @@ -760,3 +760,42 @@ Then('the program stage custom working list filters are loaded', () => { .should('have.length', 2); }); +Given('you open the main page with Ngelehun and WHO RMNCH Tracker context and configure a program stage working list', () => { + cy.visit('#/?programId=WSGAb5XwJ3Y&orgUnitId=DiszpKrYNg8'); + cy.get('[data-test="template-selector-create-list"]') + .click(); + + cy.get('[data-test="tei-working-lists"]') + .within(() => { + cy.contains('More filters') + .click(); + cy.contains('Program stage') + .click(); + }); + + cy.get('[data-test="list-view-filter-contents"]') + .contains('Postpartum care visit') + .click(); + + cy.get('[data-test="list-view-filter-apply-button"]') + .click(); +}); + +When('you open an enrollment event from the working list', () => { + cy.contains('Linda') + .click(); +}); + +When('you go back using the browser button', () => { + cy.go('back'); +}); + +Then('the program stage working list is loaded', () => { + cy.get('[data-test="tei-working-lists"]') + .find('[data-test="more-filters"]') + .should('have.length', 2); + + cy.get('[data-test="tei-working-lists"]') + .contains('WHOMCH Hemoglobin value') + .should('exist'); +}); diff --git a/src/core_modules/capture-core/components/WorkingLists/TeiWorkingLists/ReduxProvider/TeiWorkingListsReduxProvider.container.js b/src/core_modules/capture-core/components/WorkingLists/TeiWorkingLists/ReduxProvider/TeiWorkingListsReduxProvider.container.js index 2516e630a1..b5ac794c5d 100644 --- a/src/core_modules/capture-core/components/WorkingLists/TeiWorkingLists/ReduxProvider/TeiWorkingListsReduxProvider.container.js +++ b/src/core_modules/capture-core/components/WorkingLists/TeiWorkingLists/ReduxProvider/TeiWorkingListsReduxProvider.container.js @@ -51,7 +51,8 @@ export const TeiWorkingListsReduxProvider = ({ selectedTemplateId !== `${programId}-default` && onSelectTemplate && onSelectTemplate(selectedTemplateId); - }, [selectedTemplateId, programId, onSelectTemplate]); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, []); const onSelectListRow = useCallback(({ id }) => { const record = records[id]; From 13d0063c6cdd2c825c558064381404bbf1ecd4d8 Mon Sep 17 00:00:00 2001 From: Simona Domnisoru Date: Thu, 5 Oct 2023 09:58:06 +0200 Subject: [PATCH 3/3] test: [DHIS2-15782] checks for viewPreloaded and currentTempleteId --- .../TeiWorkingListsReduxProvider.container.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/core_modules/capture-core/components/WorkingLists/TeiWorkingLists/ReduxProvider/TeiWorkingListsReduxProvider.container.js b/src/core_modules/capture-core/components/WorkingLists/TeiWorkingLists/ReduxProvider/TeiWorkingListsReduxProvider.container.js index b5ac794c5d..b0fed150a7 100644 --- a/src/core_modules/capture-core/components/WorkingLists/TeiWorkingLists/ReduxProvider/TeiWorkingListsReduxProvider.container.js +++ b/src/core_modules/capture-core/components/WorkingLists/TeiWorkingLists/ReduxProvider/TeiWorkingListsReduxProvider.container.js @@ -38,6 +38,8 @@ export const TeiWorkingListsReduxProvider = ({ onDeleteTemplate, onUpdateDefaultTemplate, programStage, + currentTemplateId, + viewPreloaded, ...commonStateManagementProps } = useWorkingListsCommonStateManagement(storeId, TEI_WORKING_LISTS_TYPE, program); const dispatch = useDispatch(); @@ -47,12 +49,15 @@ export const TeiWorkingListsReduxProvider = ({ }, [dispatch, programId, storeId, selectedTemplateId]); useEffect(() => { - selectedTemplateId && - selectedTemplateId !== `${programId}-default` && - onSelectTemplate && - onSelectTemplate(selectedTemplateId); - // eslint-disable-next-line react-hooks/exhaustive-deps - }, []); + // This hook should only fire when you navigate from the search page to the main page with a working list selected + if (selectedTemplateId && + selectedTemplateId !== currentTemplateId && + !viewPreloaded && + onSelectTemplate + ) { + onSelectTemplate(selectedTemplateId); + } + }, [selectedTemplateId, viewPreloaded, currentTemplateId, onSelectTemplate]); const onSelectListRow = useCallback(({ id }) => { const record = records[id]; @@ -95,6 +100,8 @@ export const TeiWorkingListsReduxProvider = ({ return (