Skip to content

Commit

Permalink
test: Migrate download test
Browse files Browse the repository at this point in the history
- remove old test
  • Loading branch information
TheGreatRefrigerator committed Dec 7, 2022
1 parent 2d65828 commit 8a59aca
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 125 deletions.
51 changes: 51 additions & 0 deletions cypress/e2e/download.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import path from 'path'
describe('download functionality', function () {
beforeEach(() => {
cy.viewport(1848, 980)
})

function downloadFile(typeTitle, ext) {
const cleanName = typeTitle.replace(' ', '_')
cy.get('.open-download-btn').click()
cy.get('.download-modal')
cy.get('.export-file-name input[type=text]').clear().type(cleanName)
cy.get('.download-format .v-select__selections').click()
cy.get('.v-menu__content--fixed > .v-select-list > .v-list')
.contains('div > .v-list__tile > ' +
'.v-list__tile__content > .v-list__tile__title', typeTitle).click()
cy.get('.download').click()
let fileName = `${cleanName}.${ext}`
return path.join(Cypress.config('downloadsFolder'), fileName)
}

it('downloads route json file', () => {
cy.visit('/#/directions/Mannheim,BW,Germany/Heidelberg,BW,Germany/data/%7B"coordinates":"8.492765,49.488789;8.692416,49.401247","options":%7B"zoom":8,"profile":"driving-car","preference":"recommended"%7D%7D')
const filePath = downloadFile('ORS JSON', 'json')
cy.readFile(filePath).its('options').should('deep.equal',
{
'zoom': 8,
'profile': 'driving-car',
'preference': 'recommended'
})
// TODO: extend download tests. Aliasing the readFile with as(..) doesn't work
// cy.get('@response').its('places[0].placeName').should('eq', 'Mannheim, BW,Germany')
// cy.get('@response').its('mode').should('eq', 'directions')
// cy.get('@response').its('isRouteData').should('eq', 'directions')
})
it('downloads a geojson file', () => {
const filePath = downloadFile('GeoJSON', 'json')
cy.readFile(filePath).its('features').should('have.length', 3)
})
it('downloads a gpx file', () => {
const filePath = downloadFile('ORS API GPX', 'gpx')
cy.readFile(filePath)
})
it('downloads a gpx file', () => {
const filePath = downloadFile('Standard GPX', 'gpx')
cy.readFile(filePath)
})
it('downloads a kml file', () => {
const filePath = downloadFile('KML', 'kml')
cy.readFile(filePath)
})
})
125 changes: 0 additions & 125 deletions tests/e2e/specs/download.spec.js

This file was deleted.

0 comments on commit 8a59aca

Please sign in to comment.