Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: use last year's periods #3321

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions cypress/elements/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,12 @@ export const replacePeriodItems = (
if (isYearOverYear(visType)) {
const TEST_PERIOD = !useAltData
? 'Last 2 six-months'
: 'Quarters per year'
: 'Last 4 quarters'
selectYoyCategoryOption(TEST_PERIOD)
clickMenuBarUpdateButton()
} else {
const TEST_PERIOD_TYPE = !useAltData ? 'Six-months' : 'Quarters'
const TEST_PERIOD = !useAltData
? 'Last 2 six-month'
: 'Quarters this year'
const TEST_PERIOD = !useAltData ? 'Last 2 six-month' : 'Last 4 quarters'
openDimension(DIMENSION_ID_PERIOD)
unselectAllItemsByButton()
selectRelativePeriods([TEST_PERIOD], TEST_PERIOD_TYPE)
Expand Down
1 change: 1 addition & 0 deletions cypress/elements/dimensionModal/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ export {

export {
selectRelativePeriods,
selectFixedPeriodYear,
selectFixedPeriods,
expectPeriodDimensionModalToBeVisible,
expectRelativePeriodTypeToBe,
Expand Down
7 changes: 7 additions & 0 deletions cypress/elements/dimensionModal/periodDimension.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@ export const selectFixedPeriods = (periods, periodType) => {
periods.forEach((item) => clickSourceOption(item))
}

export const selectFixedPeriodYear = (year) => {
switchToFixedPeriods()
cy.getBySel('period-dimension-fixed-period-filter-year-content')
.clear()
.type(year)
}

const clickSourceOption = (itemName) =>
cy.getBySel(selectableItemsEl).contains(itemName).dblclick()

Expand Down
5 changes: 5 additions & 0 deletions cypress/helpers/period.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const getPreviousYearStr = () => (new Date().getFullYear() - 1).toString()

const getCurrentYearStr = () => new Date().getFullYear().toString()

export { getPreviousYearStr, getCurrentYearStr }
4 changes: 2 additions & 2 deletions cypress/integration/customErrors/visualizationError.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ describe('Visualization error', () => {
goToStartPage()
changeVisType(visTypeDisplayNames[VIS_TYPE_PIVOT_TABLE])

// select period 'This year'
// select period 'Last year'
openDimension(DIMENSION_ID_PERIOD)
unselectAllItemsByButton()
selectRelativePeriods(['This year'], 'Years')
selectRelativePeriods(['Last year'], 'Years')
clickDimensionModalUpdateButton()

// select a narrative item
Expand Down
6 changes: 3 additions & 3 deletions cypress/integration/interpretations.cy.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { VIS_TYPE_BAR } from '@dhis2/analytics'
import { VIS_TYPE_LINE } from '@dhis2/analytics'
import {
expectAOTitleToBeValue,
expectVisualizationToBeVisible,
Expand All @@ -9,8 +9,8 @@ import { goToStartPage } from '../elements/startScreen.js'
describe('Interpretations', () => {
it('opens the interpretations modal on a saved AO', () => {
const ao = {
name: 'ANC: 1 and 3 coverage Yearly',
type: VIS_TYPE_BAR,
name: 'ANC: 1-3 trend lines last 12 months',
type: VIS_TYPE_LINE,
}

// Open the saved AO
Expand Down
8 changes: 6 additions & 2 deletions cypress/integration/options/cumulativeValues.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
selectDataItems,
selectFixedPeriods,
unselectAllItemsByButton,
selectFixedPeriodYear,
} from '../../elements/dimensionModal/index.js'
import { openDimension } from '../../elements/dimensionsPanel.js'
import { clickContextMenuMove, openContextMenu } from '../../elements/layout.js'
Expand Down Expand Up @@ -53,6 +54,7 @@ import {
} from '../../elements/pivotTable.js'
import { goToStartPage } from '../../elements/startScreen.js'
import { changeVisType } from '../../elements/visualizationTypeSelector.js'
import { getPreviousYearStr } from '../../helpers/period.js'
import { TEST_DATA_ELEMENTS } from '../../utils/data.js'

const cumulativeValuesOptionEl = 'option-cumulative-values'
Expand Down Expand Up @@ -175,10 +177,11 @@ describe('Options - Cumulative values', () => {
openContextMenu(DIMENSION_ID_PERIOD)
clickContextMenuMove(DIMENSION_ID_PERIOD, AXIS_ID_COLUMNS)

const year = new Date().getFullYear().toString()
const year = getPreviousYearStr()

openDimension(DIMENSION_ID_PERIOD)
unselectAllItemsByButton()
selectFixedPeriodYear(year)
selectFixedPeriods(
[`October ${year}`, `November ${year}`, `December ${year}`],
'Monthly'
Expand Down Expand Up @@ -251,9 +254,10 @@ describe('Options - Cumulative values', () => {
selectDataItems(['BCG doses'])
clickDimensionModalHideButton()

const year = new Date().getFullYear().toString()
const year = getPreviousYearStr()
openDimension(DIMENSION_ID_PERIOD)
unselectAllItemsByButton()
selectFixedPeriodYear(year)
selectFixedPeriods([`October ${year}`], 'Monthly')

clickDimensionModalHideButton()
Expand Down
15 changes: 9 additions & 6 deletions cypress/integration/options/limitValues.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
clickDimensionModalUpdateButton,
unselectAllItemsByButton,
selectFixedPeriods,
selectFixedPeriodYear,
} from '../../elements/dimensionModal/index.js'
import { openDimension } from '../../elements/dimensionsPanel.js'
import {
Expand All @@ -37,9 +38,10 @@ import {
goToStartPage,
} from '../../elements/startScreen.js'
import { changeVisType } from '../../elements/visualizationTypeSelector.js'
import { getPreviousYearStr } from '../../helpers/period.js'

const TEST_INDICATOR = 'ANC visits total'
const currentYear = new Date().getFullYear().toString()
const year = getPreviousYearStr()
const expectTableValueToBe = (value, position) =>
cy
.getBySel('visualization-container')
Expand All @@ -61,13 +63,14 @@ describe('limit values', () => {
clickDimensionModalUpdateButton()
openDimension(DIMENSION_ID_PERIOD)
unselectAllItemsByButton()
selectFixedPeriodYear(year)
selectFixedPeriods(
[
`January ${currentYear}`,
`February ${currentYear}`,
`March ${currentYear}`,
`April ${currentYear}`,
`May ${currentYear}`,
`January ${year}`,
`February ${year}`,
`March ${year}`,
`April ${year}`,
`May ${year}`,
],
'Monthly'
)
Expand Down
11 changes: 8 additions & 3 deletions cypress/integration/options/totals.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
selectAllItemsByButton,
selectDataElements,
selectDataItems,
selectFixedPeriodYear,
selectFixedPeriods,
unselectAllItemsByButton,
} from '../../elements/dimensionModal/index.js'
Expand All @@ -42,6 +43,7 @@ import {
} from '../../elements/pivotTable.js'
import { goToStartPage } from '../../elements/startScreen.js'
import { changeVisType } from '../../elements/visualizationTypeSelector.js'
import { getPreviousYearStr } from '../../helpers/period.js'
import { TEST_CUSTOM_DIMENSIONS } from '../../utils/data.js'

const AREA_DIMENSION = TEST_CUSTOM_DIMENSIONS.find((dim) => dim.name === 'Area')
Expand All @@ -68,9 +70,10 @@ describe('Options - Column totals', () => {
selectDataElements(['ART enrollment stage 1'])
clickDimensionModalHideButton()

const year = new Date().getFullYear().toString()
const year = getPreviousYearStr()
openDimension(DIMENSION_ID_PERIOD)
unselectAllItemsByButton()
selectFixedPeriodYear(year)
selectFixedPeriods(
[`May ${year}`, `June ${year}`, `July ${year}`],
'Monthly'
Expand All @@ -95,9 +98,10 @@ describe('Options - Column totals', () => {
])
clickDimensionModalHideButton()

const year = new Date().getFullYear().toString()
const year = getPreviousYearStr()
openDimension(DIMENSION_ID_PERIOD)
unselectAllItemsByButton()
selectFixedPeriodYear(year)
selectFixedPeriods(
[
`January ${year}`,
Expand Down Expand Up @@ -158,9 +162,10 @@ describe('Options - Row totals', () => {
selectDataItems(['BCG doses'])
clickDimensionModalHideButton()

const year = new Date().getFullYear().toString()
const year = getPreviousYearStr()
openDimension(DIMENSION_ID_PERIOD)
unselectAllItemsByButton()
selectFixedPeriodYear(year)
selectFixedPeriods([`October ${year}`], 'Monthly')

clickDimensionModalUpdateButton()
Expand Down
6 changes: 3 additions & 3 deletions cypress/integration/save.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
selectIndicators,
selectDataElements,
clickDimensionModalUpdateButton,
deselectOrgUnitTreeItem,
selectOrgUnitTreeItem,
} from '../elements/dimensionModal/index.js'
import { openDimension } from '../elements/dimensionsPanel.js'
import {
Expand Down Expand Up @@ -185,7 +185,7 @@ describe('saving an AO', () => {
})

it('"save" a copied AO created by others works after editing', () => {
const TEST_VIS_BY_OTHERS_NAME = 'ANC: 1-3 dropout rate Yearly'
const TEST_VIS_BY_OTHERS_NAME = 'ANC: 1-3 trend lines last 12 months'
const TEST_VIS_BY_OTHERS_NAME_UPDATED = `${TEST_VIS_BY_OTHERS_NAME} - updated`

// navigates to the start page and opens an AO created by others
Expand All @@ -200,7 +200,7 @@ describe('saving an AO', () => {

// edits the AO
openDimension(DIMENSION_ID_ORGUNIT)
deselectOrgUnitTreeItem('Western Area')
selectOrgUnitTreeItem('Western Area')
clickDimensionModalUpdateButton()

// saves AO using "Save"
Expand Down
2 changes: 1 addition & 1 deletion cypress/utils/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export const visTypes = [

export const TEST_AOS = [
{
name: 'Commodities: Child health consumption districts this year',
name: 'ANC: ANC 3 coverage by districts last 12 months',
type: VIS_TYPE_COLUMN,
},
{
Expand Down
Loading