Skip to content

Commit

Permalink
chore: enhance parallel test execution setup in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
adeldhis2 committed May 20, 2024
1 parent 4b9bc73 commit 1606031
Show file tree
Hide file tree
Showing 25 changed files with 832 additions and 742 deletions.
15 changes: 13 additions & 2 deletions .github/workflows/dhis2-verify-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@ env:
D2_VERBOSE: true

jobs:
setup-matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.specs }}
steps:
- uses: actions/checkout@v3
- name: Generate test matrix
id: set-matrix
run: echo "::set-output name=specs::$(node cypress/support/generateTestMatrix.js)"

build:
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -83,10 +93,11 @@ jobs:

call-workflow-e2e-prod:
if: "!contains(github.event.head_commit.message, '[skip ci]')"
needs: [build, lint, test]
uses: dhis2/workflows/.github/workflows/analytics-e2e-tests-prod.yml@master
needs: [build, lint, test, setup-matrix]
uses: dhis2/workflows/.github/workflows/analytics-e2e-tests-prod.yml@update-cypress-setup
with:
should_record: ${{ contains(github.event.head_commit.message, '[e2e record]') || contains(join(github.event.pull_request.labels.*.name), 'e2e record')}}
spec-group: ${{ needs.setup-matrix.outputs.matrix }}
secrets:
username: ${{ secrets.CYPRESS_DHIS2_USERNAME }}
password: ${{ secrets.CYPRESS_DHIS2_PASSWORD }}
Expand Down
21 changes: 12 additions & 9 deletions cypress/elements/layout.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { EXTENDED_TIMEOUT } from '../support/utils.js'

const yoyCategorySelectEl = 'yoy-layout-rows-select'
const youCategorySelectOptionEl = 'yoy-layout-rows-select-option'
const chipEl = 'layout-chip'
Expand All @@ -6,7 +8,7 @@ const chipMenuRemoveOptionEl = 'layout-chip-menu-dimension-menu-item-remove'
const chipMenuActionOptionEl = 'layout-chip-menu-dimension-menu-item-action'
const chipMenuSubMenuOptionEl =
'layout-chip-menu-dimension-menu-item-DIMENSIONID-menu'
const chipSelectedBackgroundColor = 'rgb(178, 223, 219)'
const chipSelectedBackgroundColor = 'rgb(224, 242, 241)'

const getAxisEl = (axisId) => `${axisId}-axis`
const getDimensionChipEl = (dimensionId) => `${chipEl}-${dimensionId}`
Expand Down Expand Up @@ -54,13 +56,14 @@ export const expectDimensionToHaveItemAmount = (
itemAmount
? cy
.getBySel(getDimensionChipEl(dimensionId))
.contains(`${itemAmount} selected`)
.should('have.length', 1)
.and('be.visible')
.parent()
.findBySelLike('chip-suffix')
.contains(itemAmount, EXTENDED_TIMEOUT)
: cy
.getBySel(getDimensionChipEl(dimensionId))
.contains(`selected`)
.should('have.length', 0)
.parent()
.findBySelLike('chip-suffix')
.should('not.exist')
} else {
throw new Error('dimensionId not provided')
}
Expand All @@ -69,9 +72,9 @@ export const expectDimensionToHaveItemAmount = (
export const expectDimensionToHaveAllItemsSelected = (dimensionId) =>
cy
.getBySel(getDimensionChipEl(dimensionId))
.contains(`: All`)
.should('have.length', 1)
.and('be.visible')
.parent()
.findBySelLike('chip-suffix')
.contains('all', EXTENDED_TIMEOUT)

export const expectDimensionOnAxisToHaveLockIcon = (dimensionId, axisId) =>
cy
Expand Down
16 changes: 9 additions & 7 deletions cypress/integration/dimensions/data.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -301,10 +301,10 @@ describe('Data dimension', () => {
if (testDataType.endpoint.hasMultiplePages) {
// more items are fetched when scrolling down
cy.intercept('GET', testDataType.endpoint.requestUrl).as(
'request'
'requestSecondPage'
)
scrollSourceToBottom()
cy.wait('@request').then(({ request, response }) => {
cy.wait('@requestSecondPage').then(({ request, response }) => {
expect(request.url).to.contain('page=2')
expect(response.statusCode).to.eq(200)
expect(
Expand Down Expand Up @@ -384,13 +384,15 @@ describe('Data dimension', () => {
`default sub group: ${testDataType.defaultSubGroup.name}`
)
cy.intercept('GET', testDataType.endpoint.requestUrl).as(
'request'
'requestDefaultSubGroup'
)
switchSubGroupTo(testDataType.defaultSubGroup.name)
cy.wait('@request').then(({ request, response }) => {
expect(request.url).to.contain('page=1')
expect(response.statusCode).to.eq(200)
})
cy.wait('@requestDefaultSubGroup').then(
({ request, response }) => {
expect(request.url).to.contain('page=1')
expect(response.statusCode).to.eq(200)
}
)
expectSourceToNotBeLoading()
expectSubGroupSelectToBe(testDataType.defaultSubGroup.name)
expectSelectableDataItemsAmountToBe(
Expand Down
76 changes: 42 additions & 34 deletions cypress/integration/visTypes/scatter.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,23 +68,26 @@ const TEST_INDICATOR_NAMES = TEST_INDICATORS.slice(1, 4).map(
)
const TEST_VIS_NAME = `TEST SCATTER ${new Date().toLocaleString()}`

describe('using a Scatter chart', () => {
it('navigates to a new Scatter chart', () => {
describe('Scatter chart', () => {
it('works correctly (create, save, load, swap etc)', () => {
cy.log('navigates to a new Scatter chart')
goToStartPage()
changeVisType(visTypeDisplayNames[VIS_TYPE_SCATTER])
})
it("shows an error message when vertical and horizontal isn't selected", () => {

cy.log(
"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', () => {

cy.log('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', () => {

cy.log('adds a horizontal item and displays a chart')
openDimension(DIMENSION_ID_DATA)
switchDataTab('Horizontal')
selectIndicators([TEST_INDICATOR_NAMES[1]])
Expand All @@ -94,40 +97,41 @@ describe('using a Scatter chart', () => {
//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', () => {

cy.log('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
// 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', () => {

cy.log('Data is locked to Vertical')
expectDimensionOnAxisToHaveLockIcon(DIMENSION_ID_DATA, 'Vertical')
})
it('Data is locked to Horizontal', () => {

cy.log('Data is locked to Horizontal')
expectDimensionOnAxisToHaveLockIcon(DIMENSION_ID_DATA, 'Horizontal')
})
it('Org units is locked to Points', () => {

cy.log('Org units is locked to Points')
expectDimensionOnAxisToHaveLockIcon(DIMENSION_ID_ORGUNIT, AXIS_ID_ROWS)
})
it('swaps vertical with horizontal', () => {

cy.log('swaps vertical with horizontal')
openContextMenu('VERTICAL')
clickContextMenuSwap('VERTICAL', 'HORIZONTAL')
clickMenuBarUpdateButton()
expectVisualizationToBeVisible(VIS_TYPE_SCATTER)
expectAppToNotBeLoading()
expectVerticalToContainDimensionLabel(TEST_INDICATOR_NAMES[1])
expectHorizontalToContainDimensionLabel(TEST_INDICATOR_NAMES[0])
})
it('adds a second item to horizontal and displays warning messages', () => {

cy.log('adds a second item to horizontal and displays warning messages')
openDimensionOnAxis(DIMENSION_ID_DATA, 'Horizontal')
selectIndicators([TEST_INDICATOR_NAMES[2]])
expectDataDimensionModalWarningToContain(
Expand All @@ -139,23 +143,27 @@ describe('using a Scatter chart', () => {
).id
)
clickDimensionModalUpdateButton()
expectVisualizationToBeVisible(VIS_TYPE_SCATTER)
expectAppToNotBeLoading()
expectDimensionOnAxisToHaveWarningIcon(DIMENSION_ID_DATA, 'Horizontal')
})
it('saves and only displays 1 horizontal item', () => {

cy.log('saves and only displays 1 horizontal item')
saveNewAO(TEST_VIS_NAME)
expectVisualizationToBeVisible(VIS_TYPE_SCATTER)
expectAppToNotBeLoading()
expectVerticalToContainDimensionLabel(TEST_INDICATOR_NAMES[1])
expectHorizontalToContainDimensionLabel(TEST_INDICATOR_NAMES[0])
})
it('swaps vertical with horizontal', () => {

cy.log('swaps vertical with horizontal')
openContextMenu('HORIZONTAL')
clickContextMenuSwap('HORIZONTAL', 'VERTICAL')
clickMenuBarUpdateButton()
expectVisualizationToBeVisible(VIS_TYPE_SCATTER)
expectAppToNotBeLoading()
expectVerticalToContainDimensionLabel(TEST_INDICATOR_NAMES[0])
expectHorizontalToContainDimensionLabel(TEST_INDICATOR_NAMES[1])
})
it('Options -> Axes -> sets min/max range', () => {

cy.log('Options -> Axes -> sets min/max range')
const TEST_AXES = [
{ axis: 'RANGE_0', label: 'Vertical (y) axis', min: 50, max: 150 },
{
Expand All @@ -177,24 +185,24 @@ describe('using a Scatter chart', () => {
expectWindowConfigYAxisToHaveRangeMaxValue(TEST_AXES[0].max)
expectWindowConfigXAxisToHaveRangeMinValue(TEST_AXES[1].min)
expectWindowConfigXAxisToHaveRangeMaxValue(TEST_AXES[1].max)
})
it('Options -> Outliers -> enables outliers', () => {

cy.log('Options -> Outliers -> enables outliers')
openOptionsModal(OPTIONS_TAB_OUTLIERS)
checkOutliersCheckbox()
// 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', () => {

cy.log('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', () => {

// TODO: Open outlier options again and check that everything was saved correctly
cy.log('deletes saved scatter AO')
deleteAO()
expectStartScreenToBeVisible()
expectRouteToBeEmpty()
Expand Down
35 changes: 35 additions & 0 deletions cypress/support/generateTestMatrix.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
const fs = require('fs')
const path = require('path')

const getAllFiles = (dirPath, arrayOfFiles = []) => {
const files = fs.readdirSync(dirPath)

files.forEach((file) => {
if (fs.statSync(path.join(dirPath, file)).isDirectory()) {
arrayOfFiles = getAllFiles(path.join(dirPath, file), arrayOfFiles)
} else if (path.extname(file) === '.js') {
arrayOfFiles.push(path.join(dirPath, file))
}
})

return arrayOfFiles
}

const createGroups = (files, numberOfGroups = 10) => {
const groups = []
for (let i = 0; i < numberOfGroups; i++) {
groups.push([])
}

files.forEach((file, index) => {
groups[index % numberOfGroups].push(file)
})

return groups.map((group, index) => ({ id: index + 1, tests: group }))
}

const cypressSpecsPath = './cypress/integration'
const specs = getAllFiles(cypressSpecsPath)
const groupedSpecs = createGroups(specs)

console.log(JSON.stringify(groupedSpecs))
19 changes: 8 additions & 11 deletions i18n/ar.po
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
#
# Translators:
# KRG HIS <[email protected]>, 2020
# Philip Larsen Donnelly, 2020
# Hamza Assada <[email protected]>, 2022
# Viktor Varland <[email protected]>, 2022
# Philip Larsen Donnelly, 2024
#
msgid ""
msgstr ""
"Project-Id-Version: i18next-conv\n"
"POT-Creation-Date: 2024-03-01T08:28:43.727Z\n"
"PO-Revision-Date: 2019-06-25 18:46+0000\n"
"Last-Translator: Viktor Varland <[email protected]>, 2022\n"
"Last-Translator: Philip Larsen Donnelly, 2024\n"
"Language-Team: Arabic (https://app.transifex.com/hisp-uio/teams/100509/ar/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
Expand Down Expand Up @@ -163,14 +163,8 @@ msgstr "تحميل"
msgid "Hide"
msgstr "إخفاء"

msgid "All"
msgstr "الجميع"

msgid "{{total}} of {{axisMaxNumberOfItems}} selected"
msgstr "{{total}} من {{axisMaxNumberOfItems}} تم تحديدها"

msgid "{{total}} selected"
msgstr "{{total}} تم تحديدها"
msgid "all"
msgstr ""

msgid "{{dimensionName}} is locked to {{axisName}} for {{visTypeName}}"
msgstr "{{dimensionName}} مقفل على {{axisName}} لـ {{visTypeName}}"
Expand Down Expand Up @@ -470,6 +464,9 @@ msgstr "بعد الأخير"
msgid "Before first and after last"
msgstr "قبل الأول وبعد الأخير"

msgid "All"
msgstr "الجميع"

msgid "Hide empty rows"
msgstr "إخفاء الصفوف الفارغة"

Expand Down Expand Up @@ -729,7 +726,7 @@ msgstr ""
"منفصلة."

msgid "Category option combination"
msgstr ""
msgstr "مزيج خيارات الفئة"

msgid "Absolute deviation"
msgstr ""
Expand Down
Loading

0 comments on commit 1606031

Please sign in to comment.