-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
37 changed files
with
1,690 additions
and
1,108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
import { EXTENDED_TIMEOUT } from '../support/util.js' | ||
|
||
const mapWithThematicLayer = { | ||
id: 'eDlFx0jTtV9', | ||
name: 'ANC: LLITN Cov Chiefdom this year', | ||
downloadFileName: 'ANC LLITN Cov Chiefdom this year.png', | ||
cardTitle: 'ANC LLITN coverage', | ||
} | ||
|
||
const assertDownloadSettingChecked = (label, isChecked) => { | ||
cy.getByDataTest('download-settings') | ||
.find('label') | ||
.contains(label) | ||
.find('input') | ||
.should(`${isChecked ? '' : 'not.'}be.checked`) | ||
} | ||
|
||
const clickDownloadSetting = (label) => { | ||
cy.getByDataTest('download-settings') | ||
.find('label') | ||
.contains(label) | ||
.find('input') | ||
.click() | ||
} | ||
|
||
describe('Map Download', () => { | ||
beforeEach(() => { | ||
cy.task('emptyDownloadsFolder') | ||
}) | ||
|
||
it('downloads a map', () => { | ||
cy.visit(`/#/${mapWithThematicLayer.id}`, EXTENDED_TIMEOUT) | ||
cy.get('canvas', EXTENDED_TIMEOUT).should('be.visible') | ||
|
||
cy.get('[data-test="layercard"]') | ||
.find('h2') | ||
.contains(mapWithThematicLayer.cardTitle, EXTENDED_TIMEOUT) | ||
|
||
cy.getByDataTest('dhis2-analytics-hovermenubar') | ||
.find('button') | ||
.contains('Download') | ||
.click() | ||
|
||
cy.log('confirm that download page is open') | ||
cy.getByDataTest('download-settings').should('be.visible') | ||
cy.get('canvas.maplibregl-canvas').should('be.visible') | ||
cy.get('button').contains('Exit download mode').should('be.visible') | ||
cy.url().should('contain', `/#/${mapWithThematicLayer.id}/download`) | ||
|
||
// check the current settings | ||
assertDownloadSettingChecked('Show map name', true) | ||
|
||
cy.getByDataTest('download-map-info') | ||
.find('h1') | ||
.contains(mapWithThematicLayer.name) | ||
.should('be.visible') | ||
|
||
assertDownloadSettingChecked('Show map description', false) | ||
assertDownloadSettingChecked('Show legend', true) | ||
cy.getByDataTest('download-map-info') | ||
.findByDataTest('download-legend-title') | ||
.should('have.length', 1) | ||
|
||
assertDownloadSettingChecked('Show overview map', true) | ||
cy.getByDataTest('download-map-info') | ||
.findByDataTest('overview-map') | ||
.should('be.visible') | ||
|
||
// make some changes | ||
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') | ||
.click() | ||
|
||
// check for downloaded file | ||
cy.wait(3000) // eslint-disable-line cypress/no-unnecessary-waiting | ||
cy.waitUntil( | ||
() => cy.task('getLastDownloadFilePath').then((result) => result), | ||
{ timeout: 3000, interval: 100 } | ||
).then((filePath) => { | ||
expect(filePath).to.include(mapWithThematicLayer.downloadFileName) | ||
|
||
cy.readFile(filePath, EXTENDED_TIMEOUT).should((buffer) => | ||
expect(buffer.length).to.be.gt(10000) | ||
) | ||
}) | ||
|
||
// leave download mode | ||
cy.get('button').contains('Exit download mode').click() | ||
cy.url().should('contain', `/#/${mapWithThematicLayer.id}`) | ||
cy.url().should('not.contain', '/download') | ||
cy.getByDataTest('download-settings').should('not.exist') | ||
cy.get('[data-test="layercard"]') | ||
.find('h2') | ||
.contains(mapWithThematicLayer.cardTitle, EXTENDED_TIMEOUT) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.