From c8659fce94a94c5361a4cb047410b7cf0c4c87e4 Mon Sep 17 00:00:00 2001 From: Jacob Wasilkowski Date: Sun, 13 Sep 2015 15:29:18 -0500 Subject: [PATCH 1/4] new integration test for set-center-zoom; updated test/set-center-zoom angular version; changed example and test set-center-zoom pages to construct their zoom select elements by ng-options --- docs/app/examples/set-center-zoom.html | 10 ++-- test/e2e/specs/set-center-zoom.js | 63 ++++++++++++++++++++++++++ test/set-center-zoom.html | 8 ++-- 3 files changed, 70 insertions(+), 11 deletions(-) create mode 100644 test/e2e/specs/set-center-zoom.js diff --git a/docs/app/examples/set-center-zoom.html b/docs/app/examples/set-center-zoom.html index bdfe968..59dbec9 100644 --- a/docs/app/examples/set-center-zoom.html +++ b/docs/app/examples/set-center-zoom.html @@ -2,12 +2,10 @@

Set Map Center and Zoom

- Lat: - Lng: - , Zoom: - + Lat: + Lng:, + Zoom:

diff --git a/test/e2e/specs/set-center-zoom.js b/test/e2e/specs/set-center-zoom.js new file mode 100644 index 0000000..ade6c93 --- /dev/null +++ b/test/e2e/specs/set-center-zoom.js @@ -0,0 +1,63 @@ +'use strict'; + +var helper = require('../helper'); + +describe('Set Map Center and Zoom', function() { + // shared element locators + var map = element(by.id('map')); + var lat = element(by.model('map.center.lat')); + var lng = element(by.model('map.center.lng')); + var zoomSelect = element(by.model('map.zoom')); + + beforeAll(function() { + // refer to "gulp test" task to get the baseUrl that is prepended + browser.get('/set-center-zoom.html'); + }); + + it('should click on the "San Francisco" button and change the map "data-zoom" value, along with the lat, lng, and zoom element values', function() { + // element locator(s) specific to this test + var sanFrancisco = element(by.buttonText('San Francisco')); + helper.waitUntilElementIsReady(map); + + sanFrancisco.click(); + + helper.getAsyncAttributeValue(map, 'data-zoom').then(function(newValue) { + var expectedZoom = '10', + expectedLat = '37.75', + expectedLng = '-122.45'; + expect(newValue).toEqual(expectedZoom); + expect(zoomSelect.getAttribute('value')).toEqual('number:' + expectedZoom); + expect(lat.getAttribute('value')).toEqual(expectedLat); + expect(lng.getAttribute('value')).toEqual(expectedLng); + }); + }); + + it('should click on the "New York" button and change the map "data-zoom" value, along with the lat, lng, and zoom element values', function() { + // element locator(s) specific to this test + var newYork = element(by.buttonText('New York')); + helper.waitUntilElementIsReady(map); + + newYork.click(); + + helper.getAsyncAttributeValue(map, 'data-zoom').then(function(newValue) { + var expectedZoom = '12', + expectedLat = '40.7127', + expectedLng = '-74.0059'; + expect(newValue).toEqual(expectedZoom.toString()); + expect(zoomSelect.getAttribute('value')).toEqual('number:' + expectedZoom); + expect(lat.getAttribute('value')).toEqual(expectedLat); + expect(lng.getAttribute('value')).toEqual(expectedLng); + }); + }); + + it('should choose a new option of "7" from the zoom select and change the map "data-zoom" value to "7"', function() { + helper.waitUntilElementIsReady(map); + + var expectedZoom = '7'; + zoomSelect.sendKeys(expectedZoom); + + helper.getAsyncAttributeValue(map, 'data-zoom').then(function(newValue) { + expect(newValue).toEqual(expectedZoom); + }); + }); +}); \ No newline at end of file diff --git a/test/set-center-zoom.html b/test/set-center-zoom.html index ad004bc..a985e69 100644 --- a/test/set-center-zoom.html +++ b/test/set-center-zoom.html @@ -17,10 +17,8 @@

Set Map Center and Zoom

Lat: Lng: , - Zoom: - + Zoom:

@@ -28,7 +26,7 @@

Set Map Center and Zoom

- + From e03423ce17af4dc6c3608ef43c56627ac464d91e Mon Sep 17 00:00:00 2001 From: Jacob Wasilkowski Date: Sun, 13 Sep 2015 16:02:49 -0500 Subject: [PATCH 2/4] new integration test for map-events; updated test/set-center-zoom with some additional clicks to help it play more nicely; resolves issue # --- test/e2e/specs/map-events.js | 41 +++++++++++++++++++++++++++++++ test/e2e/specs/set-center-zoom.js | 5 ++++ test/map-events.html | 4 +-- 3 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 test/e2e/specs/map-events.js diff --git a/test/e2e/specs/map-events.js b/test/e2e/specs/map-events.js new file mode 100644 index 0000000..74b481b --- /dev/null +++ b/test/e2e/specs/map-events.js @@ -0,0 +1,41 @@ +'use strict'; + +var helper = require('../helper'); + +describe('Map Events', function() { + // shared element locators + var map = element(by.id('map')); + + beforeAll(function() { + // refer to "gulp test" task to get the baseUrl that is prepended + browser.get('/map-events.html'); + }); + + it('should load the map and change the text of a "

" element', function() { + // element locator(s) specific to this test + var mapLoadedInfo = element(by.id('mapLoadedInfo')); + + expect(mapLoadedInfo.getText()).toBe('The map is not loaded.'); + helper.waitUntilElementIsReady(map); + helper.getAsyncAttributeValue(map, 'data-zoom').then(function() { + expect(mapLoadedInfo.getText()).toBe('The map is loaded.'); + }); + }); + + it('should zoom in and change the extent information in a "

" element', function() { + // element locator(s) specific to this test + var extentInfo = element(by.id('extentInfo')); + var zoomIn = element(by.css('.esriSimpleSliderIncrementButton')); + helper.waitUntilElementIsReady(zoomIn); + helper.waitUntilElementIsReady(map); + + var beforeExtent = extentInfo.getText(); + + zoomIn.click(); + + helper.getAsyncAttributeValue(map, 'data-zoom').then(function() { + var afterExtent = extentInfo.getText(); + expect(afterExtent).not.toBe(beforeExtent); + }); + }); +}); \ No newline at end of file diff --git a/test/e2e/specs/set-center-zoom.js b/test/e2e/specs/set-center-zoom.js index ade6c93..2c47e13 100644 --- a/test/e2e/specs/set-center-zoom.js +++ b/test/e2e/specs/set-center-zoom.js @@ -5,6 +5,7 @@ var helper = require('../helper'); describe('Set Map Center and Zoom', function() { // shared element locators var map = element(by.id('map')); + var zoomIn = element(by.css('.esriSimpleSliderIncrementButton')); var lat = element(by.model('map.center.lat')); var lng = element(by.model('map.center.lng')); var zoomSelect = element(by.model('map.zoom')); @@ -17,8 +18,10 @@ describe('Set Map Center and Zoom', function() { it('should click on the "San Francisco" button and change the map "data-zoom" value, along with the lat, lng, and zoom element values', function() { // element locator(s) specific to this test var sanFrancisco = element(by.buttonText('San Francisco')); + helper.waitUntilElementIsReady(zoomIn); helper.waitUntilElementIsReady(map); + zoomIn.click(); // clicking on this first seems to help successfully execute a click on the following button sanFrancisco.click(); helper.getAsyncAttributeValue(map, 'data-zoom').then(function(newValue) { @@ -35,8 +38,10 @@ describe('Set Map Center and Zoom', function() { it('should click on the "New York" button and change the map "data-zoom" value, along with the lat, lng, and zoom element values', function() { // element locator(s) specific to this test var newYork = element(by.buttonText('New York')); + helper.waitUntilElementIsReady(zoomIn); helper.waitUntilElementIsReady(map); + zoomIn.click(); // clicking on this first seems to help successfully execute a click on the following button newYork.click(); helper.getAsyncAttributeValue(map, 'data-zoom').then(function(newValue) { diff --git a/test/map-events.html b/test/map-events.html index 2ff0923..61222e0 100644 --- a/test/map-events.html +++ b/test/map-events.html @@ -13,8 +13,8 @@

Map Events

-

The map is not loaded.

-

Extent: {{ map.extent.toJson() }}

+

The map is not loaded.

+

Extent: {{ map.extent.toJson() }}

From 30ac816a07ba765ffebe643228e46ec9ea69a8d0 Mon Sep 17 00:00:00 2001 From: Jacob Wasilkowski Date: Sun, 13 Sep 2015 16:46:13 -0500 Subject: [PATCH 3/4] new integration test for feature-layers; added show trees layer toggle to test/feature-layers.html; updated test/map-events; misc. describe name updates --- test/e2e/specs/feature-layers.js | 45 ++++++++++++++++++++++++++++++++ test/e2e/specs/map-events.js | 3 +-- test/e2e/specs/simple-map.js | 2 +- test/e2e/specs/web-map.js | 2 +- test/feature-layers.html | 6 +++-- 5 files changed, 52 insertions(+), 6 deletions(-) create mode 100644 test/e2e/specs/feature-layers.js diff --git a/test/e2e/specs/feature-layers.js b/test/e2e/specs/feature-layers.js new file mode 100644 index 0000000..655eca9 --- /dev/null +++ b/test/e2e/specs/feature-layers.js @@ -0,0 +1,45 @@ +'use strict'; + +var helper = require('../helper'); + +describe('Feature Layers', function() { + // shared element locator(s) + var zoomIn = element(by.css('.esriSimpleSliderIncrementButton')); + var map = element(by.id('map')); + var mapGraphics = element(by.id('map_gc')); + var featureLayer1 = element(by.id('graphicsLayer1_layer')); + var featureLayer2 = element(by.id('graphicsLayer2_layer')); + + beforeAll(function() { + // refer to conf.js to get the baseUrl that is prepended + browser.get('/feature-layers.html'); + }); + + it('should check that the map has 1 polygon layer and 1 point layer', function() { + // element locator(s) specific to this test + helper.waitUntilElementIsReady(zoomIn); + helper.waitUntilElementIsReady(map); + helper.waitUntilElementIsReady(mapGraphics); + + helper.getAsyncAttributeValue(featureLayer1, 'data-geometry-type').then(function(value) { + expect(value).toEqual('polygon'); + }); + + helper.getAsyncAttributeValue(featureLayer2, 'data-geometry-type').then(function(value) { + expect(value).toEqual('point'); + }); + }); + + it('should click on the checkbox control and toggle on the point layer visibility', function() { + // element locator(s) specific to this test + var showTreesToggle = element(by.model('map.showTrees')); + + showTreesToggle.click(); + + helper.getAsyncAttributeValue(featureLayer2, 'data-geometry-type').then(function() { + // we are not concerned with the data-geometry-type + // but we want to give the layer time to display itself after executing showTreesToggle.click() + expect(featureLayer2.getCssValue('display')).toEqual('block'); + }); + }); +}); \ No newline at end of file diff --git a/test/e2e/specs/map-events.js b/test/e2e/specs/map-events.js index 74b481b..029de52 100644 --- a/test/e2e/specs/map-events.js +++ b/test/e2e/specs/map-events.js @@ -14,9 +14,8 @@ describe('Map Events', function() { it('should load the map and change the text of a "

" element', function() { // element locator(s) specific to this test var mapLoadedInfo = element(by.id('mapLoadedInfo')); - - expect(mapLoadedInfo.getText()).toBe('The map is not loaded.'); helper.waitUntilElementIsReady(map); + helper.getAsyncAttributeValue(map, 'data-zoom').then(function() { expect(mapLoadedInfo.getText()).toBe('The map is loaded.'); }); diff --git a/test/e2e/specs/simple-map.js b/test/e2e/specs/simple-map.js index ea58ff8..321d279 100644 --- a/test/e2e/specs/simple-map.js +++ b/test/e2e/specs/simple-map.js @@ -2,7 +2,7 @@ var helper = require('../helper'); -describe('Simple Map Example', function() { +describe('Simple Map', function() { // shared element locator(s) var zoomIn = element(by.css('.esriSimpleSliderIncrementButton')); var map = element(by.id('map')); diff --git a/test/e2e/specs/web-map.js b/test/e2e/specs/web-map.js index 12b9555..aba675d 100644 --- a/test/e2e/specs/web-map.js +++ b/test/e2e/specs/web-map.js @@ -2,7 +2,7 @@ var helper = require('../helper'); -describe('Set Basemap', function() { +describe('Web Map', function() { // shared element locators var map = element(by.id('map')); diff --git a/test/feature-layers.html b/test/feature-layers.html index 53ec38b..d05eadf 100644 --- a/test/feature-layers.html +++ b/test/feature-layers.html @@ -13,8 +13,9 @@

Feature Layers

- + +

Lat: {{ map.center.lat | number:3 }}, Lng: {{ map.center.lng | number:3 }}, Zoom: {{map.zoom}}

Based on this JS Fiddle.

@@ -34,7 +35,8 @@

Feature Layers

lng: -122.676207, lat: 45.523452 }, - zoom: 12 + zoom: 12, + showTrees: false }; }); From 7724927ed0f891eebe4d471688a24892516bb633 Mon Sep 17 00:00:00 2001 From: Tom Wayson Date: Mon, 14 Sep 2015 07:04:43 -0700 Subject: [PATCH 4/4] added test for legend to web map spec resolves #88 --- gulpfile.js | 2 +- test/e2e/specs/web-map.js | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/gulpfile.js b/gulpfile.js index 2d3ecfa..f46b77b 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -85,7 +85,7 @@ gulp.task('deploy-prod', ['build'], function () { }); gulp.task('test', ['serve'], function() { - return gulp.src(['./test/**/*.js']) + return gulp.src(['./test/e2e/specs/*.js']) .pipe(angularProtractor({ 'configFile': 'test/e2e/conf.js', 'args': ['--baseUrl', 'http://localhost:9002'], diff --git a/test/e2e/specs/web-map.js b/test/e2e/specs/web-map.js index aba675d..092620a 100644 --- a/test/e2e/specs/web-map.js +++ b/test/e2e/specs/web-map.js @@ -11,6 +11,15 @@ describe('Web Map', function() { browser.get('/web-map.html'); }); + it('should have a legend', function() { + var legend = element(by.id('legend')); + helper.waitUntilElementIsReady(legend); + // should be an instance of the legend dijit + helper.getAsyncAttributeValue(legend, 'widgetid').then(function(newValue) { + expect(newValue).toEqual('legend'); + }); + }); + it('should load 1 bookmark and then click on this bookmark to change the map "data-zoom" value to "4"', function() { // element locator(s) specific to this test var zoomIn = element(by.css('.esriSimpleSliderIncrementButton'));