From 294a8f2fc30fa5f050d13e508ae7e00f95a166da Mon Sep 17 00:00:00 2001 From: eirikhaugstulen Date: Thu, 10 Oct 2024 15:20:14 +0200 Subject: [PATCH 1/3] fix: persist working list on navigate --- .../TeiWorkingListsUser.feature | 619 +++++++++--------- .../TeiWorkingListsUser.js | 21 +- .../Pages/MainPage/MainPage.container.js | 24 +- 3 files changed, 354 insertions(+), 310 deletions(-) diff --git a/cypress/e2e/WorkingLists/TeiWorkingLists/TeiWorkingListsUser/TeiWorkingListsUser.feature b/cypress/e2e/WorkingLists/TeiWorkingLists/TeiWorkingListsUser/TeiWorkingListsUser.feature index 3bf9fbfaf8..db142862ee 100644 --- a/cypress/e2e/WorkingLists/TeiWorkingLists/TeiWorkingListsUser/TeiWorkingListsUser.feature +++ b/cypress/e2e/WorkingLists/TeiWorkingLists/TeiWorkingListsUser/TeiWorkingListsUser.feature @@ -8,311 +8,316 @@ Feature: User interacts with tei working lists When you change the sharing settings Then you see the new sharing settings -Scenario: User opens the default working list for a tracker program -Given you open the main page with Ngelehun and child programe context -Then the default working list should be displayed -And rows per page should be set to 15 -And for a tracker program the page navigation should show that you are on the first page - -Scenario: Show only teis with completed enrollments using the predefined working list -Given you open the main page with Ngelehun and child programe context -When you select the working list called completed enrollments -Then the enrollment status filter button should show that the completed filter is in effect -And the list should display teis with a completed enrollment -And rows per page should be set to 15 -And for a tracker program the page navigation should show that you are on the first page - -Scenario: Show only teis with completed enrollments using the filter -Given you open the main page with Ngelehun and child programe context -When you set the enrollment status filter to completed -And you apply the current filter -Then the enrollment status filter button should show that the completed filter is in effect -And the list should display teis with a completed enrollment -And rows per page should be set to 15 -And for a tracker program the page navigation should show that you are on the first page - -# DHIS2-13960: /trackedEntities filter by assignee results are not consistent -@skip -Scenario: Show only teis with active enrollments and unassinged events using the filter -Given you open the main page with Ngelehun and Malaria focus investigation context -When you set the enrollment status filter to active -And you apply the current filter -And you set the assginee filter to None -And you apply the current filter -Then the enrollment status filter button should show that the active filter is in effect -And the assignee filter button should show that None filter is in effect -And the list should display teis with an active enrollment and unassinged events -And rows per page should be set to 15 -And for a tracker program the page navigation should show that you are on the first page - -Scenario: Show only teis with first name containig John using the filter -Given you open the main page with Ngelehun and child programe context -When you set the first name filter to John -And you apply the current filter -Then the first name filter button should show that the filter is in effect -And the list should display teis with John as the first name -And rows per page should be set to 15 -And for a tracker program the page navigation should show that you are on the first page - -Scenario: Show the registering unit column -Given you open the main page with Ngelehun and child programe context -When you open the column selector -And you select the organisation unit and save from the column selector -Then the organisation unit should display in the list - -Scenario: Show next page -Given you open the main page with Ngelehun and child programe context -When you click the next page button -Then the list should display data for the second page -And the pagination for the tei working list should show the second page - -Scenario: Show next page then previous page -Given you open the main page with Ngelehun and child programe context -When you click the next page button -Then the list should display data for the second page -And the pagination for the tei working list should show the second page -When you click the previous page button -Then the default working list should be displayed -And for a tracker program the page navigation should show that you are on the first page - -Scenario: Show next page then first page -Given you open the main page with Ngelehun and child programe context -When you click the next page button -Then the list should display data for the second page -And the pagination for the tei working list should show the second page -When you click the first page button -Then the default working list should be displayed -And for a tracker program the page navigation should show that you are on the first page - -Scenario: Show 10 rows per page -Given you open the main page with Ngelehun and child programe context -When you change rows per page to 10 -Then the list should display 10 rows of data -And for a tracker program the page navigation should show that you are on the first page - -Scenario: Show teis ordered ascendingly by first name -Given you open the main page with Ngelehun and child programe context -When you click the first name column header -Then the sort arrow should indicate ascending order -And the list should display data ordered ascendingly by first name -And for a tracker program the page navigation should show that you are on the first page - -Scenario: The TEI custom working lists is loaded -Given you open the 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 Events assigned to me - - - -Scenario: The user creates, updates and deletes a TEI custom working list -Given you open the main page with Ngelehun and Malaria case diagnosis context -And you set the enrollment status filter to completed -And you apply the current filter -And you set the enrollment date to a relative range -And you apply the current filter -When you save the list with the name My custom list -Then the new My custom list is created -And the enrollment status filter button should show that the completed filter is in effect -When you set the enrollment status filter to active -And you apply the current filter -When you update the list with the name My custom list -Then the enrollment status filter button should show that the active filter is in effect -And you delete the name My custom list -Then the My custom list is deleted - -Scenario: The user can delete a TEI working list right immediately after creating it. -Given you open the main page with Ngelehun and Malaria case diagnosis context -And you set the enrollment status filter to completed -And you apply the current filter -And you set the enrollment date to a relative range -And you apply the current filter -When you save the list with the name My custom list -Then the new My custom list is created -When you delete the name My custom list -Then the My custom list is deleted - -Scenario: The user can open and select a program stage filter -Given you open the main page with Ngelehun and Malaria focus investigation context -When you open the program stage filters from the more filters dropdown menu -When you select the Foci response program stage -And you apply the current filter -And you open the column selector -And you select a data element columns and save from the column selector -Then you see data elements specific filters and columns - -Scenario: While in a program stage working list, the user can filter by both TEA and data elements -Given you open the main page with Ngelehun, WHO RMNCH Tracker and First antenatal care visit context -When you set the enrollment status filter to active -And you apply the current filter -And you set the event status filter to completed -And you apply the current filter -And you set the first name filter to Urzula -And you apply the current filter -And you set the WHOMCH Smoking filter to No -And you apply the current filter -Then the list should display 1 row of data - -Scenario: While in a program stage working list, the user can sort by both TEA and data elements -Given you open the main page with Ngelehun, WHO RMNCH Tracker and First antenatal care visit context -And you set the first name filter to u -And you apply the current filter -When you click the last name column header -Then the sort arrow should indicate ascending order -And the list should display data ordered ascendingly by last name -When you click the WHOMCH Hemoglobin value column header -Then the sort arrow should indicate descending order -And the list should display data ordered descending by WHOMCH Hemoglobin - -Scenario: The user can remove the program stage filter -Given you open the main page with Ngelehun and WHO RMNCH Tracker context -When you open the program stage filters from the more filters dropdown menu -And you select the First antenatal care visit program stage -And you apply the current filter -Then you see program stage working list events -When you remove the program stage filter -Then you don't see program stage working list events - -Scenario: The user can filter the events by scheduledAt date -Given you open the main page with Ngelehun and WHO RMNCH Tracker context -When you open the program stage filters from the more filters dropdown menu -And you select the First antenatal care visit program stage -And you apply the current filter -Then you see scheduledAt filter -And you open the column selector -When you select a scheduledAt column and save from the column selector -And you select the events scheduled today -And you apply the current filter -Then you see the selected option in the scheduledAt filter - -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 - -Scenario: The program stage working list without a orgUnit selected redirects to a tracker event -Given you open the main page with all accesible records in the WHO RMNCH Tracker context and configure a program stage working list -When you open an enrollment event from the working list -Then the tracker event URL contains the orgUnitId - -Scenario: The user can open a program stage list without events -Given you open the main page with Ngelehun and WHO RMNCH Tracker context and configure a program stage working list -And you set the event visit date to Today -And you apply the current filter -Then the working list is empty - -Scenario: The user can filter the Foci response assigned events -Given you open the main page with Ngelehun and Malaria focus investigation context -When you open the program stage filters from the more filters dropdown menu -And you select the Foci response program stage -And you apply the current filter -And you set the assginee filter to Anyone -And you apply the current filter -Then the assignee filter button should show that Anyone filter is in effect -And the assignee column is displayed - -Scenario: The assigned user data is kept when switching between working list types -Given you open the main page with Ngelehun and Malaria focus investigation context -And you filter by assigned Foci investigation & classification events -And the assignee filter button should show that Anyone filter is in effect -When you remove the program stage filter -Then you don't see program stage working list events -And the assignee filter button should show that Anyone filter is in effect -When you set the assginee filter to None -And you apply the current filter -Then the assignee filter button should show that None filter is in effect -When you open the program stage filters from the more filters dropdown menu -And you select the Foci response program stage -And you apply the current filter -Then the assignee filter button should show that None filter is in effect - -@v>=40 -Scenario: The user can create and delete a program stage working list for Foci investigation & classification assigned events -Given you open the main page with Ngelehun and Malaria focus investigation context -And you filter by assigned Foci investigation & classification events -When you save the list with the name Custom Program stage list -Then the new Custom Program stage list is created -And you delete the name Custom Program stage list -Then the Custom Program stage list is deleted - -@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 -And you set the enrollment status filter to completed -And you apply the current filter -And you set the enrollment date to a relative range -And you apply the current filter -When you save the list with the name Custom Program stage list -Then the new Custom Program stage list is created -And the enrollment status filter button should show that the completed filter is in effect -When you set the enrollment status filter to active -And you apply the current filter -When you update the list with the name Custom Program stage list -Then the enrollment status filter button should show that the active filter is in effect -And you delete the name Custom Program stage list -Then the Custom Program stage list is deleted - -@v>=40 -Scenario: The user can delete a Program stage working list right immediately after creating it. -Given you open the main page with Ngelehun and Malaria case diagnosis and Household investigation context -When you save the list with the name Custom Program stage list -Then the new Custom Program stage list is created -And you delete the name Custom Program stage list -Then the Custom Program stage list is deleted - -# For the program stage WL scenarios I need to create/delete my own because there are no program stage working lists in the demo database. -@v>=40 -Scenario: The Program stage custom working can be shared -Given you open the main page with Ngelehun and Malaria case diagnosis and Household investigation context -And you save the list with the name Custom Program stage list -When you change the sharing settings -Then you see the new sharing settings - -@v>=40 -Scenario: The Program stage working list configuration is kept when changing the org unit -Given you open the main page with Ngelehun and Malaria case diagnosis and Household investigation context -And you save the list with the name Custom Program stage list -Then the new Custom Program stage list is created -And you set the event status filter to completed -And you apply the current filter -And you change the org unit -Then the working list configuration was kept -And you delete the name Custom Program stage list -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 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 -And you select the Foci response program stage -And you apply the current filter -Then you are redirect to the default templete -When you save the list with the name Custom Program stage list -Then the new Custom Program stage list is created -And the TEI working list initial configuration was kept -And you delete the name Custom Program stage list -Then the Custom Program stage list is deleted - -@v>=40 -Scenario: The user can download the tracked entity working list -Given you open the main page with Ngelehun and child programe context -And you open the menu and click the "Download data..." button -Then the download dialog opens -Then the CSV button exists -Then the JSON button exists - -@v<40 -Scenario: The user can download the tracked entity working list -Given you open the main page with Ngelehun and child programe context -And you open the menu and click the "Download data..." button -Then the download dialog opens -Then the JSON button exists - -Scenario: The user cannot download the tracked entity working list when no orgUnit is selected -Given you open the main page with child programe context -And the user clicks the element containing the text: Or see all records accessible to you in Child Programme -And you open the menu -Then the "Download data..." button is hidden + Scenario: User opens the default working list for a tracker program + Given you open the main page with Ngelehun and child programe context + Then the default working list should be displayed + And rows per page should be set to 15 + And for a tracker program the page navigation should show that you are on the first page + + Scenario: Show only teis with completed enrollments using the predefined working list + Given you open the main page with Ngelehun and child programe context + When you select the working list called completed enrollments + Then the enrollment status filter button should show that the completed filter is in effect + And the list should display teis with a completed enrollment + And rows per page should be set to 15 + And for a tracker program the page navigation should show that you are on the first page + + Scenario: Show only teis with completed enrollments using the filter + Given you open the main page with Ngelehun and child programe context + When you set the enrollment status filter to completed + And you apply the current filter + Then the enrollment status filter button should show that the completed filter is in effect + And the list should display teis with a completed enrollment + And rows per page should be set to 15 + And for a tracker program the page navigation should show that you are on the first page + + # DHIS2-13960: /trackedEntities filter by assignee results are not consistent + @skip + Scenario: Show only teis with active enrollments and unassinged events using the filter + Given you open the main page with Ngelehun and Malaria focus investigation context + When you set the enrollment status filter to active + And you apply the current filter + And you set the assginee filter to None + And you apply the current filter + Then the enrollment status filter button should show that the active filter is in effect + And the assignee filter button should show that None filter is in effect + And the list should display teis with an active enrollment and unassinged events + And rows per page should be set to 15 + And for a tracker program the page navigation should show that you are on the first page + + Scenario: Show only teis with first name containig John using the filter + Given you open the main page with Ngelehun and child programe context + When you set the first name filter to John + And you apply the current filter + Then the first name filter button should show that the filter is in effect + And the list should display teis with John as the first name + And rows per page should be set to 15 + And for a tracker program the page navigation should show that you are on the first page + + Scenario: Show the registering unit column + Given you open the main page with Ngelehun and child programe context + When you open the column selector + And you select the organisation unit and save from the column selector + Then the organisation unit should display in the list + + Scenario: Show next page + Given you open the main page with Ngelehun and child programe context + When you click the next page button + Then the list should display data for the second page + And the pagination for the tei working list should show the second page + + Scenario: Show next page then previous page + Given you open the main page with Ngelehun and child programe context + When you click the next page button + Then the list should display data for the second page + And the pagination for the tei working list should show the second page + When you click the previous page button + Then the default working list should be displayed + And for a tracker program the page navigation should show that you are on the first page + + Scenario: Show next page then first page + Given you open the main page with Ngelehun and child programe context + When you click the next page button + Then the list should display data for the second page + And the pagination for the tei working list should show the second page + When you click the first page button + Then the default working list should be displayed + And for a tracker program the page navigation should show that you are on the first page + + Scenario: Show 10 rows per page + Given you open the main page with Ngelehun and child programe context + When you change rows per page to 10 + Then the list should display 10 rows of data + And for a tracker program the page navigation should show that you are on the first page + + Scenario: Show teis ordered ascendingly by first name + Given you open the main page with Ngelehun and child programe context + When you click the first name column header + Then the sort arrow should indicate ascending order + And the list should display data ordered ascendingly by first name + And for a tracker program the page navigation should show that you are on the first page + + Scenario: The TEI custom working lists is loaded + Given you open the 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 Events assigned to me + + Scenario: The user creates, updates and deletes a TEI custom working list + Given you open the main page with Ngelehun and Malaria case diagnosis context + And you set the enrollment status filter to completed + And you apply the current filter + And you set the enrollment date to a relative range + And you apply the current filter + When you save the list with the name My custom list + Then the new My custom list is created + And the enrollment status filter button should show that the completed filter is in effect + When you set the enrollment status filter to active + And you apply the current filter + When you update the list with the name My custom list + Then the enrollment status filter button should show that the active filter is in effect + And you delete the name My custom list + Then the My custom list is deleted + + Scenario: The user is navigated back to the selected working list after closing a TEI + Given you open the main page with Ngelehun and child programe context + And you select the working list called completed enrollments + When you open a tei from the working list + And you deselect the tracked entity from the context selector + Then the working list called completed enrollments should be selected + + Scenario: The user can delete a TEI working list right immediately after creating it. + Given you open the main page with Ngelehun and Malaria case diagnosis context + And you set the enrollment status filter to completed + And you apply the current filter + And you set the enrollment date to a relative range + And you apply the current filter + When you save the list with the name My custom list + Then the new My custom list is created + When you delete the name My custom list + Then the My custom list is deleted + + Scenario: The user can open and select a program stage filter + Given you open the main page with Ngelehun and Malaria focus investigation context + When you open the program stage filters from the more filters dropdown menu + When you select the Foci response program stage + And you apply the current filter + And you open the column selector + And you select a data element columns and save from the column selector + Then you see data elements specific filters and columns + + Scenario: While in a program stage working list, the user can filter by both TEA and data elements + Given you open the main page with Ngelehun, WHO RMNCH Tracker and First antenatal care visit context + When you set the enrollment status filter to active + And you apply the current filter + And you set the event status filter to completed + And you apply the current filter + And you set the first name filter to Urzula + And you apply the current filter + And you set the WHOMCH Smoking filter to No + And you apply the current filter + Then the list should display 1 row of data + + Scenario: While in a program stage working list, the user can sort by both TEA and data elements + Given you open the main page with Ngelehun, WHO RMNCH Tracker and First antenatal care visit context + And you set the first name filter to u + And you apply the current filter + When you click the last name column header + Then the sort arrow should indicate ascending order + And the list should display data ordered ascendingly by last name + When you click the WHOMCH Hemoglobin value column header + Then the sort arrow should indicate descending order + And the list should display data ordered descending by WHOMCH Hemoglobin + + Scenario: The user can remove the program stage filter + Given you open the main page with Ngelehun and WHO RMNCH Tracker context + When you open the program stage filters from the more filters dropdown menu + And you select the First antenatal care visit program stage + And you apply the current filter + Then you see program stage working list events + When you remove the program stage filter + Then you don't see program stage working list events + + Scenario: The user can filter the events by scheduledAt date + Given you open the main page with Ngelehun and WHO RMNCH Tracker context + When you open the program stage filters from the more filters dropdown menu + And you select the First antenatal care visit program stage + And you apply the current filter + Then you see scheduledAt filter + And you open the column selector + When you select a scheduledAt column and save from the column selector + And you select the events scheduled today + And you apply the current filter + Then you see the selected option in the scheduledAt filter + + 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 + + Scenario: The program stage working list without a orgUnit selected redirects to a tracker event + Given you open the main page with all accesible records in the WHO RMNCH Tracker context and configure a program stage working list + When you open an enrollment event from the working list + Then the tracker event URL contains the orgUnitId + + Scenario: The user can open a program stage list without events + Given you open the main page with Ngelehun and WHO RMNCH Tracker context and configure a program stage working list + And you set the event visit date to Today + And you apply the current filter + Then the working list is empty + + Scenario: The user can filter the Foci response assigned events + Given you open the main page with Ngelehun and Malaria focus investigation context + When you open the program stage filters from the more filters dropdown menu + And you select the Foci response program stage + And you apply the current filter + And you set the assginee filter to Anyone + And you apply the current filter + Then the assignee filter button should show that Anyone filter is in effect + And the assignee column is displayed + + Scenario: The assigned user data is kept when switching between working list types + Given you open the main page with Ngelehun and Malaria focus investigation context + And you filter by assigned Foci investigation & classification events + And the assignee filter button should show that Anyone filter is in effect + When you remove the program stage filter + Then you don't see program stage working list events + And the assignee filter button should show that Anyone filter is in effect + When you set the assginee filter to None + And you apply the current filter + Then the assignee filter button should show that None filter is in effect + When you open the program stage filters from the more filters dropdown menu + And you select the Foci response program stage + And you apply the current filter + Then the assignee filter button should show that None filter is in effect + + @v>=40 + Scenario: The user can create and delete a program stage working list for Foci investigation & classification assigned events + Given you open the main page with Ngelehun and Malaria focus investigation context + And you filter by assigned Foci investigation & classification events + When you save the list with the name Custom Program stage list + Then the new Custom Program stage list is created + And you delete the name Custom Program stage list + Then the Custom Program stage list is deleted + + @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 + And you set the enrollment status filter to completed + And you apply the current filter + And you set the enrollment date to a relative range + And you apply the current filter + When you save the list with the name Custom Program stage list + Then the new Custom Program stage list is created + And the enrollment status filter button should show that the completed filter is in effect + When you set the enrollment status filter to active + And you apply the current filter + When you update the list with the name Custom Program stage list + Then the enrollment status filter button should show that the active filter is in effect + And you delete the name Custom Program stage list + Then the Custom Program stage list is deleted + + @v>=40 + Scenario: The user can delete a Program stage working list right immediately after creating it. + Given you open the main page with Ngelehun and Malaria case diagnosis and Household investigation context + When you save the list with the name Custom Program stage list + Then the new Custom Program stage list is created + And you delete the name Custom Program stage list + Then the Custom Program stage list is deleted + + # For the program stage WL scenarios I need to create/delete my own because there are no program stage working lists in the demo database. + @v>=40 + Scenario: The Program stage custom working can be shared + Given you open the main page with Ngelehun and Malaria case diagnosis and Household investigation context + And you save the list with the name Custom Program stage list + When you change the sharing settings + Then you see the new sharing settings + + @v>=40 + Scenario: The Program stage working list configuration is kept when changing the org unit + Given you open the main page with Ngelehun and Malaria case diagnosis and Household investigation context + And you save the list with the name Custom Program stage list + Then the new Custom Program stage list is created + And you set the event status filter to completed + And you apply the current filter + And you change the org unit + Then the working list configuration was kept + And you delete the name Custom Program stage list + 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 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 + And you select the Foci response program stage + And you apply the current filter + Then you are redirect to the default templete + When you save the list with the name Custom Program stage list + Then the new Custom Program stage list is created + And the TEI working list initial configuration was kept + And you delete the name Custom Program stage list + Then the Custom Program stage list is deleted + + @v>=40 + Scenario: The user can download the tracked entity working list + Given you open the main page with Ngelehun and child programe context + And you open the menu and click the "Download data..." button + Then the download dialog opens + Then the CSV button exists + Then the JSON button exists + + @v<40 + Scenario: The user can download the tracked entity working list + Given you open the main page with Ngelehun and child programe context + And you open the menu and click the "Download data..." button + Then the download dialog opens + Then the JSON button exists + + Scenario: The user cannot download the tracked entity working list when no orgUnit is selected + Given you open the main page with child programe context + And the user clicks the element containing the text: Or see all records accessible to you in Child Programme + And you open the menu + Then the "Download data..." button is hidden diff --git a/cypress/e2e/WorkingLists/TeiWorkingLists/TeiWorkingListsUser/TeiWorkingListsUser.js b/cypress/e2e/WorkingLists/TeiWorkingLists/TeiWorkingListsUser/TeiWorkingListsUser.js index 260e312422..0ea736c26a 100644 --- a/cypress/e2e/WorkingLists/TeiWorkingLists/TeiWorkingListsUser/TeiWorkingListsUser.js +++ b/cypress/e2e/WorkingLists/TeiWorkingLists/TeiWorkingListsUser/TeiWorkingListsUser.js @@ -1,4 +1,4 @@ -import { Given, When, Then, defineStep as And } from '@badeball/cypress-cucumber-preprocessor'; +import { defineStep as And, Given, Then, When } from '@badeball/cypress-cucumber-preprocessor'; import { v4 as uuid } from 'uuid'; import '../sharedSteps'; @@ -654,6 +654,25 @@ When('you remove the program stage filter', () => { .click(); }); +When('you open a tei from the working list', () => { + cy.get('[data-test="tei-working-lists"]') + .contains('Filona') + .click(); +}); + +When('you deselect the tracked entity from the context selector', () => { + cy.get('[data-test="person-selector-container-clear-icon"]') + .click(); +}); + +// the working list called completed enrollments should be selected +Then('the working list called completed enrollments should be selected', () => { + cy.get('[data-test="workinglist-template-selector-chip"]') + .contains('Completed enrollments') + .parent() + .should('have.class', 'selected'); +}); + Then('you see scheduledAt filter', () => { cy.get('[data-test="tei-working-lists"]') .contains('Appointment date') diff --git a/src/core_modules/capture-core/components/Pages/MainPage/MainPage.container.js b/src/core_modules/capture-core/components/Pages/MainPage/MainPage.container.js index 52a10ab4e4..8fcad393d9 100644 --- a/src/core_modules/capture-core/components/Pages/MainPage/MainPage.container.js +++ b/src/core_modules/capture-core/components/Pages/MainPage/MainPage.container.js @@ -1,7 +1,7 @@ // @flow -import React, { useEffect, useMemo, useCallback } from 'react'; +import React, { useCallback, useEffect, useMemo } from 'react'; // $FlowFixMe -import { connect, useSelector, shallowEqual, useDispatch } from 'react-redux'; +import { connect, shallowEqual, useDispatch, useSelector } from 'react-redux'; import { useHistory } from 'react-router-dom'; import { programCollection } from 'capture-core/metaDataMemoryStores/programCollection/programCollection'; import { MainPageComponent } from './MainPage.component'; @@ -120,6 +120,14 @@ const MainPageContainer = () => { showAllAccessible, categoryOptionIsInvalidForOrgUnit, }); + const reduxSelectedTemplateId + = useSelector(({ workingListsTemplates }) => workingListsTemplates.teiList?.selectedTemplateId); + const workingListProgramId = useSelector(({ workingLists }) => workingLists + .teiList + ?.currentRequest + ?.queryParams + ?.program, + ); const { onChangeTemplate, @@ -132,6 +140,16 @@ const MainPageContainer = () => { useEffect(() => { if (programId && trackedEntityTypeId && displayFrontPageList && selectedTemplateId === undefined) { + if (reduxSelectedTemplateId && workingListProgramId === programId) { + handleChangeTemplateUrl({ + programId, + orgUnitId, + selectedTemplateId: reduxSelectedTemplateId, + showAllAccessible, + history, + }); + return; + } handleChangeTemplateUrl({ programId, orgUnitId, @@ -148,6 +166,8 @@ const MainPageContainer = () => { trackedEntityTypeId, displayFrontPageList, history, + reduxSelectedTemplateId, + workingListProgramId, ]); return ( From 92b302b5822b73adb89a962b2ef1a192cbfad1f8 Mon Sep 17 00:00:00 2001 From: eirikhaugstulen Date: Thu, 10 Oct 2024 16:29:57 +0200 Subject: [PATCH 2/3] fix: allow navigate back despite displayFrontPageList --- i18n/en.pot | 7 +++++-- .../components/Pages/MainPage/MainPage.container.js | 3 ++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/i18n/en.pot b/i18n/en.pot index d299bcedcf..4d7bef69b6 100644 --- a/i18n/en.pot +++ b/i18n/en.pot @@ -5,8 +5,8 @@ msgstr "" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1)\n" -"POT-Creation-Date: 2024-09-02T11:08:16.281Z\n" -"PO-Revision-Date: 2024-09-02T11:08:16.281Z\n" +"POT-Creation-Date: 2024-10-10T14:29:59.249Z\n" +"PO-Revision-Date: 2024-10-10T14:29:59.249Z\n" msgid "Choose one or more dates..." msgstr "Choose one or more dates..." @@ -1119,6 +1119,9 @@ msgstr "Create new event" msgid "Search for a {{trackedEntityName}} in {{programName}}" msgstr "Search for a {{trackedEntityName}} in {{programName}}" +msgid "Back to list" +msgstr "Back to list" + msgid "No tracked entity types available" msgstr "No tracked entity types available" diff --git a/src/core_modules/capture-core/components/Pages/MainPage/MainPage.container.js b/src/core_modules/capture-core/components/Pages/MainPage/MainPage.container.js index 8fcad393d9..e937fe7640 100644 --- a/src/core_modules/capture-core/components/Pages/MainPage/MainPage.container.js +++ b/src/core_modules/capture-core/components/Pages/MainPage/MainPage.container.js @@ -139,7 +139,7 @@ const MainPageContainer = () => { }, [showAllAccessible, dispatch]); useEffect(() => { - if (programId && trackedEntityTypeId && displayFrontPageList && selectedTemplateId === undefined) { + if (programId && trackedEntityTypeId && selectedTemplateId === undefined) { if (reduxSelectedTemplateId && workingListProgramId === programId) { handleChangeTemplateUrl({ programId, @@ -150,6 +150,7 @@ const MainPageContainer = () => { }); return; } + if (!displayFrontPageList) return; handleChangeTemplateUrl({ programId, orgUnitId, From e58e40ede461f29373ca702a706cd4c04d673931 Mon Sep 17 00:00:00 2001 From: eirikhaugstulen Date: Thu, 10 Oct 2024 16:48:40 +0200 Subject: [PATCH 3/3] chore: review --- .../Pages/MainPage/MainPage.container.js | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/core_modules/capture-core/components/Pages/MainPage/MainPage.container.js b/src/core_modules/capture-core/components/Pages/MainPage/MainPage.container.js index e937fe7640..32ac19a65b 100644 --- a/src/core_modules/capture-core/components/Pages/MainPage/MainPage.container.js +++ b/src/core_modules/capture-core/components/Pages/MainPage/MainPage.container.js @@ -68,9 +68,11 @@ const useMainPageStatus = ({ const useSelectorMainPage = () => useSelector( - ({ currentSelections, activePage }) => ({ + ({ currentSelections, activePage, workingListsTemplates, workingListsContext }) => ({ categories: currentSelections.categories, selectedCategories: currentSelections.categoriesMeta, + reduxSelectedTemplateId: workingListsTemplates.teiList?.selectedTemplateId, + workingListProgramId: workingListsContext.teiList?.programIdView, ready: !activePage.isLoading && !activePage.lockedSelectorLoads, error: activePage.selectionsError && activePage.selectionsError.error, }), @@ -103,6 +105,8 @@ const MainPageContainer = () => { const { categories, selectedCategories, + reduxSelectedTemplateId, + workingListProgramId, error, ready, } = useSelectorMainPage(); @@ -120,14 +124,6 @@ const MainPageContainer = () => { showAllAccessible, categoryOptionIsInvalidForOrgUnit, }); - const reduxSelectedTemplateId - = useSelector(({ workingListsTemplates }) => workingListsTemplates.teiList?.selectedTemplateId); - const workingListProgramId = useSelector(({ workingLists }) => workingLists - .teiList - ?.currentRequest - ?.queryParams - ?.program, - ); const { onChangeTemplate,