Skip to content

Commit

Permalink
Merge branch 'dev' into chore/useQueryCacheProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
jenniferarnesen authored Sep 7, 2023
2 parents 3b5c6fa + d0eeeb4 commit f92133c
Show file tree
Hide file tree
Showing 28 changed files with 451 additions and 128 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/dhis2-verify-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ jobs:
call-workflow-e2e-prod:
if: "!contains(github.event.head_commit.message, '[skip ci]')"
needs: [build, lint, test]
uses: dhis2/data-visualizer-app/.github/workflows/e2e-prod.yml@dev
uses: dhis2/line-listing-app/.github/workflows/e2e-prod.yml@master
secrets:
baseurl: ${{ secrets.CYPRESS_DHIS2_BASE_URL_DEV }}
username: ${{ secrets.CYPRESS_DHIS2_USERNAME }}
Expand Down
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
## [100.1.7](https://github.com/dhis2/maps-app/compare/v100.1.6...v100.1.7) (2023-09-07)


### Bug Fixes

* draw layers with opacity ([#2948](https://github.com/dhis2/maps-app/issues/2948)) ([2eb4dd4](https://github.com/dhis2/maps-app/commit/2eb4dd44b24df2ec9df4ae24dcf2b59e33a282bf))
* hide "show longitude/latitude" from context menu for split view maps (DHIS2-15798) ([#2945](https://github.com/dhis2/maps-app/issues/2945)) ([e76c591](https://github.com/dhis2/maps-app/commit/e76c5918c1b08857bb4823af32b84c6bff3e74b1))
* post a data statistics view when map is open or saved ([#2951](https://github.com/dhis2/maps-app/issues/2951)) ([4db4fa6](https://github.com/dhis2/maps-app/commit/4db4fa62c8a90718df3bea58094d2fac0edeec19))
* set default basemap for interpretation map (DHIS2-15788) ([#2944](https://github.com/dhis2/maps-app/issues/2944)) ([49e1c2c](https://github.com/dhis2/maps-app/commit/49e1c2c384eee6455806d5f038da2cdf454416dd))
* show warning if event filter is not supported ([#2952](https://github.com/dhis2/maps-app/issues/2952)) ([6d1caa1](https://github.com/dhis2/maps-app/commit/6d1caa1c10e4fc05e93beddbefcadbed70fdd9fd))
* use display name for data sets ([#2947](https://github.com/dhis2/maps-app/issues/2947)) ([b77b0df](https://github.com/dhis2/maps-app/commit/b77b0df25a2dd77443d8c924c2291a305c536f50))
* use programIndicators endpoint respecting sharing settings ([#2950](https://github.com/dhis2/maps-app/issues/2950)) ([b43ad0f](https://github.com/dhis2/maps-app/commit/b43ad0fe1230fbf5c3d259369c09998251f969bf))

## [100.1.6](https://github.com/dhis2/maps-app/compare/v100.1.5...v100.1.6) (2023-08-31)


Expand Down
55 changes: 55 additions & 0 deletions cypress.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
const { chromeAllowXSiteCookies } = require('@dhis2/cypress-plugins')
const { defineConfig } = require('cypress')
const {
downloadedFileTasks,
} = require('./cypress/plugins/downloadedFileTasks.js')
const {
excludeByVersionTags,
} = require('./cypress/plugins/excludeByVersionTags.js')

async function setupNodeEvents(on, config) {
chromeAllowXSiteCookies(on, config)
excludeByVersionTags(on, config)
downloadedFileTasks(on)

if (!config.env.dhis2InstanceVersion) {
throw new Error(
'dhis2InstanceVersion is missing. Check the README for more information.'
)
}

return config
}

module.exports = defineConfig({
projectId: 'r5jduj',
e2e: {
setupNodeEvents,
baseUrl: 'http://localhost:3000',
specPattern: 'cypress/integration/**/*.cy.js',
viewportWidth: 1280,
viewportHeight: 800,
defaultCommandTimeout: 15000,
// Record video
video: true,
/* Only compress and upload videos for failures.
* This will save execution time and reduce the risk
* out-of-memory issues on the CI machine */
videoUploadOnPasses: false,
// Enabled to reduce the risk of out-of-memory issues
experimentalMemoryManagement: true,
// Set to a low number to reduce the risk of out-of-memory issues
numTestsKeptInMemory: 5,
/* When allowing 1 retry on CI, the test suite will pass if
* it's flaky. And/but we also get to identify flaky tests on the
* Cypress Dashboard. */
retries: {
runMode: 1,
openMode: 0,
},
},
env: {
dhis2DatatestPrefix: 'dhis2-maps',
networkMode: 'live',
},
})
13 changes: 0 additions & 13 deletions cypress.json

This file was deleted.

3 changes: 3 additions & 0 deletions cypress/elements/map_canvas.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { EXTENDED_TIMEOUT } from '../support/util.js'

export const getMaps = () => cy.get('.dhis2-map canvas', EXTENDED_TIMEOUT)
49 changes: 49 additions & 0 deletions cypress/elements/map_context_menu.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { getMaps } from './map_canvas.js'

export const DRILL_UP = 'context-menu-drill-up'
export const DRILL_DOWN = 'context-menu-drill-down'
export const VIEW_PROFILE = 'context-menu-view-profile'
export const SHOW_LONG_LAT = 'context-menu-show-long-lat'

const ALL_OPTIONS = [DRILL_UP, DRILL_DOWN, VIEW_PROFILE, SHOW_LONG_LAT]

export const expectContextMenuOptions = (availableOptions) => {
getMaps()
.first()
.then(($el) => {
const xpos = $el.width() / 2
const ypos = $el.height() / 2

// right clicking on the center of the map should hit an OU
getMaps().first().rightclick(xpos, ypos)

// menu has correct number of items
cy.getByDataTest('context-menu')
.find('li')
.should('have.length', availableOptions.length)

const unavailableOptions = ALL_OPTIONS.filter(
(opt) => !availableOptions.map((opt) => opt.name).includes(opt)
)

unavailableOptions.forEach((name) =>
cy.getByDataTest(name).should('not.exist')
)

availableOptions.forEach((option) => {
// check the menu items
cy.getByDataTest(option.name).should('be.visible')
if (option.disabled) {
cy.getByDataTest(option.name).should(
'have.class',
'disabled'
)
} else {
cy.getByDataTest(option.name).should(
'not.have.class',
'disabled'
)
}
})
})
}
14 changes: 14 additions & 0 deletions cypress/integration/filemenu.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,16 @@ describe('File menu', () => {
req.continue()
}).as('saveMap')

cy.intercept({ method: 'POST', url: /dataStatistics/ }).as(
'postDataStatistics'
)

saveNewMap(MAP_TITLE)

cy.wait('@saveMap').its('response.statusCode').should('eq', 201)
cy.wait('@postDataStatistics')
.its('response.statusCode')
.should('eq', 201)
})

it.skip('save existing as new map', () => {
Expand All @@ -67,9 +74,16 @@ describe('File menu', () => {
req.continue()
}).as('saveAsNewMap')

cy.intercept({ method: 'POST', url: /dataStatistics/ }).as(
'postDataStatistics'
)

saveAsNewMap(SAVEAS_MAP_TITLE)

cy.wait('@saveAsNewMap').its('response.statusCode').should('eq', 201)
cy.wait('@postDataStatistics')
.its('response.statusCode')
.should('eq', 201)
})

it.skip('save changes to existing map', () => {
Expand Down
45 changes: 45 additions & 0 deletions cypress/integration/interpretations.cy.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { saveNewMap, deleteMap } from '../elements/file_menu.js'
import { ThematicLayer } from '../elements/thematic_layer.js'
import { EXTENDED_TIMEOUT } from '../support/util.js'

const MAP_TITLE = 'test ' + new Date().toUTCString().slice(-24, -4)
context('Interpretations', () => {
it('opens the interpretations panel for a map', () => {
cy.visit('/?id=ZBjCfSaLSqD', EXTENDED_TIMEOUT)
Expand All @@ -22,4 +24,47 @@ context('Interpretations', () => {
)
.should('be.visible')
})

it('view interpretation after creating a map', () => {
const Layer = new ThematicLayer()
cy.visit('/')
Layer.openDialog('Thematic')
.selectIndicatorGroup('ANC')
.selectIndicator('ANC 1 Coverage')
.addToMap()

Layer.validateDialogClosed(true)

Layer.validateCardTitle('ANC 1 Coverage')
cy.get('canvas.maplibregl-canvas').should('be.visible')

saveNewMap(MAP_TITLE)

cy.get('button').contains('Interpretations').click()

cy.getByDataTest('interpretation-form')
.find('input[type="text"]')
.type('My interpretation of the map')

cy.intercept('POST', /\/interpretations\/map/).as('postInterpretation')
cy.get('button').contains('Post interpretation').click()

cy.wait('@postInterpretation')
.its('response.statusCode')
.should('eq', 201)

// Force wait because the See interpretations component
// isn't loaded yet
cy.wait(1000) // eslint-disable-line cypress/no-unnecessary-waiting

cy.get('button').contains('See interpretation').click()

cy.getByDataTest('dhis2-uicore-modalcontent')
.find('canvas.maplibregl-canvas')
.should('be.visible')

cy.get('button').contains('Hide interpretation').click()

deleteMap()
})
})
50 changes: 46 additions & 4 deletions cypress/integration/layers/thematiclayer.cy.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
import { getMaps } from '../../elements/map_canvas.js'
import {
DRILL_UP,
DRILL_DOWN,
VIEW_PROFILE,
expectContextMenuOptions,
} from '../../elements/map_context_menu.js'
import { ThematicLayer } from '../../elements/thematic_layer.js'
import { CURRENT_YEAR } from '../../support/util.js'

Expand Down Expand Up @@ -37,8 +44,6 @@ context('Thematic Layers', () => {

Layer.validateDialogClosed(true)

// TODO: use visual snapshot testing to check the rendering of the map

Layer.validateCardTitle(INDICATOR_NAME)
// TODO: test this in a way that is not dependent on the date
// Layer.validateCardItems([
Expand All @@ -48,6 +53,8 @@ context('Thematic Layers', () => {
// '89.76 - 96.28 (3)',
// '96.28 - 102.8 (4)',
// ]);

getMaps().should('have.length', 1)
})

it('adds a thematic layer for OU Bombali', () => {
Expand All @@ -63,8 +70,6 @@ context('Thematic Layers', () => {

Layer.validateDialogClosed(true)

// TODO: use visual snapshot testing to check the rendering of the map

Layer.validateCardTitle(INDICATOR_NAME)
// TODO: test this in a way that is not dependent on the date
// Layer.validateCardItems([
Expand All @@ -74,6 +79,8 @@ context('Thematic Layers', () => {
// '87.32 - 89.46 (0)',
// '89.46 - 91.6 (1)',
// ]);

getMaps().should('have.length', 1)
})

it('adds a thematic layer with start and end date', () => {
Expand All @@ -93,5 +100,40 @@ context('Thematic Layers', () => {
Layer.validateCardTitle(INDICATOR_NAME).validateCardPeriod(
`Feb 1, ${CURRENT_YEAR} - Nov 30, ${CURRENT_YEAR}`
)

getMaps().should('have.length', 1)
})

it('adds a thematic layer with split view period', () => {
Layer.openDialog('Thematic')
.selectIndicatorGroup('ANC')
.selectIndicator('ANC 1 Coverage')
.selectTab('Period')

cy.getByDataTest('relative-period-select-content').click()
cy.contains('Last 3 months').click()

cy.get('[type="radio"]').should('have.length', 3)
cy.get('[type="radio"]').check('SPLIT_BY_PERIOD')

cy.getByDataTest('dhis2-uicore-modalactions')
.contains('Add layer')
.click()

Layer.validateDialogClosed(true)

Layer.validateCardTitle('ANC 1 Coverage')

// check for 3 maps
getMaps().should('have.length', 3)

// wait to make sure the maps are loaded
cy.wait(2000) // eslint-disable-line cypress/no-unnecessary-waiting

expectContextMenuOptions([
{ name: DRILL_UP, disabled: true },
{ name: DRILL_DOWN },
{ name: VIEW_PROFILE },
])
})
})
7 changes: 7 additions & 0 deletions cypress/integration/smoke.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,15 @@ context('Smoke Test', () => {
})

it('loads with map id', () => {
cy.intercept({ method: 'POST', url: /dataStatistics/ }).as(
'postDataStatistics'
)
cy.visit('/?id=ytkZY3ChM6J', EXTENDED_TIMEOUT) //ANC: 3rd visit coverage last year by district

cy.wait('@postDataStatistics')
.its('response.statusCode')
.should('eq', 201)

cy.get('canvas', EXTENDED_TIMEOUT).should('be.visible')

const Layer = new ThematicLayer()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
const { existsSync, readdirSync, lstatSync } = require('fs')
const path = require('path')
const { chromeAllowXSiteCookies } = require('@dhis2/cypress-plugins')
const { tagify } = require('cypress-tags')
const fsExtra = require('fs-extra')
const { getExcludedTags } = require('../support/getExcludedTags.js')

const downloadsDirPath = 'cypress/downloads'

Expand Down Expand Up @@ -35,25 +32,11 @@ const emptyDownloadsFolder = () => {
return null
}

module.exports = (on, config) => {
chromeAllowXSiteCookies(on)

if (!config.env.dhis2InstanceVersion) {
throw new Error(
'dhis2InstanceVersion is missing. Check the README for more information.'
)
}

const excludedTags = getExcludedTags(config.env.dhis2InstanceVersion)

console.log('instanceVersion', config.env.dhis2InstanceVersion)
console.log('tags to exclude from testing', excludedTags)

config.env.CYPRESS_EXCLUDE_TAGS = excludedTags.join(',')

on('file:preprocessor', tagify(config))
const downloadedFileTasks = (on) => {
on('task', {
getLastDownloadFilePath,
emptyDownloadsFolder,
})
}

module.exports = { downloadedFileTasks }
Loading

0 comments on commit f92133c

Please sign in to comment.