Skip to content

Commit

Permalink
chore: add data table cypress test and enable orgunitinfo test (#3114)
Browse files Browse the repository at this point in the history
  • Loading branch information
jenniferarnesen authored Jan 24, 2024
1 parent 5f03005 commit 7c84557
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 12 deletions.
47 changes: 47 additions & 0 deletions cypress/integration/dataTable.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { EXTENDED_TIMEOUT } from '../support/util.js'

const map = {
id: 'eDlFx0jTtV9',
name: 'ANC: LLITN Cov Chiefdom this year',
downloadFileNamePrefix: 'ANC LLITN Cov Chiefdom this year',
cardTitle: 'ANC LLITN coverage',
}

describe('data table', () => {
it('opens data table', () => {
cy.visit(`/#/${map.id}`, EXTENDED_TIMEOUT)
cy.get('canvas', EXTENDED_TIMEOUT).should('be.visible')

cy.getByDataTest('moremenubutton').first().click()

cy.getByDataTest('more-menu')
.find('li')
.not('.disabled')
.should('have.length', 6)

cy.getByDataTest('more-menu')
.find('li')
.contains('Show data table')
.click()

//check that the bottom panel is present
cy.getByDataTest('bottom-panel').should('be.visible')

// check number of columns
cy.getByDataTest('bottom-panel')
.find('[role="columnheader"]')
.should('have.length', 10)

// try the filtering
cy.getByDataTest('bottom-panel')
.find('[role="columnheader"]')
.containsExact('Name')
.siblings('input')
.type('Kakua')

// check that the filter worked
cy.getByDataTest('bottom-panel')
.find('.ReactVirtualized__Table__row')
.should('have.length', 1)
})
})
12 changes: 12 additions & 0 deletions cypress/integration/mapDownload.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,18 @@ describe('Map Download', () => {
clickDownloadSetting('Show map name')
cy.getByDataTest('download-map-info').find('h1').should('not.exist')

clickDownloadSetting('Show north arrow')
cy.getByDataTest('north-arrow').should('not.exist')

clickDownloadSetting('Show overview map')
cy.getByDataTest('download-map-info')
.findByDataTest('overview-map')
.should('not.exist')

clickDownloadSetting('Show legend')
cy.getByDataTest('download-map-info').should('not.exist')

// and download the map
cy.getByDataTest('download-settings')
.find('button')
.contains('Download')
Expand Down
24 changes: 13 additions & 11 deletions cypress/integration/orgUnitInfo.cy.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
// import { ThematicLayer } from '../elements/thematic_layer.js'
import { EXTENDED_TIMEOUT } from '../support/util.js'
import { CURRENT_YEAR, EXTENDED_TIMEOUT } from '../support/util.js'

context('OrgUnitInfo', () => {
it.skip('opens the panel for an OrgUnit', () => {
cy.visit('/?id=ZBjCfSaLSqD', EXTENDED_TIMEOUT)
cy.wait(5000) // eslint-disable-line cypress/no-unnecessary-waiting
describe('OrgUnitInfo', () => {
it('opens the panel for an OrgUnit', () => {
cy.visit('/#/ZBjCfSaLSqD', EXTENDED_TIMEOUT)
cy.get('canvas').should('be.visible')

cy.wait(5000) // eslint-disable-line cypress/no-unnecessary-waiting
cy.getByDataTest('dhis2-map-container')
cy.get('#dhis2-map-container')
.findByDataTest('dhis2-uicore-componentcover', EXTENDED_TIMEOUT)
.should('not.exist')
cy.get('.dhis2-map').click(300, 100) //Bombali
cy.contains('View profile').click()
cy.get('.dhis2-map').click(350, 350) //Click somewhere on the map

cy.get('.maplibregl-popup').contains('View profile').click()

// check the Org Unit Profile panel
cy.getByDataTest('org-unit-profile').contains(
'Organisation unit profile'
)
cy.getByDataTest('org-unit-info').find('h3').contains('Bombali')

// // TODO - find a way to ensure that "Bombali" is the orgunit that was clicked on
// // cy.getByDataTest('org-unit-info').find('h3').contains('Bombali')

cy.getByDataTest('org-unit-data')
.findByDataTest('button-previous-year')
Expand All @@ -27,7 +29,7 @@ context('OrgUnitInfo', () => {
.findByDataTest('dhis2-uicore-circularloader')
.should('not.exist')

cy.getByDataTest('year-select').contains('2022')
cy.getByDataTest('year-select').contains(CURRENT_YEAR - 1)

cy.getByDataTest('org-unit-data-table').contains('Expected pregnancies')
})
Expand Down
10 changes: 10 additions & 0 deletions cypress/integration/routes.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,16 @@ context('Routes', () => {
'Viewing interpretation: ANC: LLITN coverage district and facility'
)
.should('be.visible')

cy.getByDataTest('interpretation-modal')
.find('canvas')
.should('be.visible')

cy.getByDataTest('interpretation-modal')
.contains(
'Koinadugu has a very high LLITN coverage despite low density of facilities providing nets.'
)
.should('be.visible')
})

it('loads with map id (legacy) and interpretationId uppercase', () => {
Expand Down
4 changes: 3 additions & 1 deletion src/components/core/Checkbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ const Checkbox = ({
tooltip,
onChange,
className,
dataTest,
}) => (
<div className={cx(styles.checkbox, className)}>
<div className={cx(styles.checkbox, className)} data-test={dataTest}>
<UiCheckbox
label={label}
checked={checked}
Expand All @@ -34,6 +35,7 @@ Checkbox.propTypes = {
onChange: PropTypes.func.isRequired,
checked: PropTypes.bool,
className: PropTypes.string,
dataTest: PropTypes.string,
dense: PropTypes.bool,
disabled: PropTypes.bool,
label: PropTypes.string,
Expand Down
1 change: 1 addition & 0 deletions src/components/datatable/BottomPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const BottomPanel = () => {
ref={panelRef}
className={styles.bottomPanel}
style={{ height: tableHeight }}
data-test="bottom-panel"
>
<span
className={styles.closeIcon}
Expand Down
1 change: 1 addition & 0 deletions src/components/download/NorthArrow.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const NorthArrow = ({
className={cx(styles.northArrow, styles[position], {
[styles.downloadMapInfoOpen]: downloadMapInfoOpen,
})}
data-test="north-arrow"
>
<svg
width={width}
Expand Down

0 comments on commit 7c84557

Please sign in to comment.