Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(cypress): adds tests for map overview, context menu, zoom #774

Merged
merged 2 commits into from
Nov 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
214 changes: 164 additions & 50 deletions cypress/integration/smoke-tests/map.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,65 +6,179 @@ describe('Map controls', function() {
cy.login();
});

// Note: 3D tests not supported in CI environment
describe('2D Tests', function() {
before('Ensure map is in 2D mode', function() {
cy.get(opensphere.Map.MAP_MODE_BUTTON).should('contain', '2D');
});
it('Map overview', function() {
// Setup
cy.get(opensphere.Map.OVERVIEW_MAP).should('be.visible');

// Test
cy.get(opensphere.Map.OVERVIEW_MAP_TOGGLE_BUTTON).click();
cy.get(opensphere.Map.OVERVIEW_MAP).should('not.be.visible');

// Clean up
cy.get(opensphere.Map.OVERVIEW_MAP_TOGGLE_BUTTON).click();
cy.get(opensphere.Map.OVERVIEW_MAP).should('be.visible');
});

it('Navigate via overview - left', function() {
// Setup
cy.get(opensphere.Application.PAGE).trigger('mouseenter').trigger('mousemove');
cy.get(opensphere.statusBar.COORDINATES_TEXT).should('not.contain', 'No coordinate');
cy.get(opensphere.statusBar.COORDINATES_TEXT).should('contain', '+00.');
cy.get(opensphere.statusBar.COORDINATES_TEXT).should('contain', '-000.');

// Test
cy.get(opensphere.Map.OVERVIEW_MAP).click('left');
cy.get(opensphere.Map.OVERVIEW_MAP).click('left');
cy.get(opensphere.Map.OVERVIEW_MAP).click('left');
cy.get(opensphere.Map.OVERVIEW_MAP).click('left');
cy.get(opensphere.Application.PAGE).trigger('mouseenter').trigger('mousemove');
cy.get(opensphere.statusBar.COORDINATES_TEXT).should('contain', '-167');
cy.get(opensphere.statusBar.COORDINATES_TEXT).should('contain', '+02.');

// Cleanup
cy.get(opensphere.Application.PAGE).type('v');
cy.get(opensphere.statusBar.COORDINATES_TEXT).should('contain', '+00.');
cy.get(opensphere.statusBar.COORDINATES_TEXT).should('contain', '-000.');
});

it('Navigate via overview - right', function() {
// Setup
cy.get(opensphere.Application.PAGE).trigger('mouseenter').trigger('mousemove');
cy.get(opensphere.statusBar.COORDINATES_TEXT).should('not.contain', 'No coordinate');
cy.get(opensphere.statusBar.COORDINATES_TEXT).should('contain', '+00.');
cy.get(opensphere.statusBar.COORDINATES_TEXT).should('contain', '-000.');

// Test
cy.get(opensphere.Map.OVERVIEW_MAP).click('right');
cy.get(opensphere.Map.OVERVIEW_MAP).click('right');
cy.get(opensphere.Map.OVERVIEW_MAP).click('right');
cy.get(opensphere.Map.OVERVIEW_MAP).click('right');
cy.get(opensphere.Application.PAGE).trigger('mouseenter').trigger('mousemove');
cy.get(opensphere.statusBar.COORDINATES_TEXT).should('contain', '+167');
cy.get(opensphere.statusBar.COORDINATES_TEXT).should('contain', '+02.');

// Cleanup
cy.get(opensphere.Application.PAGE).type('v');
cy.get(opensphere.statusBar.COORDINATES_TEXT).should('contain', '+00.');
cy.get(opensphere.statusBar.COORDINATES_TEXT).should('contain', '-000.');
});

it('Map overview', function() {
// Setup
cy.get(opensphere.Map.OVERVIEW_MAP).should('be.visible');
it('Navigate via overview - top', function() {
// Setup
cy.get(opensphere.Application.PAGE).trigger('mouseenter').trigger('mousemove');
cy.get(opensphere.statusBar.COORDINATES_TEXT).should('not.contain', 'No coordinate');
cy.get(opensphere.statusBar.COORDINATES_TEXT).should('contain', '+00.');
cy.get(opensphere.statusBar.COORDINATES_TEXT).should('contain', '-000.');

// Test
cy.get(opensphere.Map.OVERVIEW_MAP_TOGGLE_BUTTON).click();
cy.get(opensphere.Map.OVERVIEW_MAP).should('not.be.visible');
// Test
cy.get(opensphere.Map.OVERVIEW_MAP).click('top');
cy.get(opensphere.Map.OVERVIEW_MAP).click('top');
cy.get(opensphere.Map.OVERVIEW_MAP).click('top');
cy.get(opensphere.Map.OVERVIEW_MAP).click('top');
cy.get(opensphere.Application.PAGE).trigger('mouseenter').trigger('mousemove');
cy.get(opensphere.statusBar.COORDINATES_TEXT).should('contain', '+65');
cy.get(opensphere.statusBar.COORDINATES_TEXT).should('contain', '-000.');

// Clean up
cy.get(opensphere.Map.OVERVIEW_MAP_TOGGLE_BUTTON).click();
cy.get(opensphere.Map.OVERVIEW_MAP).should('be.visible');
// Cleanup
cy.get(opensphere.Application.PAGE).type('v');
cy.get(opensphere.statusBar.COORDINATES_TEXT).should('contain', '+00.');
cy.get(opensphere.statusBar.COORDINATES_TEXT).should('contain', '-000.');
});

it('Navigate via overview - bottom', function() {
// Setup
cy.get(opensphere.Application.PAGE).trigger('mouseenter').trigger('mousemove');
cy.get(opensphere.statusBar.COORDINATES_TEXT).should('not.contain', 'No coordinate');
cy.get(opensphere.statusBar.COORDINATES_TEXT).should('contain', '+00.');
cy.get(opensphere.statusBar.COORDINATES_TEXT).should('contain', '-000.');

// Test
cy.get(opensphere.Map.OVERVIEW_MAP).click('bottom');
cy.get(opensphere.Map.OVERVIEW_MAP).click('bottom');
cy.get(opensphere.Map.OVERVIEW_MAP).click('bottom');
cy.get(opensphere.Map.OVERVIEW_MAP).click('bottom');
cy.get(opensphere.Application.PAGE).trigger('mouseenter').trigger('mousemove');
cy.get(opensphere.statusBar.COORDINATES_TEXT).should('contain', '-63');
cy.get(opensphere.statusBar.COORDINATES_TEXT).should('contain', '-000.');

// Clean up
cy.get(opensphere.Application.PAGE).type('v');
cy.get(opensphere.statusBar.COORDINATES_TEXT).should('contain', '+00.');
cy.get(opensphere.statusBar.COORDINATES_TEXT).should('contain', '-000.');
});

it('Context menu items', function() {
cy.get(opensphere.Map.CANVAS_2D).rightclick();
cy.get(opensphere.Map.contextMenu.PANEL).should('be.visible');
cy.get(opensphere.Map.contextMenu.RESET_VIEW).should('be.visible');
cy.get(opensphere.Map.contextMenu.RESET_ROTATION).should('be.visible');
cy.get(opensphere.Map.contextMenu.TOGGLE_2D_3D_VIEW).should('be.visible');
cy.get(opensphere.Map.contextMenu.SHOW_LEGEND).should('be.visible');
cy.get(opensphere.Map.contextMenu.CLEAR_SELECTION).should('be.visible');
cy.get(opensphere.Map.contextMenu.BACKGROUND_COLOR).should('be.visible');
cy.get(opensphere.Map.contextMenu.COPY_COORDINATES).should('be.visible');
cy.get(opensphere.Map.contextMenu.CREATE_BUFFER_REGION).should('be.visible');
cy.get(opensphere.Map.contextMenu.SUN_MOON_INFO).should('be.visible');
cy.get(opensphere.Map.contextMenu.CREATE_PLACE).should('be.visible');
cy.get(opensphere.Map.contextMenu.CREATE_TEXT_BOX).should('be.visible');
cy.get(opensphere.Map.contextMenu.QUICK_ADD_PLACES).should('be.visible');
});

it('Zoom via buttons', function() {
// Setup
cy.get(opensphere.Application.PAGE).type('v');
cy.get(opensphere.statusBar.ZOOM_TEXT).should('contain', 'Zoom:');

// Test
cy.get(opensphere.statusBar.ZOOM_TEXT).then(function($zoom) {
var INITIAL_ZOOM = $zoom.text();
cy.get(opensphere.Map.ZOOM_IN_BUTTON)
.click()
.click()
.click()
.click()
.click();
cy.get(opensphere.statusBar.ZOOM_TEXT).should('not.contain', INITIAL_ZOOM);
});

// TODO: Finish test after mouse interactions with the map are working.
// https://github.com/cypress-io/cypress/issues/2768
it.skip('Navigate via overview', function() {
// Setup
// <Enter setup steps here>
cy.get(opensphere.statusBar.ZOOM_TEXT).then(function($zoom) {
var INITIAL_ZOOM = $zoom.text();
cy.get(opensphere.Map.ZOOM_OUT_BUTTON)
.click()
.click()
.click()
.click()
.click();
cy.get(opensphere.statusBar.ZOOM_TEXT).should('not.contain', INITIAL_ZOOM);
});
});

// Test
// <Enter test steps here>
it('Zoom via double click', function() {
// Setup
cy.get(opensphere.Application.PAGE).type('v');

// Clean up
// <Enter clean up steps here>
// Test
cy.get(opensphere.statusBar.ZOOM_TEXT).then(function($zoom) {
var INITIAL_ZOOM = $zoom.text();
cy.get(opensphere.Map.CANVAS_2D)
.dblclick()
.dblclick()
.dblclick()
.dblclick()
.dblclick();
cy.get(opensphere.statusBar.ZOOM_TEXT).should('not.contain', INITIAL_ZOOM);
});

it('Zoom', function() {
// Setup
cy.get(opensphere.Application.PAGE).type('v');
cy.get(opensphere.statusBar.ZOOM_TEXT).should('contain', 'Zoom:');

// Test
cy.get(opensphere.statusBar.ZOOM_TEXT).then(function($zoom) {
var INITIAL_ZOOM = $zoom.text();
cy.get(opensphere.Map.ZOOM_IN_BUTTON)
.click()
.click()
.click()
.click()
.click();
cy.get(opensphere.statusBar.ZOOM_TEXT).should('not.contain', INITIAL_ZOOM);
});

cy.get(opensphere.statusBar.ZOOM_TEXT).then(function($zoom) {
var INITIAL_ZOOM = $zoom.text();
cy.get(opensphere.Map.ZOOM_OUT_BUTTON)
.click()
.click()
.click()
.click()
.click();
cy.get(opensphere.statusBar.ZOOM_TEXT).should('not.contain', INITIAL_ZOOM);
});
cy.get(opensphere.statusBar.ZOOM_TEXT).then(function($zoom) {
var INITIAL_ZOOM = $zoom.text();
cy.get(opensphere.Application.PAGE).type('{ctrl}', {release: false});
cy.get(opensphere.Map.CANVAS_2D)
.dblclick()
.dblclick()
.dblclick()
.dblclick()
.dblclick();
cy.get(opensphere.statusBar.ZOOM_TEXT).should('not.contain', INITIAL_ZOOM);
});
});
});
23 changes: 19 additions & 4 deletions cypress/support/execute-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,21 @@ function checkArguments() {
fi

if [ -z "$STREET_MAP_URL" ]; then
echo 'INFO: STREET_MAP_URL environment variable set, using default'
export STREET_MAP_URL="http://services.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer/tile/{z}/{y}/{x}"
echo "INFO: STREET_MAP_URL environment variable not set, using default for $CYPRESS_PROJECTION"
if [ "$CYPRESS_PROJECTION" = 3857 ]; then
export STREET_MAP_URL="http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/tile/{z}/{y}/{x}"
else
export STREET_MAP_URL="http://services.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer/tile/{z}/{y}/{x}"
fi
fi

if [ -z "$WORLD_IMAGERY_URL" ]; then
echo 'INFO: WORLD_IMAGERY_URL environment variable not set, using default'
export WORLD_IMAGERY_URL="https://wi.maptiles.arcgis.com/arcgis/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}"
echo "INFO: WORLD_IMAGERY_URL environment variable not set, using default for $CYPRESS_PROJECTION"
if [ "$CYPRESS_PROJECTION" = 3857 ]; then
export WORLD_IMAGERY_URL="http://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}"
else
export WORLD_IMAGERY_URL="https://wi.maptiles.arcgis.com/arcgis/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}"
fi
fi
}

Expand Down Expand Up @@ -159,6 +167,13 @@ function overrideSettings() {
sed -i.bak 's@STREET_MAP_URL@'$STREET_MAP_URL'@g' $OPENSPHERE_CONFIG_TESTER && rm $OPENSPHERE_CONFIG_TESTER.bak
sed -i.bak 's@WORLD_IMAGERY_URL@'$WORLD_IMAGERY_URL'@g' $OPENSPHERE_CONFIG_TESTER && rm $OPENSPHERE_CONFIG_TESTER.bak

echo 'INFO: zoom offset to settings file'
if [ "$CYPRESS_PROJECTION" = 3857 ]; then
sed -i.bak 's@"ZOOM_OFFSET"@'0'@g' $OPENSPHERE_CONFIG_TESTER && rm $OPENSPHERE_CONFIG_TESTER.bak
else
sed -i.bak 's@"ZOOM_OFFSET"@'-1'@g' $OPENSPHERE_CONFIG_TESTER && rm $OPENSPHERE_CONFIG_TESTER.bak
fi

echo 'INFO: all settings adjustments finished'
}

Expand Down
15 changes: 3 additions & 12 deletions cypress/support/selectors/opensphere.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,12 @@ exports.Map = {
SHOW_LEGEND: '[title=\'Display the map legend\']',
CLEAR_SELECTION: '[title=\'Clears the selected features across all layers\']',
BACKGROUND_COLOR: '[title=\'Change the map background color\']',
Sky: {
OPTION: '[title=\'Show the sky/stars around the 3D globe\']',
IS_ACTIVE_CLASS: '[title=\'Show the sky/stars around the 3D globe\'] .fa-check-square-o',
IS_INACTIVE_CLASS: '[title=\'Show the sky/stars around the 3D globe\'] .fa-square-o'
},
Sunlight: {
OPTION: '[title=\'Light the 3D globe with the Sun\']',
IS_ACTIVE_CLASS: '[title=\'Light the 3D globe with the Sun\'] .fa-check-square-o',
IS_INACTIVE_CLASS: '[title=\'Light the 3D globe with the Sun\'] .fa-square-o'
},
COPY_COORDINATES: '[title=\'Copy coordinates to clipboard\']',
CREATE_BUFFER_REGION: '[title=\'Create a buffer region around the clicked coordinate\']',
SUN_MOON_INFO: '[title=\'See sun/moon event times for this location\']',
SAVE_TO_PLACES: '[title=\'Creates a new saved place from this location\']',
CREATE_ANNOTATION: '[title=\'Creates a new annotation at this location\']'
CREATE_PLACE: '[title=\'Creates a new saved place from this location\']',
CREATE_TEXT_BOX: '[title=\'Creates a new saved place with a text box at this location\']',
QUICK_ADD_PLACES: '[title=\'Quickly add places to the selected folder\']'
}
};

Expand Down
12 changes: 4 additions & 8 deletions cypress/support/settings/opensphere-config-tester.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,13 @@
"maps": {
"streetmap": {
"projection": "EPSG:CYPRESS_PROJECTION",
"urls": [
"STREET_MAP_URL"
],
"zoomOffset": -1
"url": "STREET_MAP_URL",
"zoomOffset": "ZOOM_OFFSET"
},
"worldimagery": {
"projection": "EPSG:CYPRESS_PROJECTION",
"urls": [
"WORLD_IMAGERY_URL"
],
"zoomOffset": -1
"url": "WORLD_IMAGERY_URL",
"zoomOffset": "ZOOM_OFFSET"
}
}
}
Expand Down