From 77d1691e705cb4b897c148ff2775bcc0a8213f4f Mon Sep 17 00:00:00 2001 From: Ismail Sunni Date: Mon, 7 Oct 2024 13:41:14 +0700 Subject: [PATCH] PB-878: Re-enable test with import layer. --- tests/cypress/tests-e2e/print.cy.js | 182 ++++++++++++++-------------- 1 file changed, 91 insertions(+), 91 deletions(-) diff --git a/tests/cypress/tests-e2e/print.cy.js b/tests/cypress/tests-e2e/print.cy.js index c9cf0bdf71..f18a80c83a 100644 --- a/tests/cypress/tests-e2e/print.cy.js +++ b/tests/cypress/tests-e2e/print.cy.js @@ -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) @@ -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()