Skip to content

Commit

Permalink
feat: make opt-in to new dashboard the default
Browse files Browse the repository at this point in the history
  • Loading branch information
simonadomnisoru committed Jan 16, 2024
1 parent 433afa5 commit e9bfd86
Show file tree
Hide file tree
Showing 23 changed files with 86 additions and 202 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ Feature: User interacts with the Enrollment New Event Workspace
Then the input should throw an error with error-message Please provide a positive integer

Scenario: User should be asked to create new event after completing a stage and choose to cancel
Given you open the main page with Ngelehun and Malaria focus investigation context
And you opt in to use the new enrollment Dashboard for Malaria focus investigation
Then you land on the enrollment new event page by having typed #/enrollmentEventNew?enrollmentId=zRfAPUpjoG3&orgUnitId=DiszpKrYNg8&programId=M3xtLkYBlKI&stageId=CWaAcQYKVpq&teiId=S3JjTA4QMNe
Given you land on the enrollment new event page by having typed #/enrollmentEventNew?enrollmentId=zRfAPUpjoG3&orgUnitId=DiszpKrYNg8&programId=M3xtLkYBlKI&stageId=CWaAcQYKVpq&teiId=S3JjTA4QMNe
Then you see the following Enrollment: New Event
And you see the widget header Foci investigation & classification
And you type 2022-01-01 in the input number 0
Expand Down
2 changes: 0 additions & 2 deletions cypress/e2e/EnrollmentPage/BreakingTheGlass.feature
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@ Feature: Breaking the glass page
@skip
Scenario: User with search scope access tries to access an enrollment in a protected program
Given the tei created by this test is cleared from the database
And you opt temporarily in on new enrollment dashboard in Child programme and WHO RMNCH Tracker
And you create a new tei in Child programme from Ngelehun CHC
And you change program to WHO RMNCH Tracker
And you enroll the tei from Njandama MCHP
And you log out
And you log in as tracker2 user
And you opt temporarily in on new enrollment dashboard in Child programme and WHO RMNCH Tracker
And you select the new tei
And you change program to WHO RMNCH Tracker
Then you see the breaking the glass page
Expand Down
4 changes: 0 additions & 4 deletions cypress/e2e/EnrollmentPage/BreakingTheGlass/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ Given('the tei created by this test is cleared from the database', () => {
));
});

And('you opt temporarily in on new enrollment dashboard in Child programme and WHO RMNCH Tracker', () => {
cy.visit('/#/?newDashboard=IpHINAT79UW,WSGAb5XwJ3Y');
});

And('you create a new tei in Child programme from Ngelehun CHC', () => {
cy.visit('/#/new?orgUnitId=DiszpKrYNg8&programId=IpHINAT79UW');
cy.get('[data-test="capture-ui-input"]')
Expand Down
7 changes: 3 additions & 4 deletions cypress/e2e/MainPage.feature
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,11 @@ Feature: User interacts with Main page

Scenario: The admin user can optin to use the new Enrollment Dashboard
Given you open the main page with Ngelehun and child programme context
And you see the opt in component for Child Programme
When you opt in to use the new enrollment Dashboard for Child Programme
Then you see the opt out component for Child Programme
And you see the opt out component for Child Programme
When you opt out to use the new enrollment Dashboard for Child Programme
Then you see the opt in component for Child Programme

When you opt in to use the new enrollment Dashboard for Child Programme
Then you see the opt out component for Child Programme
@v<41
Scenario: The icon is rendered as an svg
Given you are in the main page with no selections made
Expand Down
18 changes: 6 additions & 12 deletions cypress/e2e/NewPage.feature
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Feature: User creates a new entries from the registration page
Then you can see the multiple selections in the form
And you fill the WHO RMNCH program registration form with its required unique values
And you click the save person submit button
Then you are navigated to the WHO RMNCH program in Tracker Capture app
Then you see the enrollment event Edit page

Scenario: Viewing the registration page with incomplete program categories selection
Given you are in the main page with no selections made
Expand Down Expand Up @@ -128,15 +128,15 @@ Feature: User creates a new entries from the registration page
Given you are in the Person registration page
When you fill in a unique first name
And you click the save person submit button
Then you are navigated to the Tracker Capture
Then you are navigated to the enrollment dashboard page without enrollment

Scenario: New person > Submitting the form from the duplicates modal navigates you to the user dashboard
Given you are in the Person registration page
When you fill in the first name with value that has duplicates
And you click the save person submit button
And you see the possible duplicates modal
And you submit the form again from the duplicates modal
Then you are navigated to the Tracker Capture
Then you are navigated to the enrollment dashboard page without enrollment

Scenario: New person > Submitting the form shows a list with duplicates
Given you are in the Person registration page
Expand Down Expand Up @@ -173,15 +173,15 @@ Feature: User creates a new entries from the registration page
Given you are in the WHO RMNCH program registration page
When you fill the WHO RMNCH program registration form with its required unique values
And you click the save person submit button
Then you are navigated to the WHO RMNCH program in Tracker Capture app
Then you see the enrollment event Edit page

Scenario: New person in Tracker Program > Submitting the form from the duplicates modal navigates you to the user dashboard
Given you are in the WHO RMNCH program registration page
When you fill the WHO RMNCH program registration form with its required values
And you click the save person submit button
And you see the possible duplicates modal
When you submit the form again from the duplicates modal
Then you are navigated to the WHO RMNCH program in Tracker Capture app
Then you see the enrollment event Edit page


Scenario: New person in Tracker Program > Submitting the form shows a list with duplicates
Expand All @@ -201,16 +201,10 @@ Feature: User creates a new entries from the registration page
Then you see validation errors on the WHO RMNCH program registration page

Scenario: Go to enrollment event when Open data entry form after enrollment is checked
Given you open the main page with Ngelehun and Malaria case diagnosis, treatment and investigation context
And you opt in to use the new enrollment Dashboard for Malaria case diagnosis, treatment and investigation
And you see the opt out component for Malaria case diagnosis, treatment and investigation
When you are in the Malaria case diagnosis, treatment and investigation program registration page
Given you are in the Malaria case diagnosis, treatment and investigation program registration page
And you fill the Malaria case diagnosis registration form with values
And you click the save malaria entity submit button
Then you see the enrollment event Edit page
When you open the main page with Ngelehun and Malaria case diagnosis, treatment and investigation context
And you opt out to use the new enrollment Dashboard for Malaria case diagnosis, treatment and investigation
Then you see the opt in component for Malaria case diagnosis, treatment and investigation

## New enrollment of existing TEI

Expand Down
4 changes: 0 additions & 4 deletions cypress/e2e/NewPage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -487,10 +487,6 @@ And('you fill in child programme first name with value that has duplicates', ()
.blur();
});

Then('you are navigated to the WHO RMNCH program in Tracker Capture app', () => {
cy.url().should('include', 'dashboard?tei=');
cy.url().should('include', 'ou=DiszpKrYNg8&program=WSGAb5XwJ3Y');
});

And('you fill the Child programme registration form with a first name with value that has duplicates', () => {
cy.get('[data-test="capture-ui-input"]')
Expand Down
8 changes: 4 additions & 4 deletions cypress/e2e/SearchPage.feature
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Feature: User interacts with Search page
When you select the search domain WHO RMNCH Tracker
And you fill in the unique identifier field with values that will return a tracked entity instance
And you click find
Then you are navigated to the Tracker Capture
Then you are navigated to the enrollment dashboard page

# Scenario: Searching using attributes in Tracker Program returns no results
# Given you are on the default search page
Expand Down Expand Up @@ -102,7 +102,7 @@ Feature: User interacts with Search page
And you click search
And you can see the first page of the results
And you click the view dashboard button
Then you are navigated to the Tracker Capture
Then you are navigated to the enrollment dashboard page

Scenario: Searching using attributes in TEType navigates user to dashboard view
Given you are on the default search page
Expand All @@ -112,7 +112,7 @@ Feature: User interacts with Search page
And you click search
And you can see the first page of the results
And you click the view dashboard button
Then you are navigated to the Tracker Capture without program
Then you are navigated to the enrollment dashboard page without enrollment

Scenario: Searching using attributes in Tracker Program domain has disabled pagination
Given you are on the default search page
Expand Down Expand Up @@ -164,7 +164,7 @@ Feature: User interacts with Search page
Given you are on the default search page
When you select the search domain WHO RMNCH Tracker
And you press enter after filling in the unique identifier field with values that will return a tracked entity instance
Then you are navigated to the Tracker Capture
Then you are navigated to the enrollment dashboard page

Scenario: Pressing enter should trigger search attributes returns results
Given you are in the search page with the Child Programme being preselected from the url
Expand Down
13 changes: 0 additions & 13 deletions cypress/e2e/SearchPage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,19 +93,6 @@ When('you fill in the unique identifier field with values that will return a tra
.blur();
});

Then('you are navigated to the Tracker Capture', () => {
cy.url()
.should('include', 'dhis-web-tracker-capture/')
.should('include', 'dashboard?tei=')
.should('include', 'program=WSGAb5XwJ3Y');
});

Then('you are navigated to the Tracker Capture without program', () => {
cy.url()
.should('include', 'dhis-web-tracker-capture/')
.should('include', 'dashboard?tei=')
.should('include', 'tracked_entity_type=nEenWmSyUEp');
});

When('you fill in the first name with values that will return no results', () => {
cy.get('[data-test="form-attributes"]')
Expand Down
11 changes: 7 additions & 4 deletions cypress/e2e/sharedSteps.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,15 @@ Then(/^the user ?(.*) see the following text: (.*)$/, (not, message) =>
cy.contains(message).should(not ? 'not.exist' : 'exist'),
);

And('you navigated to the enrollment dashboard page', () => {
cy.url().should('include', 'enrollment?enrollmentId');
And('you are navigated to the enrollment dashboard page', () => {
cy.url().should('include', 'enrollment?');
cy.url().should('include', 'enrollmentId');
});

And('you navigated to the enrollment dashboard page without enrollment', () => {
cy.url().should('include', 'enrollment?orgUnit');
And('you are navigated to the enrollment dashboard page without enrollment', () => {
cy.url().should('include', 'enrollment?');
cy.url().should('not.include', 'enrollmentId');
cy.url().should('include', 'teiId');
});

Then('you should see no results found', () => {
Expand Down
16 changes: 5 additions & 11 deletions i18n/en.pot
Original file line number Diff line number Diff line change
Expand Up @@ -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: 2023-09-12T06:24:49.265Z\n"
"PO-Revision-Date: 2023-09-12T06:24:49.265Z\n"
"POT-Creation-Date: 2024-01-12T13:39:39.646Z\n"
"PO-Revision-Date: 2024-01-12T13:39:39.646Z\n"

msgid "Choose one or more dates..."
msgstr "Choose one or more dates..."
Expand Down Expand Up @@ -1101,12 +1101,6 @@ msgstr "New {{trackedEntityName}} in {{programName}}"
msgid "Search for a {{trackedEntityName}} in {{programName}}"
msgstr "Search for a {{trackedEntityName}} in {{programName}}"

msgid "To work with the selected program,"
msgstr "To work with the selected program,"

msgid "open the Tracker Capture app"
msgstr "open the Tracker Capture app"

msgid "This program is protected"
msgstr "This program is protected"

Expand Down Expand Up @@ -1380,6 +1374,9 @@ msgstr "This stage can only have one event"
msgid "Events could not be retrieved. Please try again later."
msgstr "Events could not be retrieved. Please try again later."

msgid "Assigned to"
msgstr "Assigned to"

msgid "{{ totalEvents }} events"
msgstr "{{ totalEvents }} events"

Expand Down Expand Up @@ -1446,9 +1443,6 @@ msgstr "Download data..."
msgid "an error occurred loading working lists"
msgstr "an error occurred loading working lists"

msgid "Assigned to"
msgstr "Assigned to"

msgid "Registration Date"
msgstr "Registration Date"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,10 @@ export const actionTypes = Object.freeze({
NAVIGATE_TO_ENROLLMENT_OVERVIEW: 'enrollmentNavigation.navigateToEnrollmentOverview',
});

export const navigateToEnrollmentOverview = ({ teiId, programId, orgUnitId, enrollmentId }: NavigateToEnrollmentOverviewProps) =>
export const navigateToEnrollmentOverview = ({
teiId,
programId,
orgUnitId,
enrollmentId,
}: NavigateToEnrollmentOverviewProps) =>
actionCreator(actionTypes.NAVIGATE_TO_ENROLLMENT_OVERVIEW)({ teiId, programId, orgUnitId, enrollmentId });
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,15 @@ export const navigateToEnrollmentOverviewEpic = (action$: InputObservable, store
switchMap((action) => {
const { teiId, programId, orgUnitId } = action.payload;
const enrollmentId = programId && (action.payload?.enrollmentId || 'AUTO');
const { dataStore, userDataStore, temp } = store.value.useNewDashboard;
const { dataStore, userDataStore } = store.value.useNewDashboard;

if (dataStore || userDataStore) {
const shouldRedirectToEnrollmentDashboard = shouldUseNewDashboard(userDataStore, dataStore, temp, programId);
const shouldRedirectToEnrollmentDashboard = shouldUseNewDashboard({
userDataStore,
dataStore,
programId,
teiId,
});
if (shouldRedirectToEnrollmentDashboard) {
redirectToEnrollmentDashboard({ dependencies, teiId, programId, orgUnitId, enrollmentId });
return EMPTY;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,18 @@ import { EMPTY } from 'rxjs';
import { saveDataStore } from './DataStore.actions';
import { type UseNewDashboard } from './DataStore.types';
import { appStartActionTypes } from '../../../../components/AppStart';
import { programCollection } from '../../metaDataMemoryStores';

const setNewDashboardByDefault = (key: string, dataStoreValues) => {
const programs = [...programCollection.keys()];
const valuesWithDefault = programs.reduce((acc, program) => {
const dataStoreValue = dataStoreValues[program];
acc[program] = dataStoreValue !== undefined ? dataStoreValue : true;
return acc;
}, {});

return { [key]: valuesWithDefault };
};

const getDataStoreFromApi = async querySingleResource =>
querySingleResource({
Expand All @@ -22,7 +34,7 @@ export const fetchDataStoreEpic = (action$: InputObservable, _: ReduxStore, { qu
mergeMap(async () => {
const apiDataStore: UseNewDashboard = await getDataStoreFromApi(querySingleResource);
// $FlowFixMe
return saveDataStore({ dataStore: apiDataStore });
return saveDataStore(setNewDashboardByDefault('dataStore', apiDataStore));
}),
catchError(() => EMPTY),
);
Expand All @@ -33,7 +45,7 @@ export const fetchUserDataStoreEpic = (action$: InputObservable, _: ReduxStore,
mergeMap(async () => {
const apiUserDataStore: UseNewDashboard = await getUserDataStoreFromApi(querySingleResource);
// $FlowFixMe
return saveDataStore({ userDataStore: apiUserDataStore });
return saveDataStore(setNewDashboardByDefault('userDataStore', apiUserDataStore));
}),
catchError(() => EMPTY),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { programCollection } from 'capture-core/metaDataMemoryStores/programColl
import { MainPageComponent } from './MainPage.component';
import { withLoadingIndicator } from '../../../HOC';
import { updateShowAccessibleStatus } from '../actions/crossPage.actions';
import { enableNewDashboardsTemporarily } from '../../../utils/routing/newDashboard.actions';
import { buildUrlQueryString, useLocationQuery } from '../../../utils/routing';
import { MainPageStatuses } from './MainPage.constants';
import { OrgUnitFetcher } from '../../OrgUnitFetcher';
Expand Down Expand Up @@ -87,7 +86,7 @@ const useCallbackMainPage = ({ orgUnitId, programId, showAllAccessible, history
const MainPageContainer = () => {
const dispatch = useDispatch();
const history = useHistory();
const { all, programId, orgUnitId, selectedTemplateId, newDashboard } = useLocationQuery();
const { all, programId, orgUnitId, selectedTemplateId } = useLocationQuery();
const showAllAccessible = all !== undefined;

const {
Expand All @@ -112,12 +111,6 @@ const MainPageContainer = () => {
dispatch(updateShowAccessibleStatus(showAllAccessible));
}, [showAllAccessible, dispatch]);

useEffect(() => {
if (newDashboard) {
dispatch(enableNewDashboardsTemporarily(newDashboard.split(',')));
}
}, [dispatch, newDashboard]);

useEffect(() => {
if (programId && trackedEntityTypeId && displayFrontPageList && selectedTemplateId === undefined) {
handleChangeTemplateUrl({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ export const startSavingNewTrackedEntityInstanceWithEnrollmentEpic: Epic = (
ofType(registrationFormActionTypes.NEW_TRACKED_ENTITY_INSTANCE_WITH_ENROLLMENT_SAVE_START),
map((action) => {
const { currentSelections: { programId } } = store.value;
const { dataStore, userDataStore, temp } = store.value.useNewDashboard;
const { dataStore, userDataStore } = store.value.useNewDashboard;
const { enrollmentPayload, uid } = action.payload;
const { stages, useFirstStageDuringRegistration } = getTrackerProgramThrowIfNotFound(programId);

const shouldRedirect = shouldUseNewDashboard(userDataStore, dataStore, temp, programId);
const shouldRedirect = shouldUseNewDashboard({ userDataStore, dataStore, programId });
const { stageWithOpenAfterEnrollment, redirectTo } = getStageWithOpenAfterEnrollment(
stages,
useFirstStageDuringRegistration,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,16 @@ type Props = {

export const TrackedEntityInstance = ({ name, id, orgUnitId, linkProgramId }: Props) => {
const { baseUrl } = useConfig();
const { dataStore, userDataStore, temp } = useSelector(({ useNewDashboard }) => useNewDashboard);
const { dataStore, userDataStore } = useSelector(({ useNewDashboard }) => useNewDashboard);

const getUrl = useCallback(() => {
if (linkProgramId && shouldUseNewDashboard(userDataStore, dataStore, temp, linkProgramId)) {
return `/#/enrollment?${buildUrlQueryString({ teiId: id, programId: linkProgramId, orgUnitId })}`;
if (shouldUseNewDashboard({ userDataStore, dataStore, programId: linkProgramId, teiId: id })) {
return `/#/enrollment?${buildUrlQueryString({
teiId: id,
programId: linkProgramId,
orgUnitId,
enrollmentId: 'AUTO',
})}`;
}
const trackerBaseUrl = buildUrl(baseUrl, systemSettingsStore.get().trackerAppRelativePath, '/#/dashboard?');
const baseParams = `tei=${id}&ou=${orgUnitId}`;
Expand All @@ -32,7 +37,6 @@ export const TrackedEntityInstance = ({ name, id, orgUnitId, linkProgramId }: Pr
linkProgramId,
dataStore,
userDataStore,
temp,
]);

return (
Expand Down
Loading

0 comments on commit e9bfd86

Please sign in to comment.