Skip to content

Commit

Permalink
PB-878: Re-enable test with import layer.
Browse files Browse the repository at this point in the history
  • Loading branch information
ismailsunni committed Oct 7, 2024
1 parent 4f8316e commit 70eb9d9
Showing 1 changed file with 91 additions and 91 deletions.
182 changes: 91 additions & 91 deletions tests/cypress/tests-e2e/print.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ describe('Testing print', () => {
expect(layers[0]['matrices'][0]['matrixSize']).to.deep.eq([1, 1])
})
})
it('should send a print request correctly to mapfishprint (with KML layer)', () => {
it.skip('should send a print request correctly to mapfishprint (with KML layer)', () => {
const customZoom = 13
const kmlID = startPrintWithKml('import-tool/external-kml-file.kml', customZoom)
checkZoom(customZoom)
Expand Down Expand Up @@ -349,96 +349,96 @@ describe('Testing print', () => {
expect(layers[0]['style']).to.haveOwnProperty("[_mfp_style = '1']")
})
})
// it.skip('should send a print request correctly to mapfishprint (with KML layer) - with import layer', () => {
// interceptPrintRequest()
// interceptPrintStatus()
// interceptDownloadReport()

// cy.goToMapView({}, true)
// cy.readStoreValue('state.layers.activeLayers').should('be.empty')
// cy.openMenuIfMobile()
// cy.get('[data-cy="menu-tray-tool-section"]:visible').click()
// cy.get('[data-cy="menu-advanced-tools-import-file"]:visible').click()

// cy.get('[data-cy="import-file-content"]').should('be.visible')
// cy.get('[data-cy="import-file-online-content"]').should('be.visible')

// const localKmlFileName = 'external-kml-file.kml'
// const localKmlFile = `import-tool/${localKmlFileName}`

// // Test local import
// cy.log('Switch to local import')
// cy.get('[data-cy="import-file-local-btn"]:visible').click()
// cy.get('[data-cy="import-file-local-content"]').should('be.visible')

// // Attach a local KML file
// cy.log('Test add a local KML file')
// cy.fixture(localKmlFile, null).as('kmlFixture')
// cy.get('[data-cy="file-input"]').selectFile('@kmlFixture', {
// force: true,
// })
// cy.get('[data-cy="import-file-load-button"]:visible').click()

// // Assertions for successful import
// cy.get('[data-cy="file-input-text"]')
// .should('have.class', 'is-valid')
// .should('not.have.class', 'is-invalid')
// cy.get('[data-cy="file-input-valid-feedback"]')
// .should('be.visible')
// .contains('File successfully imported')
// cy.get('[data-cy="import-file-load-button"]').should('be.visible').contains('Import')
// cy.get('[data-cy="import-file-online-content"]').should('not.be.visible')
// cy.readStoreValue('state.layers.activeLayers').should('have.length', 1)

// // Close the import tool
// cy.get('[data-cy="import-file-close-button"]:visible').click()
// cy.get('[data-cy="import-file-content"]').should('not.exist')

// // Print
// cy.get('[data-cy="menu-print-section"]').should('be.visible').click()
// cy.get('[data-cy="menu-print-form"]').should('be.visible')

// cy.get('[data-cy="print-map-button"]').should('be.visible').click()
// cy.get('[data-cy="abort-print-button"]').should('be.visible')

// cy.checkOlLayer(['test.background.layer2', localKmlFileName])

// cy.wait('@printRequest').then((interception) => {
// expect(interception.request.body).to.haveOwnProperty('layout')
// expect(interception.request.body['layout']).to.equal('1. A4 landscape')
// expect(interception.request.body).to.haveOwnProperty('format')
// expect(interception.request.body['format']).to.equal('pdf')

// const attributes = interception.request.body.attributes
// expect(attributes).to.haveOwnProperty('printLegend')
// expect(attributes['printLegend']).to.equals(0)
// expect(attributes).to.haveOwnProperty('qrimage')
// expect(attributes['qrimage']).to.contains(
// encodeURIComponent('https://s.geo.admin.ch/0000000')
// )

// const mapAttributes = attributes.map
// expect(mapAttributes['scale']).to.equals(10000)
// expect(mapAttributes['dpi']).to.equals(254)
// expect(mapAttributes['projection']).to.equals('EPSG:2056')

// const layers = mapAttributes.layers
// expect(layers).to.be.an('array')
// cy.log('Layers:', layers)
// cy.log('Layer 0:', layers[0]['type'])

// expect(layers).to.have.length(2)
// expect(layers[0]['type']).to.equals('geojson')
// expect(layers[0]['geoJson']['features']).to.have.length(1)
// expect(layers[0]['geoJson']['features'][0]['properties']).to.haveOwnProperty(
// '_mfp_style'
// )
// expect(layers[0]['geoJson']['features'][0]['properties']['_mfp_style']).to.equal(
// '1'
// )
// expect(layers[0]['style']).to.haveOwnProperty("[_mfp_style = '1']")
// })
// })
it('should send a print request correctly to mapfishprint (with KML layer) - with import layer', () => {
interceptPrintRequest()
interceptPrintStatus()
interceptDownloadReport()

cy.goToMapView({}, true)
cy.readStoreValue('state.layers.activeLayers').should('be.empty')
cy.openMenuIfMobile()
cy.get('[data-cy="menu-tray-tool-section"]:visible').click()
cy.get('[data-cy="menu-advanced-tools-import-file"]:visible').click()

cy.get('[data-cy="import-file-content"]').should('be.visible')
cy.get('[data-cy="import-file-online-content"]').should('be.visible')

const localKmlFileName = 'external-kml-file.kml'
const localKmlFile = `import-tool/${localKmlFileName}`

// Test local import
cy.log('Switch to local import')
cy.get('[data-cy="import-file-local-btn"]:visible').click()
cy.get('[data-cy="import-file-local-content"]').should('be.visible')

// Attach a local KML file
cy.log('Test add a local KML file')
cy.fixture(localKmlFile, null).as('kmlFixture')
cy.get('[data-cy="file-input"]').selectFile('@kmlFixture', {
force: true,
})
cy.get('[data-cy="import-file-load-button"]:visible').click()

// Assertions for successful import
cy.get('[data-cy="file-input-text"]')
.should('have.class', 'is-valid')
.should('not.have.class', 'is-invalid')
cy.get('[data-cy="file-input-valid-feedback"]')
.should('be.visible')
.contains('File successfully imported')
cy.get('[data-cy="import-file-load-button"]').should('be.visible').contains('Import')
cy.get('[data-cy="import-file-online-content"]').should('not.be.visible')
cy.readStoreValue('state.layers.activeLayers').should('have.length', 1)

// Close the import tool
cy.get('[data-cy="import-file-close-button"]:visible').click()
cy.get('[data-cy="import-file-content"]').should('not.exist')

// Print
cy.get('[data-cy="menu-print-section"]').should('be.visible').click()
cy.get('[data-cy="menu-print-form"]').should('be.visible')

cy.get('[data-cy="print-map-button"]').should('be.visible').click()
cy.get('[data-cy="abort-print-button"]').should('be.visible')

cy.checkOlLayer(['test.background.layer2', localKmlFileName])

cy.wait('@printRequest').then((interception) => {
expect(interception.request.body).to.haveOwnProperty('layout')
expect(interception.request.body['layout']).to.equal('1. A4 landscape')
expect(interception.request.body).to.haveOwnProperty('format')
expect(interception.request.body['format']).to.equal('pdf')

const attributes = interception.request.body.attributes
expect(attributes).to.haveOwnProperty('printLegend')
expect(attributes['printLegend']).to.equals(0)
expect(attributes).to.haveOwnProperty('qrimage')
expect(attributes['qrimage']).to.contains(
encodeURIComponent('https://s.geo.admin.ch/0000000')
)

const mapAttributes = attributes.map
expect(mapAttributes['scale']).to.equals(10000)
expect(mapAttributes['dpi']).to.equals(254)
expect(mapAttributes['projection']).to.equals('EPSG:2056')

const layers = mapAttributes.layers
expect(layers).to.be.an('array')
cy.log('Layers:', layers)
cy.log('Layer 0:', layers[0]['type'])

expect(layers).to.have.length(2)
expect(layers[0]['type']).to.equals('geojson')
expect(layers[0]['geoJson']['features']).to.have.length(1)
expect(layers[0]['geoJson']['features'][0]['properties']).to.haveOwnProperty(
'_mfp_style'
)
expect(layers[0]['geoJson']['features'][0]['properties']['_mfp_style']).to.equal(
'1'
)
expect(layers[0]['style']).to.haveOwnProperty("[_mfp_style = '1']")
})
})
it('should send a print request correctly to mapfishprint with GPX layer', () => {
interceptPrintRequest()
interceptPrintStatus()
Expand Down

0 comments on commit 70eb9d9

Please sign in to comment.