Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: [DHIS2-15782] navigation with program stage filter #3431

Merged
merged 5 commits into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ export const TeiWorkingListsReduxProvider = ({
onDeleteTemplate,
onUpdateDefaultTemplate,
programStage,
currentTemplateId,
viewPreloaded,
...commonStateManagementProps
} = useWorkingListsCommonStateManagement(storeId, TEI_WORKING_LISTS_TYPE, program);
const dispatch = useDispatch();
Expand All @@ -47,9 +49,15 @@ export const TeiWorkingListsReduxProvider = ({
}, [dispatch, programId, storeId, selectedTemplateId]);

useEffect(() => {
selectedTemplateId && 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];
Expand Down Expand Up @@ -92,6 +100,8 @@ export const TeiWorkingListsReduxProvider = ({
return (
<TeiWorkingListsSetup
{...commonStateManagementProps}
currentTemplateId={currentTemplateId}
viewPreloaded={viewPreloaded}
templateSharingType={templateSharingType}
onSelectListRow={onSelectListRow}
onLoadTemplates={onLoadTemplates}
Expand Down
Loading