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

chore: forward-ports the last two PRs #1588

Merged
merged 2 commits into from
Mar 26, 2021
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
9 changes: 9 additions & 0 deletions cypress/integration/SearchPage.feature
Original file line number Diff line number Diff line change
Expand Up @@ -228,3 +228,12 @@ Feature: User interacts with Search page
When you select Child Programme
And you are in the search page with the Child Programme being preselected from the url
And and you can see the unique identifier input

Scenario: Fallback search navigates back to main page
Given you are in the search page with the Child Programme and org unit being preselected from the url
And you expand the attributes search area
When you fill in the first and last name with values that will return results
And you click search
And you click the fallback search button
When you click the back button
Then you should be taken to the main page with org unit preselected
14 changes: 14 additions & 0 deletions cypress/integration/SearchPage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -345,3 +345,17 @@ When('and you can see the unique identifier input', () => {
.find('[data-test="capture-ui-input"]')
.should('exist');
});

Given('you are in the search page with the Child Programme and org unit being preselected from the url', () => {
cy.visit('/#/search?programId=IpHINAT79UW&orgUnitId=DiszpKrYNg8');
});

When('you click the back button', () => {
cy.get('[data-test="dhis2-capture-back-button"]')
.click();
});

Then('you should be taken to the main page with org unit preselected', () => {
cy.url()
.should('eq', `${Cypress.config().baseUrl}/#/?orgUnitId=DiszpKrYNg8`);
});
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@ const getFiltersForAttributesSearchQuery = (formValues) => {

return [...stringFilters, ...rangeFilers];
};

const handleErrors = ({ httpStatusCode, message }) => {
if (httpStatusCode === 409 && message === 'maxteicountreached') {
return of(showTooManyResultsViewOnSearchPage());
}
return of(showErrorViewOnSearchPage());
};

const searchViaAttributesStream = (queryArgs, attributes, triggeredFrom) =>
from(getTrackedEntityInstances(queryArgs, attributes)).pipe(
map(({ trackedEntityInstanceContainers: searchResults, pagingData }) => {
Expand All @@ -79,12 +87,7 @@ const searchViaAttributesStream = (queryArgs, attributes, triggeredFrom) =>
return showEmptyResultsViewOnSearchPage();
}),
startWith(showLoadingViewOnSearchPage()),
catchError(({ httpStatusCode, message }) => {
if (httpStatusCode === 409 && message === 'maxteicountreached') {
return of(showTooManyResultsViewOnSearchPage());
}
return of(showErrorViewOnSearchPage());
}),
catchError(handleErrors),
);

export const searchViaUniqueIdOnScopeProgramEpic: Epic = (action$, store) =>
Expand Down Expand Up @@ -259,7 +262,7 @@ export const fallbackSearchEpic: Epic = (action$: InputObservable) =>
return of(showEmptyResultsViewOnSearchPage());
}),
startWith(showLoadingViewOnSearchPage()),
catchError(() => of(showErrorViewOnSearchPage())),
catchError(handleErrors),
);
}),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ export const getCurrentSelectionsReducerDesc = (appUpdaters: Updaters) => create
[searchPageActionTypes.FALLBACK_SEARCH_COMPLETED]:
(state, { payload: { trackedEntityTypeId } }) => ({
...state,
complete: false,
programId: undefined,
categories: undefined,
categoriesMeta: undefined,
Expand All @@ -219,6 +220,7 @@ export const getCurrentSelectionsReducerDesc = (appUpdaters: Updaters) => create
programId: undefined,
categories: undefined,
categoriesMeta: undefined,
complete: false,
trackedEntityTypeId,
}),
}, 'currentSelections', {
Expand Down