From e9c64feb9da97f191cbd5de7e07c96d2a4ba8569 Mon Sep 17 00:00:00 2001 From: Jen Jones Arnesen Date: Wed, 25 Oct 2023 10:39:50 +0200 Subject: [PATCH] chore: test cleanup and use non-recording e2e-prod --- .github/workflows/dhis2-verify-app.yml | 2 +- cypress/integration/new.cy.js | 81 ++++--- cypress/integration/save.cy.js | 297 ++++++++++++------------- cypress/integration/start.cy.js | 98 ++++---- 4 files changed, 237 insertions(+), 241 deletions(-) diff --git a/.github/workflows/dhis2-verify-app.yml b/.github/workflows/dhis2-verify-app.yml index b1c195385b..9feb7536e3 100644 --- a/.github/workflows/dhis2-verify-app.yml +++ b/.github/workflows/dhis2-verify-app.yml @@ -83,7 +83,7 @@ jobs: call-workflow-e2e-prod: needs: [build, lint, test] - uses: dhis2/workflows/.github/workflows/analytics-e2e-tests.yml@master + uses: dhis2/line-listing-app/.github/workflows/e2e-prod.yml@e2e-prod-maps secrets: baseurl: ${{ secrets.CYPRESS_DHIS2_BASE_URL_DEV }} username: ${{ secrets.CYPRESS_DHIS2_USERNAME }} diff --git a/cypress/integration/new.cy.js b/cypress/integration/new.cy.js index 756be88ede..6975aadd81 100644 --- a/cypress/integration/new.cy.js +++ b/cypress/integration/new.cy.js @@ -41,64 +41,61 @@ const TEST_INDICATOR_NAMES = TEST_INDICATORS.slice(1, 3).map( ) describe('creating a new AO', () => { - it('navigates to the start page', () => { - goToStartPage() - }) visTypes.forEach((visType) => { const visTypeName = visTypeDisplayNames[visType] - describe(visTypeName, () => { - it(`create AO of type ${visTypeName}`, () => { - // creates a new AO - createNewAO() - expectStoreCurrentToBeEmpty() - expectVisualizationToNotBeVisible() - expectVisTypeToBeDefault() + it(`create AO of type ${visTypeName}`, () => { + // navigates to start page + goToStartPage() - // changes vis type - changeVisType(visTypeName) - expectVisTypeToBeValue(visTypeName) + // creates a new AO + createNewAO() + expectStoreCurrentToBeEmpty() + expectVisualizationToNotBeVisible() + expectVisTypeToBeDefault() - // adds dimensions - openDimension(DIMENSION_ID_DATA) + // changes vis type + changeVisType(visTypeName) + expectVisTypeToBeValue(visTypeName) - if (visType === VIS_TYPE_SCATTER) { - selectIndicators(TEST_INDICATOR_NAMES.slice(0, 1)) - switchDataTab('Horizontal') - selectDataElements(TEST_DATA_ELEMENT_NAMES.slice(0, 1)) - } else { - if (getAxisMaxNumberOfItems(visType, TEST_AXIS_ID) === 1) { - // Gauge and SV can only have 1 data item - TEST_DATA_ELEMENT_NAMES.splice(1) - } + // adds dimensions + openDimension(DIMENSION_ID_DATA) - selectDataElements(TEST_DATA_ELEMENT_NAMES) + if (visType === VIS_TYPE_SCATTER) { + selectIndicators(TEST_INDICATOR_NAMES.slice(0, 1)) + switchDataTab('Horizontal') + selectDataElements(TEST_DATA_ELEMENT_NAMES.slice(0, 1)) + } else { + if (getAxisMaxNumberOfItems(visType, TEST_AXIS_ID) === 1) { + // Gauge and SV can only have 1 data item + TEST_DATA_ELEMENT_NAMES.splice(1) } - clickDimensionModalUpdateButton() + selectDataElements(TEST_DATA_ELEMENT_NAMES) + } + + clickDimensionModalUpdateButton() - expectVisualizationToBeVisible(visType) + expectVisualizationToBeVisible(visType) - isYearOverYear(visType) && expectAOTitleToBeUnsaved() + isYearOverYear(visType) && expectAOTitleToBeUnsaved() - // FIXME: Store is always in default state - /* !isYearOverYear(visType) + // FIXME: Store is always in default state + /* !isYearOverYear(visType) ? expectStoreCurrentColumnsToHaveLength(1) : expectAOTitleToBeUnsaved() */ - if (visType !== VIS_TYPE_SCATTER) { - TEST_DATA_ELEMENT_NAMES.forEach((item) => - expectChartToContainDimensionItem(visType, item) - ) - } - }) + if (visType !== VIS_TYPE_SCATTER) { + TEST_DATA_ELEMENT_NAMES.forEach((item) => + expectChartToContainDimensionItem(visType, item) + ) + } if ([VIS_TYPE_SINGLE_VALUE, VIS_TYPE_GAUGE].includes(visType)) { - it('Data is locked to Series', () => { - expectDimensionOnAxisToHaveLockIcon( - DIMENSION_ID_DATA, - AXIS_ID_COLUMNS - ) - }) + // Data is locked to Series + expectDimensionOnAxisToHaveLockIcon( + DIMENSION_ID_DATA, + AXIS_ID_COLUMNS + ) } }) }) diff --git a/cypress/integration/save.cy.js b/cypress/integration/save.cy.js index eaf5c88fb8..07f9e6339c 100644 --- a/cypress/integration/save.cy.js +++ b/cypress/integration/save.cy.js @@ -61,162 +61,157 @@ const TEST_INDICATOR_NAMES = TEST_INDICATORS.slice(1, 4).map( // TODO: Add test to check that the description is saved and shown in the interpretations panel describe('saving an AO', () => { - describe('"save" and "save as" for a new AO', () => { - it('"save" and "save as" for a new AO', () => { - // navigates to the start page - goToStartPage() - - // checks that Save is disabled - clickMenuBarFileButton() - expectFileMenuButtonToBeDisabled(FILE_MENU_BUTTON_SAVE_EXISTING) - closeFileMenuWithClick() - - // changes vis type to ${TEST_VIS_TYPE_NAME} - changeVisType(TEST_VIS_TYPE_NAME) - - // adds Data dimension items - if (TEST_VIS_TYPE === VIS_TYPE_SCATTER) { - openDimension(DIMENSION_ID_DATA) - switchDataTab('Vertical') - selectIndicators([TEST_INDICATOR_NAMES[0]]) - clickDimensionModalUpdateButton() - openDimension(DIMENSION_ID_DATA) - switchDataTab('Horizontal') - selectIndicators([TEST_INDICATOR_NAMES[1]]) - clickDimensionModalUpdateButton() - } else { - openDimension(DIMENSION_ID_DATA) - selectDataElements( - TEST_DATA_ELEMENTS.slice(1, 2).map((item) => item.name) - ) - clickDimensionModalUpdateButton() - } - - // displays an unsaved visualization - expectVisualizationToBeVisible(TEST_VIS_TYPE) - expectAOTitleToBeUnsaved() - expectRouteToBeEmpty() - - // checks that Save is enabled - clickMenuBarFileButton() - expectFileMenuButtonToBeEnabled(FILE_MENU_BUTTON_SAVE_EXISTING) - closeFileMenuWithClick() - - // checks that Save as is disabled - clickMenuBarFileButton() - expectFileMenuButtonToBeDisabled(FILE_MENU_BUTTON_SAVEAS) - closeFileMenuWithClick() - - // saves new AO using "Save" - saveNewAO(TEST_VIS_NAME, TEST_VIS_DESCRIPTION) - expectAOTitleToBeValue(TEST_VIS_NAME) - expectVisualizationToBeVisible(TEST_VIS_TYPE) - - // checks that the url was changed - expectRouteToBeAOId() - - // all File menu buttons but Save are enabled - clickMenuBarFileButton() - const enabledButtons = [ - FILE_MENU_BUTTON_NEW, - FILE_MENU_BUTTON_OPEN, - FILE_MENU_BUTTON_SAVEAS, - FILE_MENU_BUTTON_RENAME, - FILE_MENU_BUTTON_TRANSLATE, - FILE_MENU_BUTTON_SHARE, - FILE_MENU_BUTTON_GETLINK, - FILE_MENU_BUTTON_DELETE, - ] - enabledButtons.forEach((button) => - expectFileMenuButtonToBeEnabled(button) + it('"save" and "save as" for a new AO', () => { + // navigates to the start page + goToStartPage() + + // checks that Save is disabled + clickMenuBarFileButton() + expectFileMenuButtonToBeDisabled(FILE_MENU_BUTTON_SAVE_EXISTING) + closeFileMenuWithClick() + + // changes vis type + cy.log('change vis type to', TEST_VIS_TYPE_NAME) + changeVisType(TEST_VIS_TYPE_NAME) + + // adds Data dimension items + if (TEST_VIS_TYPE === VIS_TYPE_SCATTER) { + openDimension(DIMENSION_ID_DATA) + switchDataTab('Vertical') + selectIndicators([TEST_INDICATOR_NAMES[0]]) + clickDimensionModalUpdateButton() + openDimension(DIMENSION_ID_DATA) + switchDataTab('Horizontal') + selectIndicators([TEST_INDICATOR_NAMES[1]]) + clickDimensionModalUpdateButton() + } else { + openDimension(DIMENSION_ID_DATA) + selectDataElements( + TEST_DATA_ELEMENTS.slice(1, 2).map((item) => item.name) ) - closeFileMenuWithClick() - - // replaces the selected period - replacePeriodItems(TEST_VIS_TYPE) - expectAOTitleToBeDirty() - expectVisualizationToBeVisible(TEST_VIS_TYPE) - - // saves AO using "Save" - saveExistingAO() - expectAOTitleToNotBeDirty() - expectAOTitleToBeValue(TEST_VIS_NAME) - expectVisualizationToBeVisible(TEST_VIS_TYPE) - - // saves AO using "Save As" - saveAOAs(TEST_VIS_NAME_UPDATED) - expectAOTitleToBeValue(TEST_VIS_NAME_UPDATED) - expectVisualizationToBeVisible(TEST_VIS_TYPE) - }) + clickDimensionModalUpdateButton() + } + + // displays an unsaved visualization + expectVisualizationToBeVisible(TEST_VIS_TYPE) + expectAOTitleToBeUnsaved() + expectRouteToBeEmpty() + + // checks that Save is enabled + clickMenuBarFileButton() + expectFileMenuButtonToBeEnabled(FILE_MENU_BUTTON_SAVE_EXISTING) + closeFileMenuWithClick() + + // checks that Save as is disabled + clickMenuBarFileButton() + expectFileMenuButtonToBeDisabled(FILE_MENU_BUTTON_SAVEAS) + closeFileMenuWithClick() + + // saves new AO using "Save" + saveNewAO(TEST_VIS_NAME, TEST_VIS_DESCRIPTION) + expectAOTitleToBeValue(TEST_VIS_NAME) + expectVisualizationToBeVisible(TEST_VIS_TYPE) + + // checks that the url was changed + expectRouteToBeAOId() + + // all File menu buttons but Save are enabled + clickMenuBarFileButton() + const enabledButtons = [ + FILE_MENU_BUTTON_NEW, + FILE_MENU_BUTTON_OPEN, + FILE_MENU_BUTTON_SAVEAS, + FILE_MENU_BUTTON_RENAME, + FILE_MENU_BUTTON_TRANSLATE, + FILE_MENU_BUTTON_SHARE, + FILE_MENU_BUTTON_GETLINK, + FILE_MENU_BUTTON_DELETE, + ] + enabledButtons.forEach((button) => + expectFileMenuButtonToBeEnabled(button) + ) + closeFileMenuWithClick() + + // replaces the selected period + replacePeriodItems(TEST_VIS_TYPE) + expectAOTitleToBeDirty() + expectVisualizationToBeVisible(TEST_VIS_TYPE) + + // saves AO using "Save" + saveExistingAO() + expectAOTitleToNotBeDirty() + expectAOTitleToBeValue(TEST_VIS_NAME) + expectVisualizationToBeVisible(TEST_VIS_TYPE) + + // saves AO using "Save As" + saveAOAs(TEST_VIS_NAME_UPDATED) + expectAOTitleToBeValue(TEST_VIS_NAME_UPDATED) + expectVisualizationToBeVisible(TEST_VIS_TYPE) }) - describe('"save" and "save as" for a saved AO created by you', () => { - it('navigates to the start page and opens a saved AO', () => { - // navigates to the start page and opens a saved AO - cy.intercept( - /systemSettings(\S)*keyAnalysisRelativePeriod(\S)*/, - (req) => { - req.reply((res) => { - res.send({ - body: { - ...res.body, - keyHideMonthlyPeriods: false, - }, - }) + it('navigates to the start page and opens a saved AO created by you', () => { + // navigates to the start page and opens a saved AO + cy.intercept( + /systemSettings(\S)*keyAnalysisRelativePeriod(\S)*/, + (req) => { + req.reply((res) => { + res.send({ + body: { + ...res.body, + keyHideMonthlyPeriods: false, + }, }) - } - ) - goToStartPage() - openAOByName(TEST_VIS_NAME_UPDATED) - expectAOTitleToBeValue(TEST_VIS_NAME_UPDATED) - - // replaces the selected period - replacePeriodItems(TEST_VIS_TYPE, { useAltData: true }) - expectAOTitleToBeDirty() - - // saves AO using "Save" - saveExistingAO() - expectAOTitleToNotBeDirty() - expectAOTitleToBeValue(TEST_VIS_NAME) - expectVisualizationToBeVisible(TEST_VIS_TYPE) - - // deletes AO - deleteAO() - expectRouteToBeEmpty() - expectStartScreenToBeVisible() - }) + }) + } + ) + goToStartPage() + openAOByName(TEST_VIS_NAME_UPDATED) + expectAOTitleToBeValue(TEST_VIS_NAME_UPDATED) + + // replaces the selected period + replacePeriodItems(TEST_VIS_TYPE, { useAltData: true }) + expectAOTitleToBeDirty() + + // saves AO using "Save" + saveExistingAO() + expectAOTitleToNotBeDirty() + expectAOTitleToBeValue(TEST_VIS_NAME) + expectVisualizationToBeVisible(TEST_VIS_TYPE) + + // deletes AO + deleteAO() + expectRouteToBeEmpty() + expectStartScreenToBeVisible() }) - describe('"save" a copied AO created by others', () => { - it('works after editing', () => { - const TEST_VIS_BY_OTHERS_NAME = 'ANC: 1-3 dropout rate Yearly' - const TEST_VIS_BY_OTHERS_NAME_UPDATED = `${TEST_VIS_BY_OTHERS_NAME} - updated` - - // navigates to the start page and opens an AO created by others - goToStartPage() - openAOByName(TEST_VIS_BY_OTHERS_NAME) - expectAOTitleToBeValue(TEST_VIS_BY_OTHERS_NAME) - - // saves AO using "Save As" - saveAOAs(TEST_VIS_BY_OTHERS_NAME_UPDATED) - expectAOTitleToBeValue(TEST_VIS_BY_OTHERS_NAME_UPDATED) - expectVisualizationToBeVisible() - - // edits the AO - openDimension(DIMENSION_ID_ORGUNIT) - deselectOrgUnitTreeItem('Western Area') - clickDimensionModalUpdateButton() - - // saves AO using "Save" - saveExistingAO() - expectAOTitleToNotBeDirty() - expectAOTitleToBeValue(TEST_VIS_BY_OTHERS_NAME_UPDATED) - expectVisualizationToBeVisible() - - // deletes AO - deleteAO() - expectRouteToBeEmpty() - expectStartScreenToBeVisible() - }) + it('"save" a copied AO created by others works after editing', () => { + const TEST_VIS_BY_OTHERS_NAME = 'ANC: 1-3 dropout rate Yearly' + const TEST_VIS_BY_OTHERS_NAME_UPDATED = `${TEST_VIS_BY_OTHERS_NAME} - updated` + + // navigates to the start page and opens an AO created by others + goToStartPage() + openAOByName(TEST_VIS_BY_OTHERS_NAME) + expectAOTitleToBeValue(TEST_VIS_BY_OTHERS_NAME) + + // saves AO using "Save As" + saveAOAs(TEST_VIS_BY_OTHERS_NAME_UPDATED) + expectAOTitleToBeValue(TEST_VIS_BY_OTHERS_NAME_UPDATED) + expectVisualizationToBeVisible() + + // edits the AO + openDimension(DIMENSION_ID_ORGUNIT) + deselectOrgUnitTreeItem('Western Area') + clickDimensionModalUpdateButton() + + // saves AO using "Save" + saveExistingAO() + expectAOTitleToNotBeDirty() + expectAOTitleToBeValue(TEST_VIS_BY_OTHERS_NAME_UPDATED) + expectVisualizationToBeVisible() + + // deletes AO + deleteAO() + expectRouteToBeEmpty() + expectStartScreenToBeVisible() }) }) diff --git a/cypress/integration/start.cy.js b/cypress/integration/start.cy.js index 95770ac1ca..abbd2fee4b 100644 --- a/cypress/integration/start.cy.js +++ b/cypress/integration/start.cy.js @@ -35,65 +35,69 @@ import { expectVisTypeToBeDefault } from '../elements/visualizationTypeSelector. import { expectWindowTitleToBeDefault } from '../elements/window.js' import { expectStoreCurrentToBeEmpty } from '../utils/store.js' -test('Start screen shows the correct initial state', () => { - //navigates to the start page - goToStartPage() +describe('Start screen', () => { + it('Start screen shows the correct initial state', () => { + // navigates to the start page + goToStartPage() - //window has a title - expectWindowTitleToBeDefault() + // window has a title + expectWindowTitleToBeDefault() - //store is empty - expectStoreCurrentToBeEmpty() + // store is empty + expectStoreCurrentToBeEmpty() - //no chart is visible - expectVisualizationToNotBeVisible() + // no chart is visible + expectVisualizationToNotBeVisible() - //displays most viewed section - expectMostViewedToBeVisible() + // displays most viewed section + expectMostViewedToBeVisible() - //vis type is default - expectVisTypeToBeDefault() + // vis type is default + expectVisTypeToBeDefault() - //axis series has data dimension - expectAxisToHaveDimension(AXIS_ID_COLUMNS, DIMENSION_ID_DATA) + // axis series has data dimension + expectAxisToHaveDimension(AXIS_ID_COLUMNS, DIMENSION_ID_DATA) - //data dimension has no items - expectDimensionToNotHaveItems(DIMENSION_ID_DATA) + // data dimension has no items + expectDimensionToNotHaveItems(DIMENSION_ID_DATA) - //axis category has period dimension - expectAxisToHaveDimension(AXIS_ID_ROWS, DIMENSION_ID_PERIOD) + // axis category has period dimension + expectAxisToHaveDimension(AXIS_ID_ROWS, DIMENSION_ID_PERIOD) - //period dimension has 1 item - expectDimensionToHaveItemAmount(DIMENSION_ID_PERIOD, 1) + // period dimension has 1 item + expectDimensionToHaveItemAmount(DIMENSION_ID_PERIOD, 1) - //axis filter has orgunit dimension - expectAxisToHaveDimension(AXIS_ID_FILTERS, DIMENSION_ID_ORGUNIT) + // axis filter has orgunit dimension + expectAxisToHaveDimension(AXIS_ID_FILTERS, DIMENSION_ID_ORGUNIT) - //orgunit dimension has 1 item - expectDimensionToHaveItemAmount(DIMENSION_ID_ORGUNIT, 1) + // orgunit dimension has 1 item + expectDimensionToHaveItemAmount(DIMENSION_ID_ORGUNIT, 1) - //primary File menu buttons are enabled and menu is closed with click - clickMenuBarFileButton() - const enabledButtons = [FILE_MENU_BUTTON_NEW, FILE_MENU_BUTTON_OPEN] - enabledButtons.forEach((button) => expectFileMenuButtonToBeEnabled(button)) - closeFileMenuWithClick() + // primary File menu buttons are enabled and menu is closed with click + clickMenuBarFileButton() + const enabledButtons = [FILE_MENU_BUTTON_NEW, FILE_MENU_BUTTON_OPEN] + enabledButtons.forEach((button) => + expectFileMenuButtonToBeEnabled(button) + ) + closeFileMenuWithClick() - //secondary File menu buttons are disabled and menu is closed with click - clickMenuBarFileButton() - const disabledButtons = [ - FILE_MENU_BUTTON_SAVEAS, - FILE_MENU_BUTTON_RENAME, - FILE_MENU_BUTTON_TRANSLATE, - FILE_MENU_BUTTON_SHARE, - FILE_MENU_BUTTON_GETLINK, - FILE_MENU_BUTTON_DELETE, - ] - disabledButtons.forEach((button) => - expectFileMenuButtonToBeDisabled(button) - ) - closeFileMenuWithClick() + // secondary File menu buttons are disabled and menu is closed with click + clickMenuBarFileButton() + const disabledButtons = [ + FILE_MENU_BUTTON_SAVEAS, + FILE_MENU_BUTTON_RENAME, + FILE_MENU_BUTTON_TRANSLATE, + FILE_MENU_BUTTON_SHARE, + FILE_MENU_BUTTON_GETLINK, + FILE_MENU_BUTTON_DELETE, + ] + disabledButtons.forEach((button) => + expectFileMenuButtonToBeDisabled(button) + ) + closeFileMenuWithClick() - //File menu is closed with Escape - clickMenuBarFileButton() - closeFileMenuWithEsc() + // File menu is closed with Escape + clickMenuBarFileButton() + closeFileMenuWithEsc() + }) })