From 8c1bb8c54268c39e551b1c0b91675dbaf1d2787f Mon Sep 17 00:00:00 2001 From: Pavel Galkin Date: Tue, 12 Nov 2019 15:05:38 +0300 Subject: [PATCH] cypress update --- cypress.json | 4 +- cypress/integration/tests.js | 42 ++++++++++++++++ examples/Cypress/src/App.vue | 94 ++++++++++++++++++++++++++++++++++-- makefile | 2 +- 4 files changed, 135 insertions(+), 7 deletions(-) create mode 100644 cypress/integration/tests.js diff --git a/cypress.json b/cypress.json index 0967ef4..d1ab2fc 100644 --- a/cypress.json +++ b/cypress.json @@ -1 +1,3 @@ -{} +{ + "baseUrl": "http://localhost:8080" +} diff --git a/cypress/integration/tests.js b/cypress/integration/tests.js new file mode 100644 index 0000000..7903a67 --- /dev/null +++ b/cypress/integration/tests.js @@ -0,0 +1,42 @@ +describe('Check functionality', () => { + it('maps should load', () => { + cy.visit('/'); + + cy.get('.passedMap1 input[value="loaded"]') + .should('be.checked'); + + cy.get('.passedMap2 input[value="loaded"]') + .should('be.checked'); + + cy.get('.passedMap3 input[value="loaded"]') + .should('be.checked'); + }); + + it('markers should be edit', () => { + cy.get('#changeButton') + .click(); + + cy.get('.passedMap1 input[value="edited"]') + .should('be.checked'); + + cy.get('.passedMap2 input[value="edited"]') + .should('be.checked'); + + cy.get('.passedMap3 input[value="edited"]') + .should('be.checked'); + }); + + it('markers should be delete', () => { + cy.get('#filterButton') + .click(); + + cy.get('.passedMap1 input[value="filtered"]') + .should('be.checked'); + + cy.get('.passedMap2 input[value="filtered"]') + .should('be.checked'); + + cy.get('.passedMap3 input[value="filtered"]') + .should('be.checked'); + }); +}); diff --git a/examples/Cypress/src/App.vue b/examples/Cypress/src/App.vue index 7a814fe..4f708c8 100644 --- a/examples/Cypress/src/App.vue +++ b/examples/Cypress/src/App.vue @@ -1,7 +1,15 @@ @@ -49,15 +92,48 @@ export default { coords: [34, 34], showMaps: false, markers, + passedMap1: [], + passedMap2: [], + passedMap3: [], + myMap1: {}, + myMap2: {}, + myMap3: {}, }), async created() { await loadYmap(); if (window.ymaps) this.showMaps = true; }, methods: { + onLoading(map, mapNumber) { + this[`myMap${mapNumber}`] = map; + this[`passedMap${mapNumber}`].push('loaded'); + }, filterMarkers() { this.markers = this.markers.filter(_ => _.clusterName > 1); }, + changeMarkers() { + this.markers.splice(0, 1, { ...this.markers[0], coords: [34, 55] }); + }, + checkLength(mapNumber) { + let length = 0; + this.$refs[`map${mapNumber}`].myMap.geoObjects.each((_) => { + length + += (_.getLength && _.getLength()) + || (_.getGeoObjects && _.getGeoObjects().length) + || (_.objects && _.objects.getLength()); + }); + return length; + }, + checkDeleteMarkers(mapNumber) { + const length = this.checkLength(mapNumber); + if (length === this.markers.length) this[`passedMap${mapNumber}`].push('filtered'); + }, + checkChangeMarkers(mapNumber) { + const map = this[`myMap${mapNumber}`]; + map.setBounds(map.geoObjects.getBounds()); + const length = this.checkLength(mapNumber); + if (length === this.markers.length) this[`passedMap${mapNumber}`].push('edited'); + }, }, }; @@ -75,6 +151,14 @@ export default { .ymap-container { height: 600px; - margin-bottom: 50px; + margin-bottom: 10px; +} + +.passed { + margin-bottom: 60px; +} + +.passed label { + margin-right: 20px; } diff --git a/makefile b/makefile index 153a82f..7f7d56b 100644 --- a/makefile +++ b/makefile @@ -1,5 +1,5 @@ cypress: - gnome-terminal --tab -- sh -c "npm run serve --prefix examples/Vue; bash" + gnome-terminal --tab -- sh -c "npm run serve --prefix examples/Cypress; bash" npx cypress open .PHONY: cypress \ No newline at end of file