From bc37417bc9c0fb7164c88bd113a129902c8225f7 Mon Sep 17 00:00:00 2001 From: eirikhaugstulen Date: Mon, 2 Oct 2023 22:47:58 +0200 Subject: [PATCH] chore: tests --- .../EnrollmentAddEventPageForm/index.js | 13 -- .../EnrollmentPage/BreakingTheGlass/index.js | 1 + .../StagesAndEventsWidget/index.js | 25 +-- cypress/e2e/MainPage.feature | 6 +- cypress/e2e/MainPage/index.js | 2 +- .../NewEventThroughAddRelationship/index.js | 5 +- .../WidgetEnrollment/index.js | 2 +- .../WidgetProfile/index.js | 1 - .../EventWorkingListsDev/index.js | 83 +++++----- .../EventWorkingListsUser.feature | 2 +- .../EventWorkingListsUser/index.js | 6 - .../TeiWorkingListsDev/index.js | 52 ++++--- .../TeiWorkingListsUser/index.js | 18 +-- cypress/e2e/common/index.js | 1 + cypress/e2e/sharedSteps.js | 3 +- ...EnrollmentAddEventPageDefault.component.js | 147 +++++++++--------- src/prompts/generate-component.md | 61 -------- 17 files changed, 179 insertions(+), 249 deletions(-) delete mode 100644 src/prompts/generate-component.md diff --git a/cypress/e2e/EnrollmentAddEventPage/EnrollmentAddEventPageForm/index.js b/cypress/e2e/EnrollmentAddEventPage/EnrollmentAddEventPageForm/index.js index 8e34aca626..9791f3f190 100644 --- a/cypress/e2e/EnrollmentAddEventPage/EnrollmentAddEventPageForm/index.js +++ b/cypress/e2e/EnrollmentAddEventPage/EnrollmentAddEventPageForm/index.js @@ -59,19 +59,6 @@ When(/^you click the checkbox number (.*)$/, (eq) => { .click(); }); -When(/^you click the (.*) button/, (buttonText) => { - cy.intercept({ - method: 'POST', - url: '**/tracker?async=false', - }).as('postEvents'); - - cy.get('[data-test="dhis2-uicore-button"]') - .contains(buttonText) - .click(); - - cy.wait('@postEvents'); -}); - When(/^you click the button to (.*) without post request/, (buttonText) => { cy.get('[data-test="dhis2-uicore-button"]') .contains(buttonText) diff --git a/cypress/e2e/EnrollmentPage/BreakingTheGlass/index.js b/cypress/e2e/EnrollmentPage/BreakingTheGlass/index.js index 6af4d1b0c6..e6b06365ed 100644 --- a/cypress/e2e/EnrollmentPage/BreakingTheGlass/index.js +++ b/cypress/e2e/EnrollmentPage/BreakingTheGlass/index.js @@ -86,6 +86,7 @@ And('you log out', () => { }); And('you log in as tracker2 user', () => { + cy.clearCookies(); cy.visit('/').then(() => { cy.get('#j_username').type('tracker2'); cy.get('#j_password').type('Tracker@123'); diff --git a/cypress/e2e/EnrollmentPage/StagesAndEventsWidget/index.js b/cypress/e2e/EnrollmentPage/StagesAndEventsWidget/index.js index 5d2ac784fa..7d867b0437 100644 --- a/cypress/e2e/EnrollmentPage/StagesAndEventsWidget/index.js +++ b/cypress/e2e/EnrollmentPage/StagesAndEventsWidget/index.js @@ -23,7 +23,6 @@ Then('the stages and events widget should be closed', () => { cy.get('[data-test="stages-and-events-widget"]') .within(() => { cy.get('[data-test="widget-contents"]') - .children() .should('not.exist'); cy.contains('Birth').should('not.exist'); }); @@ -115,23 +114,29 @@ Then('the default list should be displayed', () => { }); When(/^you sort list asc by (.*)$/, (columnName) => { - cy.get('[data-test="stages-and-events-widget"]') - .find('[data-test="widget-contents"]') + cy.get('[data-test="stages-and-events-widget"]').should('exist') + .find('[data-test="widget-contents"]').should('exist') .find('[data-test="stage-content"]') + .should('exist') .eq(2) .find('thead') + .should('exist') .find('th') + .should('exist') + .contains(columnName) + .parent() + .should('exist') .within(() => { - cy.contains('th', columnName) - .find('button') - .click(); - cy.wait(100); - cy.contains('th', columnName) - .find('button') - .click(); + cy.get('button').should('exist') // Use cy.get() instead of cy.find() + .click() + .then(() => { + // Perform further actions or assertions if needed + cy.get('button').should('exist').click(); + }); }); }); + Then(/^the sorted list by (.*) asc should be displayed$/, () => { const rows = [ '07-13|Bumbeh MCHP', diff --git a/cypress/e2e/MainPage.feature b/cypress/e2e/MainPage.feature index c95a65b9ff..70a5430db6 100644 --- a/cypress/e2e/MainPage.feature +++ b/cypress/e2e/MainPage.feature @@ -1,6 +1,6 @@ Feature: User interacts with Main page - Scenario: The Working list is displayed + Scenario: The Working list is displayed Given you are in the main page with no selections made And the user selects the program Child Programme And the user selects the org unit Ngelehun CHC @@ -29,7 +29,7 @@ Feature: User interacts with Main page Then the current url is /#/?orgUnitId=DiszpKrYNg8&programId=M3xtLkYBlKI&selectedTemplateId=PpGINOT00UX Scenario: You are redirected to create a custom working list - Given you are in the search page with Ngelehun and MNCH / PNC context + Given you are in the search page with Ngelehun and MNCH PNC context And the search form is displayed When the user clicks the element containing the text: Create saved list Then the current url is /#/?orgUnitId=DiszpKrYNg8&programId=uy2gU8kT1jF&selectedTemplateId=uy2gU8kT1jF-default @@ -41,4 +41,4 @@ Feature: User interacts with Main page When you opt in to use the new enrollment Dashboard for Child Programme Then 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 \ No newline at end of file + Then you see the opt in component for Child Programme diff --git a/cypress/e2e/MainPage/index.js b/cypress/e2e/MainPage/index.js index 9cb7d28292..f004659122 100644 --- a/cypress/e2e/MainPage/index.js +++ b/cypress/e2e/MainPage/index.js @@ -1,7 +1,7 @@ import { Given, Then, defineStep as And } from '@badeball/cypress-cucumber-preprocessor'; import '../sharedSteps'; -Given('you are in the search page with Ngelehun and MNCH / PNC context', () => { +Given('you are in the search page with Ngelehun and MNCH PNC context', () => { cy.visit('/#/search?orgUnitId=DiszpKrYNg8&programId=uy2gU8kT1jF'); }); diff --git a/cypress/e2e/NewEventThroughAddRelationship/index.js b/cypress/e2e/NewEventThroughAddRelationship/index.js index a3488816bb..d525b595a4 100644 --- a/cypress/e2e/NewEventThroughAddRelationship/index.js +++ b/cypress/e2e/NewEventThroughAddRelationship/index.js @@ -16,8 +16,7 @@ When('you add data to the form', () => { }); When('you submit the form', () => { - cy.server(); - cy.route('POST', '**/tracker?async=false').as('postData'); + cy.intercept('POST', '**/tracker?async=false').as('postData'); cy.get('[data-test="dhis2-uicore-splitbutton-button"]') .click(); }); @@ -25,7 +24,7 @@ When('you submit the form', () => { Then('the event should be sent to the server successfully', () => { cy.wait('@postData', { timeout: 30000 }) .then((result) => { - expect(result.status).to.equal(200); + expect(result.response.statusCode).to.equal(200); // clean up const id = result.response.body.bundleReport.typeReportMap.EVENT.objectReports[0].uid; cy.buildApiUrl('events', id) diff --git a/cypress/e2e/WidgetsForEnrollmentPages/WidgetEnrollment/index.js b/cypress/e2e/WidgetsForEnrollmentPages/WidgetEnrollment/index.js index 2726064014..676a73b3bb 100644 --- a/cypress/e2e/WidgetsForEnrollmentPages/WidgetEnrollment/index.js +++ b/cypress/e2e/WidgetsForEnrollmentPages/WidgetEnrollment/index.js @@ -9,7 +9,7 @@ When('you click the enrollment widget toggle open close button', () => { Then('the enrollment widget should be closed', () => { cy.get('[data-test="widget-enrollment"]').within(() => { - cy.get('[data-test="widget-contents"]').children().should('not.exist'); + cy.get('[data-test="widget-contents"]').should('not.exist'); }); }); diff --git a/cypress/e2e/WidgetsForEnrollmentPages/WidgetProfile/index.js b/cypress/e2e/WidgetsForEnrollmentPages/WidgetProfile/index.js index 5ecab8cdbc..31370a0606 100644 --- a/cypress/e2e/WidgetsForEnrollmentPages/WidgetProfile/index.js +++ b/cypress/e2e/WidgetsForEnrollmentPages/WidgetProfile/index.js @@ -17,7 +17,6 @@ Then('the widget profile should be closed', () => { cy.get('[data-test="profile-widget"]') .within(() => { cy.get('[data-test="widget-contents"]') - .children() .should('not.exist'); }); }); diff --git a/cypress/e2e/WorkingLists/EventWorkingLists/EventWorkingListsDev/index.js b/cypress/e2e/WorkingLists/EventWorkingLists/EventWorkingListsDev/index.js index d06382c62f..e1d79d283a 100644 --- a/cypress/e2e/WorkingLists/EventWorkingLists/EventWorkingListsDev/index.js +++ b/cypress/e2e/WorkingLists/EventWorkingLists/EventWorkingListsDev/index.js @@ -1,9 +1,22 @@ import { Given, When, Then } from '@badeball/cypress-cucumber-preprocessor'; import '../../sharedSteps'; +beforeEach(() => { + // Disable cache for chromium browsers to force the api to be called + if (Cypress.browser.family === 'chromium') { + Cypress.automation('remote:debugger:protocol', { + command: 'Network.enable', + params: {}, + }); + Cypress.automation('remote:debugger:protocol', { + command: 'Network.setCacheDisabled', + params: { cacheDisabled: true }, + }); + } +}); + Given('you open the main page with Ngelehun and malaria case context', () => { - cy.server(); - cy.route('GET', '**/tracker/events**').as('getDefaultEvents'); + cy.intercept('GET', '**/tracker/events**').as('getDefaultEvents'); cy.visit('#/?programId=VBqh0ynB2wv&orgUnitId=DiszpKrYNg8'); }); @@ -12,15 +25,15 @@ Then('events should be retrieved from the api using the default query args', () cy.wait('@getDefaultEvents', { timeout: 40000 }).as('result'); cy.get('@result') - .its('status') + .its('response.statusCode') .should('equal', 200); cy.get('@result') - .its('url') + .its('response.url') .should('include', 'pageSize=15'); cy.get('@result') - .its('url') + .its('response.url') .should('include', 'page=1'); cy.get('@result').its('response.body.instances').as('events'); @@ -52,7 +65,7 @@ When('you select the working list called events assigned to anyone', () => { .contains('Events assigned to anyone') .should('exist'); - cy.route('GET', '**/tracker/events**').as('getEventsAssignedToAnyone'); + cy.intercept('GET', '**/tracker/events**').as('getEventsAssignedToAnyone'); cy.get('[data-test="workinglists-template-selector-chips-container"]') .contains('Events assigned to anyone') @@ -63,29 +76,29 @@ Then('events assigned to anyone should be retrieved from the api', () => { cy.wait('@getEventsAssignedToAnyone', { timeout: 40000 }).as('result'); cy.get('@result') - .its('status') + .its('response.statusCode') .should('equal', 200); cy.get('@result') - .its('url') + .its('response.url') .should('include', 'assignedUserMode=ANY'); cy.get('@result') - .its('url') + .its('response.url') .should('include', 'page=1'); cy.get('@result').its('response.body.instances').as('events'); }); When('you apply the assignee filter', () => { - cy.route('GET', '**/tracker/events**').as('getEventsAssignedToAnyone'); + cy.intercept('GET', '**/tracker/events**').as('getEventsAssignedToAnyone'); cy.get('[data-test="list-view-filter-apply-button"]') .click(); }); When('you apply the status filter', () => { - cy.route('GET', '**/tracker/events**').as('getActiveEventsAssignedToAnyone'); + cy.intercept('GET', '**/tracker/events**').as('getActiveEventsAssignedToAnyone'); cy.get('[data-test="list-view-filter-apply-button"]') .click(); @@ -95,54 +108,48 @@ Then('active events that are assigned to anyone should be retrieved from the api cy.wait('@getActiveEventsAssignedToAnyone', { timeout: 40000 }).as('result'); cy.get('@result') - .its('status') + .its('response.statusCode') .should('equal', 200); cy.get('@result') - .its('url') + .its('response.url') .should('include', 'assignedUserMode=ANY'); cy.get('@result') - .its('url') + .its('response.url') .should('include', 'status=ACTIVE'); cy.get('@result') - .its('url') + .its('response.url') .should('include', 'page=1'); cy.get('@result').its('response.body.instances').as('events'); }); When('you apply the current filter on the event working list', () => { - cy.route('GET', '**/tracker/events**').as('getEvents'); + cy.intercept('GET', '**/tracker/events**').as('getEvents'); cy.get('[data-test="list-view-filter-apply-button"]') .click(); }); -Then('the age filter button should show that the filter is in effect', () => { - cy.get('[data-test="event-working-lists"]') - .contains('Age (years): 10 to 20') - .should('exist'); -}); - Then('events where age is between 10 and 20 should be retrieved from the api', () => { cy.wait('@getEvents', { timeout: 40000 }).as('result'); cy.get('@result') - .its('status') + .its('response.statusCode') .should('equal', 200); cy.get('@result') - .its('url') + .its('response.url') .should('match', /filter=.*10/); cy.get('@result') - .its('url') + .its('response.url') .should('match', /filter=.*20/); cy.get('@result') - .its('url') + .its('response.url') .should('include', 'page=1'); cy.get('@result').its('response.body.instances').as('events'); @@ -152,7 +159,7 @@ When('you click the next page button on the event working list', () => { cy.get('[data-test="search-pagination-next-page"]') .should('exist'); - cy.route('GET', '**/tracker/events**').as('getEvents'); + cy.intercept('GET', '**/tracker/events**').as('getEvents'); cy.get('[data-test="search-pagination-next-page"]') .click(); @@ -162,21 +169,21 @@ Then('new events should be retrieved from the api', () => { cy.wait('@getEvents', { timeout: 40000 }).as('result'); cy.get('@result') - .its('status') + .its('response.statusCode') .should('equal', 200); cy.get('@result').its('response.body.instances').as('events'); }); When('you click the previous page button on the event working list', () => { - cy.route('GET', '**/tracker/events**').as('getEvents'); + cy.intercept('GET', '**/tracker/events**').as('getEvents'); cy.get('[data-test="search-pagination-previous-page"]') .click(); }); When('you click the first page button on the event working list', () => { - cy.route('GET', '**/tracker/events**').as('getEvents'); + cy.intercept('GET', '**/tracker/events**').as('getEvents'); cy.get('[data-test="search-pagination-first-page"]') .click(); @@ -186,7 +193,7 @@ When('you change rows per page to 50', () => { cy.get('div[data-test="rows-per-page-selector"]') .should('exist'); - cy.route('GET', '**/tracker/events**').as('getEvents'); + cy.intercept('GET', '**/tracker/events**').as('getEvents'); cy.get('div[data-test="rows-per-page-selector"]') .click() @@ -198,15 +205,15 @@ Then('an event batch capped at 50 records should be retrieved from the api', () cy.wait('@getEvents', { timeout: 40000 }).as('result'); cy.get('@result') - .its('status') + .its('response.statusCode') .should('equal', 200); cy.get('@result') - .its('url') + .its('response.url') .should('include', 'pageSize=50'); cy.get('@result') - .its('url') + .its('response.url') .should('include', 'page=1'); cy.get('@result').its('response.body.instances').as('events'); @@ -217,7 +224,7 @@ When('you click the report date column header', () => { .contains('Report date') .should('exist'); - cy.route('GET', '**/tracker/events**').as('getEvents'); + cy.intercept('GET', '**/tracker/events**').as('getEvents'); cy.get('[data-test="dhis2-uicore-tableheadercellaction"]') .eq(0) @@ -230,15 +237,15 @@ Then('events should be retrieved from the api ordered ascendingly by report date cy.wait('@getEvents', { timeout: 40000 }).as('resultAsc'); cy.get('@resultAsc') - .its('status') + .its('response.statusCode') .should('equal', 200); cy.get('@resultAsc') - .its('url') + .its('response.url') .should('match', /order=.*asc/); cy.get('@resultAsc') - .its('url') + .its('response.url') .should('include', 'page=1'); cy.get('@resultAsc').its('response.body.instances').as('events'); diff --git a/cypress/e2e/WorkingLists/EventWorkingLists/EventWorkingListsUser.feature b/cypress/e2e/WorkingLists/EventWorkingLists/EventWorkingListsUser.feature index 529b1f43d4..46f86686fc 100644 --- a/cypress/e2e/WorkingLists/EventWorkingLists/EventWorkingListsUser.feature +++ b/cypress/e2e/WorkingLists/EventWorkingLists/EventWorkingListsUser.feature @@ -117,4 +117,4 @@ Given you open the main page with Ngelehun and Inpatient morbidity and mortality When you set the date of admission filter And you save the view as toDeleteWorkingList When you delete the name toDeleteWorkingList -Then the custom events working list is deleted \ No newline at end of file +Then the custom events working list is deleted diff --git a/cypress/e2e/WorkingLists/EventWorkingLists/EventWorkingListsUser/index.js b/cypress/e2e/WorkingLists/EventWorkingLists/EventWorkingListsUser/index.js index f18389053d..7946b94e2e 100644 --- a/cypress/e2e/WorkingLists/EventWorkingLists/EventWorkingListsUser/index.js +++ b/cypress/e2e/WorkingLists/EventWorkingLists/EventWorkingListsUser/index.js @@ -107,12 +107,6 @@ Then('the list should display active events that are assigned to anyone', () => }); }); -Then('the age filter button should show that the filter is in effect', () => { - cy.get('[data-test="event-working-lists"]') - .contains('Age (years): 10 to 20') - .should('exist'); -}); - Then('the list should display events where age is between 10 and 20', () => { const rows = [ '14 Male', diff --git a/cypress/e2e/WorkingLists/TeiWorkingLists/TeiWorkingListsDev/index.js b/cypress/e2e/WorkingLists/TeiWorkingLists/TeiWorkingListsDev/index.js index fd8022922a..56989dd920 100644 --- a/cypress/e2e/WorkingLists/TeiWorkingLists/TeiWorkingListsDev/index.js +++ b/cypress/e2e/WorkingLists/TeiWorkingLists/TeiWorkingListsDev/index.js @@ -1,6 +1,20 @@ import { Given, When, Then } from '@badeball/cypress-cucumber-preprocessor'; import '../../sharedSteps'; +beforeEach(() => { + // Disable cache for chromium browsers to force the api to be called + if (Cypress.browser.family === 'chromium') { + Cypress.automation('remote:debugger:protocol', { + command: 'Network.enable', + params: {}, + }); + Cypress.automation('remote:debugger:protocol', { + command: 'Network.setCacheDisabled', + params: { cacheDisabled: true }, + }); + } +}); + Given('you open the main page with Ngelehun and child programme context', () => { cy.intercept('GET', '**/tracker/trackedEntities**').as('getDefaultTeis'); @@ -18,7 +32,7 @@ Then('teis should be retrieved from the api using the default query args', () => cy.get('@result') .its('response.statusCode') - .should('be.oneOf', [200, 304]); + .should('eq', 200); cy.get('@result') .its('response.url') @@ -64,8 +78,8 @@ Then('teis with an active enrollment should be retrieved from the api', () => { cy.wait('@getTeisWithEnrollmentStatusActive', { timeout: 40000 }).as('result'); cy.get('@result') - .its('status') - .should('be.oneOf', [200, 304]); + .its('response.statusCode') + .should('eq', 200); cy.get('@result') .its('response.url') @@ -89,8 +103,8 @@ Then('teis with active enrollments and unassigned events should be retrieved fro cy.wait('@getTeisStatusAndAssigneeFilter', { timeout: 40000 }).as('result'); cy.get('@result') - .its('status') - .should('be.oneOf', [200, 304]); + .its('response.statusCode') + .should('eq', 200); cy.get('@result') .its('response.url') @@ -118,15 +132,15 @@ Then('teis with a first name containing John should be retrieved from the api', cy.wait('@getTeis', { timeout: 40000 }).as('result'); cy.get('@result') - .its('status') - .should('be.oneOf', [200, 304]); + .its('response.statusCode') + .should('eq', 200); cy.get('@result') - .its('url') + .its('response.url') .should('match', /filter=.*John/); cy.get('@result') - .its('url') + .its('response.url') .should('include', 'page=1'); cy.get('@result').its('response.body.instances').as('teis'); @@ -167,8 +181,8 @@ Then('new teis should be retrieved from the api', () => { cy.wait('@getTeis', { timeout: 40000 }).as('result'); cy.get('@result') - .its('status') - .should('be.oneOf', [200, 304]); + .its('response.statusCode') + .should('eq', 200); cy.get('@result').its('response.body.instances').as('teis'); }); @@ -197,15 +211,15 @@ Then('a tei batch capped at 50 records should be retrieved from the api', () => cy.wait('@getTeis', { timeout: 40000 }).as('result'); cy.get('@result') - .its('status') - .should('be.oneOf', [200, 304]); + .its('response.statusCode') + .should('eq', 200); cy.get('@result') - .its('url') + .its('response.url') .should('include', 'pageSize=50'); cy.get('@result') - .its('url') + .its('response.url') .should('include', 'page=1'); cy.get('@result').its('response.body.instances').as('teis'); @@ -234,15 +248,15 @@ Then('teis should be retrieved from the api ordered ascendingly by first name', cy.wait('@getTeis', { timeout: 40000 }).as('result'); cy.get('@result') - .its('status') - .should('be.oneOf', [200, 304]); + .its('response.statusCode') + .should('eq', 200); cy.get('@result') - .its('url') + .its('response.url') .should('match', /order=.*asc/); cy.get('@result') - .its('url') + .its('response.url') .should('include', 'page=1'); cy.get('@result').its('response.body.instances').as('teis'); diff --git a/cypress/e2e/WorkingLists/TeiWorkingLists/TeiWorkingListsUser/index.js b/cypress/e2e/WorkingLists/TeiWorkingLists/TeiWorkingListsUser/index.js index 34e5fe6669..36560cf46d 100644 --- a/cypress/e2e/WorkingLists/TeiWorkingLists/TeiWorkingListsUser/index.js +++ b/cypress/e2e/WorkingLists/TeiWorkingLists/TeiWorkingListsUser/index.js @@ -7,7 +7,7 @@ const cleanUpIfApplicable = () => { cy.buildApiUrl('programStageWorkingLists?filter=program.id:eq:qDkgAbB5Jlk&fields=id,displayName') .then(url => cy.request(url)) .then(({ body }) => { - const workingList = body.programStageWorkingLists?.find(e => e.displayName === 'Custom Program stage list'); + const workingList = body.programStageWorkingLists && body.programStageWorkingLists.find(e => e.displayName === 'Custom Program stage list'); if (!workingList) { return null; } @@ -168,11 +168,6 @@ When('you set the enrollment date to a relative range', () => { .type('1000'); }); -When('you apply the current filter', () => { - cy.get('[data-test="list-view-filter-apply-button"]') - .click(); -}); - When('you set the enrollment status filter to active', () => { cy.get('[data-test="tei-working-lists"]') .contains('Enrollment status') @@ -193,17 +188,6 @@ When('you set the event status filter to completed', () => { .click(); }); -When(/^you set the first name filter to (.*)$/, (name) => { - cy.get('[data-test="tei-working-lists"]') - .contains('First name') - .click(); - - cy.get('[data-test="list-view-filter-contents"]') - .find('input') - .type(name) - .blur(); -}); - When('you set the WHOMCH Smoking filter to No', () => { cy.get('[data-test="tei-working-lists"]') .within(() => { diff --git a/cypress/e2e/common/index.js b/cypress/e2e/common/index.js index 3cdea825dc..6d1163d2d3 100644 --- a/cypress/e2e/common/index.js +++ b/cypress/e2e/common/index.js @@ -1,3 +1,4 @@ +import { Before } from '@badeball/cypress-cucumber-preprocessor'; import { filterInstanceVersion } from '../../support/tagUtils'; diff --git a/cypress/e2e/sharedSteps.js b/cypress/e2e/sharedSteps.js index 9c78d2a315..8f419b639b 100644 --- a/cypress/e2e/sharedSteps.js +++ b/cypress/e2e/sharedSteps.js @@ -193,8 +193,7 @@ Then(/^you see the opt out component for (.*)$/, (program) => { }); When(/^you opt out to use the new enrollment Dashboard for (.*)$/, (program) => { - cy.server(); - cy.route('PUT', '**/dataStore/capture/useNewDashboard').as('optOutEnrollmentDashboard'); + cy.intercept('PUT', '**/dataStore/capture/useNewDashboard').as('optOutEnrollmentDashboard'); cy.contains('[data-test="dhis2-uicore-button"]', `Opt out for ${program}`).click(); cy.wait('@optOutEnrollmentDashboard', { timeout: 30000 }); }); diff --git a/src/core_modules/capture-core/components/Pages/EnrollmentAddEvent/EnrollmentAddEventPageDefault/EnrollmentAddEventPageDefault.component.js b/src/core_modules/capture-core/components/Pages/EnrollmentAddEvent/EnrollmentAddEventPageDefault/EnrollmentAddEventPageDefault.component.js index f7abac3990..6466d5f93b 100644 --- a/src/core_modules/capture-core/components/Pages/EnrollmentAddEvent/EnrollmentAddEventPageDefault/EnrollmentAddEventPageDefault.component.js +++ b/src/core_modules/capture-core/components/Pages/EnrollmentAddEvent/EnrollmentAddEventPageDefault/EnrollmentAddEventPageDefault.component.js @@ -57,87 +57,88 @@ const EnrollmentAddEventPagePain = ({ ready, classes, ...passOnProps -}: Props) => (
-
{i18n.t('Enrollment{{escape}} New Event', { escape: ':' })}
- {(() => { - if (pageFailure) { +}: Props) => ( +
+
{i18n.t('Enrollment{{escape}} New Event', { escape: ':' })}
+ {(() => { + if (pageFailure) { + return ( +
+ {i18n.t('There was an error loading the page')} +
+ ); + } else if (!orgUnitId) { + return ( + + {i18n.t('Choose a registering unit to start reporting')} + + ); + } else if (!ready) { + return null; + } + return (
- {i18n.t('There was an error loading the page')} -
- ); - } else if (!orgUnitId) { - return ( - - {i18n.t('Choose a registering unit to start reporting')} - - ); - } else if (!ready) { - return null; - } - - return ( -
-
-
-
- {!stageId ? - +
+
+ {!stageId ? + + : + + } +
+
+
+ + + {!hideWidgets.feedback && ( + - : - - } -
-
-
- - - {!hideWidgets.feedback && ( - - )} - {!hideWidgets.indicator && ( - - )} - - +
-
- ); - })()} -
); + ); + })()} +
); export const EnrollmentAddEventPageDefaultComponent: ComponentType<$Diff> = withStyles(styles)(EnrollmentAddEventPagePain); diff --git a/src/prompts/generate-component.md b/src/prompts/generate-component.md deleted file mode 100644 index 081ff140eb..0000000000 --- a/src/prompts/generate-component.md +++ /dev/null @@ -1,61 +0,0 @@ -# Generate component - Instructions -Follow these steps to generate a new component - -## Your role -You are an expert javascript developer who has been hired to build clean and maintainable code. - -## Requirements -Always output a full file of code, including imports, types and functional components -Never output markup, only javascript - -## Styling -We use withStyles from material-ui to style our components -Only use withStyles if you need to style a component - -## Variables -All functions should be arrow functions -All variables should be declared with const or let - -## Naming conventions -Variables and functions should be named using camelCase -Types should be named using PascalCase - -## Types -All javascript files must have a @flow comment at the top -Make sure everythign is typed -Do not allow any types to be `any` - -## Linting -Always add a semicolon at the end of a line -Always use single quotes -Always use 1 tab for indentation - -## DRY code -Make sure the code is DRY -Check for repeated code and refactor it into a function - -## Example component -```js -// @flow -import React from 'react'; - -type Props = { - title: string, -} - -const styles = { - container: { - display: 'flex', - justifyContent: 'center', - alignItems: 'center', - }, -}; - -const MyComponentPlain = ({ title, classes }: Props) => ( -
- {title} -
-); - -export const MyComponent = withStyles(styles)(MyComponentPlain); -``` \ No newline at end of file