diff --git a/cypress/integration/confirmLeave.cy.js b/cypress/integration/confirmLeave.cy.js index 0f49e9ff03..fbf40da4ec 100644 --- a/cypress/integration/confirmLeave.cy.js +++ b/cypress/integration/confirmLeave.cy.js @@ -24,7 +24,7 @@ describe('confirm leave modal', () => { goToStartPage() openAOByName(TEST_AO.name) expectVisualizationToBeVisible(TEST_AO.type) - expectAOTitleToNotBeDirty() + expectAOTitleToBeDirty() }) it(`replaces the selected period`, () => { replacePeriodItems(TEST_AO.type) diff --git a/cypress/integration/customErrors/visualizationError.cy.js b/cypress/integration/customErrors/visualizationError.cy.js deleted file mode 100644 index f6dfb97301..0000000000 --- a/cypress/integration/customErrors/visualizationError.cy.js +++ /dev/null @@ -1,81 +0,0 @@ -import { - DIMENSION_ID_DATA, - DIMENSION_ID_PERIOD, - visTypeDisplayNames, - VIS_TYPE_COLUMN, - VIS_TYPE_PIVOT_TABLE, -} from '@dhis2/analytics' -import { expectVisualizationToBeVisible } from '../../elements/chart.js' -import { - selectDataElements, - clickDimensionModalUpdateButton, - inputSearchTerm, - unselectAllItemsByButton, - selectRelativePeriods, - unselectItemByDoubleClick, -} from '../../elements/dimensionModal/index.js' -import { openDimension } from '../../elements/dimensionsPanel.js' -import { - expectErrorToContainTitle, - goToStartPage, -} from '../../elements/startScreen.js' -import { changeVisType } from '../../elements/visualizationTypeSelector.js' - -const NARRATIVE_ITEM = { - name: 'Cholera (Deaths < 5 yrs) Narrative', - content: - 'Cholera is an infection of the small intestine caused by the bacterium Vibrio cholerae.', -} - -const REGULAR_ITEM = { - name: 'All other follow-ups', - content: '53 666', -} - -describe('Visualization error', () => { - it('navigates to the start page and changes vis type to PT', () => { - goToStartPage() - changeVisType(visTypeDisplayNames[VIS_TYPE_PIVOT_TABLE]) - }) - it("selects period 'This year'", () => { - openDimension(DIMENSION_ID_PERIOD) - unselectAllItemsByButton() - selectRelativePeriods(['This year'], 'Years') - clickDimensionModalUpdateButton() - }) - it('selects a narrative item', () => { - openDimension(DIMENSION_ID_DATA) - inputSearchTerm('narrative') - selectDataElements([NARRATIVE_ITEM.name]) - clickDimensionModalUpdateButton() - expectVisualizationToBeVisible(VIS_TYPE_PIVOT_TABLE) - }) - it('narrative item is displayed correctly', () => { - cy.contains(NARRATIVE_ITEM.content) - }) - it('selects a regular item', () => { - openDimension(DIMENSION_ID_DATA) - selectDataElements([REGULAR_ITEM.name]) - clickDimensionModalUpdateButton() - expectVisualizationToBeVisible(VIS_TYPE_PIVOT_TABLE) - }) - it('both items are displayed correctly', () => { - cy.contains(NARRATIVE_ITEM.content) - cy.contains(REGULAR_ITEM.content) - }) - - it('changes vis type to Column', () => { - changeVisType(visTypeDisplayNames[VIS_TYPE_COLUMN]) - }) - it('regular item is displayed correctly', () => { - cy.contains(REGULAR_ITEM.content) - }) - it('removes the regular item', () => { - openDimension(DIMENSION_ID_DATA) - unselectItemByDoubleClick(REGULAR_ITEM.name) - clickDimensionModalUpdateButton() - }) - it('error is shown', () => { - expectErrorToContainTitle('Invalid data type') - }) -}) diff --git a/cypress/integration/dimensions/calculations.cy.js b/cypress/integration/dimensions/calculations.cy.js deleted file mode 100644 index cb3430fc92..0000000000 --- a/cypress/integration/dimensions/calculations.cy.js +++ /dev/null @@ -1,400 +0,0 @@ -import { DIMENSION_ID_DATA, VIS_TYPE_COLUMN } from '@dhis2/analytics' -import { - clickCancelButton, - clickCheckFormulaButton, - clickConfirmDeleteButton, - clickDeleteButton, - clickNewCalculationButton, - clickSaveButton, - expectCalculationsModalToBeVisible, - expectDimensionsListToHaveLength, - expectFormulaFieldToContainItem, - expectFormulaFieldToNotContainItem, - expectFormulaToBeInvalid, - expectFormulaToBeValid, - expectFormulaToNotBeValidated, - expectSaveButtonToBeDisabled, - expectSaveButtonToBeEnabled, - expectSaveButtonToHaveTooltip, - expectSaveButtonToNotHaveTooltip, - inputCalculationLabel, - removeItemFromFormulaFieldByDoubleClick, - selectItemFromDimensionsListByDoubleClick, - selectOperatorFromListByDoubleClick, - typeInNumberField, -} from '../../elements/calculationsModal.js' -import { expectVisualizationToBeVisible } from '../../elements/chart.js' -import { expectAppToNotBeLoading, typeInput } from '../../elements/common.js' -import { - clickDimensionModalUpdateButton, - clickEDIEditButton, - expectDataDimensionModalToBeVisible, - expectItemToBeSelectable, - expectItemToBeSelected, - expectNoDataItemsToBeSelected, - switchDataTypeTo, - unselectItemByDoubleClick, -} from '../../elements/dimensionModal/index.js' -import { openDimension } from '../../elements/dimensionsPanel.js' -import { saveNewAO } from '../../elements/fileMenu/save.js' -import { goToStartPage } from '../../elements/startScreen.js' - -const PAGE_SIZE = 50 -const DATA_ELEMENTS_URL = '**/dataElements?*' -const tooltipContentEl = 'tooltip-content' -const dataChipEl = 'layout-chip-dx' - -describe('Calculations', () => { - beforeEach(() => { - goToStartPage() - }) - it('initial state loads correctly', () => { - openDimension(DIMENSION_ID_DATA) - expectDataDimensionModalToBeVisible() - - cy.intercept('GET', DATA_ELEMENTS_URL).as('request') - clickNewCalculationButton() - cy.wait('@request').then(({ request, response }) => { - expect(request.url).to.contain('page=1') - expect(response.statusCode).to.eq(200) - expect(response.body.dataElements.length).to.eq(PAGE_SIZE) - }) - expectCalculationsModalToBeVisible() - - cy.getBySel('calculation-modal-title').should( - 'contain', - 'Data / New calculation' - ) - - cy.getBySel('data-element-group-select').contains('All groups') - - cy.getBySel('data-element-disaggregation-select').contains( - 'Totals only' - ) - - expectDimensionsListToHaveLength(PAGE_SIZE) - }) - it('can save, load and delete', () => { - const date = new Date().toLocaleString() - const TEST_DATA_ELEMENT = 'ANC 2nd visit' - const TEST_LABEL = `EDI ${date}` - const TEST_AO_NAME = `TEST with EDI ${date}` - - // create - openDimension(DIMENSION_ID_DATA) - clickNewCalculationButton() - selectItemFromDimensionsListByDoubleClick(TEST_DATA_ELEMENT) - expectFormulaFieldToContainItem(TEST_DATA_ELEMENT) - expectSaveButtonToBeDisabled() - expectSaveButtonToHaveTooltip('Add a name to save this calculation') - inputCalculationLabel(TEST_LABEL) - clickSaveButton() - expectItemToBeSelected(TEST_LABEL) - clickEDIEditButton(TEST_LABEL) - expectFormulaFieldToContainItem(TEST_DATA_ELEMENT) - clickCancelButton() - clickDimensionModalUpdateButton() - expectVisualizationToBeVisible(VIS_TYPE_COLUMN) - cy.getBySel(dataChipEl).trigger('mouseover') - cy.getBySelLike(tooltipContentEl).should('contain', TEST_LABEL) - cy.getBySel(dataChipEl).trigger('mouseout') - - // save - saveNewAO(TEST_AO_NAME) - expectAppToNotBeLoading() - expectVisualizationToBeVisible(VIS_TYPE_COLUMN) - - // load - openDimension(DIMENSION_ID_DATA) - expectItemToBeSelected(TEST_LABEL) - clickEDIEditButton(TEST_LABEL) - expectFormulaFieldToContainItem(TEST_DATA_ELEMENT) - - // delete - clickDeleteButton() - clickConfirmDeleteButton() - expectNoDataItemsToBeSelected() - }) - it('can search and filter data elements', () => { - let item - const expectFirstItemToBe = (name) => - cy - .getBySelLike('dimension-list') - .findBySelLike('data-element-option') - .eq(0) - .contains(name) - - openDimension(DIMENSION_ID_DATA) - clickNewCalculationButton() - - // initial state - item = 'ANC 1st visit' - expectDimensionsListToHaveLength(50) - expectFirstItemToBe(item) - selectItemFromDimensionsListByDoubleClick(item) - expectFormulaFieldToContainItem(item) - - // scroll down to fetch page 2 - cy.getBySelLike('dimension-list') - .parent() - .scrollTo('bottom', { duration: 50 }) // using regular Cypress scrolling doesn't trigger the fetch for some reason - expectDimensionsListToHaveLength(100) - expectFirstItemToBe(item) - cy.getBySelLike('dimension-list') - .findBySelLike('data-element-option') - .eq(50) - .contains('Blood pressure monitor, electronic or manual available') - - // search - typeInput('data-element-search', 'malaria') - expectDimensionsListToHaveLength(21) - item = 'IDSR Malaria' - expectFirstItemToBe(item) - selectItemFromDimensionsListByDoubleClick(item) - expectFormulaFieldToContainItem(item) - - // filter by group - cy.getBySel('data-element-group-select').click() - cy.getBySelLike('data-element-group-select-option') - .contains('Malaria') - .click() - expectDimensionsListToHaveLength(13) - item = 'Malaria referrals' - expectFirstItemToBe(item) - selectItemFromDimensionsListByDoubleClick(item) - expectFormulaFieldToContainItem(item) - - // change to details only - cy.getBySel('data-element-disaggregation-select').click() - cy.getBySelLike('data-element-disaggregation-select-option') - .contains('Details only') - .click() - expectDimensionsListToHaveLength(50) - item = 'Malaria referrals 0-4y' - selectItemFromDimensionsListByDoubleClick(item) - expectFormulaFieldToContainItem(item) - }) - it('can add and remove formula items', () => { - const TEST_DATA_ELEMENTS = [ - 'ART enrollment stage 1', - 'ART enrollment stage 2', - 'ART enrollment stage 3', - 'ART enrollment stage 4', - ] - const TEST_OPERATORS = ['+', '-', '×', '/', '(', ')', 'Number'] - - openDimension(DIMENSION_ID_DATA) - clickNewCalculationButton() - - // add with double click - selectItemFromDimensionsListByDoubleClick(TEST_DATA_ELEMENTS[0]) - expectFormulaFieldToContainItem(TEST_DATA_ELEMENTS[0]) - - // remove with double click - removeItemFromFormulaFieldByDoubleClick(TEST_DATA_ELEMENTS[0]) - expectFormulaFieldToNotContainItem(TEST_DATA_ELEMENTS[0]) - - // add with double click - selectItemFromDimensionsListByDoubleClick(TEST_DATA_ELEMENTS[1]) - expectFormulaFieldToContainItem(TEST_DATA_ELEMENTS[1]) - - // remove with remove button - cy.getBySel('formula-field') - .findBySelLike('formula-item') - .contains(TEST_DATA_ELEMENTS[1]) - .click() - cy.getBySel('calculation-modal') - .find('button') - .contains('Remove item') - .click() - expectFormulaFieldToNotContainItem(TEST_DATA_ELEMENTS[1]) - - // TODO: add and reorder with DND - - // add math operators: ( DE1 + DE2 - DE3 ) * DE4 / 10 - selectOperatorFromListByDoubleClick(TEST_OPERATORS[4]) - for (let i = 0; i < 4; i++) { - selectItemFromDimensionsListByDoubleClick(TEST_DATA_ELEMENTS[i]) - if (i === 2) { - selectOperatorFromListByDoubleClick(TEST_OPERATORS[5]) - } - selectOperatorFromListByDoubleClick(TEST_OPERATORS[i]) - } - selectOperatorFromListByDoubleClick(TEST_OPERATORS[6]) - typeInNumberField(13, 10) - - // validate formula - clickCheckFormulaButton() - expectFormulaToBeValid() - }) - - it('validates formulas', () => { - const saveButtonIsDisabled = () => { - expectSaveButtonToBeDisabled() - expectSaveButtonToHaveTooltip( - 'The calculation can only be saved with a valid formula' - ) - } - - const saveButtonIsEnabled = () => { - expectSaveButtonToBeEnabled() - expectSaveButtonToNotHaveTooltip() - } - - const TEST_LABEL = `EDI ${new Date().toLocaleString()}` - const TEST_DATA_ELEMENTS = [ - 'ART enrollment stage 1', - 'ART enrollment stage 2', - 'ART enrollment stage 3', - ] - openDimension(DIMENSION_ID_DATA) - clickNewCalculationButton() - inputCalculationLabel(TEST_LABEL) - expectFormulaToNotBeValidated() - saveButtonIsEnabled() - - // empty formula - invalid - clickCheckFormulaButton() - expectFormulaToBeInvalid( - 'Formula is empty. Add items to the formula from the lists on the left.' - ) - saveButtonIsDisabled() - - // single data element - valid - selectItemFromDimensionsListByDoubleClick(TEST_DATA_ELEMENTS[0]) - expectFormulaToNotBeValidated() - saveButtonIsEnabled() - clickCheckFormulaButton() - expectFormulaToBeValid() - saveButtonIsEnabled() - - // consecutive data elements - invalid - selectItemFromDimensionsListByDoubleClick(TEST_DATA_ELEMENTS[1]) - expectFormulaToNotBeValidated() - saveButtonIsEnabled() - clickCheckFormulaButton() - expectFormulaToBeInvalid('Consecutive data elements') - saveButtonIsDisabled() - - // data element, math operator, data element - valid - removeItemFromFormulaFieldByDoubleClick(TEST_DATA_ELEMENTS[1]) - expectFormulaToNotBeValidated() - saveButtonIsEnabled() - selectOperatorFromListByDoubleClick('+') - selectItemFromDimensionsListByDoubleClick(TEST_DATA_ELEMENTS[1]) - clickCheckFormulaButton() - expectFormulaToBeValid() - saveButtonIsEnabled() - - // // consecutive math operators - invalid - // TODO: currently allowed as negative values needs to be supported, e.g. 10 + -5 - - // ends with math operator - invalid - selectOperatorFromListByDoubleClick('/') - expectFormulaToNotBeValidated() - saveButtonIsEnabled() - clickCheckFormulaButton() - expectFormulaToBeInvalid('Starts or ends with a math operator') - saveButtonIsDisabled() - - // missing right parenthesis - invalid - selectOperatorFromListByDoubleClick('(') - expectFormulaToNotBeValidated() - saveButtonIsEnabled() - selectItemFromDimensionsListByDoubleClick(TEST_DATA_ELEMENTS[2]) - clickCheckFormulaButton() - expectFormulaToBeInvalid('Missing right parenthesis )') - saveButtonIsDisabled() - - // both parentheses - valid - selectOperatorFromListByDoubleClick(')') - expectFormulaToNotBeValidated() - saveButtonIsEnabled() - clickCheckFormulaButton() - expectFormulaToBeValid() - saveButtonIsEnabled() - - // missing left parenthesis - invalid - removeItemFromFormulaFieldByDoubleClick('(') - expectFormulaToNotBeValidated() - saveButtonIsEnabled() - clickCheckFormulaButton() - expectFormulaToBeInvalid('Missing left parenthesis (') - saveButtonIsDisabled() - }) - it('changes persist after saving', () => { - const getEditedLabel = (label) => label.slice(0, -1) + 'E' // "E" for edited - const date = new Date().toLocaleString() - const TEST_DATA_ELEMENTS = ['ANC 1st visit', 'ANC 2nd visit'] - const TEST_LABELS = [`EDI 1 ${date} O`, `EDI 2 ${date} O`] // "O" for original - const TEST_AO_NAME = `TEST with EDI ${date}` - - // create - openDimension(DIMENSION_ID_DATA) - TEST_LABELS.forEach((label, i) => { - clickNewCalculationButton() - selectItemFromDimensionsListByDoubleClick(TEST_DATA_ELEMENTS[i]) - inputCalculationLabel(label) - clickSaveButton() - expectItemToBeSelected(label) - }) - - // edit - clickEDIEditButton(TEST_LABELS[0]) - inputCalculationLabel(getEditedLabel(TEST_LABELS[0])) - clickSaveButton() - expectItemToBeSelected(getEditedLabel(TEST_LABELS[0])) - expectItemToBeSelected(TEST_LABELS[1]) - clickDimensionModalUpdateButton() - expectVisualizationToBeVisible(VIS_TYPE_COLUMN) - cy.getBySel(dataChipEl).trigger('mouseover') - cy.getBySelLike(tooltipContentEl).should( - 'contain', - getEditedLabel(TEST_LABELS[0]) - ) - cy.getBySelLike(tooltipContentEl).should('contain', TEST_LABELS[1]) - cy.getBySel(dataChipEl).trigger('mouseout') - - // reopen and deselect second EDI - openDimension(DIMENSION_ID_DATA) - expectItemToBeSelected(getEditedLabel(TEST_LABELS[0])) - expectItemToBeSelected(TEST_LABELS[1]) - unselectItemByDoubleClick(TEST_LABELS[1]) - clickDimensionModalUpdateButton() - expectVisualizationToBeVisible(VIS_TYPE_COLUMN) - cy.getBySel(dataChipEl).trigger('mouseover') - cy.getBySelLike(tooltipContentEl).should( - 'contain', - getEditedLabel(TEST_LABELS[0]) - ) - cy.getBySelLike(tooltipContentEl).should('not.contain', TEST_LABELS[1]) - cy.getBySel(dataChipEl).trigger('mouseout') - - // save - saveNewAO(TEST_AO_NAME) - expectAppToNotBeLoading() - expectVisualizationToBeVisible(VIS_TYPE_COLUMN) - cy.getBySel(dataChipEl).trigger('mouseover') - cy.getBySelLike(tooltipContentEl).should( - 'contain', - getEditedLabel(TEST_LABELS[0]) - ) - cy.getBySelLike(tooltipContentEl).should('not.contain', TEST_LABELS[1]) - cy.getBySel(dataChipEl).trigger('mouseout') - - // reopen and delete - openDimension(DIMENSION_ID_DATA) - expectItemToBeSelected(getEditedLabel(TEST_LABELS[0])) - switchDataTypeTo('Calculations') - expectItemToBeSelectable(TEST_LABELS[1]) - clickEDIEditButton(getEditedLabel(TEST_LABELS[0])) - expectFormulaFieldToContainItem(TEST_DATA_ELEMENTS[0]) - clickDeleteButton() - clickConfirmDeleteButton() - clickEDIEditButton(TEST_LABELS[1]) - expectFormulaFieldToContainItem(TEST_DATA_ELEMENTS[1]) - clickDeleteButton() - clickConfirmDeleteButton() - expectNoDataItemsToBeSelected() - }) -}) diff --git a/cypress/integration/dimensions/data.cy.js b/cypress/integration/dimensions/data.cy.js deleted file mode 100644 index 58965ee184..0000000000 --- a/cypress/integration/dimensions/data.cy.js +++ /dev/null @@ -1,457 +0,0 @@ -import { DIMENSION_ID_DATA } from '@dhis2/analytics' -import { - clickDimensionModalHideButton, - expectDimensionModalToContain, - expectDimensionModalToNotBeVisible, - unselectItemByDoubleClick, - selectItemByDoubleClick, - expectDataDimensionModalToBeVisible, - expectItemToBeSelected, - expectDataTypeToBe, - expectGroupSelectToNotBeVisible, - expectNoDataItemsToBeSelected, - expectSelectedItemsAmountToBeLeast, - expectSelectedItemsAmountToBe, - expectItemToBeSelectable, - expectSelectableDataItemsAmountToBe, - inputSearchTerm, - switchDataTypeTo, - clearSearchTerm, - expectSelectableDataItemsAmountToBeLeast, - expectGroupSelectToBeVisible, - switchGroupTo, - selectFirstDataItem, - expectGroupSelectToBe, - expectEmptySourceMessageToBe, - switchGroupToAll, - switchDataTypeToAll, - scrollSourceToBottom, - unselectItemByButton, - selectItemByButton, - expectSubGroupSelectToBeVisible, - expectSubGroupSelectToBe, - switchSubGroupTo, - expectSourceToBeLoading, - expectSourceToNotBeLoading, - unselectAllItemsByButton, - selectAllItemsByButton, - expectDataItemsToBeInSource, -} from '../../elements/dimensionModal/index.js' -import { openDimension } from '../../elements/dimensionsPanel.js' -import { goToStartPage } from '../../elements/startScreen.js' -import { - TEST_DATA_ELEMENTS, - TEST_DATA_SETS, - TEST_INDICATORS, -} from '../../utils/data.js' - -const PAGE_SIZE = 50 -const DATA_ITEMS_URL = '**/dataItems*' - -describe('Data dimension', () => { - describe('initial state', () => { - it('navigates to the start page', () => { - goToStartPage() - }) - it('opens the data dimension modal', () => { - cy.intercept('GET', DATA_ITEMS_URL).as('request') - openDimension(DIMENSION_ID_DATA) - cy.wait('@request').then(({ request, response }) => { - expect(request.url).to.contain('page=1') - expect(response.statusCode).to.eq(200) - expect(response.body.dataItems.length).to.eq(PAGE_SIZE) - }) - expectDataDimensionModalToBeVisible() - }) - it('modal has a title', () => { - expectDimensionModalToContain('Data') - }) - it('no items are selected', () => { - expectNoDataItemsToBeSelected() - }) - it("data type is 'All'", () => { - expectDataTypeToBe('All') - }) - it('group select is not visible', () => { - expectGroupSelectToNotBeVisible() - }) - const firstPageItemName = TEST_INDICATORS[0].name - it('an item can be selected by double click', () => { - selectItemByDoubleClick(firstPageItemName) - expectItemToBeSelected(firstPageItemName) - }) - it('an item can be unselected by double click', () => { - unselectItemByDoubleClick(firstPageItemName) - expectNoDataItemsToBeSelected() - }) - it('an item can be selected by button', () => { - selectItemByButton(firstPageItemName) - expectItemToBeSelected(firstPageItemName) - }) - it('an item can be unselected by button', () => { - unselectItemByButton(firstPageItemName) - expectNoDataItemsToBeSelected() - }) - }) - describe('selecting all and fetching more', () => { - const secondPageItemName = 'BCG doses' - it('all items can be selected', () => { - cy.intercept('GET', DATA_ITEMS_URL).as('request') - selectAllItemsByButton() - expectSelectedItemsAmountToBeLeast(PAGE_SIZE) - cy.wait('@request').then(({ request, response }) => { - expect(request.url).to.contain('page=2') - expect(response.statusCode).to.eq(200) - expect(response.body.dataItems.length).to.eq(PAGE_SIZE) - }) - expectSourceToNotBeLoading() - }) - it('more items are fetched', () => { - expectSelectableDataItemsAmountToBeLeast(PAGE_SIZE) - expectItemToBeSelectable(secondPageItemName) - }) - it('all items can be unselected', () => { - unselectAllItemsByButton() - expectNoDataItemsToBeSelected() - }) - it('more items are fetched when scrolling down', () => { - cy.intercept('GET', DATA_ITEMS_URL).as('request') - scrollSourceToBottom() - cy.wait('@request').then(({ request, response }) => { - expect(request.url).to.contain('page=3') - expect(response.statusCode).to.eq(200) - expect(response.body.dataItems.length).to.eq(PAGE_SIZE) - }) - expectSourceToNotBeLoading() - expectSelectableDataItemsAmountToBeLeast(PAGE_SIZE * 3) - }) - }) - describe('global search', () => { - const testSearchTerm = 'Dispenser' // Use a data element for the third step to work - it('receives a search term', () => { - cy.intercept('GET', DATA_ITEMS_URL).as('request') - inputSearchTerm(testSearchTerm) - cy.wait('@request').then(({ request, response }) => { - expect(request.url).to.contain('page=1') - expect(request.url).to.contain(testSearchTerm) - expect(response.statusCode).to.eq(200) - expect(response.body.dataItems.length).to.eq(1) - }) - expectSourceToNotBeLoading() - }) - // TODO: Test that the search is only called once, i.e. debounce works - it('search result is displayed', () => { - expectSelectableDataItemsAmountToBe(1) - expectItemToBeSelectable(testSearchTerm) - }) - it('search result is maintained when switching data type', () => { - cy.intercept('GET', '**/dataElements*').as('dataElements') - switchDataTypeTo('Data elements') - cy.wait('@dataElements').then(({ request, response }) => { - expect(request.url).to.contain('page=1') - expect(response.statusCode).to.eq(200) - expect(response.body.dataElements.length).to.be.eq(1) - }) - expectSourceToNotBeLoading() - expectSelectableDataItemsAmountToBe(1) - expectItemToBeSelectable(testSearchTerm) - clearSearchTerm() - cy.wait('@dataElements').then(({ request, response }) => { - expect(request.url).to.contain('page=1') - expect(response.statusCode).to.eq(200) - expect(response.body.dataElements.length).to.be.eq(PAGE_SIZE) - }) - expectSourceToNotBeLoading() - cy.intercept('GET', DATA_ITEMS_URL).as('dataItems') - switchDataTypeToAll() - cy.wait('@dataItems').then(({ request, response }) => { - expect(request.url).to.contain('page=1') - expect(response.statusCode).to.eq(200) - expect(response.body.dataItems.length).to.eq(PAGE_SIZE) - }) - expectSourceToNotBeLoading() - expectSelectableDataItemsAmountToBeLeast(PAGE_SIZE) - }) - it('search displays a correct error message', () => { - const testSearchTermWithNoMatch = 'nomatch' - cy.intercept('GET', DATA_ITEMS_URL).as('request') - inputSearchTerm(testSearchTermWithNoMatch) - cy.wait('@request').then(({ request, response }) => { - expect(request.url).to.contain('page=1') - expect(request.url).to.contain(testSearchTermWithNoMatch) - expect(response.statusCode).to.eq(200) - expect(response.body.dataItems.length).to.eq(0) - }) - expectSourceToNotBeLoading() - expectEmptySourceMessageToBe( - `Nothing found for "${testSearchTermWithNoMatch}"` - ) - }) - it('search result can be cleared', () => { - cy.intercept('GET', DATA_ITEMS_URL).as('request') - clearSearchTerm() - cy.wait('@request').then(({ request, response }) => { - expect(request.url).to.contain('page=1') - expect(response.statusCode).to.eq(200) - expect(response.body.dataItems.length).to.be.eq(PAGE_SIZE) - }) - expectSourceToNotBeLoading() - expectSelectableDataItemsAmountToBeLeast(PAGE_SIZE) - }) - it('modal is closed', () => { - clickDimensionModalHideButton() - expectDimensionModalToNotBeVisible() - }) - }) - const testDataTypes = [ - { - name: 'Indicators', - testGroup: { name: 'Facility infrastructure', itemAmount: 3 }, - testItem: { name: TEST_INDICATORS[2].name }, - defaultGroup: { name: 'All groups' }, - endpoint: { - hasMultiplePages: true, - requestUrl: '**/indicators*', - responseBody: 'indicators', - }, - }, - { - name: 'Data elements', - testGroup: { name: 'Measles', itemAmount: 3 }, - testSubGroup: { - name: 'Details only', - itemAmount: 10, - endpoint: { - hasMultiplePages: true, - requestUrl: '**/dataElementOperands*', - responseBody: 'dataElementOperands', - }, - }, - testItem: { name: TEST_DATA_ELEMENTS[2].name }, - defaultGroup: { name: 'All groups' }, - defaultSubGroup: { name: 'Totals only' }, - endpoint: { - hasMultiplePages: true, - requestUrl: '**/dataElements*', - responseBody: 'dataElements', - }, - }, - { - name: 'Data sets', - testGroup: { name: 'Child Health', itemAmount: 5 }, - testSubGroup: { name: 'Actual reports', itemAmount: 1 }, - testItem: { name: TEST_DATA_SETS[2].name }, - defaultGroup: { name: 'All data sets' }, - defaultSubGroup: { name: 'All metrics' }, - endpoint: { - hasMultiplePages: false, - requestUrl: '**/dataSets*', - responseBody: 'dataSets', - }, - }, - { - name: 'Event data items', - testGroup: { name: 'Information Campaign', itemAmount: 6 }, - testItem: { name: 'Diagnosis (ICD-10)' }, - defaultGroup: { name: 'All programs' }, - endpoint: { - hasMultiplePages: true, - requestUrl: DATA_ITEMS_URL, - responseBody: 'dataItems', - }, - }, - { - name: 'Program indicators', - testGroup: { name: 'Malaria focus investigation', itemAmount: 6 }, - testItem: { name: 'BMI male' }, - defaultGroup: { name: 'All programs' }, - endpoint: { - hasMultiplePages: true, - requestUrl: DATA_ITEMS_URL, - responseBody: 'dataItems', - }, - }, - ] - testDataTypes.forEach((testDataType) => { - describe(`${testDataType.name}`, () => { - it('opens the data dimension modal', () => { - openDimension(DIMENSION_ID_DATA) - expectDataDimensionModalToBeVisible() - }) - it(`switches to ${testDataType.name}`, () => { - cy.intercept('GET', testDataType.endpoint.requestUrl).as( - 'request' - ) - switchDataTypeTo(testDataType.name) - cy.wait('@request').then(({ response }) => { - expect(response.statusCode).to.eq(200) - expect( - response.body[testDataType.endpoint.responseBody].length - ).to.be.least(1) - }) - expectSourceToNotBeLoading() - expectSelectableDataItemsAmountToBeLeast(PAGE_SIZE) - }) - it('group select is visible', () => { - expectGroupSelectToBeVisible() - expectGroupSelectToBe(testDataType.defaultGroup.name) - }) - if (testDataType.endpoint.hasMultiplePages) { - it('more items are fetched when scrolling down', () => { - cy.intercept('GET', testDataType.endpoint.requestUrl).as( - 'request' - ) - scrollSourceToBottom() - cy.wait('@request').then(({ request, response }) => { - expect(request.url).to.contain('page=2') - expect(response.statusCode).to.eq(200) - expect( - response.body[testDataType.endpoint.responseBody] - .length - ).to.be.least(1) - }) - expectSourceToNotBeLoading() - expectSelectableDataItemsAmountToBeLeast(PAGE_SIZE + 1) - }) - } - it('an item can be selected', () => { - expectDataItemsToBeInSource([testDataType.testItem.name]) - selectItemByDoubleClick(testDataType.testItem.name) - expectItemToBeSelected(testDataType.testItem.name) - }) - it(`group can be changed to "${testDataType.testGroup.name}"`, () => { - cy.intercept('GET', testDataType.endpoint.requestUrl).as( - 'request' - ) - switchGroupTo(testDataType.testGroup.name) - cy.wait('@request').then(({ request, response }) => { - expect(request.url).to.contain('page=1') - expect(response.statusCode).to.eq(200) - }) - expectSourceToNotBeLoading() - expectGroupSelectToBe(testDataType.testGroup.name) - expectSelectableDataItemsAmountToBe( - testDataType.testGroup.itemAmount - ) - expectItemToBeSelected(testDataType.testItem.name) - }) - it('the first item can be selected', () => { - selectFirstDataItem() - expectSelectedItemsAmountToBe(2) - expectSelectableDataItemsAmountToBe( - testDataType.testGroup.itemAmount - 1 - ) - }) - if (['Data elements', 'Data sets'].includes(testDataType.name)) { - it('sub group select is visible', () => { - expectSubGroupSelectToBeVisible() - expectSubGroupSelectToBe(testDataType.defaultSubGroup.name) - }) - - it(`sub group can be changed to "${testDataType.testSubGroup.name}"`, () => { - cy.intercept( - 'GET', - testDataType.testSubGroup.endpoint?.requestUrl || - testDataType.endpoint.requestUrl - ).as('request') - switchSubGroupTo(testDataType.testSubGroup.name) - cy.wait('@request').then(({ request, response }) => { - expect(request.url).to.contain('page=1') - expect(response.statusCode).to.eq(200) - expect( - response.body[ - testDataType.testSubGroup.endpoint - ?.responseBody || - testDataType.endpoint.responseBody - ].length - ).to.be.eq(testDataType.testSubGroup.itemAmount) - }) - expectSourceToNotBeLoading() - expectSubGroupSelectToBe(testDataType.testSubGroup.name) - expectSelectableDataItemsAmountToBe( - testDataType.testSubGroup.itemAmount - ) - expectItemToBeSelected(testDataType.testItem.name) - }) - it(`sub group can be changed back to "${testDataType.defaultSubGroup.name}"`, () => { - cy.intercept('GET', testDataType.endpoint.requestUrl).as( - 'request' - ) - switchSubGroupTo(testDataType.defaultSubGroup.name) - cy.wait('@request').then(({ request, response }) => { - expect(request.url).to.contain('page=1') - expect(response.statusCode).to.eq(200) - }) - expectSourceToNotBeLoading() - expectSubGroupSelectToBe(testDataType.defaultSubGroup.name) - expectSelectableDataItemsAmountToBe( - testDataType.testGroup.itemAmount - 1 - ) - expectItemToBeSelected(testDataType.testItem.name) - }) - } - it('search displays a correct error message', () => { - const testSearchTermWithNoMatch = 'nomatch' - cy.intercept('GET', testDataType.endpoint.requestUrl).as( - 'request' - ) - inputSearchTerm(testSearchTermWithNoMatch) - cy.wait('@request').then(({ request, response }) => { - expect(request.url).to.contain('page=1') - expect(request.url).to.contain(testSearchTermWithNoMatch) - expect(response.statusCode).to.eq(200) - expect( - response.body[testDataType.endpoint.responseBody].length - ).to.eq(0) - }) - expectSourceToNotBeLoading() - expectEmptySourceMessageToBe( - `No ${testDataType.name.toLowerCase()} found for "${testSearchTermWithNoMatch}"` - ) - }) - it('selection and filter can be reset', () => { - unselectAllItemsByButton() - expectNoDataItemsToBeSelected() - cy.intercept('GET', testDataType.endpoint.requestUrl).as( - testDataType.endpoint.requestUrl - ) - clearSearchTerm() - cy.wait(`@${testDataType.endpoint.requestUrl}`).then( - ({ request, response }) => { - expect(request.url).to.contain('page=1') - expect(response.statusCode).to.eq(200) - } - ) - expectSourceToNotBeLoading() - expectSelectableDataItemsAmountToBe( - testDataType.testGroup.itemAmount - ) - switchGroupToAll() - cy.wait(`@${testDataType.endpoint.requestUrl}`).then( - ({ request, response }) => { - expect(request.url).to.contain('page=1') - expect(response.statusCode).to.eq(200) - } - ) - expectSourceToNotBeLoading() - expectSelectableDataItemsAmountToBeLeast(PAGE_SIZE) - if (testDataType.endpoint.requestUrl !== DATA_ITEMS_URL) { - cy.intercept('GET', DATA_ITEMS_URL).as('**/dataItems*') - } - switchDataTypeToAll() - expectSourceToBeLoading() - cy.wait('@**/dataItems*').then(({ request, response }) => { - expect(request.url).to.contain('page=1') - expect(response.statusCode).to.eq(200) - expect(response.body.dataItems.length).to.eq(PAGE_SIZE) - }) - expectSourceToNotBeLoading() - expectSelectableDataItemsAmountToBeLeast(PAGE_SIZE) - }) - it('modal is closed', () => { - clickDimensionModalHideButton() - expectDimensionModalToNotBeVisible() - }) - }) - }) -}) diff --git a/cypress/integration/dimensions/dynamic.cy.js b/cypress/integration/dimensions/dynamic.cy.js deleted file mode 100644 index 44e722fbc6..0000000000 --- a/cypress/integration/dimensions/dynamic.cy.js +++ /dev/null @@ -1,94 +0,0 @@ -import { DIMENSION_ID_DATA, VIS_TYPE_COLUMN } from '@dhis2/analytics' -import { expectVisualizationToBeVisible } from '../../elements/chart.js' -import { expectAppToNotBeLoading } from '../../elements/common.js' -import { - changeSelectionToAutomatic, - changeSelectionToManual, - clickDimensionModalAddToButton, - clickDimensionModalUpdateButton, - expectAutomaticSelectionToBeChecked, - expectDimensionModalToBeVisible, - expectItemToBeSelected, - expectManualSelectionToBeChecked, - selectDataElements, - selectItemByButton, -} from '../../elements/dimensionModal/index.js' -import { openDimension } from '../../elements/dimensionsPanel.js' -import { saveNewAO } from '../../elements/fileMenu/index.js' -import { - expectDimensionToHaveAllItemsSelected, - expectDimensionToHaveItemAmount, -} from '../../elements/layout.js' -import { goToStartPage } from '../../elements/startScreen.js' -import { TEST_DATA_ELEMENTS } from '../../utils/data.js' -import { getRandomArrayItem } from '../../utils/random.js' -import { expectWindowConfigSeriesToHaveLength } from '../../utils/window.js' - -const TEST_DATA_ELEMENT_NAME = getRandomArrayItem(TEST_DATA_ELEMENTS).name -const TEST_DYNAMIC_DIMENSION = { - id: 'J5jldMd8OHv', - name: 'Facility type', - itemAmount: 5, -} - -describe(`Dynamic dimension - ${TEST_DYNAMIC_DIMENSION.name}`, () => { - it('navigates to the start page and adds a data item', () => { - goToStartPage() - openDimension(DIMENSION_ID_DATA) - selectDataElements([TEST_DATA_ELEMENT_NAME]) - clickDimensionModalUpdateButton() - expectVisualizationToBeVisible(VIS_TYPE_COLUMN) - }) - const TEST_ITEM = 'Hospital' - it('adds an item manually', () => { - openDimension(TEST_DYNAMIC_DIMENSION.id) - expectDimensionModalToBeVisible(TEST_DYNAMIC_DIMENSION.id) - expectManualSelectionToBeChecked() - selectItemByButton(TEST_ITEM) - clickDimensionModalAddToButton() - expectVisualizationToBeVisible(VIS_TYPE_COLUMN) - expectWindowConfigSeriesToHaveLength(1) - expectDimensionToHaveItemAmount(TEST_DYNAMIC_DIMENSION.id, 1) - }) - it('adds all items automatically', () => { - openDimension(TEST_DYNAMIC_DIMENSION.id) - expectDimensionModalToBeVisible(TEST_DYNAMIC_DIMENSION.id) - expectManualSelectionToBeChecked() - changeSelectionToAutomatic() - expectAutomaticSelectionToBeChecked() - clickDimensionModalUpdateButton() - expectVisualizationToBeVisible(VIS_TYPE_COLUMN) - expectWindowConfigSeriesToHaveLength(TEST_DYNAMIC_DIMENSION.itemAmount) - expectDimensionToHaveAllItemsSelected(TEST_DYNAMIC_DIMENSION.id) - }) - it('switches back to manual and previous item is presisted', () => { - openDimension(TEST_DYNAMIC_DIMENSION.id) - expectDimensionModalToBeVisible(TEST_DYNAMIC_DIMENSION.id) - expectAutomaticSelectionToBeChecked() - changeSelectionToManual() - expectManualSelectionToBeChecked() - expectItemToBeSelected(TEST_ITEM) - clickDimensionModalUpdateButton() - expectVisualizationToBeVisible(VIS_TYPE_COLUMN) - expectWindowConfigSeriesToHaveLength(1) - expectDimensionToHaveItemAmount(TEST_DYNAMIC_DIMENSION.id, 1) - }) - it('switches back to automatic, saving, the selection is presisted', () => { - openDimension(TEST_DYNAMIC_DIMENSION.id) - expectDimensionModalToBeVisible(TEST_DYNAMIC_DIMENSION.id) - expectManualSelectionToBeChecked() - changeSelectionToAutomatic() - expectAutomaticSelectionToBeChecked() - clickDimensionModalUpdateButton() - expectVisualizationToBeVisible(VIS_TYPE_COLUMN) - expectWindowConfigSeriesToHaveLength(TEST_DYNAMIC_DIMENSION.itemAmount) - expectDimensionToHaveAllItemsSelected(TEST_DYNAMIC_DIMENSION.id) - saveNewAO( - `TEST DYNAMIC DIMENSION AUTOMATIC SELECTION ${new Date().toLocaleString()}` - ) - expectAppToNotBeLoading() - expectVisualizationToBeVisible(VIS_TYPE_COLUMN) - expectWindowConfigSeriesToHaveLength(TEST_DYNAMIC_DIMENSION.itemAmount) - expectDimensionToHaveAllItemsSelected(TEST_DYNAMIC_DIMENSION.id) - }) -}) diff --git a/cypress/integration/dimensions/orgUnit.cy.js b/cypress/integration/dimensions/orgUnit.cy.js deleted file mode 100644 index 1acf9f433a..0000000000 --- a/cypress/integration/dimensions/orgUnit.cy.js +++ /dev/null @@ -1,170 +0,0 @@ -import { - DIMENSION_ID_DATA, - VIS_TYPE_COLUMN, - DIMENSION_ID_ORGUNIT, - AXIS_ID_COLUMNS, -} from '@dhis2/analytics' -import { expectVisualizationToBeVisible } from '../../elements/chart.js' -import { - clickDimensionModalHideButton, - clickDimensionModalUpdateButton, - expectOrgUnitDimensionModalToBeVisible, - expectOrgUnitItemToBeSelected, - selectDataElements, - selectOrgUnitTreeItem, - expectOrgUnitDimensionToNotBeLoading, - openOrgUnitTreeItem, - deselectOrgUnitTreeItem, - toggleOrgUnitLevel, - toggleOrgUnitGroup, - selectUserOrgUnit, - expectOrgUnitTreeToBeDisabled, - expectOrgUnitTreeToBeEnabled, - deselectUserOrgUnit, -} from '../../elements/dimensionModal/index.js' -import { - clickContextMenuMove, - expectDimensionToHaveItemAmount, - openContextMenu, - openDimension, -} from '../../elements/layout.js' -import { clickMenuBarUpdateButton } from '../../elements/menuBar.js' -import { goToStartPage } from '../../elements/startScreen.js' -import { TEST_DATA_ELEMENTS } from '../../utils/data.js' -import { getRandomArrayItem } from '../../utils/random.js' -import { expectWindowConfigSeriesToHaveLength } from '../../utils/window.js' - -const TEST_DATA_ELEMENT_NAME = getRandomArrayItem(TEST_DATA_ELEMENTS).name - -describe(`Org unit dimension`, () => { - const TEST_ROOT = 'Sierra Leone' - const TEST_DEFAULT_ORG_UNIT = 'User organisation unit' - it('navigates to the start page, adds a data item, moves Org Unit to Series', () => { - goToStartPage() - openDimension(DIMENSION_ID_DATA) - selectDataElements([TEST_DATA_ELEMENT_NAME]) - clickDimensionModalHideButton() - openContextMenu(DIMENSION_ID_ORGUNIT) - clickContextMenuMove(DIMENSION_ID_ORGUNIT, AXIS_ID_COLUMNS) - clickMenuBarUpdateButton() - expectVisualizationToBeVisible(VIS_TYPE_COLUMN) - expectWindowConfigSeriesToHaveLength(1) - expectDimensionToHaveItemAmount(DIMENSION_ID_ORGUNIT, 1) - }) - const TEST_DISTRICT_1 = 'Bo' - it(`selects a district level org unit - ${TEST_DISTRICT_1}`, () => { - openDimension(DIMENSION_ID_ORGUNIT) - expectOrgUnitDimensionModalToBeVisible() - expectOrgUnitDimensionToNotBeLoading() - expectOrgUnitTreeToBeDisabled() - deselectUserOrgUnit(TEST_DEFAULT_ORG_UNIT) - selectOrgUnitTreeItem(TEST_ROOT) - selectOrgUnitTreeItem(TEST_DISTRICT_1) - clickDimensionModalUpdateButton() - expectVisualizationToBeVisible(VIS_TYPE_COLUMN) - expectWindowConfigSeriesToHaveLength(2) - expectDimensionToHaveItemAmount(DIMENSION_ID_ORGUNIT, 2) - }) - const TEST_DISTRICT_2 = 'Bombali' - const TEST_CHIEFDOM = 'Biriwa' - it(`selects a chiefdom level org unit - ${TEST_CHIEFDOM} in ${TEST_DISTRICT_2}`, () => { - openDimension(DIMENSION_ID_ORGUNIT) - expectOrgUnitDimensionModalToBeVisible() - expectOrgUnitDimensionToNotBeLoading() - expectOrgUnitItemToBeSelected(TEST_ROOT) - expectOrgUnitItemToBeSelected(TEST_DISTRICT_1) - openOrgUnitTreeItem(TEST_DISTRICT_2) - expectOrgUnitDimensionToNotBeLoading() - selectOrgUnitTreeItem(TEST_CHIEFDOM) - clickDimensionModalUpdateButton() - expectVisualizationToBeVisible(VIS_TYPE_COLUMN) - expectWindowConfigSeriesToHaveLength(3) - expectDimensionToHaveItemAmount(DIMENSION_ID_ORGUNIT, 3) - }) - it(`deselects ${TEST_DISTRICT_1} and ${TEST_CHIEFDOM}`, () => { - openDimension(DIMENSION_ID_ORGUNIT) - expectOrgUnitDimensionModalToBeVisible() - expectOrgUnitDimensionToNotBeLoading() - expectOrgUnitItemToBeSelected(TEST_ROOT) - expectOrgUnitItemToBeSelected(TEST_DISTRICT_1) - expectOrgUnitItemToBeSelected(TEST_CHIEFDOM) - deselectOrgUnitTreeItem(TEST_DISTRICT_1) - deselectOrgUnitTreeItem(TEST_CHIEFDOM) - clickDimensionModalUpdateButton() - expectVisualizationToBeVisible(VIS_TYPE_COLUMN) - expectWindowConfigSeriesToHaveLength(1) - expectDimensionToHaveItemAmount(DIMENSION_ID_ORGUNIT, 1) - }) - const TEST_LEVEL = 'District' - it(`selects a level - ${TEST_LEVEL}`, () => { - openDimension(DIMENSION_ID_ORGUNIT) - expectOrgUnitDimensionModalToBeVisible() - expectOrgUnitDimensionToNotBeLoading() - expectOrgUnitTreeToBeEnabled() - toggleOrgUnitLevel(TEST_LEVEL) - clickDimensionModalUpdateButton() - expectVisualizationToBeVisible(VIS_TYPE_COLUMN) - expectWindowConfigSeriesToHaveLength(13) // number of districts in Sierra Leone - expectDimensionToHaveItemAmount(DIMENSION_ID_ORGUNIT, 2) - }) - it(`deselects ${TEST_LEVEL}`, () => { - openDimension(DIMENSION_ID_ORGUNIT) - expectOrgUnitDimensionModalToBeVisible() - expectOrgUnitDimensionToNotBeLoading() - toggleOrgUnitLevel(TEST_LEVEL) - clickDimensionModalUpdateButton() - expectVisualizationToBeVisible(VIS_TYPE_COLUMN) - expectWindowConfigSeriesToHaveLength(1) - expectDimensionToHaveItemAmount(DIMENSION_ID_ORGUNIT, 1) - }) - const TEST_GROUP = 'Eastern Area' - it(`selects a group - ${TEST_GROUP}`, () => { - openDimension(DIMENSION_ID_ORGUNIT) - expectOrgUnitDimensionModalToBeVisible() - expectOrgUnitDimensionToNotBeLoading() - expectOrgUnitItemToBeSelected(TEST_ROOT) - toggleOrgUnitGroup(TEST_GROUP) - clickDimensionModalUpdateButton() - expectVisualizationToBeVisible(VIS_TYPE_COLUMN) - expectWindowConfigSeriesToHaveLength(3) // number of items in group - expectDimensionToHaveItemAmount(DIMENSION_ID_ORGUNIT, 2) - }) - it(`deselects ${TEST_GROUP}`, () => { - openDimension(DIMENSION_ID_ORGUNIT) - expectOrgUnitDimensionModalToBeVisible() - expectOrgUnitDimensionToNotBeLoading() - toggleOrgUnitGroup(TEST_GROUP) - clickDimensionModalUpdateButton() - expectVisualizationToBeVisible(VIS_TYPE_COLUMN) - expectWindowConfigSeriesToHaveLength(1) - expectDimensionToHaveItemAmount(DIMENSION_ID_ORGUNIT, 1) - }) - const TEST_USER_ORG_UNIT = 'User sub-units' - it(`selects a user org unit - '${TEST_USER_ORG_UNIT}'`, () => { - openDimension(DIMENSION_ID_ORGUNIT) - expectOrgUnitDimensionModalToBeVisible() - expectOrgUnitDimensionToNotBeLoading() - expectOrgUnitItemToBeSelected(TEST_ROOT) - expectOrgUnitTreeToBeEnabled() - selectUserOrgUnit(TEST_USER_ORG_UNIT) - expectOrgUnitTreeToBeDisabled() - clickDimensionModalUpdateButton() - expectVisualizationToBeVisible(VIS_TYPE_COLUMN) - expectWindowConfigSeriesToHaveLength(13) // number of items in user org unit - expectDimensionToHaveItemAmount(DIMENSION_ID_ORGUNIT, 1) - }) - it(`deselects '${TEST_USER_ORG_UNIT}'`, () => { - openDimension(DIMENSION_ID_ORGUNIT) - expectOrgUnitDimensionModalToBeVisible() - expectOrgUnitDimensionToNotBeLoading() - expectOrgUnitTreeToBeDisabled() - deselectUserOrgUnit(TEST_USER_ORG_UNIT) - expectOrgUnitTreeToBeEnabled() - selectOrgUnitTreeItem(TEST_ROOT) - expectOrgUnitItemToBeSelected(TEST_ROOT) - clickDimensionModalUpdateButton() - expectVisualizationToBeVisible(VIS_TYPE_COLUMN) - expectWindowConfigSeriesToHaveLength(1) - expectDimensionToHaveItemAmount(DIMENSION_ID_ORGUNIT, 1) - }) -}) diff --git a/cypress/integration/dimensions/period.cy.js b/cypress/integration/dimensions/period.cy.js deleted file mode 100644 index c0eb222091..0000000000 --- a/cypress/integration/dimensions/period.cy.js +++ /dev/null @@ -1,490 +0,0 @@ -import { DIMENSION_ID_PERIOD } from '@dhis2/analytics' -import { - expectDimensionModalToContain, - expectPeriodDimensionModalToBeVisible, - expectSelectedItemsAmountToBe, - expectItemToBeSelected, - expectRelativePeriodTypeToBe, - expectRelativeToBeSelected, - unselectItemByDoubleClick, - selectItemByDoubleClick, - unselectItemByButton, - selectItemByButton, - expectNoPeriodsToBeSelected, - expectRelativePeriodTypeSelectToContain, - expectFixedPeriodTypeSelectToContain, - openRelativePeriodsTypeSelect, - selectPeriodType, - unselectAllItemsByButton, - switchToFixedPeriods, - openFixedPeriodsTypeSelect, - expectRelativePeriodTypeSelectToNotContain, - expectFixedPeriodTypeSelectToNotContain, - expectFixedPeriodTypeToBe, - selectAllItemsByButton, - expectFirstSelectedItemToBe, - clickMoveUpButton, - clickMoveDownButton, - singleClickSelectedItem, - expectSelectablePeriodItemsAmountToBeLeast, - expectSelectablePeriodItemsAmountToBe, -} from '../../elements/dimensionModal/index.js' -import { openDimension } from '../../elements/dimensionsPanel.js' -import { goToStartPage } from '../../elements/startScreen.js' - -const defaultRelativePeriod = 'Last 3 months' -const systemSettingsBody = { - keyAnalysisRelativePeriod: 'LAST_3_MONTHS', - keyAnalysisDigitGroupSeparator: 'COMMA', - keyHideDailyPeriods: false, - keyHideWeeklyPeriods: false, - // TODO: Add Bi-weekly periods once it's supported - keyHideMonthlyPeriods: false, - keyHideBiMonthlyPeriods: false, - keyIgnoreAnalyticsApprovalYearThreshold: -1, - keyDateFormat: 'yyyy-MM-dd', -} - -describe('Period dimension', () => { - describe('initial state', () => { - it('navigates to the start page', () => { - cy.intercept( - /systemSettings(\S)*keyAnalysisRelativePeriod(\S)*/, - (req) => { - req.reply((res) => { - res.send({ body: systemSettingsBody }) - }) - } - ) - goToStartPage() - }) - it('opens the period dimension modal', () => { - openDimension(DIMENSION_ID_PERIOD) - expectPeriodDimensionModalToBeVisible() - }) - it('modal has a title', () => { - expectDimensionModalToContain('Period') - }) - it('1 period is selected', () => { - expectSelectedItemsAmountToBe(1) - }) - it(`period '${defaultRelativePeriod}' is selected`, () => { - expectItemToBeSelected(defaultRelativePeriod) - }) - it("period category is 'Relative'", () => { - expectRelativeToBeSelected() - }) - it("period type is 'Months'", () => { - expectRelativePeriodTypeToBe('Months') - }) - it('a period can be unselected by double click', () => { - unselectItemByDoubleClick(defaultRelativePeriod) - expectNoPeriodsToBeSelected() - }) - it('a period can be selected by double click', () => { - selectItemByDoubleClick(defaultRelativePeriod) - expectItemToBeSelected(defaultRelativePeriod) - }) - it('a period can be unselected by button', () => { - unselectItemByButton(defaultRelativePeriod) - expectNoPeriodsToBeSelected() - }) - it('a period can be selected by button', () => { - selectItemByButton(defaultRelativePeriod) - expectItemToBeSelected(defaultRelativePeriod) - }) - it('all can be selected by button', () => { - selectAllItemsByButton() - expectSelectedItemsAmountToBe(6) - }) - it('all can be unselected by button', () => { - unselectAllItemsByButton() - expectNoPeriodsToBeSelected() - }) - it('periods can be reordered', () => { - const itemA = 'This month' - const itemB = 'Last month' - selectItemByDoubleClick(itemA) - selectItemByDoubleClick(itemB) - expectFirstSelectedItemToBe(itemA) - singleClickSelectedItem(itemB) - clickMoveUpButton(itemB) - expectFirstSelectedItemToBe(itemB) - clickMoveDownButton(itemB) - expectFirstSelectedItemToBe(itemA) - unselectAllItemsByButton() - }) - const relativePeriodTypes = [ - { name: 'Days', amountOfChildren: 9 }, - { name: 'Weeks', amountOfChildren: 6 }, - { name: 'Bi-weeks', amountOfChildren: 3 }, - { name: 'Months', amountOfChildren: 6 }, - { name: 'Bi-months', amountOfChildren: 4 }, - { name: 'Quarters', amountOfChildren: 4 }, - { name: 'Six-months', amountOfChildren: 3 }, - { name: 'Financial Years', amountOfChildren: 3 }, - { name: 'Years', amountOfChildren: 4 }, - ] - relativePeriodTypes.forEach((type) => - it(`relative period type '${type.name}' has ${type.amountOfChildren} items`, () => { - openRelativePeriodsTypeSelect() - selectPeriodType(type.name) - expectSelectablePeriodItemsAmountToBe(type.amountOfChildren) - }) - ) - it('can switch to fixed periods', () => { - switchToFixedPeriods() - }) - it("period type is 'Monthly'", () => { - expectFixedPeriodTypeToBe('Monthly') - }) - const fixedPeriodTypes = [ - { name: 'Daily', amountOfChildren: 365 }, - { name: 'Weekly', amountOfChildren: 52 }, - { name: 'Weekly (Start Wednesday)', amountOfChildren: 52 }, - { name: 'Weekly (Start Thursday)', amountOfChildren: 52 }, - { name: 'Weekly (Start Saturday)', amountOfChildren: 52 }, - { name: 'Weekly (Start Sunday)', amountOfChildren: 52 }, - { name: 'Bi-weekly', amountOfChildren: 26 }, - { name: 'Monthly', amountOfChildren: 12 }, - { name: 'Bi-monthly', amountOfChildren: 6 }, - { name: 'Quarterly', amountOfChildren: 4 }, - { name: 'Six-monthly', amountOfChildren: 2 }, - { name: 'Six-monthly April', amountOfChildren: 2 }, - { name: 'Yearly', amountOfChildren: 10 }, - { name: 'Financial year (Start November)', amountOfChildren: 10 }, - { name: 'Financial year (Start October)', amountOfChildren: 10 }, - { name: 'Financial year (Start July)', amountOfChildren: 10 }, - { name: 'Financial year (Start April)', amountOfChildren: 10 }, - ] - fixedPeriodTypes.forEach((type) => - it(`fixed period type '${type.name}' has ${type.amountOfChildren} items`, () => { - openFixedPeriodsTypeSelect() - selectPeriodType(type.name) - type.amountOfChildren > 50 - ? expectSelectablePeriodItemsAmountToBeLeast( - type.amountOfChildren - ) - : expectSelectablePeriodItemsAmountToBe( - type.amountOfChildren - ) - }) - ) - }) - describe('using period settings - hidden monthly', () => { - it('navigates to the start page', () => { - cy.intercept( - /systemSettings(\S)*keyAnalysisRelativePeriod(\S)*/, - (req) => { - req.reply((res) => { - res.send({ - body: { - ...systemSettingsBody, - keyHideMonthlyPeriods: true, - }, - }) - }) - } - ) - goToStartPage() - }) - it('opens the period dimension modal', () => { - openDimension(DIMENSION_ID_PERIOD) - expectPeriodDimensionModalToBeVisible() - }) - it("period type is 'Quarters'", () => { - expectRelativePeriodTypeToBe('Quarters') - }) - it("relative type 'Months' is not shown", () => { - openRelativePeriodsTypeSelect() - expectRelativePeriodTypeSelectToNotContain('Months') - }) - it('all other relative types are shown', () => { - const relativePeriodTypes = [ - 'Days', - 'Weeks', - 'Bi-weeks', - 'Bi-months', - 'Quarters', - 'Six-months', - 'Financial Years', - 'Years', - ] - relativePeriodTypes.forEach((type) => - expectRelativePeriodTypeSelectToContain(type) - ) - selectPeriodType(relativePeriodTypes.slice(-1)[0]) // Click the last item to close the dropdown - }) - it('can switch to fixed periods', () => { - switchToFixedPeriods() - }) - it("period type is 'Quarterly'", () => { - expectFixedPeriodTypeToBe('Quarterly') - }) - it("fixed type 'Monthly' is not shown", () => { - openFixedPeriodsTypeSelect() - expectFixedPeriodTypeSelectToNotContain('Monthly') - }) - it('all other fixed types are shown', () => { - const fixedPeriodTypes = [ - 'Daily', - 'Weekly', - 'Weekly (Start Wednesday)', - 'Weekly (Start Thursday)', - 'Weekly (Start Saturday)', - 'Weekly (Start Sunday)', - 'Bi-weekly', - 'Bi-monthly', - 'Quarterly', - 'Six-monthly', - 'Six-monthly April', - 'Yearly', - 'Financial year (Start November)', - 'Financial year (Start October)', - 'Financial year (Start July)', - 'Financial year (Start April)', - ] - fixedPeriodTypes.forEach((type) => - expectFixedPeriodTypeSelectToContain(type) - ) - selectPeriodType(fixedPeriodTypes[1]) // Click the second item to close the dropdown - }) - }) - describe('using period settings - hidden weekly', () => { - it('navigates to the start page', () => { - cy.intercept( - /systemSettings(\S)*keyAnalysisRelativePeriod(\S)*/, - (req) => { - req.reply((res) => { - res.send({ - body: { - ...systemSettingsBody, - keyHideWeeklyPeriods: true, - }, - }) - }) - } - ) - goToStartPage() - }) - it('opens the period dimension modal', () => { - openDimension(DIMENSION_ID_PERIOD) - expectPeriodDimensionModalToBeVisible() - }) - it("period type is 'Months'", () => { - expectRelativePeriodTypeToBe('Months') - }) - it("relative type 'Weeks' is not shown", () => { - openRelativePeriodsTypeSelect() - expectRelativePeriodTypeSelectToNotContain('Weeks') - }) - it('all other relative types are shown', () => { - const relativePeriodTypes = [ - 'Days', - 'Bi-weeks', - 'Months', - 'Bi-months', - 'Quarters', - 'Six-months', - 'Financial Years', - 'Years', - ] - relativePeriodTypes.forEach((type) => - expectRelativePeriodTypeSelectToContain(type) - ) - selectPeriodType(relativePeriodTypes.slice(-1)[0]) // Click the last item to close the dropdown - }) - it('can switch to fixed periods', () => { - switchToFixedPeriods() - }) - it("period type is 'Monthly'", () => { - expectFixedPeriodTypeToBe('Monthly') - }) - it("fixed type 'Weekly' and other weekly based periods are not shown", () => { - openFixedPeriodsTypeSelect() - expectFixedPeriodTypeSelectToNotContain('Weekly') - expectFixedPeriodTypeSelectToNotContain('Weekly (Start Wednesday)') - expectFixedPeriodTypeSelectToNotContain('Weekly (Start Thursday)') - expectFixedPeriodTypeSelectToNotContain('Weekly (Start Saturday)') - expectFixedPeriodTypeSelectToNotContain('Weekly (Start Sunday)') - }) - it('all other fixed types are shown', () => { - const fixedPeriodTypes = [ - 'Daily', - 'Bi-weekly', - 'Monthly', - 'Bi-monthly', - 'Quarterly', - 'Six-monthly', - 'Six-monthly April', - 'Yearly', - 'Financial year (Start November)', - 'Financial year (Start October)', - 'Financial year (Start July)', - 'Financial year (Start April)', - ] - fixedPeriodTypes.forEach((type) => - expectFixedPeriodTypeSelectToContain(type) - ) - selectPeriodType(fixedPeriodTypes[1]) // Click the second item to close the dropdown - }) - }) - describe('using period settings - hidden daily', () => { - it('navigates to the start page', () => { - cy.intercept( - /systemSettings(\S)*keyAnalysisRelativePeriod(\S)*/, - (req) => { - req.reply((res) => { - res.send({ - body: { - ...systemSettingsBody, - keyHideDailyPeriods: true, - }, - }) - }) - } - ) - goToStartPage() - }) - it('opens the period dimension modal', () => { - openDimension(DIMENSION_ID_PERIOD) - expectPeriodDimensionModalToBeVisible() - }) - it("period type is 'Months'", () => { - expectRelativePeriodTypeToBe('Months') - }) - it("relative type 'Days' is not shown", () => { - openRelativePeriodsTypeSelect() - expectRelativePeriodTypeSelectToNotContain('Days') - }) - it('all other relative types are shown', () => { - const relativePeriodTypes = [ - 'Weeks', - 'Bi-weeks', - 'Months', - 'Bi-months', - 'Quarters', - 'Six-months', - 'Financial Years', - 'Years', - ] - relativePeriodTypes.forEach((type) => - expectRelativePeriodTypeSelectToContain(type) - ) - selectPeriodType(relativePeriodTypes.slice(-1)[0]) // Click the last item to close the dropdown - }) - it('can switch to fixed periods', () => { - switchToFixedPeriods() - }) - it("period type is 'Monthly'", () => { - expectFixedPeriodTypeToBe('Monthly') - }) - it("fixed type 'Daily' is not shown", () => { - openFixedPeriodsTypeSelect() - expectFixedPeriodTypeSelectToNotContain('Daily') - }) - it('all other fixed types are shown', () => { - const fixedPeriodTypes = [ - 'Weekly', - 'Weekly (Start Wednesday)', - 'Weekly (Start Thursday)', - 'Weekly (Start Saturday)', - 'Weekly (Start Sunday)', - 'Bi-weekly', - 'Monthly', - 'Bi-monthly', - 'Quarterly', - 'Six-monthly', - 'Six-monthly April', - 'Yearly', - 'Financial year (Start November)', - 'Financial year (Start October)', - 'Financial year (Start July)', - 'Financial year (Start April)', - ] - fixedPeriodTypes.forEach((type) => - expectFixedPeriodTypeSelectToContain(type) - ) - selectPeriodType(fixedPeriodTypes[1]) // Click the second item to close the dropdown - }) - }) - describe('using period settings - hidden bi-monthly', () => { - it('navigates to the start page', () => { - cy.intercept( - /systemSettings(\S)*keyAnalysisRelativePeriod(\S)*/, - (req) => { - req.reply((res) => { - res.send({ - body: { - ...systemSettingsBody, - keyHideBiMonthlyPeriods: true, - }, - }) - }) - } - ) - goToStartPage() - }) - it('opens the period dimension modal', () => { - openDimension(DIMENSION_ID_PERIOD) - expectPeriodDimensionModalToBeVisible() - }) - it("period type is 'Months'", () => { - expectRelativePeriodTypeToBe('Months') - }) - it("relative type 'Bi-months' is not shown", () => { - openRelativePeriodsTypeSelect() - expectRelativePeriodTypeSelectToNotContain('Bi-months') - }) - it('all other relative types are shown', () => { - const relativePeriodTypes = [ - 'Days', - 'Weeks', - 'Bi-weeks', - 'Months', - 'Quarters', - 'Six-months', - 'Financial Years', - 'Years', - ] - relativePeriodTypes.forEach((type) => - expectRelativePeriodTypeSelectToContain(type) - ) - selectPeriodType(relativePeriodTypes.slice(-1)[0]) // Click the last item to close the dropdown - }) - it('can switch to fixed periods', () => { - switchToFixedPeriods() - }) - it("period type is 'Monthly'", () => { - expectFixedPeriodTypeToBe('Monthly') - }) - it("fixed type 'Bi-monthly' is not shown", () => { - openFixedPeriodsTypeSelect() - expectFixedPeriodTypeSelectToNotContain('Bi-monthly') - }) - it('all other fixed types are shown', () => { - const fixedPeriodTypes = [ - 'Daily', - 'Weekly', - 'Weekly (Start Wednesday)', - 'Weekly (Start Thursday)', - 'Weekly (Start Saturday)', - 'Weekly (Start Sunday)', - 'Bi-weekly', - 'Monthly', - 'Quarterly', - 'Six-monthly', - 'Six-monthly April', - 'Yearly', - 'Financial year (Start November)', - 'Financial year (Start October)', - 'Financial year (Start July)', - 'Financial year (Start April)', - ] - fixedPeriodTypes.forEach((type) => - expectFixedPeriodTypeSelectToContain(type) - ) - selectPeriodType(fixedPeriodTypes[1]) // Click the second item to close the dropdown - }) - }) -}) diff --git a/cypress/integration/dimensionsPanel.cy.js b/cypress/integration/dimensionsPanel.cy.js deleted file mode 100644 index 0b4dabf71d..0000000000 --- a/cypress/integration/dimensionsPanel.cy.js +++ /dev/null @@ -1,164 +0,0 @@ -// TODO: Test drag-and-drop to the layout - -import { - getFixedDimensions, - getDynamicDimensions, - DIMENSION_ID_DATA, - DIMENSION_ID_PERIOD, - DIMENSION_ID_ORGUNIT, - AXIS_ID_COLUMNS, - DIMENSION_ID_ASSIGNED_CATEGORIES, - AXIS_ID_ROWS, -} from '@dhis2/analytics' -import { - expectDimensionModalToBeVisible, - clickDimensionModalHideButton, - deselectUserOrgUnit, - clickDimensionModalUpdateButton, - expectDimensionModalToNotBeVisible, - unselectAllItemsByButton, -} from '../elements/dimensionModal/index.js' -import { - openDimension, - openContextMenu, - clickContextMenuAdd, - clickContextMenuRemove, - filterDimensionsByText, - expectFixedDimensionsToHaveLength, - clearDimensionsFilter, - clickContextMenuMove, - expectDimensionToNotHaveSelectedStyle, - expectDimensionToHaveSelectedStyle, - clickContextMenuDimSubMenu, - expectRecommendedIconToBeVisible, -} from '../elements/dimensionsPanel.js' -import { expectAxisToHaveDimension } from '../elements/layout.js' -import { goToStartPage } from '../elements/startScreen.js' -import { - TEST_CUSTOM_DIMENSIONS, - TEST_DEFAULT_RECOMMENDED_DIMENSIONS, -} from '../utils/data.js' -import { getRandomArrayItem } from '../utils/random.js' - -const TEST_FIXED_DIMS = Object.values(getFixedDimensions()) -const TEST_DYNAMIC_DIMS = Object.values(getDynamicDimensions()) -const TEST_CUSTOM_DIMS = [getRandomArrayItem(TEST_CUSTOM_DIMENSIONS)] - -describe('interacting with the dimensions panel', () => { - it('navigates to the start page', () => { - goToStartPage() - }) - describe('displays recommended icons', () => { - ;[getRandomArrayItem(TEST_DEFAULT_RECOMMENDED_DIMENSIONS)].forEach( - (dim) => - describe(`${dim.name}`, () => { - it('displays the recommended icon', () => { - expectRecommendedIconToBeVisible(dim.id) - }) - }) - ) - }) - describe('removes all default items from the layout', () => { - it('removes data', () => { - openContextMenu(DIMENSION_ID_DATA) - clickContextMenuRemove(DIMENSION_ID_DATA) - expectDimensionToNotHaveSelectedStyle(DIMENSION_ID_DATA) - }) - it('removes period and period items', () => { - openDimension(DIMENSION_ID_PERIOD) - unselectAllItemsByButton() - clickDimensionModalUpdateButton() - openContextMenu(DIMENSION_ID_PERIOD) - clickContextMenuRemove(DIMENSION_ID_PERIOD) - expectDimensionToNotHaveSelectedStyle(DIMENSION_ID_PERIOD) - }) - it('removes org unit and org unit items', () => { - openDimension(DIMENSION_ID_ORGUNIT) - deselectUserOrgUnit('User organisation unit') - clickDimensionModalUpdateButton() - openContextMenu(DIMENSION_ID_ORGUNIT) - clickContextMenuRemove(DIMENSION_ID_ORGUNIT) - expectDimensionToNotHaveSelectedStyle(DIMENSION_ID_ORGUNIT) - }) - }) - describe('opening items by clicking them', () => { - ;[...TEST_FIXED_DIMS, ...TEST_CUSTOM_DIMS].forEach((dim) => { - it(`opens and closes ${dim.name}`, () => { - openDimension(dim.id) - expectDimensionModalToBeVisible(dim.id) - clickDimensionModalHideButton() - }) - }) - }) - describe('adding items by using the context menu', () => { - const TEST_AXIS = AXIS_ID_COLUMNS - ;[ - ...TEST_FIXED_DIMS, - ...TEST_DYNAMIC_DIMS, - ...TEST_CUSTOM_DIMS, - ].forEach((dim) => { - it(`adds ${dim.name} to ${TEST_AXIS} axis`, () => { - openContextMenu(dim.id) - clickContextMenuAdd(dim.id, TEST_AXIS) - expectDimensionToHaveSelectedStyle(dim.id) - expectAxisToHaveDimension(TEST_AXIS, dim.id) - if (dim.id !== DIMENSION_ID_ASSIGNED_CATEGORIES) { - expectDimensionModalToBeVisible(dim.id) - clickDimensionModalHideButton() - expectDimensionModalToNotBeVisible() - } - }) - }) - }) - describe('moving items by using the context menu', () => { - const TEST_AXIS = AXIS_ID_ROWS - const TEST_DIM = getRandomArrayItem(TEST_FIXED_DIMS) - it(`moves ${TEST_DIM.name} to ${TEST_AXIS} axis`, () => { - openContextMenu(TEST_DIM.id) - clickContextMenuMove(TEST_DIM.id, TEST_AXIS) - expectAxisToHaveDimension(TEST_AXIS, TEST_DIM.id) - }) - }) - describe('removing by using the context menu', () => { - const TEST_DIM = getRandomArrayItem(TEST_FIXED_DIMS) - it(`removes ${TEST_DIM.name}`, () => { - openContextMenu(TEST_DIM.id) - clickContextMenuRemove(TEST_DIM.id) - expectDimensionToNotHaveSelectedStyle(TEST_DIM.id) - }) - }) - describe('handling AC by using the Data item context menu', () => { - const TEST_DIM = TEST_DYNAMIC_DIMS.find( - (dim) => dim.id === DIMENSION_ID_ASSIGNED_CATEGORIES - ) - it(`removes and adds ${TEST_DIM.name}`, () => { - const TEST_AXIS = AXIS_ID_COLUMNS - // remove - openContextMenu(DIMENSION_ID_DATA) - clickContextMenuRemove(TEST_DIM.id) - expectDimensionToNotHaveSelectedStyle(TEST_DIM.id) - - // add - openContextMenu(DIMENSION_ID_DATA) - clickContextMenuDimSubMenu(TEST_DIM.id) - clickContextMenuAdd(TEST_DIM.id, TEST_AXIS) - expectDimensionToHaveSelectedStyle(TEST_DIM.id) - expectAxisToHaveDimension(TEST_AXIS, TEST_DIM.id) - }) - }) - describe('filtering dimensions', () => { - const TEST_DEFAULT_FIXED_DIMS_LENGTH = TEST_FIXED_DIMS.length - const TEST_FILTER_SEARCH_TERM = getRandomArrayItem(TEST_FIXED_DIMS).name - - it(`applies dimension filter "${TEST_FILTER_SEARCH_TERM} and clears it"`, () => { - // apply - expectFixedDimensionsToHaveLength(TEST_DEFAULT_FIXED_DIMS_LENGTH) - filterDimensionsByText(TEST_FILTER_SEARCH_TERM) - expectFixedDimensionsToHaveLength(1) - - // clear - clearDimensionsFilter() - expectFixedDimensionsToHaveLength(TEST_DEFAULT_FIXED_DIMS_LENGTH) - }) - }) -}) diff --git a/cypress/integration/drillDown.cy.js b/cypress/integration/drillDown.cy.js deleted file mode 100644 index 139b5e5f99..0000000000 --- a/cypress/integration/drillDown.cy.js +++ /dev/null @@ -1,131 +0,0 @@ -import { - DIMENSION_ID_DATA, - VIS_TYPE_COLUMN, - DIMENSION_ID_PERIOD, - DIMENSION_ID_ORGUNIT, - AXIS_ID_FILTERS, - AXIS_ID_ROWS, - visTypeDisplayNames, - VIS_TYPE_PIVOT_TABLE, -} from '@dhis2/analytics' -import { - clickChartItem, - expectChartItemsToHaveLength, - expectVisualizationToBeVisible, -} from '../elements/chart.js' -import { - clickDimensionModalUpdateButton, - selectIndicators, -} from '../elements/dimensionModal/index.js' -import { - clickChangeOrgUnit, - drillDown, - drillUp, - expectDrillDownMenuToBeVisible, - expectDrillDownMenuToNotBeVisible, -} from '../elements/drillDownMenu.js' -import { - clickContextMenuMove, - expectAxisToHaveDimension, - expectDimensionToHaveItemAmount, - openContextMenu, - openDimension, -} from '../elements/layout.js' -import { clickMenuBarUpdateButton } from '../elements/menuBar.js' -import { - clickTableValueCell, - expectTableValueCellsToHaveLength, -} from '../elements/pivotTable.js' -import { goToStartPage } from '../elements/startScreen.js' -import { changeVisType } from '../elements/visualizationTypeSelector.js' -import { TEST_INDICATORS } from '../utils/data.js' - -describe('Drill-down: Column', () => { - it('navigates to the start page and adds a data item', () => { - goToStartPage() - openDimension(DIMENSION_ID_DATA) - selectIndicators([TEST_INDICATORS[2].name]) - clickDimensionModalUpdateButton() - expectVisualizationToBeVisible(VIS_TYPE_COLUMN) - }) - it('no context menu is opened when org unit is in filter', () => { - clickChartItem(0) - expectDrillDownMenuToNotBeVisible() - }) - it('swaps org unit and period dimensions', () => { - openContextMenu(DIMENSION_ID_PERIOD) - clickContextMenuMove(DIMENSION_ID_PERIOD, AXIS_ID_FILTERS) - openContextMenu(DIMENSION_ID_ORGUNIT) - clickContextMenuMove(DIMENSION_ID_ORGUNIT, AXIS_ID_ROWS) - clickMenuBarUpdateButton() - expectVisualizationToBeVisible() - expectAxisToHaveDimension(AXIS_ID_FILTERS, DIMENSION_ID_PERIOD) - expectAxisToHaveDimension(AXIS_ID_ROWS, DIMENSION_ID_ORGUNIT) - expectDimensionToHaveItemAmount(DIMENSION_ID_ORGUNIT, 1) - }) - it('context menu is opened when org unit is in category', () => { - clickChartItem(0) - expectDrillDownMenuToBeVisible() - }) - it('drills down one level', () => { - clickChangeOrgUnit() - drillDown('District level in Sierra Leone') - expectVisualizationToBeVisible() - expectDimensionToHaveItemAmount(DIMENSION_ID_ORGUNIT, 2) - expectChartItemsToHaveLength(13) - }) - it('drills up one level', () => { - clickChartItem(0) - clickChangeOrgUnit() - drillUp('Sierra Leone') - expectVisualizationToBeVisible() - expectDimensionToHaveItemAmount(DIMENSION_ID_ORGUNIT, 1) - expectChartItemsToHaveLength(1) - }) -}) - -describe('Drill-down: Pivot table', () => { - it('navigates to the start page, changes vis type to Pivot table and adds a data item', () => { - goToStartPage() - changeVisType(visTypeDisplayNames[VIS_TYPE_PIVOT_TABLE]) - clickMenuBarUpdateButton() - openDimension(DIMENSION_ID_DATA) - selectIndicators([TEST_INDICATORS[2].name]) - clickDimensionModalUpdateButton() - expectVisualizationToBeVisible(VIS_TYPE_PIVOT_TABLE) - }) - it('no context menu is opened when org unit is in filter', () => { - clickTableValueCell(0) - expectDrillDownMenuToNotBeVisible() - }) - it('swaps org unit and period dimensions', () => { - openContextMenu(DIMENSION_ID_PERIOD) - clickContextMenuMove(DIMENSION_ID_PERIOD, AXIS_ID_FILTERS) - openContextMenu(DIMENSION_ID_ORGUNIT) - clickContextMenuMove(DIMENSION_ID_ORGUNIT, AXIS_ID_ROWS) - clickMenuBarUpdateButton() - expectVisualizationToBeVisible(VIS_TYPE_PIVOT_TABLE) - expectAxisToHaveDimension(AXIS_ID_FILTERS, DIMENSION_ID_PERIOD) - expectAxisToHaveDimension(AXIS_ID_ROWS, DIMENSION_ID_ORGUNIT) - expectDimensionToHaveItemAmount(DIMENSION_ID_ORGUNIT, 1) - }) - it('context menu is opened when org unit is in category', () => { - clickTableValueCell(0) - expectDrillDownMenuToBeVisible() - }) - it('drills down one level', () => { - clickChangeOrgUnit() - drillDown('District level in Sierra Leone') - expectVisualizationToBeVisible(VIS_TYPE_PIVOT_TABLE) - expectDimensionToHaveItemAmount(DIMENSION_ID_ORGUNIT, 2) - expectTableValueCellsToHaveLength(13) - }) - it('drills up one level', () => { - clickTableValueCell(0) - clickChangeOrgUnit() - drillUp('Sierra Leone') - expectVisualizationToBeVisible(VIS_TYPE_PIVOT_TABLE) - expectDimensionToHaveItemAmount(DIMENSION_ID_ORGUNIT, 1) - expectTableValueCellsToHaveLength(1) - }) -}) diff --git a/cypress/integration/layout.cy.js b/cypress/integration/layout.cy.js deleted file mode 100644 index ed297da03c..0000000000 --- a/cypress/integration/layout.cy.js +++ /dev/null @@ -1,88 +0,0 @@ -// TODO: Test drag-and-drop in the layout - -import { - DIMENSION_ID_DATA, - DIMENSION_ID_PERIOD, - DIMENSION_ID_ASSIGNED_CATEGORIES, - AXIS_ID_COLUMNS, - AXIS_ID_FILTERS, - getFixedDimensions, - getDynamicDimensions, -} from '@dhis2/analytics' -import { - expectDimensionModalToBeVisible, - clickDimensionModalHideButton, - expectDimensionModalToNotBeVisible, -} from '../elements/dimensionModal/index.js' -import { - openDimension, - openContextMenu, - clickContextMenuAdd, - clickContextMenuRemove, - clickContextMenuMove, - expectDimensionToHaveSelectedStyle, - clickContextMenuDimSubMenu, - expectAxisToHaveDimension, - expectAxisToNotHaveDimension, - expectLayoutToNotHaveDimension, -} from '../elements/layout.js' -import { goToStartPage } from '../elements/startScreen.js' - -const TEST_FIXED_DIMS = Object.values(getFixedDimensions()) -const TEST_DYNAMIC_DIMS = Object.values(getDynamicDimensions()) - -describe('interacting with the layout', () => { - it('navigates to the start page', () => { - goToStartPage() - }) - describe('opening items by clicking them', () => { - TEST_FIXED_DIMS.forEach((dim) => { - it(`opens and closes ${dim.name}`, () => { - openDimension(dim.id) - expectDimensionModalToBeVisible(dim.id) - clickDimensionModalHideButton() - expectDimensionModalToNotBeVisible() - }) - }) - }) - describe('moving items by using the context menu', () => { - const TEST_AXIS = AXIS_ID_FILTERS - const TEST_DIM = TEST_FIXED_DIMS.find( - (dim) => dim.id === DIMENSION_ID_DATA - ) - it(`moves ${TEST_DIM.name} to ${TEST_AXIS}`, () => { - openContextMenu(TEST_DIM.id) - clickContextMenuMove(TEST_DIM.id, TEST_AXIS) - expectAxisToHaveDimension(TEST_AXIS, TEST_DIM.id) - }) - }) - describe('removing item by using the context menu', () => { - const TEST_DIM = TEST_FIXED_DIMS.find( - (dim) => dim.id === DIMENSION_ID_PERIOD - ) - it(`removes ${TEST_DIM.name}`, () => { - openContextMenu(TEST_DIM.id) - clickContextMenuRemove(TEST_DIM.id) - expectLayoutToNotHaveDimension(TEST_DIM.id) - }) - }) - describe('handling AC by using the Data item context menu', () => { - const TEST_DIM = TEST_DYNAMIC_DIMS.find( - (dim) => dim.id === DIMENSION_ID_ASSIGNED_CATEGORIES - ) - const TEST_AXIS = AXIS_ID_COLUMNS - it(`adds and removes ${TEST_DIM.name}`, () => { - // add - openContextMenu(DIMENSION_ID_DATA) - clickContextMenuDimSubMenu(TEST_DIM.id) - clickContextMenuAdd(TEST_DIM.id, TEST_AXIS) - expectDimensionToHaveSelectedStyle(TEST_DIM.id) - expectAxisToHaveDimension(TEST_AXIS, TEST_DIM.id) - - // remove - openContextMenu(DIMENSION_ID_DATA) - clickContextMenuRemove(TEST_DIM.id) - expectAxisToNotHaveDimension(TEST_AXIS, TEST_DIM.id) - }) - }) -}) diff --git a/cypress/integration/new.cy.js b/cypress/integration/new.cy.js deleted file mode 100644 index 33a979783d..0000000000 --- a/cypress/integration/new.cy.js +++ /dev/null @@ -1,103 +0,0 @@ -import { - AXIS_ID_COLUMNS, - DIMENSION_ID_DATA, - getAxisMaxNumberOfItems, - isYearOverYear, - visTypeDisplayNames, - VIS_TYPE_SCATTER, - VIS_TYPE_SINGLE_VALUE, - VIS_TYPE_GAUGE, -} from '@dhis2/analytics' -import { - expectAOTitleToBeUnsaved, - expectVisualizationToBeVisible, - expectVisualizationToNotBeVisible, - expectChartToContainDimensionItem, -} from '../elements/chart.js' -import { - selectDataElements, - selectIndicators, - clickDimensionModalUpdateButton, - switchDataTab, -} from '../elements/dimensionModal/index.js' -import { openDimension } from '../elements/dimensionsPanel.js' -import { createNewAO } from '../elements/fileMenu/index.js' -import { expectDimensionOnAxisToHaveLockIcon } from '../elements/layout.js' -import { goToStartPage } from '../elements/startScreen.js' -import { - changeVisType, - expectVisTypeToBeDefault, - expectVisTypeToBeValue, -} from '../elements/visualizationTypeSelector.js' -import { TEST_DATA_ELEMENTS, TEST_INDICATORS, visTypes } from '../utils/data.js' -import { expectStoreCurrentToBeEmpty } from '../utils/store.js' - -const TEST_AXIS_ID = AXIS_ID_COLUMNS -const TEST_DATA_ELEMENT_NAMES = TEST_DATA_ELEMENTS.slice(2, 4).map( - (item) => item.name -) -const TEST_INDICATOR_NAMES = TEST_INDICATORS.slice(1, 3).map( - (item) => item.name -) - -describe('creating a new AO', () => { - it('navigates to the start page', () => { - goToStartPage() - }) - visTypes.forEach((visType) => { - const visTypeName = visTypeDisplayNames[visType] - describe(visTypeName, () => { - it('creates a new AO', () => { - createNewAO() - expectStoreCurrentToBeEmpty() - expectVisualizationToNotBeVisible() - expectVisTypeToBeDefault() - }) - it('changes vis type', () => { - changeVisType(visTypeName) - expectVisTypeToBeValue(visTypeName) - }) - it('adds dimensions', () => { - openDimension(DIMENSION_ID_DATA) - - 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) - } - - selectDataElements(TEST_DATA_ELEMENT_NAMES) - } - - clickDimensionModalUpdateButton() - - expectVisualizationToBeVisible(visType) - - isYearOverYear(visType) && expectAOTitleToBeUnsaved() - - // 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 ([VIS_TYPE_SINGLE_VALUE, VIS_TYPE_GAUGE].includes(visType)) { - it('Data is locked to Series', () => { - expectDimensionOnAxisToHaveLockIcon( - DIMENSION_ID_DATA, - AXIS_ID_COLUMNS - ) - }) - } - }) - }) -}) diff --git a/cypress/integration/open.cy.js b/cypress/integration/open.cy.js deleted file mode 100644 index fdd9dbb469..0000000000 --- a/cypress/integration/open.cy.js +++ /dev/null @@ -1,47 +0,0 @@ -import { visTypeDisplayNames } from '@dhis2/analytics' -import { - expectAOTitleToBeDirty, - expectAOTitleToBeValue, - expectAOTitleToNotBeDirty, - expectVisualizationToBeVisible, -} from '../elements/chart.js' -import { replacePeriodItems } from '../elements/common.js' -import { confirmLeave } from '../elements/confirmLeaveModal.js' -import { createNewAO, openAOByName } from '../elements/fileMenu/index.js' -import { expectRouteToBeAOId, expectRouteToBeEmpty } from '../elements/route.js' -import { goToStartPage } from '../elements/startScreen.js' -import { TEST_AOS } from '../utils/data.js' - -describe('opening a saved AO', () => { - it('navigates to the start page', () => { - goToStartPage() - }) - TEST_AOS.forEach((ao) => { - // FIXME: Add a saved Scatter chart to the default database - describe(visTypeDisplayNames[ao.type], () => { - it( - 'opens a saved AO ', - { - retries: 2, - }, - () => { - openAOByName(ao.name) - expectRouteToBeAOId() - expectAOTitleToBeValue(ao.name) - expectVisualizationToBeVisible(ao.type) - expectAOTitleToNotBeDirty() - } - ) - it(`replaces the selected period`, () => { - replacePeriodItems(ao.type) - expectAOTitleToBeDirty() - expectVisualizationToBeVisible(ao.type) - }) - it('resets to a new AO', () => { - createNewAO() - confirmLeave(true) - expectRouteToBeEmpty() - }) - }) - }) -}) diff --git a/cypress/integration/options/axes.cy.js b/cypress/integration/options/axes.cy.js deleted file mode 100644 index 8b42ce1868..0000000000 --- a/cypress/integration/options/axes.cy.js +++ /dev/null @@ -1,280 +0,0 @@ -import { DIMENSION_ID_DATA, VIS_TYPE_COLUMN } from '@dhis2/analytics' -import { - expectVisualizationToBeVisible, - expectChartTitleToBeVisible, -} from '../../elements/chart.js' -import { - selectDataElements, - clickDimensionModalUpdateButton, -} from '../../elements/dimensionModal/index.js' -import { openDimension } from '../../elements/dimensionsPanel.js' -import { openOptionsModal } from '../../elements/menuBar.js' -import { - clickOptionsModalUpdateButton, - clickOptionsTab, - switchAxesTabTo, - expectAxisRangeMaxToBeValue, - expectAxisRangeMinToBeValue, - expectAxisTitleToBeValue, - OPTIONS_TAB_AXES, - setAxisRangeMaxValue, - setAxisRangeMinValue, - setAxisTitleText, - setAxisTitleTextModeTo, - OPTIONS_TAB_SERIES, - setItemToAxis, - setAxisDecimalsValue, - setAxisStepsValue, -} from '../../elements/optionsModal/index.js' -import { goToStartPage } from '../../elements/startScreen.js' -import { CONFIG_DEFAULT_VERTICAL_AXIS_TITLE } from '../../utils/config.js' -import { TEST_DATA_ELEMENTS } from '../../utils/data.js' -import { generateRandomNumber, getRandomArrayItem } from '../../utils/random.js' -import { - expectWindowConfigYAxisToHaveRangeMinValue, - expectWindowConfigYAxisToHaveRangeMaxValue, - expectWindowConfigYAxisToHaveTitleText, - expectWindowConfigXAxisToHaveTitleText, - expectWindowConfigYAxisToHaveStepsValue, - expectWindowConfigAxisTitleToBeValue, -} from '../../utils/window.js' - -const TEST_DATA_ELEMENT_NAME = getRandomArrayItem(TEST_DATA_ELEMENTS).name -const TEST_MIN_VALUE = generateRandomNumber(-1000, 1000) -const TEST_MAX_VALUE = generateRandomNumber(2000, 5000) -const TEST_STEPS_VALUE = generateRandomNumber(2, 8) -const TEST_DECIMALS_VALUE = generateRandomNumber(1, 3) - -describe('Options - Vertical axis', () => { - const TEST_AXIS = 'RANGE_0' - const TEST_TITLE = 'VT' - it('navigates to the start page and add a data item', () => { - goToStartPage() - openDimension(DIMENSION_ID_DATA) - selectDataElements([TEST_DATA_ELEMENT_NAME]) - clickDimensionModalUpdateButton() - expectVisualizationToBeVisible(VIS_TYPE_COLUMN) - }) - describe('title', () => { - it('opens Options -> Axes', () => { - openOptionsModal(OPTIONS_TAB_AXES) - }) - it("sets axis title to 'Custom'", () => { - setAxisTitleTextModeTo('Custom') - }) - it('types the title', () => { - setAxisTitleText(TEST_AXIS, TEST_TITLE) - }) - it('clicks the modal update button', () => { - clickOptionsModalUpdateButton() - expectChartTitleToBeVisible() - }) - it(`config has vertical axis title "${TEST_TITLE}"`, () => { - expectWindowConfigYAxisToHaveTitleText(TEST_TITLE) - }) - }) - describe('range', () => { - it('opens Options -> Axes', () => { - openOptionsModal(OPTIONS_TAB_AXES) - }) - it('sets min value', () => { - setAxisRangeMinValue(TEST_AXIS, TEST_MIN_VALUE) - }) - it('sets max value', () => { - setAxisRangeMaxValue(TEST_AXIS, TEST_MAX_VALUE) - }) - it('sets steps value', () => { - setAxisStepsValue(TEST_AXIS, TEST_STEPS_VALUE) - }) - it('sets decimals value', () => { - setAxisDecimalsValue(TEST_AXIS, TEST_DECIMALS_VALUE) - }) - it('clicks the modal update button', () => { - clickOptionsModalUpdateButton() - expectChartTitleToBeVisible() - }) - it('config has range min value', () => { - cy.log(`Value: ${TEST_MIN_VALUE}`) - expectWindowConfigYAxisToHaveRangeMinValue(TEST_MIN_VALUE) - }) - it('config has range max value', () => { - cy.log(`Value: ${TEST_MAX_VALUE}`) - expectWindowConfigYAxisToHaveRangeMaxValue(TEST_MAX_VALUE) - }) - it('config has steps value', () => { - cy.log(`Value: ${TEST_STEPS_VALUE}`) - expectWindowConfigYAxisToHaveStepsValue(TEST_STEPS_VALUE) - }) - // Note: the output of setting the decimals option can't be evaluated using the config - }) - describe('options modal keeps changes when reopening', () => { - it('opens Options -> Axes', () => { - openOptionsModal(OPTIONS_TAB_AXES) - }) - it(`title is "${TEST_TITLE}"`, () => { - expectAxisTitleToBeValue(TEST_AXIS, TEST_TITLE) - }) - it('range min is set', () => { - cy.log(`Value: ${TEST_MIN_VALUE}`) - expectAxisRangeMinToBeValue(TEST_AXIS, TEST_MIN_VALUE) - }) - it('range max is set', () => { - cy.log(`Value: ${TEST_MAX_VALUE}`) - expectAxisRangeMaxToBeValue(TEST_AXIS, TEST_MAX_VALUE) - }) - }) -}) - -describe('Options - Horizontal axis', () => { - const TEST_AXIS = 'DOMAIN_0' - const TEST_TITLE = 'HT' - const TEST_TAB = 'Horizontal (x) axis' - it('navigates to the start page and add a data item', () => { - goToStartPage() - openDimension(DIMENSION_ID_DATA) - selectDataElements([TEST_DATA_ELEMENT_NAME]) - clickDimensionModalUpdateButton() - expectVisualizationToBeVisible(VIS_TYPE_COLUMN) - }) - describe('title', () => { - it('opens Options -> Axes', () => { - openOptionsModal(OPTIONS_TAB_AXES) - }) - it(`switches to '${TEST_TAB}' tab`, () => { - switchAxesTabTo(TEST_TAB) - }) - it("sets axis title to 'Custom'", () => { - setAxisTitleTextModeTo('Custom') - }) - it('types the title', () => { - setAxisTitleText(TEST_AXIS, TEST_TITLE) - }) - it('clicks the modal update button', () => { - clickOptionsModalUpdateButton() - expectChartTitleToBeVisible() - }) - it(`config has horizontal axis title "${TEST_TITLE}"`, () => { - expectWindowConfigXAxisToHaveTitleText(TEST_TITLE) - }) - }) - describe('options modal keeps changes when reopening', () => { - it('opens Options -> Axes', () => { - openOptionsModal(OPTIONS_TAB_AXES) - }) - it(`switches to '${TEST_TAB}' tab`, () => { - switchAxesTabTo(TEST_TAB) - }) - it(`title is "${TEST_TITLE}"`, () => { - expectAxisTitleToBeValue(TEST_AXIS, TEST_TITLE) - }) - }) -}) - -describe('Options - Auto-generated axis title', () => { - it('navigates to the start page and add a data item', () => { - goToStartPage() - openDimension(DIMENSION_ID_DATA) - selectDataElements([TEST_DATA_ELEMENT_NAME]) - clickDimensionModalUpdateButton() - expectVisualizationToBeVisible(VIS_TYPE_COLUMN) - }) - describe('Single item - single axis', () => { - it('opens Options -> Axes', () => { - openOptionsModal(OPTIONS_TAB_AXES) - }) - it("sets axis title to 'Auto generated'", () => { - setAxisTitleTextModeTo('Auto generated') - }) - it('clicks the modal update button', () => { - clickOptionsModalUpdateButton() - expectChartTitleToBeVisible() - }) - const TEST_TITLE = TEST_DATA_ELEMENT_NAME - it(`config has vertical axis title "${TEST_TITLE}" and default black color`, () => { - expectWindowConfigAxisTitleToBeValue('yAxis', 0, { - ...CONFIG_DEFAULT_VERTICAL_AXIS_TITLE, - text: TEST_TITLE, - style: { - ...CONFIG_DEFAULT_VERTICAL_AXIS_TITLE.style, - color: '#212934', - }, - }) - }) - }) - describe('Multi items - single axis', () => { - it('adds a second data element', () => { - openDimension(DIMENSION_ID_DATA) - selectDataElements(['ART enrollment stage 1']) - clickDimensionModalUpdateButton() - expectChartTitleToBeVisible() - }) - const TEST_TITLE = '2 items' - it(`config has vertical axis title "${TEST_TITLE} and default black color`, () => { - expectWindowConfigAxisTitleToBeValue('yAxis', 0, { - ...CONFIG_DEFAULT_VERTICAL_AXIS_TITLE, - text: TEST_TITLE, - style: { - ...CONFIG_DEFAULT_VERTICAL_AXIS_TITLE.style, - color: '#212934', - }, - }) - }) - }) - describe('Multi items - multi axis', () => { - it('navigates to the start page and adds two data items', () => { - goToStartPage() - openDimension(DIMENSION_ID_DATA) - selectDataElements([ - TEST_DATA_ELEMENT_NAME, - 'ART enrollment stage 1', - ]) - clickDimensionModalUpdateButton() - expectVisualizationToBeVisible(VIS_TYPE_COLUMN) - }) - it('opens Options -> Series', () => { - openOptionsModal(OPTIONS_TAB_SERIES) - }) - it('enables multi axis', () => { - setItemToAxis(1, 2) - }) - it('opens Options -> Axes', () => { - clickOptionsTab(OPTIONS_TAB_AXES) - }) - it("sets axis title to 'Auto generated'", () => { - setAxisTitleTextModeTo('Auto generated') - }) - const TEST_TAB = 'Vertical (y) axis 2' - it(`switches to '${TEST_TAB}' tab`, () => { - switchAxesTabTo(TEST_TAB) - }) - it("sets axis title to 'Auto generated'", () => { - setAxisTitleTextModeTo('Auto generated') - }) - it('clicks the modal update button', () => { - clickOptionsModalUpdateButton() - expectChartTitleToBeVisible() - }) - const TEST_TITLE_1 = 'Axis 1' - it(`config has vertical axis 1 title "${TEST_TITLE_1} and blue color`, () => { - expectWindowConfigAxisTitleToBeValue('yAxis', 0, { - ...CONFIG_DEFAULT_VERTICAL_AXIS_TITLE, - text: TEST_TITLE_1, - style: { - ...CONFIG_DEFAULT_VERTICAL_AXIS_TITLE.style, - color: '#4292c6', - }, - }) - }) - const TEST_TITLE_2 = 'Axis 2' - it(`config has vertical axis 2 title "${TEST_TITLE_2} and red color`, () => { - expectWindowConfigAxisTitleToBeValue('yAxis', 1, { - ...CONFIG_DEFAULT_VERTICAL_AXIS_TITLE, - text: TEST_TITLE_2, - style: { - ...CONFIG_DEFAULT_VERTICAL_AXIS_TITLE.style, - color: '#cb181d', - }, - }) - }) - }) -}) diff --git a/cypress/integration/options/fontStyles.cy.js b/cypress/integration/options/fontStyles.cy.js deleted file mode 100644 index 15408d334f..0000000000 --- a/cypress/integration/options/fontStyles.cy.js +++ /dev/null @@ -1,532 +0,0 @@ -import { DIMENSION_ID_DATA, VIS_TYPE_COLUMN } from '@dhis2/analytics' -import { - expectVisualizationToBeVisible, - expectChartTitleToBeVisible, - expectChartSubtitleToBeVisible, -} from '../../elements/chart.js' -import { - selectDataElements, - clickDimensionModalUpdateButton, -} from '../../elements/dimensionModal/index.js' -import { openDimension } from '../../elements/dimensionsPanel.js' -import { openOptionsModal } from '../../elements/menuBar.js' -import { - changeFontSizeOption, - clickOptionsModalUpdateButton, - changeTextAlignOption, - clickBoldButton, - clickItalicButton, - setCustomSubtitle, - OPTIONS_TAB_STYLE, - OPTIONS_TAB_DATA, - OPTIONS_TAB_AXES, - clickTargetLineCheckbox, - setTargetLineValue, - setTargetLineLabel, - clickBaseLineCheckbox, - setBaseLineLabel, - setBaseLineValue, - setAxisTitleText, - setAxisTitleTextModeTo, - switchAxesTabTo, - changeColor, -} from '../../elements/optionsModal/index.js' -import { goToStartPage } from '../../elements/startScreen.js' -import { - CONFIG_DEFAULT_SUBTITLE, - CONFIG_DEFAULT_TITLE, - CONFIG_DEFAULT_LEGEND, - CONFIG_DEFAULT_TARGET_LINE, - CONFIG_DEFAULT_BASE_LINE, - CONFIG_DEFAULT_VERTICAL_AXIS_TITLE, - CONFIG_DEFAULT_HORIZONTAL_AXIS_TITLE, - CONFIG_DEFAULT_AXIS_LABELS, -} from '../../utils/config.js' -import { TEST_DATA_ELEMENTS } from '../../utils/data.js' -import { - generateRandomBool, - generateRandomNumber, - getRandomArrayItem, -} from '../../utils/random.js' -import { - expectWindowConfigSubtitleToBeValue, - expectWindowConfigTitleToBeValue, - expectWindowConfigLegendToBeValue, - expectWindowConfigAxisPlotLinesToBeValue, - expectWindowConfigAxisTitleToBeValue, - expectWindowConfigAxisLabelsToBeValue, -} from '../../utils/window.js' - -const TEST_DATA_ELEMENT_NAME = getRandomArrayItem(TEST_DATA_ELEMENTS).name -const TITLE_PREFIX = 'option-chart-title' -const SUBTITLE_PREFIX = 'option-chart-subtitle' -const SERIES_KEY_PREFIX = 'option-series-key' -const TARGET_LINE_PREFIX = 'option-target-line-label' -const BASE_LINE_PREFIX = 'option-base-line-label' -const VERTICAL_AXIS_TITLE_PREFIX = 'RANGE_0-axis-title' -const HORIZONTAL_AXIS_TITLE_PREFIX = 'DOMAIN_0-axis-title' -const VERTICAL_AXIS_LABELS_PREFIX = 'option-axis-label-RANGE_0' -const HORIZONTAL_AXIS_LABELS_PREFIX = 'option-axis-label-DOMAIN_0' - -const randomizeBoldOption = () => { - const useBold = generateRandomBool() - return { input: useBold, output: useBold ? 'bold' : 'normal' } -} - -const randomizeItalicOption = () => { - const useItalic = generateRandomBool() - return { input: useItalic, output: useItalic ? 'italic' : 'normal' } -} - -const setFontStyleOptions = ({ - fontSize, - textAlign, - bold, - italic, - color, - prefix, -}) => { - if (fontSize) { - it(`changes the font size to ${fontSize}`, () => - changeFontSizeOption(prefix, fontSize)) - } - if (textAlign) { - it(`changes the text align to ${textAlign}`, () => - changeTextAlignOption(prefix, textAlign)) - } - if (bold) { - it('changes font to bold', () => clickBoldButton(prefix)) - } - if (italic) { - it('changes font to italic', () => clickItalicButton(prefix)) - } - if (color) { - it(`changes color to ${color}`, () => changeColor(prefix, color)) - } -} - -describe('Options - Font styles', () => { - it('navigates to the start page and adds a data item', () => { - goToStartPage() - openDimension(DIMENSION_ID_DATA) - selectDataElements([TEST_DATA_ELEMENT_NAME]) - clickDimensionModalUpdateButton() - expectVisualizationToBeVisible(VIS_TYPE_COLUMN) - }) - describe('title', () => { - const TEST_FONT_SIZE_OPTION = { input: 'Small', output: '13px' } - const TEST_TEXT_ALIGN_OPTION = generateRandomBool() - ? { input: 'Left', output: 'left' } - : { input: 'Right', output: 'right' } - const TEST_BOLD_OPTION = randomizeBoldOption() - const TEST_ITALIC_OPTION = randomizeItalicOption() - const TEST_COLOR = '#fafa00' - const prefix = TITLE_PREFIX - - it('has default value', () => { - expectChartTitleToBeVisible() - expectWindowConfigTitleToBeValue(CONFIG_DEFAULT_TITLE) - }) - it('opens Options -> Style', () => { - openOptionsModal(OPTIONS_TAB_STYLE) - }) - setFontStyleOptions({ - fontSize: TEST_FONT_SIZE_OPTION.input, - textAlign: TEST_TEXT_ALIGN_OPTION.input, - bold: TEST_BOLD_OPTION.input, - italic: TEST_ITALIC_OPTION.input, - color: TEST_COLOR, - prefix, - }) - it('clicks the modal update button', () => { - clickOptionsModalUpdateButton() - }) - it(`config has font size "${TEST_FONT_SIZE_OPTION.output}", text align ${TEST_TEXT_ALIGN_OPTION.output}, bold ${TEST_BOLD_OPTION.input}, italic ${TEST_ITALIC_OPTION.input}, color ${TEST_COLOR}`, () => { - expectChartTitleToBeVisible() - expectWindowConfigTitleToBeValue({ - ...CONFIG_DEFAULT_TITLE, - align: TEST_TEXT_ALIGN_OPTION.output, - style: { - ...CONFIG_DEFAULT_TITLE.style, - fontSize: TEST_FONT_SIZE_OPTION.output, - fontWeight: TEST_BOLD_OPTION.output, - fontStyle: TEST_ITALIC_OPTION.output, - color: TEST_COLOR, - }, - }) - }) - }) - describe('subtitle', () => { - const TEST_FONT_SIZE_OPTION = { input: 'Regular', output: '18px' } - const TEST_TEXT_ALIGN_OPTION = generateRandomBool() - ? { input: 'Left', output: 'left' } - : { input: 'Right', output: 'right' } - const TEST_BOLD_OPTION = randomizeBoldOption() - const TEST_ITALIC_OPTION = randomizeItalicOption() - const TEST_COLOR = '#fa00fa' - const prefix = SUBTITLE_PREFIX - const TEST_SUBTITLE_TEXT = 'S' - - it('has default value', () => { - expectChartSubtitleToBeVisible() - expectWindowConfigSubtitleToBeValue(CONFIG_DEFAULT_SUBTITLE) - }) - it('opens Options -> Style', () => { - openOptionsModal(OPTIONS_TAB_STYLE) - }) - it('sets a custom subtitle', () => { - setCustomSubtitle(TEST_SUBTITLE_TEXT) - }) - setFontStyleOptions({ - fontSize: TEST_FONT_SIZE_OPTION.input, - textAlign: TEST_TEXT_ALIGN_OPTION.input, - bold: TEST_BOLD_OPTION.input, - italic: TEST_ITALIC_OPTION.input, - color: TEST_COLOR, - prefix, - }) - it('clicks the modal update button', () => { - clickOptionsModalUpdateButton() - }) - it(`config has font size "${TEST_FONT_SIZE_OPTION.output}", text align ${TEST_TEXT_ALIGN_OPTION.output}, bold ${TEST_BOLD_OPTION.input}, italic ${TEST_ITALIC_OPTION.input}, color ${TEST_COLOR}`, () => { - expectChartSubtitleToBeVisible() - expectWindowConfigSubtitleToBeValue({ - ...CONFIG_DEFAULT_SUBTITLE, - align: TEST_TEXT_ALIGN_OPTION.output, - text: TEST_SUBTITLE_TEXT, - style: { - ...CONFIG_DEFAULT_SUBTITLE.style, - fontSize: TEST_FONT_SIZE_OPTION.output, - fontWeight: TEST_BOLD_OPTION.output, - fontStyle: TEST_ITALIC_OPTION.output, - color: TEST_COLOR, - }, - }) - }) - }) - describe('target line', () => { - const TEST_FONT_SIZE_OPTION = { input: 'Small', output: '11px' } - const TEST_TEXT_ALIGN_OPTION = generateRandomBool() - ? { input: 'Center', output: 'center', x: 0 } - : { input: 'Right', output: 'right', x: -10 } - const TEST_BOLD_OPTION = randomizeBoldOption() - const TEST_ITALIC_OPTION = randomizeItalicOption() - const TEST_COLOR = '#00fafa' - const TEST_LABEL = 'TL' - const TEST_VALUE = generateRandomNumber(10, 100) - const prefix = TARGET_LINE_PREFIX - - it('opens Options -> Data', () => { - openOptionsModal(OPTIONS_TAB_DATA) - }) - it('sets target line', () => { - cy.log(`Test value: ${TEST_VALUE}`) - clickTargetLineCheckbox() - setTargetLineLabel(TEST_LABEL) - setTargetLineValue(TEST_VALUE) - }) - setFontStyleOptions({ - fontSize: TEST_FONT_SIZE_OPTION.input, - textAlign: TEST_TEXT_ALIGN_OPTION.input, - bold: TEST_BOLD_OPTION.input, - italic: TEST_ITALIC_OPTION.input, - color: TEST_COLOR, - prefix, - }) - it('clicks the modal update button', () => { - clickOptionsModalUpdateButton() - }) - it(`config has font size "${TEST_FONT_SIZE_OPTION.output}", text align ${TEST_TEXT_ALIGN_OPTION.output}, bold ${TEST_BOLD_OPTION.input}, italic ${TEST_ITALIC_OPTION.input}, color ${TEST_COLOR}`, () => { - expectVisualizationToBeVisible(VIS_TYPE_COLUMN) - expectWindowConfigAxisPlotLinesToBeValue({ - axisType: 'yAxis', - axisIndex: 0, - lineIndex: 0, - value: { - ...CONFIG_DEFAULT_TARGET_LINE, - value: TEST_VALUE, - color: TEST_COLOR, - label: { - ...CONFIG_DEFAULT_TARGET_LINE.label, - x: TEST_TEXT_ALIGN_OPTION.x, - text: TEST_LABEL, - align: TEST_TEXT_ALIGN_OPTION.output, - style: { - ...CONFIG_DEFAULT_TARGET_LINE.label.style, - fontSize: TEST_FONT_SIZE_OPTION.output, - fontWeight: TEST_BOLD_OPTION.output, - fontStyle: TEST_ITALIC_OPTION.output, - color: TEST_COLOR, - }, - }, - }, - }) - }) - }) - describe('base line', () => { - const TEST_FONT_SIZE_OPTION = { input: 'Large', output: '18px' } - const TEST_TEXT_ALIGN_OPTION = generateRandomBool() - ? { input: 'Center', output: 'center', x: 0 } - : { input: 'Right', output: 'right', x: -10 } - const TEST_BOLD_OPTION = randomizeBoldOption() - const TEST_ITALIC_OPTION = randomizeItalicOption() - const TEST_COLOR = '#99fa99' - const TEST_LABEL = 'BL' - const TEST_VALUE = generateRandomNumber(10, 100) - const prefix = BASE_LINE_PREFIX - - it('opens Options -> Data', () => { - openOptionsModal(OPTIONS_TAB_DATA) - }) - it('sets base line', () => { - cy.log(`Test value: ${TEST_VALUE}`) - clickBaseLineCheckbox() - setBaseLineLabel(TEST_LABEL) - setBaseLineValue(TEST_VALUE) - }) - setFontStyleOptions({ - fontSize: TEST_FONT_SIZE_OPTION.input, - textAlign: TEST_TEXT_ALIGN_OPTION.input, - bold: TEST_BOLD_OPTION.input, - italic: TEST_ITALIC_OPTION.input, - color: TEST_COLOR, - prefix, - }) - it('clicks the modal update button', () => { - clickOptionsModalUpdateButton() - }) - it(`config has font size "${TEST_FONT_SIZE_OPTION.output}", text align ${TEST_TEXT_ALIGN_OPTION.output}, bold ${TEST_BOLD_OPTION.input}, italic ${TEST_ITALIC_OPTION.input}, color ${TEST_COLOR}`, () => { - expectVisualizationToBeVisible(VIS_TYPE_COLUMN) - expectWindowConfigAxisPlotLinesToBeValue({ - axisType: 'yAxis', - axisIndex: 0, - lineIndex: 1, - value: { - ...CONFIG_DEFAULT_BASE_LINE, - value: TEST_VALUE, - color: TEST_COLOR, - label: { - ...CONFIG_DEFAULT_BASE_LINE.label, - x: TEST_TEXT_ALIGN_OPTION.x, - text: TEST_LABEL, - align: TEST_TEXT_ALIGN_OPTION.output, - style: { - ...CONFIG_DEFAULT_BASE_LINE.label.style, - fontSize: TEST_FONT_SIZE_OPTION.output, - fontWeight: TEST_BOLD_OPTION.output, - fontStyle: TEST_ITALIC_OPTION.output, - color: TEST_COLOR, - }, - }, - }, - }) - }) - }) - describe('series key', () => { - const TEST_FONT_SIZE_OPTION = { input: 'Extra Large', output: '24px' } - const TEST_TEXT_ALIGN_OPTION = generateRandomBool() - ? { input: 'Left', output: 'left' } - : { input: 'Right', output: 'right' } - const TEST_BOLD_OPTION = randomizeBoldOption() - const TEST_ITALIC_OPTION = randomizeItalicOption() - const TEST_COLOR = '#9090fa' - const prefix = SERIES_KEY_PREFIX - - it('opens Options -> Style', () => { - openOptionsModal(OPTIONS_TAB_STYLE) - }) - setFontStyleOptions({ - fontSize: TEST_FONT_SIZE_OPTION.input, - textAlign: TEST_TEXT_ALIGN_OPTION.input, - bold: TEST_BOLD_OPTION.input, - italic: TEST_ITALIC_OPTION.input, - color: TEST_COLOR, - prefix, - }) - it('clicks the modal update button', () => { - clickOptionsModalUpdateButton() - }) - it(`config has font size "${TEST_FONT_SIZE_OPTION.output}", text align ${TEST_TEXT_ALIGN_OPTION.output}, bold ${TEST_BOLD_OPTION.input}, italic ${TEST_ITALIC_OPTION.input}, color ${TEST_COLOR}`, () => { - expectVisualizationToBeVisible(VIS_TYPE_COLUMN) - expectWindowConfigLegendToBeValue({ - ...CONFIG_DEFAULT_LEGEND, - align: TEST_TEXT_ALIGN_OPTION.output, - itemStyle: { - ...CONFIG_DEFAULT_LEGEND.itemStyle, - fontSize: TEST_FONT_SIZE_OPTION.output, - fontWeight: TEST_BOLD_OPTION.output, - fontStyle: TEST_ITALIC_OPTION.output, - color: TEST_COLOR, - }, - }) - }) - }) - describe('vertical axis labels', () => { - const TEST_FONT_SIZE_OPTION = { input: 'Regular', output: '13px' } - const TEST_BOLD_OPTION = randomizeBoldOption() - const TEST_ITALIC_OPTION = randomizeItalicOption() - const TEST_COLOR = '#0909fa' - const prefix = VERTICAL_AXIS_LABELS_PREFIX - - it('opens Options -> Axes', () => { - openOptionsModal(OPTIONS_TAB_AXES) - }) - setFontStyleOptions({ - fontSize: TEST_FONT_SIZE_OPTION.input, - bold: TEST_BOLD_OPTION.input, - italic: TEST_ITALIC_OPTION.input, - color: TEST_COLOR, - prefix, - }) - it('clicks the modal update button', () => { - clickOptionsModalUpdateButton() - }) - it(`config has font size "${TEST_FONT_SIZE_OPTION.output}", bold ${TEST_BOLD_OPTION.input}, italic ${TEST_ITALIC_OPTION.input}, color ${TEST_COLOR}`, () => { - expectVisualizationToBeVisible(VIS_TYPE_COLUMN) - expectWindowConfigAxisLabelsToBeValue('yAxis', 0, { - ...CONFIG_DEFAULT_AXIS_LABELS, - style: { - ...CONFIG_DEFAULT_AXIS_LABELS.style, - fontSize: TEST_FONT_SIZE_OPTION.output, - fontWeight: TEST_BOLD_OPTION.output, - fontStyle: TEST_ITALIC_OPTION.output, - color: TEST_COLOR, - }, - }) - }) - }) - describe('horizontal axis labels', () => { - const TEST_FONT_SIZE_OPTION = { input: 'Large', output: '18px' } - const TEST_BOLD_OPTION = randomizeBoldOption() - const TEST_ITALIC_OPTION = randomizeItalicOption() - const TEST_COLOR = '#fa0909' - const prefix = HORIZONTAL_AXIS_LABELS_PREFIX - - it('opens Options -> Axes', () => { - openOptionsModal(OPTIONS_TAB_AXES) - switchAxesTabTo('Horizontal (x) axis') - }) - setFontStyleOptions({ - fontSize: TEST_FONT_SIZE_OPTION.input, - bold: TEST_BOLD_OPTION.input, - italic: TEST_ITALIC_OPTION.input, - color: TEST_COLOR, - prefix, - }) - it('clicks the modal update button', () => { - clickOptionsModalUpdateButton() - }) - it(`config has font size "${TEST_FONT_SIZE_OPTION.output}", bold ${TEST_BOLD_OPTION.input}, italic ${TEST_ITALIC_OPTION.input}, color ${TEST_COLOR}`, () => { - expectVisualizationToBeVisible(VIS_TYPE_COLUMN) - expectWindowConfigAxisLabelsToBeValue('xAxis', 0, { - ...CONFIG_DEFAULT_AXIS_LABELS, - style: { - ...CONFIG_DEFAULT_AXIS_LABELS.style, - fontSize: TEST_FONT_SIZE_OPTION.output, - fontWeight: TEST_BOLD_OPTION.output, - fontStyle: TEST_ITALIC_OPTION.output, - color: TEST_COLOR, - }, - }) - }) - }) - describe('horizontal axis title', () => { - const TEST_FONT_SIZE_OPTION = { input: 'Extra Small', output: '9px' } - const TEST_TEXT_ALIGN_OPTION = generateRandomBool() - ? { input: 'Start', output: 'low' } - : { input: 'End', output: 'high' } - const TEST_BOLD_OPTION = randomizeBoldOption() - const TEST_ITALIC_OPTION = randomizeItalicOption() - const TEST_COLOR = '#0f9a09' - const TEST_TITLE = 'HT' - const TEST_AXIS = 'DOMAIN_0' - const prefix = HORIZONTAL_AXIS_TITLE_PREFIX - - it('opens Options -> Axes', () => { - openOptionsModal(OPTIONS_TAB_AXES) - }) - it(`sets horizontal axis title to "${TEST_TITLE}"`, () => { - switchAxesTabTo('Horizontal (x) axis') - setAxisTitleTextModeTo('Custom') - setAxisTitleText(TEST_AXIS, TEST_TITLE) - }) - setFontStyleOptions({ - fontSize: TEST_FONT_SIZE_OPTION.input, - textAlign: TEST_TEXT_ALIGN_OPTION.input, - bold: TEST_BOLD_OPTION.input, - italic: TEST_ITALIC_OPTION.input, - color: TEST_COLOR, - prefix, - }) - it('clicks the modal update button', () => { - clickOptionsModalUpdateButton() - }) - - it(`config has font size "${TEST_FONT_SIZE_OPTION.output}", text align ${TEST_TEXT_ALIGN_OPTION.output}, bold ${TEST_BOLD_OPTION.input}, italic ${TEST_ITALIC_OPTION.input}, color ${TEST_COLOR}`, () => { - expectVisualizationToBeVisible(VIS_TYPE_COLUMN) - expectWindowConfigAxisTitleToBeValue('xAxis', 0, { - ...CONFIG_DEFAULT_HORIZONTAL_AXIS_TITLE, - text: TEST_TITLE, - align: TEST_TEXT_ALIGN_OPTION.output, - style: { - ...CONFIG_DEFAULT_HORIZONTAL_AXIS_TITLE.style, - fontSize: TEST_FONT_SIZE_OPTION.output, - fontWeight: TEST_BOLD_OPTION.output, - fontStyle: TEST_ITALIC_OPTION.output, - color: TEST_COLOR, - }, - }) - }) - }) - describe('vertical axis title', () => { - const TEST_FONT_SIZE_OPTION = { input: 'Large', output: '18px' } - const TEST_TEXT_ALIGN_OPTION = generateRandomBool() - ? { input: 'Start', output: 'low' } - : { input: 'End', output: 'high' } - const TEST_BOLD_OPTION = randomizeBoldOption() - const TEST_ITALIC_OPTION = randomizeItalicOption() - const TEST_COLOR = '#a090f9' - const TEST_TITLE = 'VT' - const TEST_AXIS = 'RANGE_0' - const prefix = VERTICAL_AXIS_TITLE_PREFIX - - it('opens Options -> Axes', () => { - openOptionsModal(OPTIONS_TAB_AXES) - }) - it(`sets vertical axis title to "${TEST_TITLE}"`, () => { - setAxisTitleTextModeTo('Custom') - setAxisTitleText(TEST_AXIS, TEST_TITLE) - }) - setFontStyleOptions({ - fontSize: TEST_FONT_SIZE_OPTION.input, - textAlign: TEST_TEXT_ALIGN_OPTION.input, - bold: TEST_BOLD_OPTION.input, - italic: TEST_ITALIC_OPTION.input, - color: TEST_COLOR, - prefix, - }) - it('clicks the modal update button', () => { - clickOptionsModalUpdateButton() - }) - it(`config has font size "${TEST_FONT_SIZE_OPTION.output}", text align ${TEST_TEXT_ALIGN_OPTION.output}, bold ${TEST_BOLD_OPTION.input}, italic ${TEST_ITALIC_OPTION.input}, color ${TEST_COLOR}`, () => { - expectVisualizationToBeVisible(VIS_TYPE_COLUMN) - expectWindowConfigAxisTitleToBeValue('yAxis', 0, { - ...CONFIG_DEFAULT_VERTICAL_AXIS_TITLE, - text: TEST_TITLE, - align: TEST_TEXT_ALIGN_OPTION.output, - style: { - ...CONFIG_DEFAULT_VERTICAL_AXIS_TITLE.style, - fontSize: TEST_FONT_SIZE_OPTION.output, - fontWeight: TEST_BOLD_OPTION.output, - fontStyle: TEST_ITALIC_OPTION.output, - color: TEST_COLOR, - }, - }) - }) - }) -}) - -/* TODO: Add tests for all axes based options for Scatter - Add tests for regression lines and vertical axis labels for Gauge - Add tests for axes based options for a vertical type (e.g. Bar) -*/ diff --git a/cypress/integration/options/icon.cy.js b/cypress/integration/options/icon.cy.js deleted file mode 100644 index 541e586eac..0000000000 --- a/cypress/integration/options/icon.cy.js +++ /dev/null @@ -1,186 +0,0 @@ -import { - DIMENSION_ID_DATA, - DIMENSION_ID_PERIOD, - DIMENSION_TYPE_DATA_ELEMENT, - DIMENSION_TYPE_DATA_SET, - DIMENSION_TYPE_EVENT_DATA_ITEM, - DIMENSION_TYPE_INDICATOR, - VIS_TYPE_SINGLE_VALUE, - visTypeDisplayNames, -} from '@dhis2/analytics' -import { expectVisualizationToBeVisible } from '../../elements/chart.js' -import { clickCheckbox } from '../../elements/common.js' -import { - expectSelectableDataItemsAmountToBeLeast, - switchDataTypeTo, - switchGroupTo, - switchSubGroupTo, -} from '../../elements/dimensionModal/dataDimension.js' -import { - clickDimensionModalHideButton, - clickDimensionModalUpdateButton, - expectDataDimensionModalToBeVisible, - expectItemToBeSelected, - inputSearchTerm, - selectItemByDoubleClick, - selectRelativePeriods, - unselectAllItemsByButton, -} from '../../elements/dimensionModal/index.js' -import { openDimension } from '../../elements/dimensionsPanel.js' -import { openOptionsModal } from '../../elements/menuBar.js' -import { - OPTIONS_TAB_LEGEND, - OPTIONS_TAB_STYLE, - clickOptionsModalHideButton, - clickOptionsModalUpdateButton, - clickOptionsTab, -} from '../../elements/optionsModal/index.js' -import { - changeDisplayStrategyToFixed, - changeDisplayStyleToText, - changeFixedLegendSet, - expectSingleValueToHaveIconColor, - toggleLegend, -} from '../../elements/optionsModal/legend.js' -import { goToStartPage } from '../../elements/startScreen.js' -import { changeVisType } from '../../elements/visualizationTypeSelector.js' - -const expectIconToBeVisible = () => { - cy.getBySelLike('visualization-icon') - .should('have.length', 1) - .and('be.visible') -} - -const expectIconToBeHidden = () => { - cy.getBySelLike('visualization-icon').should('not.exist') -} - -// TODO: Remove the commented out types below once 2.40.1 has been released, as only indicators are supported in 2.40.0 - -const TEST_TYPES = [ - DIMENSION_TYPE_INDICATOR, - // DIMENSION_TYPE_DATA_ELEMENT, - // DIMENSION_TYPE_DATA_SET, - // DIMENSION_TYPE_EVENT_DATA_ITEM, - // DIMENSION_TYPE_PROGRAM_INDICATOR, -] - -const TEST_ITEMS = { - [DIMENSION_TYPE_INDICATOR]: 'ANC 2 Coverage', - // [DIMENSION_TYPE_DATA_ELEMENT]: 'ANC 2nd visit', - // [DIMENSION_TYPE_DATA_SET]: 'Child Health', - // [DIMENSION_TYPE_EVENT_DATA_ITEM]: 'MCH Weight (g)', - // [DIMENSION_TYPE_PROGRAM_INDICATOR]: 'Average weight (g)', -} - -const PAGE_SIZE = 50 - -describe('Icon', () => { - beforeEach(() => { - goToStartPage() - changeVisType(visTypeDisplayNames[VIS_TYPE_SINGLE_VALUE]) - }) - it('no icon shows when option is disabled', () => { - // select a data item - openDimension(DIMENSION_ID_DATA) - expectDataDimensionModalToBeVisible() - expectSelectableDataItemsAmountToBeLeast(PAGE_SIZE) - inputSearchTerm(TEST_ITEMS[DIMENSION_TYPE_INDICATOR]) - selectItemByDoubleClick(TEST_ITEMS[DIMENSION_TYPE_INDICATOR]) - expectItemToBeSelected(TEST_ITEMS[DIMENSION_TYPE_INDICATOR]) - clickDimensionModalUpdateButton() - - // icon is hidden - expectVisualizationToBeVisible(VIS_TYPE_SINGLE_VALUE) - expectIconToBeHidden() - }) - TEST_TYPES.forEach((type) => { - it(`icon shows when option is enabled for ${type}`, () => { - // enable the icon - openOptionsModal(OPTIONS_TAB_STYLE) - clickCheckbox('option-show-data-item-icon') - clickOptionsModalHideButton() - - // find the data item - openDimension(DIMENSION_ID_DATA) - expectDataDimensionModalToBeVisible() - expectSelectableDataItemsAmountToBeLeast(PAGE_SIZE) - inputSearchTerm(TEST_ITEMS[type]) - - if (type === DIMENSION_TYPE_DATA_SET) { - switchDataTypeTo('Data sets') - switchSubGroupTo('Reporting rate') - } else if (type === DIMENSION_TYPE_EVENT_DATA_ITEM) { - switchDataTypeTo('Event data items') - switchGroupTo('Child Programme') - } - - // select the data item - selectItemByDoubleClick(TEST_ITEMS[type]) - expectItemToBeSelected(TEST_ITEMS[type]) - clickDimensionModalUpdateButton() - - // icon is shown - expectVisualizationToBeVisible(VIS_TYPE_SINGLE_VALUE) - expectIconToBeVisible() - }) - }) - // TODO: Skipped because of the same reason as the commented out tests above - it.skip('icon gets correct color when a legend is in use', () => { - // enable the icon - openOptionsModal(OPTIONS_TAB_STYLE) - clickCheckbox('option-show-data-item-icon') - - // enable the legend - clickOptionsTab(OPTIONS_TAB_LEGEND) - toggleLegend() - changeDisplayStrategyToFixed() - changeFixedLegendSet('E2E legend') - clickOptionsModalHideButton() - - // select a period - openDimension(DIMENSION_ID_PERIOD) - unselectAllItemsByButton() - selectRelativePeriods(['This year'], 'Years') - clickDimensionModalHideButton() - - // select a data item - openDimension(DIMENSION_ID_DATA) - expectDataDimensionModalToBeVisible() - expectSelectableDataItemsAmountToBeLeast(PAGE_SIZE) - inputSearchTerm(TEST_ITEMS[DIMENSION_TYPE_INDICATOR]) - selectItemByDoubleClick(TEST_ITEMS[DIMENSION_TYPE_INDICATOR]) - expectItemToBeSelected(TEST_ITEMS[DIMENSION_TYPE_INDICATOR]) - clickDimensionModalUpdateButton() - - // default text color is applied to icon - expectVisualizationToBeVisible(VIS_TYPE_SINGLE_VALUE) - expectIconToBeVisible() - expectSingleValueToHaveIconColor('#212934') - - // switch to use a data item that will trigger the contrast color - openDimension(DIMENSION_ID_DATA) - expectDataDimensionModalToBeVisible() - unselectAllItemsByButton() - expectSelectableDataItemsAmountToBeLeast(PAGE_SIZE) - inputSearchTerm(TEST_ITEMS[DIMENSION_TYPE_DATA_ELEMENT]) - selectItemByDoubleClick(TEST_ITEMS[DIMENSION_TYPE_DATA_ELEMENT]) - expectItemToBeSelected(TEST_ITEMS[DIMENSION_TYPE_DATA_ELEMENT]) - clickDimensionModalUpdateButton() - - // contrast color is applied to icon - expectVisualizationToBeVisible(VIS_TYPE_SINGLE_VALUE) - expectIconToBeVisible() - expectSingleValueToHaveIconColor('#ffffff') - - // switch to apply legend color to text - openOptionsModal(OPTIONS_TAB_LEGEND) - changeDisplayStyleToText() - clickOptionsModalUpdateButton() - - // legend color is applied to icon - expectVisualizationToBeVisible(VIS_TYPE_SINGLE_VALUE) - expectIconToBeVisible() - expectSingleValueToHaveIconColor('#2166ac') - }) -}) diff --git a/cypress/integration/options/legend.cy.js b/cypress/integration/options/legend.cy.js deleted file mode 100644 index 4b1d67b9cd..0000000000 --- a/cypress/integration/options/legend.cy.js +++ /dev/null @@ -1,980 +0,0 @@ -import { - DIMENSION_ID_DATA, - VIS_TYPE_COLUMN, - VIS_TYPE_SINGLE_VALUE, - VIS_TYPE_GAUGE, - VIS_TYPE_PIVOT_TABLE, - VIS_TYPE_STACKED_COLUMN, - VIS_TYPE_LINE, - visTypeDisplayNames, - DIMENSION_ID_PERIOD, - AXIS_ID_COLUMNS, - VIS_TYPE_AREA, -} from '@dhis2/analytics' -import { - expectChartTitleToBeVisible, - expectSeriesKeyToHaveSeriesKeyItems, - expectSVSubtitleToHaveColor, - expectSVTitleToHaveColor, - expectVisualizationToBeVisible, -} from '../../elements/chart.js' -import { - selectIndicators, - clickDimensionModalUpdateButton, - selectRelativePeriods, - unselectAllItemsByButton, -} from '../../elements/dimensionModal/index.js' -import { - clickContextMenuMove, - expectAxisToHaveDimension, - openContextMenu, - openDimension, -} from '../../elements/layout.js' -import { - clickMenuBarUpdateButton, - openOptionsModal, -} from '../../elements/menuBar.js' -import { - changeDisplayStrategyToFixed, - changeDisplayStyleToText, - changeFixedLegendSet, - clickOptionsModalUpdateButton, - toggleLegend, - expectFixedLegendSetToBe, - expectLegendDisplayStrategyToBeByDataItem, - expectLegendDisplayStrategyToBeFixed, - expectLegendDisplayStyleToBeFill, - expectLegendDisplayStyleToBeText, - expectLegendToBeEnabled, - expectSingleValueToHaveTextColor, - OPTIONS_TAB_LEGEND, - toggleLegendKeyOption, - expectLegendKeyOptionToBeEnabled, - expectLegendKeyToBeVisible, - expectLegendKeyToBeHidden, - expectLegendKeyOptionToBeDisabled, - expectOptionsTabToBeHidden, - expectLegedKeyItemAmountToBe, - OPTIONS_TAB_SERIES, - setItemToType, - clickOptionsModalHideButton, - expectSingleValueToHaveBackgroundColor, - expectSingleValueToNotHaveBackgroundColor, - changeDisplayStyleToFill, - changeColor, - OPTIONS_TAB_STYLE, - changeDisplayStrategyToByDataItem, -} from '../../elements/optionsModal/index.js' -import { goToStartPage } from '../../elements/startScreen.js' -import { changeVisType } from '../../elements/visualizationTypeSelector.js' -import { - expectEachWindowConfigSeriesItemToHaveLegendSet, - expectEachWindowConfigSeriesItemToNotHaveLegendSet, - expectWindowConfigSeriesDataLabelsToHaveColor, - expectWindowConfigSeriesItemToBeType, - expectWindowConfigSeriesItemToHaveLegendSet, - expectWindowConfigSeriesItemToNotHaveLegendSet, - expectWindowConfigSeriesItemToNotHaveType, - expectWindowConfigYAxisToHaveColor, -} from '../../utils/window.js' - -const TEST_ITEMS = [ - { - name: 'ANC 1 Coverage', - legendSet: 'ANC Coverage', - }, - { - name: 'Diarrhoea <5 y incidence rate (%)', - legendSet: 'Diarrhoea', - }, -] - -const TEST_LEGEND_SET = 'Height in cm' - -describe('Options - Legend', () => { - describe('Applying a legend: Column', () => { - it('navigates to the start page and adds data items', () => { - goToStartPage() - openDimension(DIMENSION_ID_DATA) - selectIndicators(TEST_ITEMS.map((item) => item.name)) - clickDimensionModalUpdateButton() - expectVisualizationToBeVisible(VIS_TYPE_COLUMN) - }) - it('enables legend', () => { - openOptionsModal(OPTIONS_TAB_LEGEND) - toggleLegend() - expectLegendToBeEnabled() - expectLegendDisplayStrategyToBeByDataItem() - clickOptionsModalUpdateButton() - expectChartTitleToBeVisible() - }) - it('legend by data item is applied', () => { - TEST_ITEMS.forEach((item) => - expectWindowConfigSeriesItemToHaveLegendSet( - item.name, - item.legendSet - ) - ) - }) - it(`changes legend display strategy to fixed (${TEST_LEGEND_SET})`, () => { - openOptionsModal(OPTIONS_TAB_LEGEND) - expectLegendDisplayStrategyToBeByDataItem() - changeDisplayStrategyToFixed() - expectLegendDisplayStrategyToBeFixed() - changeFixedLegendSet(TEST_LEGEND_SET) - clickOptionsModalUpdateButton() - expectChartTitleToBeVisible() - }) - it('fixed legend is applied', () => { - TEST_ITEMS.forEach((item) => - expectWindowConfigSeriesItemToHaveLegendSet( - item.name, - TEST_LEGEND_SET - ) - ) - }) - it('legend key is hidden', () => { - expectLegendKeyToBeHidden() - }) - it('verifies that options are persisted', () => { - openOptionsModal(OPTIONS_TAB_LEGEND) - expectLegendDisplayStrategyToBeFixed() - expectFixedLegendSetToBe(TEST_LEGEND_SET) - }) - it('enables legend key option', () => { - toggleLegendKeyOption() - expectLegendKeyOptionToBeEnabled() - clickOptionsModalUpdateButton() - expectVisualizationToBeVisible() - }) - it('legend key is shown with 1 item', () => { - expectLegendKeyToBeVisible() - expectLegedKeyItemAmountToBe(1) - }) - }) - describe('Applying a legend: Single value', () => { - const TEST_ITEM = TEST_ITEMS[0] - const EXPECTED_STANDARD_TEXT_COLOR = '#212934' - const EXPECTED_CONTRAST_TEXT_COLOR = '#ffffff' - const EXPECTED_BACKGROUND_COLOR_1 = '#FFFFB2' - const EXPECTED_TEXT_COLOR_1 = '#FFFFB2' - const EXPECTED_BACKGROUND_COLOR_2 = '#B3402B' - const EXPECTED_TEXT_COLOR_2 = '#B3402B' - const EXPECTED_CUSTOM_TITLE_COLOR = '#ff7700' - const EXPECTED_CUSTOM_SUBTITLE_COLOR = '#ffaa00' - const TEST_LEGEND_SET_WITH_CONTRAST = 'Age 15y interval' - const EXPECTED_STANDARD_TITLE_COLOR = '#212934' - const EXPECTED_STANDARD_SUBTITLE_COLOR = '#4a5768' - it('navigates to the start page and adds data items', () => { - goToStartPage() - changeVisType(visTypeDisplayNames[VIS_TYPE_SINGLE_VALUE]) - openDimension(DIMENSION_ID_DATA) - selectIndicators([TEST_ITEM.name]) - clickDimensionModalUpdateButton() - expectVisualizationToBeVisible(VIS_TYPE_SINGLE_VALUE) - expectSingleValueToHaveTextColor(EXPECTED_STANDARD_TEXT_COLOR) - expectSingleValueToNotHaveBackgroundColor() - }) - it('enables legend', () => { - openOptionsModal(OPTIONS_TAB_LEGEND) - toggleLegend() - expectLegendToBeEnabled() - expectLegendDisplayStrategyToBeByDataItem() - expectLegendDisplayStyleToBeFill() - clickOptionsModalUpdateButton() - expectVisualizationToBeVisible(VIS_TYPE_SINGLE_VALUE) - }) - // Legend on background, no contrast, no custom title colors - it('background color legend is applied', () => { - expectSingleValueToHaveTextColor(EXPECTED_STANDARD_TEXT_COLOR) - expectSingleValueToHaveBackgroundColor(EXPECTED_BACKGROUND_COLOR_1) - expectSVTitleToHaveColor(EXPECTED_STANDARD_TITLE_COLOR) - expectSVSubtitleToHaveColor(EXPECTED_STANDARD_SUBTITLE_COLOR) - }) - it('changes legend display style to text color', () => { - openOptionsModal(OPTIONS_TAB_LEGEND) - expectLegendDisplayStrategyToBeByDataItem() - expectLegendDisplayStyleToBeFill() - changeDisplayStyleToText() - expectLegendDisplayStyleToBeText() - clickOptionsModalUpdateButton() - expectVisualizationToBeVisible(VIS_TYPE_SINGLE_VALUE) - }) - // Legend on text, no contrast, no custom title colors - it('text color legend is applied', () => { - expectSingleValueToHaveTextColor(EXPECTED_TEXT_COLOR_1) - expectSingleValueToNotHaveBackgroundColor() - expectSVTitleToHaveColor(EXPECTED_STANDARD_TITLE_COLOR) - expectSVSubtitleToHaveColor(EXPECTED_STANDARD_SUBTITLE_COLOR) - }) - it(`changes legend display strategy to fixed (${TEST_LEGEND_SET_WITH_CONTRAST})`, () => { - openOptionsModal(OPTIONS_TAB_LEGEND) - expectLegendDisplayStyleToBeText() - expectLegendDisplayStrategyToBeByDataItem() - changeDisplayStrategyToFixed() - expectLegendDisplayStrategyToBeFixed() - changeFixedLegendSet(TEST_LEGEND_SET_WITH_CONTRAST) - clickOptionsModalUpdateButton() - expectVisualizationToBeVisible(VIS_TYPE_SINGLE_VALUE) - }) - // Legend on text, with contrast (N/A), no custom title colors - it('text color legend is applied', () => { - expectSingleValueToHaveTextColor(EXPECTED_TEXT_COLOR_2) - expectSingleValueToNotHaveBackgroundColor() - expectSVTitleToHaveColor(EXPECTED_STANDARD_TITLE_COLOR) - expectSVSubtitleToHaveColor(EXPECTED_STANDARD_SUBTITLE_COLOR) - }) - it('changes legend display style to background color', () => { - openOptionsModal(OPTIONS_TAB_LEGEND) - expectLegendDisplayStrategyToBeFixed() - expectLegendDisplayStyleToBeText() - changeDisplayStyleToFill() - expectLegendDisplayStyleToBeFill() - clickOptionsModalUpdateButton() - expectVisualizationToBeVisible(VIS_TYPE_SINGLE_VALUE) - }) - // Legend on background, with contrast, no custom title colors - it('background color legend and contrast text color is applied', () => { - expectSingleValueToHaveTextColor(EXPECTED_CONTRAST_TEXT_COLOR) - expectSingleValueToHaveBackgroundColor(EXPECTED_BACKGROUND_COLOR_2) - expectSVTitleToHaveColor(EXPECTED_CONTRAST_TEXT_COLOR) - expectSVSubtitleToHaveColor(EXPECTED_CONTRAST_TEXT_COLOR) - }) - it(`changes title and subtitle colors`, () => { - openOptionsModal(OPTIONS_TAB_STYLE) - changeColor('option-chart-title', EXPECTED_CUSTOM_TITLE_COLOR) - changeColor('option-chart-subtitle', EXPECTED_CUSTOM_SUBTITLE_COLOR) - clickOptionsModalUpdateButton() - }) - // Legend on background, with contrast, with custom title colors - it('background color legend, contrast text color and custom title colors are applied', () => { - expectSingleValueToHaveTextColor(EXPECTED_CONTRAST_TEXT_COLOR) - expectSingleValueToHaveBackgroundColor(EXPECTED_BACKGROUND_COLOR_2) - expectSVTitleToHaveColor(EXPECTED_CUSTOM_TITLE_COLOR) - expectSVSubtitleToHaveColor(EXPECTED_CUSTOM_SUBTITLE_COLOR) - }) - it('changes legend display style to text color', () => { - openOptionsModal(OPTIONS_TAB_LEGEND) - expectLegendDisplayStrategyToBeFixed() - expectLegendDisplayStyleToBeFill() - changeDisplayStyleToText() - expectLegendDisplayStyleToBeText() - clickOptionsModalUpdateButton() - expectVisualizationToBeVisible(VIS_TYPE_SINGLE_VALUE) - }) - // Legend on text, with contrast, with custom title colors - it('text color legend and custom title colors are applied', () => { - expectSingleValueToHaveTextColor(EXPECTED_TEXT_COLOR_2) - expectSingleValueToNotHaveBackgroundColor() - expectSVTitleToHaveColor(EXPECTED_CUSTOM_TITLE_COLOR) - expectSVSubtitleToHaveColor(EXPECTED_CUSTOM_SUBTITLE_COLOR) - }) - it(`changes legend display strategy to by data item`, () => { - openOptionsModal(OPTIONS_TAB_LEGEND) - expectLegendDisplayStyleToBeText() - expectLegendDisplayStrategyToBeFixed() - changeDisplayStrategyToByDataItem() - expectLegendDisplayStrategyToBeByDataItem() - clickOptionsModalUpdateButton() - expectVisualizationToBeVisible(VIS_TYPE_SINGLE_VALUE) - }) - // Legend on text, no contrast, with custom title colors - it('text color legend and custom title colors are applied', () => { - expectSingleValueToHaveTextColor(EXPECTED_TEXT_COLOR_1) - expectSingleValueToNotHaveBackgroundColor() - expectSVTitleToHaveColor(EXPECTED_CUSTOM_TITLE_COLOR) - expectSVSubtitleToHaveColor(EXPECTED_CUSTOM_SUBTITLE_COLOR) - }) - it('changes legend display style to background color', () => { - openOptionsModal(OPTIONS_TAB_LEGEND) - changeDisplayStrategyToByDataItem() - expectLegendDisplayStyleToBeText() - changeDisplayStyleToFill() - expectLegendDisplayStyleToBeFill() - clickOptionsModalUpdateButton() - expectVisualizationToBeVisible(VIS_TYPE_SINGLE_VALUE) - }) - // Legend on background, no contrast, with custom title colors - it('background color legend and custom title colors are applied', () => { - expectSingleValueToHaveTextColor(EXPECTED_STANDARD_TEXT_COLOR) - expectSingleValueToHaveBackgroundColor(EXPECTED_BACKGROUND_COLOR_1) - expectSVTitleToHaveColor(EXPECTED_CUSTOM_TITLE_COLOR) - expectSVSubtitleToHaveColor(EXPECTED_CUSTOM_SUBTITLE_COLOR) - }) - it('legend key is hidden', () => { - expectLegendKeyToBeHidden() - }) - it('enables legend key option', () => { - openOptionsModal(OPTIONS_TAB_LEGEND) - toggleLegendKeyOption() - expectLegendKeyOptionToBeEnabled() - clickOptionsModalUpdateButton() - expectVisualizationToBeVisible(VIS_TYPE_SINGLE_VALUE) - }) - it('legend key is shown with 1 item', () => { - expectLegendKeyToBeVisible() - expectLegedKeyItemAmountToBe(1) - }) - }) - describe('Applying a legend: Gauge', () => { - const TEST_ITEM = TEST_ITEMS[0] - const EXPECTED_BY_DATA_COLOR = '#FFFFB2' - const EXPECTED_FIXED_COLOR = '#c7e9c0' - it('navigates to the start page and adds data items', () => { - goToStartPage() - changeVisType(visTypeDisplayNames[VIS_TYPE_GAUGE]) - openDimension(DIMENSION_ID_DATA) - selectIndicators([TEST_ITEM.name]) - clickDimensionModalUpdateButton() - expectVisualizationToBeVisible(VIS_TYPE_GAUGE) - }) - it('enables legend', () => { - openOptionsModal(OPTIONS_TAB_LEGEND) - toggleLegend() - expectLegendToBeEnabled() - expectLegendDisplayStrategyToBeByDataItem() - expectLegendDisplayStyleToBeFill() - clickOptionsModalUpdateButton() - expectVisualizationToBeVisible(VIS_TYPE_GAUGE) - }) - it('legend by data item is applied', () => { - expectWindowConfigYAxisToHaveColor(EXPECTED_BY_DATA_COLOR) - }) - it(`changes legend display strategy to fixed (${TEST_LEGEND_SET})`, () => { - openOptionsModal(OPTIONS_TAB_LEGEND) - expectLegendDisplayStrategyToBeByDataItem() - expectLegendDisplayStyleToBeFill() - changeDisplayStrategyToFixed() - expectLegendDisplayStrategyToBeFixed() - changeFixedLegendSet(TEST_LEGEND_SET) - clickOptionsModalUpdateButton() - expectVisualizationToBeVisible(VIS_TYPE_GAUGE) - }) - it('fixed legend is applied', () => { - expectWindowConfigYAxisToHaveColor(EXPECTED_FIXED_COLOR) - }) - it('changes legend display style to text color', () => { - openOptionsModal(OPTIONS_TAB_LEGEND) - expectLegendDisplayStrategyToBeFixed() - expectFixedLegendSetToBe(TEST_LEGEND_SET) - expectLegendDisplayStyleToBeFill() - changeDisplayStyleToText() - expectLegendDisplayStyleToBeText() - clickOptionsModalUpdateButton() - expectVisualizationToBeVisible(VIS_TYPE_GAUGE) - }) - it('legend style is applied', () => { - expectWindowConfigSeriesDataLabelsToHaveColor( - 0, - EXPECTED_FIXED_COLOR - ) - }) - it('legend key is hidden', () => { - expectLegendKeyToBeHidden() - }) - it('verifies that options are persisted', () => { - openOptionsModal(OPTIONS_TAB_LEGEND) - expectLegendDisplayStrategyToBeFixed() - expectFixedLegendSetToBe(TEST_LEGEND_SET) - }) - it('enables legend key option', () => { - toggleLegendKeyOption() - expectLegendKeyOptionToBeEnabled() - clickOptionsModalUpdateButton() - expectVisualizationToBeVisible(VIS_TYPE_GAUGE) - }) - it('legend key is shown with 1 item', () => { - expectLegendKeyToBeVisible() - expectLegedKeyItemAmountToBe(1) - }) - }) - describe('Applying a legend: Stacked column', () => { - it('navigates to the start page and adds data items', () => { - goToStartPage() - changeVisType(visTypeDisplayNames[VIS_TYPE_STACKED_COLUMN]) - openDimension(DIMENSION_ID_DATA) - selectIndicators(TEST_ITEMS.map((item) => item.name)) - clickDimensionModalUpdateButton() - expectVisualizationToBeVisible(VIS_TYPE_STACKED_COLUMN) - }) - it('enables legend', () => { - openOptionsModal(OPTIONS_TAB_LEGEND) - toggleLegend() - expectLegendToBeEnabled() - expectLegendDisplayStrategyToBeByDataItem() - clickOptionsModalUpdateButton() - expectChartTitleToBeVisible() - }) - it('legend by data item is applied', () => { - TEST_ITEMS.forEach((item) => - expectWindowConfigSeriesItemToHaveLegendSet( - item.name, - item.legendSet - ) - ) - }) - it(`changes legend display strategy to fixed (${TEST_LEGEND_SET})`, () => { - openOptionsModal(OPTIONS_TAB_LEGEND) - expectLegendDisplayStrategyToBeByDataItem() - changeDisplayStrategyToFixed() - expectLegendDisplayStrategyToBeFixed() - changeFixedLegendSet(TEST_LEGEND_SET) - clickOptionsModalUpdateButton() - expectChartTitleToBeVisible() - }) - it('fixed legend is applied', () => { - TEST_ITEMS.forEach((item) => - expectWindowConfigSeriesItemToHaveLegendSet( - item.name, - TEST_LEGEND_SET - ) - ) - }) - it('legend key is hidden', () => { - expectLegendKeyToBeHidden() - }) - it('verifies that options are persisted', () => { - openOptionsModal(OPTIONS_TAB_LEGEND) - expectLegendDisplayStrategyToBeFixed() - expectFixedLegendSetToBe(TEST_LEGEND_SET) - }) - it('enables legend key option', () => { - toggleLegendKeyOption() - expectLegendKeyOptionToBeEnabled() - clickOptionsModalUpdateButton() - expectVisualizationToBeVisible() - }) - it('legend key is shown with 1 item', () => { - expectLegendKeyToBeVisible() - expectLegedKeyItemAmountToBe(1) - }) - }) - describe('Applying a legend: Pivot table', () => { - const TEST_ITEM = TEST_ITEMS[0] - const EXPECTED_STANDARD_TEXT_COLOR = 'color: rgb(33, 41, 52)' - const valueCellEl = 'visualization-value-cell' - it('navigates to the start page and adds data items', () => { - goToStartPage() - changeVisType(visTypeDisplayNames[VIS_TYPE_PIVOT_TABLE]) - openDimension(DIMENSION_ID_DATA) - selectIndicators([TEST_ITEM.name]) - clickDimensionModalUpdateButton() - expectVisualizationToBeVisible(VIS_TYPE_PIVOT_TABLE) - }) - it('no legend is applied', () => { - cy.getBySel(valueCellEl).each(($el) => { - cy.wrap($el) - .invoke('attr', 'style') - .should('not.contain', 'color') - .and('not.contain', 'background-color') - }) - }) - it('enables legend', () => { - openOptionsModal(OPTIONS_TAB_LEGEND) - toggleLegend() - expectLegendToBeEnabled() - expectLegendDisplayStrategyToBeByDataItem() - expectLegendDisplayStyleToBeFill() - clickOptionsModalUpdateButton() - expectVisualizationToBeVisible(VIS_TYPE_PIVOT_TABLE) - }) - it('background color legend is applied', () => { - cy.getBySel(valueCellEl).each(($el) => { - cy.wrap($el) - .invoke('attr', 'style') - .should('contain', 'background-color') - .and('contain', EXPECTED_STANDARD_TEXT_COLOR) - }) - }) - it('changes legend display style to text color', () => { - openOptionsModal(OPTIONS_TAB_LEGEND) - expectLegendDisplayStrategyToBeByDataItem() - expectLegendDisplayStyleToBeFill() - changeDisplayStyleToText() - expectLegendDisplayStyleToBeText() - clickOptionsModalUpdateButton() - expectVisualizationToBeVisible(VIS_TYPE_PIVOT_TABLE) - }) - it('text color legend is applied', () => { - cy.getBySel(valueCellEl).each(($el) => { - cy.wrap($el) - .invoke('attr', 'style') - .should('not.contain', 'background-color') - .and('not.contain', EXPECTED_STANDARD_TEXT_COLOR) - }) - }) - it('legend key is hidden', () => { - expectLegendKeyToBeHidden() - }) - it('verifies that options are persisted', () => { - openOptionsModal(OPTIONS_TAB_LEGEND) - expectLegendDisplayStrategyToBeByDataItem() - }) - it('enables legend key option', () => { - toggleLegendKeyOption() - expectLegendKeyOptionToBeEnabled() - clickOptionsModalUpdateButton() - expectVisualizationToBeVisible(VIS_TYPE_PIVOT_TABLE) - }) - it('legend key is shown with 1 item', () => { - expectLegendKeyToBeVisible() - expectLegedKeyItemAmountToBe(1) - }) - }) - describe('Transferring a legend: Pivot table -> Gauge', () => { - const TEST_ITEM = TEST_ITEMS[0] - const EXPECTED_STANDARD_TEXT_COLOR = 'color: rgb(33, 41, 52)' - const EXPECTED_FIXED_COLOR = '#c7e9c0' - const valueCellEl = 'visualization-value-cell' - it('navigates to the start page and adds data items', () => { - goToStartPage() - changeVisType(visTypeDisplayNames[VIS_TYPE_PIVOT_TABLE]) - openDimension(DIMENSION_ID_DATA) - selectIndicators([TEST_ITEM.name]) - clickDimensionModalUpdateButton() - expectVisualizationToBeVisible(VIS_TYPE_PIVOT_TABLE) - }) - it('enables legend', () => { - openOptionsModal(OPTIONS_TAB_LEGEND) - toggleLegend() - expectLegendToBeEnabled() - expectLegendDisplayStrategyToBeByDataItem() - expectLegendDisplayStyleToBeFill() - changeDisplayStyleToText() - expectLegendDisplayStyleToBeText() - changeDisplayStrategyToFixed() - expectLegendDisplayStrategyToBeFixed() - changeFixedLegendSet(TEST_LEGEND_SET) - clickOptionsModalUpdateButton() - expectVisualizationToBeVisible(VIS_TYPE_PIVOT_TABLE) - }) - it(`text color fixed legend (${TEST_LEGEND_SET}) is applied`, () => { - cy.getBySel(valueCellEl).each(($el) => { - cy.wrap($el) - .invoke('attr', 'style') - .should('not.contain', 'background-color') - .and('not.contain', EXPECTED_STANDARD_TEXT_COLOR) - }) - }) - it('changes vis type to Gauge', () => { - changeVisType(visTypeDisplayNames[VIS_TYPE_GAUGE]) - clickMenuBarUpdateButton() - expectVisualizationToBeVisible(VIS_TYPE_GAUGE) - }) - it(`text color fixed legend (${TEST_LEGEND_SET}) is applied`, () => { - expectWindowConfigSeriesDataLabelsToHaveColor( - 0, - EXPECTED_FIXED_COLOR - ) - }) - it('verifies that options are persisted', () => { - openOptionsModal(OPTIONS_TAB_LEGEND) - expectLegendDisplayStyleToBeText() - expectLegendDisplayStrategyToBeFixed() - }) - }) - describe('Transferring a legend: Pivot table -> Single value', () => { - const TEST_ITEM = TEST_ITEMS[0] - const EXPECTED_FIXED_COLOR = '#c7e9c0' - const valueCellEl = 'visualization-value-cell' - const EXPECTED_SV_STANDARD_TEXT_COLOR = '#212934' - const EXPECTED_PT_STANDARD_TEXT_COLOR = 'color: rgb(33, 41, 52)' - it('navigates to the start page and adds data items', () => { - goToStartPage() - changeVisType(visTypeDisplayNames[VIS_TYPE_PIVOT_TABLE]) - openDimension(DIMENSION_ID_DATA) - selectIndicators([TEST_ITEM.name]) - clickDimensionModalUpdateButton() - expectVisualizationToBeVisible(VIS_TYPE_PIVOT_TABLE) - }) - it('enables legend', () => { - openOptionsModal(OPTIONS_TAB_LEGEND) - toggleLegend() - expectLegendToBeEnabled() - expectLegendDisplayStrategyToBeByDataItem() - expectLegendDisplayStyleToBeFill() - changeDisplayStrategyToFixed() - expectLegendDisplayStrategyToBeFixed() - changeFixedLegendSet(TEST_LEGEND_SET) - clickOptionsModalUpdateButton() - expectVisualizationToBeVisible(VIS_TYPE_PIVOT_TABLE) - }) - it(`background color fixed legend (${TEST_LEGEND_SET}) is applied`, () => { - cy.getBySel(valueCellEl).each(($el) => { - cy.wrap($el) - .invoke('attr', 'style') - .should('contain', 'background-color') - .and('contain', EXPECTED_PT_STANDARD_TEXT_COLOR) - }) - }) - it('changes vis type to Single value', () => { - changeVisType(visTypeDisplayNames[VIS_TYPE_SINGLE_VALUE]) - clickMenuBarUpdateButton() - expectVisualizationToBeVisible(VIS_TYPE_SINGLE_VALUE) - }) - it('legend is applied to Single value', () => { - expectSingleValueToHaveTextColor(EXPECTED_SV_STANDARD_TEXT_COLOR) - expectSingleValueToHaveBackgroundColor(EXPECTED_FIXED_COLOR) - }) - it('verifies that options are persisted', () => { - openOptionsModal(OPTIONS_TAB_LEGEND) - expectLegendDisplayStyleToBeFill() - expectLegendDisplayStrategyToBeFixed() - }) - }) - describe('Transferring the legend key: Column -> Pivot table -> Gauge -> Single value', () => { - it('navigates to the start page and adds data items', () => { - goToStartPage() - openDimension(DIMENSION_ID_DATA) - selectIndicators(TEST_ITEMS.map((item) => item.name)) - clickDimensionModalUpdateButton() - expectVisualizationToBeVisible() - }) - it('enables legend (Column)', () => { - openOptionsModal(OPTIONS_TAB_LEGEND) - toggleLegend() - expectLegendToBeEnabled() - clickOptionsModalUpdateButton() - expectVisualizationToBeVisible() - }) - it('legend key is hidden (Column)', () => { - expectLegendKeyToBeHidden() - }) - it('enables legend key option (Column)', () => { - openOptionsModal(OPTIONS_TAB_LEGEND) - toggleLegendKeyOption() - expectLegendKeyOptionToBeEnabled() - clickOptionsModalUpdateButton() - expectVisualizationToBeVisible() - }) - it(`legend key is shown (Column) with ${TEST_ITEMS.length} items`, () => { - expectLegendKeyToBeVisible() - expectLegedKeyItemAmountToBe(TEST_ITEMS.length) - }) - it('changes vis type to Pivot table', () => { - changeVisType(visTypeDisplayNames[VIS_TYPE_PIVOT_TABLE]) - clickMenuBarUpdateButton() - expectVisualizationToBeVisible(VIS_TYPE_PIVOT_TABLE) - }) - it(`legend key is shown (Pivot table) with ${TEST_ITEMS.length} items`, () => { - expectLegendKeyToBeVisible() - expectLegedKeyItemAmountToBe(TEST_ITEMS.length) - }) - it('disables legend key option (Pivot table)', () => { - openOptionsModal(OPTIONS_TAB_LEGEND) - toggleLegendKeyOption() - expectLegendKeyOptionToBeDisabled() - clickOptionsModalUpdateButton() - expectVisualizationToBeVisible(VIS_TYPE_PIVOT_TABLE) - }) - it('legend key is hidden (Pivot table)', () => { - expectLegendKeyToBeHidden() - }) - it('changes vis type to Gauge', () => { - changeVisType(visTypeDisplayNames[VIS_TYPE_GAUGE]) - clickMenuBarUpdateButton() - expectVisualizationToBeVisible(VIS_TYPE_GAUGE) - }) - it('legend key is hidden (Gauge)', () => { - expectLegendKeyToBeHidden() - }) - it('enables legend key option (Gauge)', () => { - openOptionsModal(OPTIONS_TAB_LEGEND) - toggleLegendKeyOption() - expectLegendKeyOptionToBeEnabled() - clickOptionsModalUpdateButton() - expectVisualizationToBeVisible(VIS_TYPE_GAUGE) - }) - it('legend key is shown (Gauge) with 1 item', () => { - expectLegendKeyToBeVisible() - expectLegedKeyItemAmountToBe(1) - }) - it('changes vis type to Single value', () => { - changeVisType(visTypeDisplayNames[VIS_TYPE_SINGLE_VALUE]) - clickMenuBarUpdateButton() - expectVisualizationToBeVisible(VIS_TYPE_SINGLE_VALUE) - }) - it('legend key is shown (Single value) with 1 item', () => { - expectLegendKeyToBeVisible() - expectLegedKeyItemAmountToBe(1) - }) - it('disables legend key option (Single value)', () => { - openOptionsModal(OPTIONS_TAB_LEGEND) - toggleLegendKeyOption() - expectLegendKeyOptionToBeDisabled() - clickOptionsModalUpdateButton() - expectVisualizationToBeVisible(VIS_TYPE_SINGLE_VALUE) - }) - it('legend key is hidden (Single value)', () => { - expectLegendKeyToBeHidden() - }) - }) - describe('Preventing options bleed: Column -> Area', () => { - it('navigates to the start page and adds data items', () => { - goToStartPage() - openDimension(DIMENSION_ID_DATA) - selectIndicators(TEST_ITEMS.map((item) => item.name)) - clickDimensionModalUpdateButton() - expectVisualizationToBeVisible(VIS_TYPE_COLUMN) - }) - it('enables legend', () => { - openOptionsModal(OPTIONS_TAB_LEGEND) - toggleLegend() - expectLegendToBeEnabled() - expectLegendDisplayStrategyToBeByDataItem() - clickOptionsModalUpdateButton() - expectChartTitleToBeVisible() - }) - it('legend is applied to Column', () => { - TEST_ITEMS.forEach((item) => - expectWindowConfigSeriesItemToHaveLegendSet( - item.name, - item.legendSet - ) - ) - }) - it('changes vis type to Area', () => { - changeVisType(visTypeDisplayNames[VIS_TYPE_AREA]) - clickMenuBarUpdateButton() - expectVisualizationToBeVisible(VIS_TYPE_AREA) - }) - it('legend is not applied to Area', () => { - TEST_ITEMS.forEach((item) => - expectWindowConfigSeriesItemToNotHaveLegendSet(item.name) - ) - }) - it('legend options are not available', () => { - openOptionsModal() - expectOptionsTabToBeHidden(OPTIONS_TAB_LEGEND) - clickOptionsModalHideButton() - }) - it('legend key is hidden', () => { - expectLegendKeyToBeHidden() - }) - it(`series key displays the correct amount of items`, () => { - expectSeriesKeyToHaveSeriesKeyItems(2) - }) - }) - describe('Non-legend set type displays correctly: Line', () => { - it('navigates to the start page and adds data items', () => { - goToStartPage() - changeVisType(visTypeDisplayNames[VIS_TYPE_LINE]) - openDimension(DIMENSION_ID_DATA) - selectIndicators(TEST_ITEMS.map((item) => item.name)) - clickDimensionModalUpdateButton() - expectVisualizationToBeVisible(VIS_TYPE_LINE) - }) - it('legend is not applied to Line', () => { - TEST_ITEMS.forEach((item) => - expectWindowConfigSeriesItemToNotHaveLegendSet(item.name) - ) - }) - it('legend options are not available', () => { - openOptionsModal() - expectOptionsTabToBeHidden(OPTIONS_TAB_LEGEND) - }) - it('legend key is hidden', () => { - expectLegendKeyToBeHidden() - }) - it(`series key displays the correct amount of items`, () => { - expectSeriesKeyToHaveSeriesKeyItems(2) - }) - }) - describe('The chart series key displaying legend colors', () => { - it('navigates to the start page and adds data items', () => { - goToStartPage() - openDimension(DIMENSION_ID_DATA) - selectIndicators(TEST_ITEMS.map((item) => item.name)) - clickDimensionModalUpdateButton() - expectVisualizationToBeVisible(VIS_TYPE_COLUMN) - }) - it(`series key displays the correct amount of items`, () => { - expectSeriesKeyToHaveSeriesKeyItems(2) - }) - it('enables legend', () => { - openOptionsModal(OPTIONS_TAB_LEGEND) - toggleLegend() - expectLegendToBeEnabled() - expectLegendDisplayStrategyToBeByDataItem() - clickOptionsModalUpdateButton() - expectChartTitleToBeVisible() - }) - it(`changes legend display strategy to fixed (${TEST_ITEMS[1].legendSet})`, () => { - openOptionsModal(OPTIONS_TAB_LEGEND) - expectLegendDisplayStrategyToBeByDataItem() - changeDisplayStrategyToFixed() - expectLegendDisplayStrategyToBeFixed() - changeFixedLegendSet(TEST_ITEMS[1].legendSet) - clickOptionsModalUpdateButton() - expectChartTitleToBeVisible() - }) - }) - describe('When data is not on series, legend is only applied when strategy fixed is used', () => { - const TEST_ITEM = TEST_ITEMS[0] - it('navigates to the start page and adds data items, legend and legend key', () => { - goToStartPage() - openDimension(DIMENSION_ID_DATA) - selectIndicators([TEST_ITEM.name]) - clickDimensionModalUpdateButton() - expectVisualizationToBeVisible(VIS_TYPE_COLUMN) - openOptionsModal(OPTIONS_TAB_LEGEND) - toggleLegend() - expectLegendToBeEnabled() - expectLegendDisplayStrategyToBeByDataItem() - toggleLegendKeyOption() - expectLegendKeyOptionToBeEnabled() - clickOptionsModalUpdateButton() - expectVisualizationToBeVisible() - }) - it("selects period 'Last 3 months'", () => { - openDimension(DIMENSION_ID_PERIOD) - unselectAllItemsByButton() - selectRelativePeriods(['Last 3 months'], 'Months') - clickDimensionModalUpdateButton() - }) - it('legend by data item is applied', () => { - expectWindowConfigSeriesItemToHaveLegendSet( - TEST_ITEM.name, - TEST_ITEM.legendSet - ) - }) - it('legend key is shown with 1 item', () => { - expectLegendKeyToBeVisible() - expectLegedKeyItemAmountToBe(1) - }) - it(`series key displays the correct amount of items`, () => { - expectSeriesKeyToHaveSeriesKeyItems(1) - }) - it('moves period dimension to series axis', () => { - openContextMenu(DIMENSION_ID_PERIOD) - clickContextMenuMove(DIMENSION_ID_PERIOD, AXIS_ID_COLUMNS) - clickMenuBarUpdateButton() - expectVisualizationToBeVisible() - expectAxisToHaveDimension(AXIS_ID_COLUMNS, DIMENSION_ID_PERIOD) - }) - it('no legend is applied', () => { - expectEachWindowConfigSeriesItemToNotHaveLegendSet() - }) - it('legend key is hidden', () => { - expectLegendKeyToBeHidden() - }) - it(`changes legend display strategy to fixed (${TEST_ITEMS[1].legendSet})`, () => { - openOptionsModal(OPTIONS_TAB_LEGEND) - expectLegendDisplayStrategyToBeByDataItem() - changeDisplayStrategyToFixed() - expectLegendDisplayStrategyToBeFixed() - changeFixedLegendSet(TEST_ITEMS[1].legendSet) - clickOptionsModalUpdateButton() - expectVisualizationToBeVisible() - }) - it('fixed legend is applied', () => { - expectEachWindowConfigSeriesItemToHaveLegendSet( - TEST_ITEMS[1].legendSet - ) - }) - it('legend key is shown with 1 item', () => { - expectLegendKeyToBeVisible() - expectLegedKeyItemAmountToBe(1) - }) - it(`series key displays the correct amount of items`, () => { - expectSeriesKeyToHaveSeriesKeyItems(3) - }) - }) - describe('Legend is not applied to column-as-line items', () => { - it('navigates to the start page and adds data items, legend and legend key', () => { - goToStartPage() - openDimension(DIMENSION_ID_DATA) - selectIndicators(TEST_ITEMS.map((item) => item.name)) - clickDimensionModalUpdateButton() - expectVisualizationToBeVisible(VIS_TYPE_COLUMN) - openOptionsModal(OPTIONS_TAB_LEGEND) - toggleLegend() - expectLegendToBeEnabled() - expectLegendDisplayStrategyToBeByDataItem() - toggleLegendKeyOption() - expectLegendKeyOptionToBeEnabled() - clickOptionsModalUpdateButton() - expectVisualizationToBeVisible() - }) - it('legend by data item is applied', () => { - TEST_ITEMS.forEach((item) => - expectWindowConfigSeriesItemToHaveLegendSet( - item.name, - item.legendSet - ) - ) - }) - it(`changes all items to type ${VIS_TYPE_LINE}`, () => { - openOptionsModal(OPTIONS_TAB_SERIES) - TEST_ITEMS.forEach((item, index) => - setItemToType(index, VIS_TYPE_LINE) - ) - clickOptionsModalUpdateButton() - expectVisualizationToBeVisible() - TEST_ITEMS.forEach((item, index) => - expectWindowConfigSeriesItemToBeType(index, 'line') - ) - }) - it('no legend is applied', () => { - expectEachWindowConfigSeriesItemToNotHaveLegendSet() - }) - it('legend key is hidden', () => { - expectLegendKeyToBeHidden() - }) - it(`series key displays the correct amount of items`, () => { - expectSeriesKeyToHaveSeriesKeyItems(2) - }) - it(`changes first item (${TEST_ITEMS[0].name}) to type ${VIS_TYPE_COLUMN}`, () => { - openOptionsModal(OPTIONS_TAB_SERIES) - setItemToType(0, VIS_TYPE_COLUMN) - clickOptionsModalUpdateButton() - expectVisualizationToBeVisible() - expectWindowConfigSeriesItemToNotHaveType(0) - }) - it('legend by data item is applied to the first item', () => { - expectWindowConfigSeriesItemToHaveLegendSet( - TEST_ITEMS[0].name, - TEST_ITEMS[0].legendSet - ) - expectWindowConfigSeriesItemToNotHaveLegendSet(TEST_ITEMS[1].name) - }) - it('legend key is shown with 1 item', () => { - expectLegendKeyToBeVisible() - expectLegedKeyItemAmountToBe(1) - }) - it(`series key displays the correct amount of items`, () => { - expectSeriesKeyToHaveSeriesKeyItems(2) - }) - const TEST_ITEM = { - name: 'ANC 2 Coverage', - legendSet: 'ANC Coverage', - legends: 7, - } - it(`adds a third item (${TEST_ITEM.name} - same legendset as the first item) with type ${VIS_TYPE_LINE}`, () => { - openDimension(DIMENSION_ID_DATA) - selectIndicators([TEST_ITEM.name]) - clickDimensionModalUpdateButton() - expectVisualizationToBeVisible(VIS_TYPE_COLUMN) - openOptionsModal(OPTIONS_TAB_SERIES) - setItemToType(2, VIS_TYPE_LINE) - clickOptionsModalUpdateButton() - expectVisualizationToBeVisible() - expectWindowConfigSeriesItemToNotHaveType(0) - }) - it('legend key is shown with 1 item', () => { - expectLegendKeyToBeVisible() - expectLegedKeyItemAmountToBe(1) - }) - it('legend by data item is applied to the first item', () => { - expectWindowConfigSeriesItemToHaveLegendSet( - TEST_ITEMS[0].name, - TEST_ITEMS[0].legendSet - ) - expectWindowConfigSeriesItemToNotHaveLegendSet(TEST_ITEMS[1].name) - expectWindowConfigSeriesItemToNotHaveLegendSet(TEST_ITEM.name) - }) - it(`series key displays the correct amount of items`, () => { - expectSeriesKeyToHaveSeriesKeyItems(3) - }) - }) -}) diff --git a/cypress/integration/options/lines.cy.js b/cypress/integration/options/lines.cy.js deleted file mode 100644 index ea8fef0357..0000000000 --- a/cypress/integration/options/lines.cy.js +++ /dev/null @@ -1,85 +0,0 @@ -import { DIMENSION_ID_DATA, VIS_TYPE_COLUMN } from '@dhis2/analytics' -import { - expectVisualizationToBeVisible, - expectChartTitleToBeVisible, -} from '../../elements/chart.js' -import { - selectDataElements, - clickDimensionModalUpdateButton, -} from '../../elements/dimensionModal/index.js' -import { openDimension } from '../../elements/dimensionsPanel.js' -import { openOptionsModal } from '../../elements/menuBar.js' -import { - clickOptionsModalUpdateButton, - clickTrendLineCheckbox, - OPTIONS_TAB_DATA, - selectTrendLineType, -} from '../../elements/optionsModal/index.js' -import { goToStartPage } from '../../elements/startScreen.js' -import { CONFIG_DEFAULT_TREND_LINE } from '../../utils/config.js' -import { TEST_DATA_ELEMENTS } from '../../utils/data.js' -import { - expectWindowConfigSeriesToHaveTrendline, - expectWindowConfigSeriesToNotHaveTrendline, -} from '../../utils/window.js' - -const TEST_DATA_ELEMENT_NAMES = TEST_DATA_ELEMENTS.slice(2, 4).map( - (item) => item.name -) - -describe('Options - Lines', () => { - it('navigates to the start page and adds data items', () => { - goToStartPage() - openDimension(DIMENSION_ID_DATA) - selectDataElements(TEST_DATA_ELEMENT_NAMES) - clickDimensionModalUpdateButton() - expectVisualizationToBeVisible(VIS_TYPE_COLUMN) - }) - describe('trendline', () => { - const trendLineTypes = [ - { name: 'Polynomial', type: 'spline' }, - { name: 'Loess', type: 'spline' }, - { name: 'Linear', type: 'line' }, - ] - - it('has no trend line', () => { - expectChartTitleToBeVisible() - expectWindowConfigSeriesToNotHaveTrendline() - }) - - trendLineTypes.forEach((trendLineType, index) => { - describe(trendLineType.name, () => { - it('opens Options -> Data', () => { - openOptionsModal(OPTIONS_TAB_DATA) - }) - if (index === 0) { - it('enables trendline', () => { - clickTrendLineCheckbox() - }) - } - it('selects trendline type', () => { - selectTrendLineType(trendLineType.name) - }) - it('clicks the modal update button', () => { - clickOptionsModalUpdateButton() - expectChartTitleToBeVisible() - }) - TEST_DATA_ELEMENT_NAMES.forEach((dataElement) => { - it(`config has "${dataElement}" trendline`, () => { - const trendline = { - ...CONFIG_DEFAULT_TREND_LINE, - type: trendLineType.type, - name: `${dataElement} (trend)`, - } - expectWindowConfigSeriesToHaveTrendline(trendline) - }) - }) - }) - }) - }) - /* TODO: - - Test base line and target line like trend line (above) - - Pie, PT, SV shouldn't have the lines section in options - - Gauge should only display base and target line (no trend line) - */ -}) diff --git a/cypress/integration/save.cy.js b/cypress/integration/save.cy.js deleted file mode 100644 index 65b0a555a0..0000000000 --- a/cypress/integration/save.cy.js +++ /dev/null @@ -1,195 +0,0 @@ -import { - DIMENSION_ID_DATA, - visTypeDisplayNames, - VIS_TYPE_SCATTER, -} from '@dhis2/analytics' -import { - expectAOTitleToBeDirty, - expectAOTitleToBeUnsaved, - expectAOTitleToBeValue, - expectAOTitleToNotBeDirty, - expectVisualizationToBeVisible, -} from '../elements/chart.js' -import { replacePeriodItems } from '../elements/common.js' -import { - switchDataTab, - selectIndicators, - selectDataElements, - clickDimensionModalUpdateButton, -} from '../elements/dimensionModal/index.js' -import { openDimension } from '../elements/dimensionsPanel.js' -import { - //openRandomAOCreatedByOthers, - saveNewAO, - closeFileMenuWithClick, - saveAOAs, - saveExistingAO, - openAOByName, - deleteAO, - expectFileMenuButtonToBeEnabled, - expectFileMenuButtonToBeDisabled, - FILE_MENU_BUTTON_NEW, - FILE_MENU_BUTTON_OPEN, - FILE_MENU_BUTTON_SAVE_EXISTING, - FILE_MENU_BUTTON_SAVEAS, - FILE_MENU_BUTTON_DELETE, - FILE_MENU_BUTTON_RENAME, - FILE_MENU_BUTTON_TRANSLATE, - FILE_MENU_BUTTON_SHARE, - FILE_MENU_BUTTON_GETLINK, -} from '../elements/fileMenu/index.js' -import { clickMenuBarFileButton } from '../elements/menuBar.js' -import { expectRouteToBeAOId, expectRouteToBeEmpty } from '../elements/route.js' -import { - expectStartScreenToBeVisible, - goToStartPage, -} from '../elements/startScreen.js' -import { changeVisType } from '../elements/visualizationTypeSelector.js' -import { TEST_DATA_ELEMENTS, TEST_INDICATORS } from '../utils/data.js' -import { getRandomVisType } from '../utils/random.js' - -const TEST_VIS_NAME = `TEST ${new Date().toLocaleString()}` -const TEST_VIS_NAME_UPDATED = `${TEST_VIS_NAME} - updated` -const TEST_VIS_DESCRIPTION = 'Generated by Cypress' -const TEST_VIS_TYPE = getRandomVisType() -const TEST_VIS_TYPE_NAME = visTypeDisplayNames[TEST_VIS_TYPE] -const TEST_INDICATOR_NAMES = TEST_INDICATORS.slice(1, 4).map( - (item) => item.name -) - -// 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('navigates to the start page', () => { - goToStartPage() - }) - it(`changes vis type to ${TEST_VIS_TYPE_NAME}`, () => { - changeVisType(TEST_VIS_TYPE_NAME) - }) - it('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() - } - }) - it('displays an unsaved visualization', () => { - expectVisualizationToBeVisible(TEST_VIS_TYPE) - expectAOTitleToBeUnsaved() - expectRouteToBeEmpty() - }) - it('checks that Save as is disabled', () => { - clickMenuBarFileButton() - expectFileMenuButtonToBeDisabled(FILE_MENU_BUTTON_SAVEAS) - closeFileMenuWithClick() - }) - it('saves new AO using "Save"', () => { - saveNewAO(TEST_VIS_NAME, TEST_VIS_DESCRIPTION) - expectAOTitleToBeValue(TEST_VIS_NAME) - expectVisualizationToBeVisible(TEST_VIS_TYPE) - }) - it('checks that the url was changed', () => { - expectRouteToBeAOId() - }) - it('all File menu buttons are enabled', () => { - clickMenuBarFileButton() - const enabledButtons = [ - FILE_MENU_BUTTON_NEW, - FILE_MENU_BUTTON_OPEN, - FILE_MENU_BUTTON_SAVE_EXISTING, - 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() - }) - it(`replaces the selected period`, () => { - replacePeriodItems(TEST_VIS_TYPE) - expectAOTitleToBeDirty() - expectVisualizationToBeVisible(TEST_VIS_TYPE) - }) - it('saves AO using "Save"', () => { - saveExistingAO() - expectAOTitleToNotBeDirty() - expectAOTitleToBeValue(TEST_VIS_NAME) - expectVisualizationToBeVisible(TEST_VIS_TYPE) - }) - it('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', () => { - 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) - }) - it(`replaces the selected period`, () => { - replacePeriodItems(TEST_VIS_TYPE, { useAltData: true }) - expectAOTitleToBeDirty() - }) - it('saves AO using "Save"', () => { - saveExistingAO() - expectAOTitleToNotBeDirty() - expectAOTitleToBeValue(TEST_VIS_NAME) - expectVisualizationToBeVisible(TEST_VIS_TYPE) - }) - it('deletes AO', () => { - deleteAO() - expectRouteToBeEmpty() - expectStartScreenToBeVisible() - }) - }) - - /* - describe('"save" for a saved AO created by others', () => { - it('navigates to the start page', () => { - goToStartPage() - }) - it('opens a random AO created by others', () => { - openRandomAOCreatedByOthers() - }) - it('checks that Save is disabled - WIP', () => { - clickMenuBarFileButton() - expectFileMenuButtonToBeDisabled(FILE_MENU_BUTTON_SAVEAS) - // TODO: This is not always true, as different AOs can have different sharing settings. - // @edoardo will add additional tests here later - closeFileMenuWithClick() - }) - }) - */ -}) diff --git a/cypress/integration/start.cy.js b/cypress/integration/start.cy.js deleted file mode 100644 index f546d27c34..0000000000 --- a/cypress/integration/start.cy.js +++ /dev/null @@ -1,107 +0,0 @@ -import { - AXIS_ID_COLUMNS, - AXIS_ID_FILTERS, - AXIS_ID_ROWS, - DIMENSION_ID_DATA, - DIMENSION_ID_ORGUNIT, - DIMENSION_ID_PERIOD, -} from '@dhis2/analytics' -import { expectVisualizationToNotBeVisible } from '../elements/chart.js' -import { - closeFileMenuWithEsc, - closeFileMenuWithClick, - expectFileMenuButtonToBeDisabled, - FILE_MENU_BUTTON_NEW, - FILE_MENU_BUTTON_OPEN, - FILE_MENU_BUTTON_SAVE_NEW, - FILE_MENU_BUTTON_SAVEAS, - FILE_MENU_BUTTON_GETLINK, - FILE_MENU_BUTTON_SHARE, - FILE_MENU_BUTTON_TRANSLATE, - FILE_MENU_BUTTON_RENAME, - FILE_MENU_BUTTON_DELETE, - expectFileMenuButtonToBeEnabled, -} from '../elements/fileMenu/index.js' -import { - expectAxisToHaveDimension, - expectDimensionToHaveItemAmount, - expectDimensionToNotHaveItems, -} from '../elements/layout.js' -import { clickMenuBarFileButton } from '../elements/menuBar.js' -import { - expectMostViewedToBeVisible, - goToStartPage, -} from '../elements/startScreen.js' -import { expectVisTypeToBeDefault } from '../elements/visualizationTypeSelector.js' -import { expectWindowTitleToBeDefault } from '../elements/window.js' -import { expectStoreCurrentToBeEmpty } from '../utils/store.js' - -describe('viewing the start screen', () => { - it('navigates to the start page', () => { - goToStartPage() - }) - it('window has a title', () => { - expectWindowTitleToBeDefault() - }) - it('store is empty', () => { - expectStoreCurrentToBeEmpty() - }) - it('no chart is visible', () => { - expectVisualizationToNotBeVisible() - }) - it('displays most viewed section', () => { - expectMostViewedToBeVisible() - }) - it('vis type is default', () => { - expectVisTypeToBeDefault() - }) - it('axis series has data dimension', () => { - expectAxisToHaveDimension(AXIS_ID_COLUMNS, DIMENSION_ID_DATA) - }) - it('data dimension has no items', () => { - expectDimensionToNotHaveItems(DIMENSION_ID_DATA) - }) - it('axis category has period dimension', () => { - expectAxisToHaveDimension(AXIS_ID_ROWS, DIMENSION_ID_PERIOD) - }) - it('period dimension has 1 item', () => { - expectDimensionToHaveItemAmount(DIMENSION_ID_PERIOD, 1) - }) - it('axis filter has orgunit dimension', () => { - expectAxisToHaveDimension(AXIS_ID_FILTERS, DIMENSION_ID_ORGUNIT) - }) - it('orgunit dimension has 1 item', () => { - expectDimensionToHaveItemAmount(DIMENSION_ID_ORGUNIT, 1) - }) - it('primary File menu buttons are enabled and menu is closed with click', () => { - clickMenuBarFileButton() - const enabledButtons = [ - FILE_MENU_BUTTON_NEW, - FILE_MENU_BUTTON_OPEN, - FILE_MENU_BUTTON_SAVE_NEW, - ] - enabledButtons.forEach((button) => - expectFileMenuButtonToBeEnabled(button) - ) - closeFileMenuWithClick() - }) - it('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() - }) - it('File menu is closed with Escape', () => { - clickMenuBarFileButton() - closeFileMenuWithEsc() - }) -}) diff --git a/cypress/integration/visTypes/scatter.cy.js b/cypress/integration/visTypes/scatter.cy.js deleted file mode 100644 index 6fba12f094..0000000000 --- a/cypress/integration/visTypes/scatter.cy.js +++ /dev/null @@ -1,207 +0,0 @@ -import { - DIMENSION_ID_DATA, - DIMENSION_ID_ORGUNIT, - visTypeDisplayNames, - VIS_TYPE_SCATTER, - AXIS_ID_ROWS, -} from '@dhis2/analytics' -import { - expectVisualizationToBeVisible, - expectChartTitleToBeVisible, -} from '../../elements/chart.js' -import { expectAppToNotBeLoading } from '../../elements/common.js' -import { - selectIndicators, - clickDimensionModalUpdateButton, - switchDataTab, - expectDataDimensionModalWarningToContain, - expectDataItemToBeInactive, - expectOrgUnitDimensionModalToBeVisible, - expectOrgUnitDimensionToNotBeLoading, - toggleOrgUnitLevel, - deselectUserOrgUnit, - selectOrgUnitTreeItem, -} from '../../elements/dimensionModal/index.js' -import { openDimension } from '../../elements/dimensionsPanel.js' -import { - deleteAO, - saveExistingAO, - saveNewAO, -} from '../../elements/fileMenu/index.js' -import { - clickContextMenuSwap, - expectDimensionOnAxisToHaveLockIcon, - expectDimensionOnAxisToHaveWarningIcon, - openContextMenu, - openDimensionOnAxis, -} from '../../elements/layout.js' -import { - clickMenuBarUpdateButton, - openOptionsModal, -} from '../../elements/menuBar.js' -import { - clickOptionsModalUpdateButton, - clickOutliersCheckbox, - OPTIONS_TAB_AXES, - OPTIONS_TAB_OUTLIERS, - setAxisRangeMaxValue, - setAxisRangeMinValue, - switchAxesTabTo, -} from '../../elements/optionsModal/index.js' -import { expectRouteToBeEmpty } from '../../elements/route.js' -import { - expectErrorToContainTitle, - expectStartScreenToBeVisible, - goToStartPage, -} from '../../elements/startScreen.js' -import { changeVisType } from '../../elements/visualizationTypeSelector.js' -import { TEST_INDICATORS } from '../../utils/data.js' -import { - expectWindowConfigYAxisToHaveRangeMaxValue, - expectWindowConfigYAxisToHaveRangeMinValue, - expectWindowConfigXAxisToHaveRangeMaxValue, - expectWindowConfigXAxisToHaveRangeMinValue, -} from '../../utils/window.js' - -const TEST_INDICATOR_NAMES = TEST_INDICATORS.slice(1, 4).map( - (item) => item.name -) -const TEST_VIS_NAME = `TEST SCATTER ${new Date().toLocaleString()}` - -describe('using a Scatter chart', () => { - it('navigates to a new Scatter chart', () => { - goToStartPage() - changeVisType(visTypeDisplayNames[VIS_TYPE_SCATTER]) - }) - it("shows an error message when vertical and horizontal isn't selected", () => { - clickMenuBarUpdateButton() - expectErrorToContainTitle('Vertical is empty') - }) - it('adds a vertical item and shows an error message', () => { - openDimension(DIMENSION_ID_DATA) - selectIndicators([TEST_INDICATOR_NAMES[0]]) - clickDimensionModalUpdateButton() - expectErrorToContainTitle('Horizontal is empty') - expectVerticalToContainDimensionLabel(TEST_INDICATOR_NAMES[0]) - }) - it('adds a horizontal item and displays a chart', () => { - openDimension(DIMENSION_ID_DATA) - switchDataTab('Horizontal') - selectIndicators([TEST_INDICATOR_NAMES[1]]) - clickDimensionModalUpdateButton() - expectVisualizationToBeVisible(VIS_TYPE_SCATTER) - expectChartTitleToBeVisible() - //expectStoreCurrentColumnsToHaveLength(1) // FIXME: Store is always in default state - expectVerticalToContainDimensionLabel(TEST_INDICATOR_NAMES[0]) - expectHorizontalToContainDimensionLabel(TEST_INDICATOR_NAMES[1]) - }) - it('selects org unit level Facility', () => { - const TEST_ORG_UNIT_LEVEL = 'Facility' - openDimension(DIMENSION_ID_ORGUNIT) - expectOrgUnitDimensionModalToBeVisible() - deselectUserOrgUnit('User organisation unit') - expectOrgUnitDimensionToNotBeLoading() - // FIXME this selection causes a analytics request that takes too long on test instances - //selectOrgUnitTreeItem('Sierra Leone') - selectOrgUnitTreeItem('Bo') - selectOrgUnitTreeItem('Bombali') - toggleOrgUnitLevel(TEST_ORG_UNIT_LEVEL) - expectOrgUnitDimensionModalToBeVisible() - clickDimensionModalUpdateButton() - expectVisualizationToBeVisible(VIS_TYPE_SCATTER) - }) - it('Data is locked to Vertical', () => { - expectDimensionOnAxisToHaveLockIcon(DIMENSION_ID_DATA, 'Vertical') - }) - it('Data is locked to Horizontal', () => { - expectDimensionOnAxisToHaveLockIcon(DIMENSION_ID_DATA, 'Horizontal') - }) - it('Org units is locked to Points', () => { - expectDimensionOnAxisToHaveLockIcon(DIMENSION_ID_ORGUNIT, AXIS_ID_ROWS) - }) - it('swaps vertical with horizontal', () => { - openContextMenu('VERTICAL') - clickContextMenuSwap('VERTICAL', 'HORIZONTAL') - clickMenuBarUpdateButton() - expectVisualizationToBeVisible(VIS_TYPE_SCATTER) - expectVerticalToContainDimensionLabel(TEST_INDICATOR_NAMES[1]) - expectHorizontalToContainDimensionLabel(TEST_INDICATOR_NAMES[0]) - }) - it('adds a second item to horizontal and displays warning messages', () => { - openDimensionOnAxis(DIMENSION_ID_DATA, 'Horizontal') - selectIndicators([TEST_INDICATOR_NAMES[2]]) - expectDataDimensionModalWarningToContain( - "'Scatter' is intended to show a single data item per axis." - ) - expectDataItemToBeInactive( - TEST_INDICATORS.find( - (indicator) => indicator.name === TEST_INDICATOR_NAMES[2] - ).id - ) - clickDimensionModalUpdateButton() - expectDimensionOnAxisToHaveWarningIcon(DIMENSION_ID_DATA, 'Horizontal') - }) - it('saves and only displays 1 horizontal item', () => { - saveNewAO(TEST_VIS_NAME) - expectVisualizationToBeVisible(VIS_TYPE_SCATTER) - expectVerticalToContainDimensionLabel(TEST_INDICATOR_NAMES[1]) - expectHorizontalToContainDimensionLabel(TEST_INDICATOR_NAMES[0]) - }) - it('swaps vertical with horizontal', () => { - openContextMenu('HORIZONTAL') - clickContextMenuSwap('HORIZONTAL', 'VERTICAL') - clickMenuBarUpdateButton() - expectVisualizationToBeVisible(VIS_TYPE_SCATTER) - expectVerticalToContainDimensionLabel(TEST_INDICATOR_NAMES[0]) - expectHorizontalToContainDimensionLabel(TEST_INDICATOR_NAMES[1]) - }) - it('Options -> Axes -> sets min/max range', () => { - const TEST_AXES = [ - { axis: 'RANGE_0', label: 'Vertical (y) axis', min: 50, max: 150 }, - { - axis: 'RANGE_1', - label: 'Horizontal (x) axis', - min: 100, - max: 200, - }, - ] - openOptionsModal(OPTIONS_TAB_AXES) - TEST_AXES.forEach((test) => { - switchAxesTabTo(test.label) - setAxisRangeMinValue(test.axis, test.min) - setAxisRangeMaxValue(test.axis, test.max) - }) - clickOptionsModalUpdateButton() - expectVisualizationToBeVisible(VIS_TYPE_SCATTER) - expectWindowConfigYAxisToHaveRangeMinValue(TEST_AXES[0].min) - expectWindowConfigYAxisToHaveRangeMaxValue(TEST_AXES[0].max) - expectWindowConfigXAxisToHaveRangeMinValue(TEST_AXES[1].min) - expectWindowConfigXAxisToHaveRangeMaxValue(TEST_AXES[1].max) - }) - it('Options -> Outliers -> enables outliers', () => { - openOptionsModal(OPTIONS_TAB_OUTLIERS) - clickOutliersCheckbox() - // TODO: Set more outlier options - clickOptionsModalUpdateButton() - expectVisualizationToBeVisible(VIS_TYPE_SCATTER) - // TODO: Intercept the data returned to simplify / standardise it, then check that the $config has the correct data - }) - it('saves and displays items in the correct places', () => { - saveExistingAO() - expectAppToNotBeLoading() - expectVisualizationToBeVisible(VIS_TYPE_SCATTER) - expectVerticalToContainDimensionLabel(TEST_INDICATOR_NAMES[0]) - expectHorizontalToContainDimensionLabel(TEST_INDICATOR_NAMES[1]) - }) - // TODO: Open outlier options again and check that everything was saved correctly - it('deletes saved scatter AO', () => { - deleteAO() - expectStartScreenToBeVisible() - expectRouteToBeEmpty() - }) -}) - -const expectVerticalToContainDimensionLabel = (label) => - cy.getBySel('Vertical-axis').should('contain', label) -const expectHorizontalToContainDimensionLabel = (label) => - cy.getBySel('Horizontal-axis').should('contain', label)