Skip to content

Commit

Permalink
Fix: project config is not loaded in tests after a change
Browse files Browse the repository at this point in the history
The disk cache of the browser needs to be cleared. This can be achieved by splitting into two cy.js files.
  • Loading branch information
simar0at committed Jun 7, 2024
1 parent 360c4cd commit 27ae42d
Show file tree
Hide file tree
Showing 4 changed files with 536 additions and 1,126 deletions.
23 changes: 0 additions & 23 deletions cypress/e2e/homepage_config.cy.js

This file was deleted.

34 changes: 34 additions & 0 deletions cypress/e2e/homepage_config_a_tunisia.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
describe('Home page', function() {
const BASEX_ROOT = Cypress.env('BASEX_ROOT') || '/app/.heroku/basex'
const BASEX_PWD = Cypress.env('BASEX_admin_pw') || 'admin'

it('should show Tunisia with different config', function() {
cy.exec(`${BASEX_ROOT}/bin/basexclient -Uadmin -P${BASEX_PWD} -c "OPEN vicav_projects; REPLACE vicav.xml ${Cypress.config()['fileServerFolder']}/fixtures/vicav_projects/map.xml"`)
cy.request({
method: 'PUT',
url: 'http://localhost:8984/vicav/project',
headers: {'Accept': 'application/json'}
}).as('refreshConfig')
cy.get('@refreshConfig').should((response) => {
expect(response.status).to.equal(200)
expect(response.body.projectConfig).to.exist
})
cy.request({
method: 'GET',
url: 'http://localhost:8984/vicav/project',
headers: {'Accept': 'application/json'}
}).as('config')
cy.get('@config').should((response) => {
expect(response.status).to.equal(200)
expect(response.body.projectConfig).to.exist
expect(response.body.projectConfig.cached).to.be.true
expect(response.body.ETag).to.exist
})
cy.visit('http://localhost:8984/vicav/')
cy.get('#cookie-overlay').should('be.visible')
cy.get('.cookie-accept-btn').click()
cy.get('#cookie-overlay').should('not.be.visible')
cy.get('img.leaflet-marker-icon') // Wait until the initial markers appear.
cy.get('img[alt^="Khorasan"]').should('not.be.visible');
})
})
34 changes: 34 additions & 0 deletions cypress/e2e/homepage_config_b_default.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
describe('Home page', function() {
const BASEX_ROOT = Cypress.env('BASEX_ROOT') || '/app/.heroku/basex'
const BASEX_PWD = Cypress.env('BASEX_admin_pw') || 'admin'

it('should show whole Middle-East by deafult', function() {
cy.exec(`${BASEX_ROOT}/bin/basexclient -Uadmin -P${BASEX_PWD} -c "OPEN vicav_projects; REPLACE vicav.xml ${Cypress.config()['fileServerFolder']}/fixtures/vicav_projects/vicav.xml"`)
cy.request({
method: 'PUT',
url: 'http://localhost:8984/vicav/project',
headers: {'Accept': 'application/json'}
}).as('refreshConfig')
cy.get('@refreshConfig').should((response) => {
expect(response.status).to.equal(200)
expect(response.body.projectConfig).to.exist
})
cy.request({
method: 'GET',
url: 'http://localhost:8984/vicav/project',
headers: {'Accept': 'application/json'}
}).as('config')
cy.get('@config').should((response) => {
expect(response.status).to.equal(200)
expect(response.body.projectConfig).to.exist
expect(response.body.projectConfig.cached).to.be.true
expect(response.body.ETag).to.exist
})
cy.visit('http://localhost:8984/vicav/')
cy.get('#cookie-overlay').should('be.visible')
cy.get('.cookie-accept-btn').click()
cy.get('#cookie-overlay').should('not.be.visible')
cy.get('img.leaflet-marker-icon') // Wait until the initial markers appear.
cy.get('img[alt^="Khorasan"]').should('be.visible');
})
})
Loading

0 comments on commit 27ae42d

Please sign in to comment.