From a2a166027cc50e80f5a0c652abc9d1fce8aa53c8 Mon Sep 17 00:00:00 2001 From: Brad Hards Date: Sun, 26 May 2019 17:33:28 +1000 Subject: [PATCH] test(featurelist): Cypress tests for featurelist. --- .../layers-dialog/layer-features/feat.kml | 156 +++++++++++++++ .../layers-dialog/layer-features.spec.js | 180 ++++++++++++++++++ cypress/support/selectors.js | 7 + src/os/ui/descriptioninfo.js | 3 +- views/descriptioninfo.html | 2 +- views/windows/featurelist.html | 2 +- 6 files changed, 347 insertions(+), 3 deletions(-) create mode 100644 cypress/fixtures/regression-tests/layers-dialog/layer-features/feat.kml create mode 100644 cypress/integration/regression-tests/layers-dialog/layer-features.spec.js diff --git a/cypress/fixtures/regression-tests/layers-dialog/layer-features/feat.kml b/cypress/fixtures/regression-tests/layers-dialog/layer-features/feat.kml new file mode 100644 index 0000000000..aecc34662c --- /dev/null +++ b/cypress/fixtures/regression-tests/layers-dialog/layer-features/feat.kml @@ -0,0 +1,156 @@ + + + + + + + #defaultStyle + Astor Pl + + + 4-6-6 Express + + + 4 nights, 6-all times, 6 Express-weekdays AM southbound, PM northbound + + + 1 + + + + + -73.99106999861966,40.73005400028978 + + + + + #defaultStyle + Canal St + + + 4-6-6 Express + + + 4 nights, 6-all times, 6 Express-weekdays AM southbound, PM northbound + + + 2 + + + + + -74.00019299927328,40.71880300107709 + + + + + #defaultStyle + 50th St + + + 1-2 + + + 1-all times, 2-nights + + + 3 + + + + + -73.98384899986625,40.76172799961419 + + + + + #defaultStyle + Bergen St + + + 2-3-4 + + + 4-nights, 3-all other times, 2-all times + + + 4 + + + + + -73.97499915116808,40.68086213682956 + + + + + #defaultStyle + Pennsylvania Ave + + + 3-4 + + + 4-nights, 3-all other times + + + 5 + + + + + -73.89488591154061,40.66471445143568 + + + + + #defaultStyle + Morrison Av - Soundview + + + 6 + + + 6-all times + + + 51 + + + + + -73.87451599929486,40.82952100156747 + + + + + #defaultStyle + 96th St + + + Q + + + Q-all times + + + 643 + + + This is the description text. + + + -73.9470660219183,40.784236650177654 + + + + + + \ No newline at end of file diff --git a/cypress/integration/regression-tests/layers-dialog/layer-features.spec.js b/cypress/integration/regression-tests/layers-dialog/layer-features.spec.js new file mode 100644 index 0000000000..43586f974a --- /dev/null +++ b/cypress/integration/regression-tests/layers-dialog/layer-features.spec.js @@ -0,0 +1,180 @@ +/// +var os = require('../../../support/selectors.js'); + +os.layerFeaturesDialog = { + CELLS: '.slick-cell', + DESCRIPTION_CELL: '[data-testid=\'featurelist\'] .slick-viewport .slick-cell', + DIALOG: '[data-testid=\'featurelist\']', + FOOTER_STATUS_TEXT: '[ng-if=\'ctrl.status\']', + FULL_FOOTER_STATUS_TEXT: '[data-testid=\'featurelist\'] [ng-if=\'ctrl.status\']', + GRID: '[data-testid=\'featurelist\'] .slick-grid', + HEADER_CELLS: '.slick-column-name', + HEADER_ROW: '.slick-header', + ROWS_CELLS: '[data-testid=\'featurelist\'] .slick-cell.l5', + SOURCE_GRID: '.js-source-grid', + VIEWPORT: '.slick-viewport', + buttons: { + CLOSE: '[ng-click=\'ctrl.close()\']' + }, + contextMenu: { + EXPORT: '[title=\'Exports data to a file\']', + DESELECT_ALL: '[title=\'Deselects all items\']', + INVERT_SELECTION: '[title=\'Inverts the selection\']', + SELECT_ALL: '[title=\'Selects all items\']', + HIDE_SELECTED: '[title=\'Hides selected items\']', + DISPLAY_ALL: '[title=\'Displays all items\']', + HIDE_UNSELECTED: '[title=\'Hides unselected items\']', + REMOVE_SELECTED: '[title=\'Removes selected items\']', + REMOVE_UNSELECTED: '[title=\'Removes the unselected items\']' + } +}; + +var TEST_FIXTURE_DATA = 'regression-tests/layers-dialog/layer-features/feat.kml'; + +describe('Feature grid', function() { + before('Login', function() { + cy.login(); + }); + + it('Shows data', function() { + // Upload a file + cy.get(os.Toolbar.addData.OPEN_FILE_BUTTON).click(); + cy.get(os.importDataDialog.DIALOG).should('be.visible'); + cy.upload(TEST_FIXTURE_DATA); + cy.get(os.importDataDialog.NEXT_BUTTON).click(); + cy.get(os.importKMLDialog.DIALOG).should('be.visible'); + cy.get(os.importKMLDialog.LAYER_TITLE_INPUT).should('be.visible'); + cy.get(os.importKMLDialog.OK_BUTTON).click(); + + // Load a layer + cy.get(os.layersDialog.Tabs.Layers.Tree.LAYER_4).should('contain', TEST_FIXTURE_DATA + ' Features (7)'); + + cy.get(os.layersDialog.Tabs.Layers.Tree.LAYER_4).rightClick(); + cy.get(os.layersDialog.Tabs.Layers.Tree.Type.featureLayer.Local.contextMenu.menuOptions.SHOW_FEATURES).click(); + cy.get('[title=\'' + TEST_FIXTURE_DATA + '\']').should('be.visible'); + + // Check status bar + cy.get(os.layerFeaturesDialog.DIALOG).within(function() { + cy.get(os.layerFeaturesDialog.FOOTER_STATUS_TEXT).should('be.visible'); + cy.get(os.layerFeaturesDialog.FOOTER_STATUS_TEXT).should('contain', '7 records'); + }); + + cy.get(os.layerFeaturesDialog.DIALOG).within(function() { + cy.get(os.layerFeaturesDialog.SOURCE_GRID).should('be.visible'); + cy.get(os.layerFeaturesDialog.SOURCE_GRID).within(function() { + cy.get(os.layerFeaturesDialog.HEADER_ROW).should('be.visible'); + // Check column headers + cy.get(os.layerFeaturesDialog.HEADER_ROW).within(function() { + cy.get(os.layerFeaturesDialog.HEADER_CELLS).should('have.length', 15); + cy.get(os.layerFeaturesDialog.HEADER_CELLS + ':empty').should('exist'); + cy.get(os.layerFeaturesDialog.HEADER_CELLS).contains('TIME'); + cy.get(os.layerFeaturesDialog.HEADER_CELLS).contains('MGRS'); + cy.get(os.layerFeaturesDialog.HEADER_CELLS).contains('LAT_DMS'); + cy.get(os.layerFeaturesDialog.HEADER_CELLS).contains('LON_DMS'); + cy.get(os.layerFeaturesDialog.HEADER_CELLS).contains('LAT'); + cy.get(os.layerFeaturesDialog.HEADER_CELLS).contains('LON'); + cy.get(os.layerFeaturesDialog.HEADER_CELLS).contains('LAT_DDM'); + cy.get(os.layerFeaturesDialog.HEADER_CELLS).contains('LON_DDM'); + cy.get(os.layerFeaturesDialog.HEADER_CELLS).contains('line'); + cy.get(os.layerFeaturesDialog.HEADER_CELLS).contains('name'); + cy.get(os.layerFeaturesDialog.HEADER_CELLS).contains('notes'); + cy.get(os.layerFeaturesDialog.HEADER_CELLS).contains('objectid'); + cy.get(os.layerFeaturesDialog.HEADER_CELLS).contains('ID'); + cy.get(os.layerFeaturesDialog.HEADER_CELLS).contains('description'); + }); + }); + + // Check data + cy.get(os.layerFeaturesDialog.VIEWPORT).should('be.visible'); + cy.get(os.layerFeaturesDialog.VIEWPORT).within(function() { + cy.get(os.layerFeaturesDialog.CELLS).contains('18TWL8884215339'); + }); + }); + + cy.get(os.layerFeaturesDialog.DESCRIPTION_CELL).should('be.visible'); + cy.get(os.layerFeaturesDialog.DESCRIPTION_CELL).contains('Show'); + cy.get(os.layerFeaturesDialog.DESCRIPTION_CELL).contains('Show').click(); + cy.get(os.descriptionInfoDialog.DIALOG, {timeout: 5000}).should('be.visible'); + cy.get(os.descriptionInfoDialog.DIALOG).within(function() { + // Check description content + cy.get(os.descriptionInfoDialog.CONTENT).should('be.visible'); + // https://github.com/cypress-io/cypress/issues/136 for why this is needed + cy.get(os.descriptionInfoDialog.CONTENT).then(function($iframe) { + const $body = $iframe.contents().find('body'); + expect($body.text()).to.equal('This is the description text.'); + }); + cy.get(os.descriptionInfoDialog.CLOSE_BUTTON).click(); + }); + cy.get(os.descriptionInfoDialog.DIALOG, {timeout: 5000}).should('not.exist'); + + // Check selection + cy.get(os.layerFeaturesDialog.ROWS_CELLS).should('be.visible'); + cy.get(os.layerFeaturesDialog.ROWS_CELLS).first().click(); + cy.get(os.layerFeaturesDialog.FULL_FOOTER_STATUS_TEXT).should('contain', '7 records (1 selected)'); + + // Check context menu works. + cy.get(os.layerFeaturesDialog.ROWS_CELLS).first().rightClick(); + cy.get(os.layerFeaturesDialog.contextMenu.EXPORT).should('be.visible'); + + cy.get(os.layerFeaturesDialog.contextMenu.DESELECT_ALL).click(); + cy.get(os.layerFeaturesDialog.FULL_FOOTER_STATUS_TEXT).should('contain', '7 records'); + + cy.get(os.layerFeaturesDialog.ROWS_CELLS).first().click(); + cy.get(os.layerFeaturesDialog.FULL_FOOTER_STATUS_TEXT).should('contain', '7 records (1 selected)'); + + cy.get(os.layerFeaturesDialog.ROWS_CELLS).first().rightClick(); + cy.get(os.layerFeaturesDialog.contextMenu.INVERT_SELECTION).click(); + cy.get(os.layerFeaturesDialog.FULL_FOOTER_STATUS_TEXT).should('contain', '7 records (6 selected)'); + + cy.get(os.layerFeaturesDialog.GRID).rightClick(); + cy.get(os.layerFeaturesDialog.contextMenu.SELECT_ALL).click(); + cy.get(os.layerFeaturesDialog.FULL_FOOTER_STATUS_TEXT).should('contain', '7 records (7 selected)'); + + cy.get(os.layerFeaturesDialog.GRID).rightClick(); + cy.get(os.layerFeaturesDialog.contextMenu.DESELECT_ALL).click(); + cy.get(os.layerFeaturesDialog.FULL_FOOTER_STATUS_TEXT).should('contain', '7 records'); + + cy.get(os.layerFeaturesDialog.ROWS_CELLS).last().click(); + cy.get(os.layerFeaturesDialog.FULL_FOOTER_STATUS_TEXT).should('contain', '7 records (1 selected)'); + cy.get(os.layerFeaturesDialog.GRID).rightClick(); + cy.get(os.layerFeaturesDialog.contextMenu.HIDE_SELECTED).click(); + cy.get(os.layerFeaturesDialog.FULL_FOOTER_STATUS_TEXT).should('contain', '6 records (1 hidden)'); + + cy.get(os.layerFeaturesDialog.GRID).rightClick(); + cy.get(os.layerFeaturesDialog.contextMenu.DISPLAY_ALL).click(); + cy.get(os.layerFeaturesDialog.FULL_FOOTER_STATUS_TEXT).should('contain', '7 records'); + + cy.get(os.layerFeaturesDialog.ROWS_CELLS).last().click(); + cy.get(os.layerFeaturesDialog.FULL_FOOTER_STATUS_TEXT).should('contain', '7 records (1 selected)'); + cy.get(os.layerFeaturesDialog.GRID).rightClick(); + cy.get(os.layerFeaturesDialog.contextMenu.HIDE_UNSELECTED).click(); + cy.get(os.layerFeaturesDialog.FULL_FOOTER_STATUS_TEXT).should('contain', '1 record (1 selected, 6 hidden)'); + cy.get(os.layerFeaturesDialog.GRID).rightClick(); + cy.get(os.layerFeaturesDialog.contextMenu.DISPLAY_ALL).click(); + cy.get(os.layerFeaturesDialog.FULL_FOOTER_STATUS_TEXT).should('contain', '7 records (1 selected)'); + + cy.get(os.layerFeaturesDialog.GRID).rightClick(); + cy.get(os.layerFeaturesDialog.contextMenu.REMOVE_SELECTED).click(); + cy.get(os.layerFeaturesDialog.FULL_FOOTER_STATUS_TEXT).should('contain', '6 records'); + + cy.get(os.layerFeaturesDialog.ROWS_CELLS).last().click(); + cy.get(os.layerFeaturesDialog.FULL_FOOTER_STATUS_TEXT).should('contain', '6 records (1 selected)'); + cy.get(os.layerFeaturesDialog.GRID).rightClick(); + cy.get(os.layerFeaturesDialog.contextMenu.REMOVE_UNSELECTED).click(); + cy.get(os.layerFeaturesDialog.FULL_FOOTER_STATUS_TEXT).should('contain', '1 record (1 selected)'); + + // Check Close button works + cy.get(os.layerFeaturesDialog.DIALOG).within(function() { + cy.get(os.layerFeaturesDialog.buttons.CLOSE).should('be.visible'); + cy.get(os.layerFeaturesDialog.buttons.CLOSE).click(); + }); + cy.get('[title=\'' + TEST_FIXTURE_DATA + '\']').should('not.exist'); + + // Clean up + cy.get(os.layersDialog.Tabs.Layers.Tree.LAYER_4).should('contain', TEST_FIXTURE_DATA + ' Features (1)'); + cy.get(os.layersDialog.Tabs.Layers.Tree.LAYER_4).click(); + cy.get(os.layersDialog.Tabs.Layers.Tree.Type.featureLayer.REMOVE_LAYER_BUTTON_WILDCARD).click(); + cy.get(os.layersDialog.DIALOG).should('not.contain', TEST_FIXTURE_DATA + ' Features'); + cy.get(os.Application.PAGE).type('v'); + }); +}); diff --git a/cypress/support/selectors.js b/cypress/support/selectors.js index 3a3a942f09..608446bf81 100644 --- a/cypress/support/selectors.js +++ b/cypress/support/selectors.js @@ -492,6 +492,12 @@ exports.customDateTimeFormatsDialog = { CLOSE_BUTTON: '[ng-click=\'th.close()\']' }; +exports.descriptionInfoDialog = { + DIALOG: '[data-testid=\'descriptioninfo\']', + CONTENT: '[data-testid=\'descriptioninfocontent\']', + CLOSE_BUTTON: '[ng-click=\'windowCtrl.close(true)\']' +}; + exports.editArcServerDialog = { DIALOG: '[label=\'Edit Arc Server\']', DIALOG_HEADER: '[title=\'Edit Arc Server\']', @@ -1420,6 +1426,7 @@ exports.layersDialog = { REMOVE: '[title=\'Removes the layer\']', RENAME: '[title=\'Rename the layer\']', SHOW_DESCRIPTION: '[title=\'Gives details about the layer\']', + SHOW_FEATURES: '[title=\'Displays features in the layer\']', EXPORT: '[title=\'Exports data from this layer\']', ADD_TO_TRACK: '[title=\'Adds selected features (or all features if none are selected) ' + 'to an existing track.\']', diff --git a/src/os/ui/descriptioninfo.js b/src/os/ui/descriptioninfo.js index e14d939f71..7c60910138 100644 --- a/src/os/ui/descriptioninfo.js +++ b/src/os/ui/descriptioninfo.js @@ -126,7 +126,8 @@ os.ui.launchDescriptionInfo = function(id, description, opt_titleDetail) { 'height': '600', 'min-height': '600', 'max-height': '600', - 'show-close': 'true' + 'show-close': 'true', + 'data-testid': 'descriptioninfo' }; var template = ''; diff --git a/views/descriptioninfo.html b/views/descriptioninfo.html index cc99a24b3b..8d7a6e0657 100644 --- a/views/descriptioninfo.html +++ b/views/descriptioninfo.html @@ -1,5 +1,5 @@
diff --git a/views/windows/featurelist.html b/views/windows/featurelist.html index caf90eabbd..3fd583857b 100644 --- a/views/windows/featurelist.html +++ b/views/windows/featurelist.html @@ -1,4 +1,4 @@ -
+