Skip to content

Commit

Permalink
Merge pull request #567 from bradh/features_cypress
Browse files Browse the repository at this point in the history
test(featurelist): Cypress tests for featurelist
  • Loading branch information
schmidtk authored Jun 17, 2019
2 parents 52c21c7 + 9f1ccec commit 265200d
Show file tree
Hide file tree
Showing 6 changed files with 347 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
<?xml version='1.0' encoding='UTF-8'?>
<kml xmlns:kml="http://earth.google.com/kml/2.2">
<Document id="featureCollection">
<Style id="defaultStyle">
<LineStyle>
<width>1.5</width>
</LineStyle>
<PolyStyle>
<color>7d8a30c4</color>
</PolyStyle>
</Style>
<Folder>
<Placemark>
<styleUrl>#defaultStyle</styleUrl>
<name>Astor Pl</name>
<ExtendedData>
<Data name="line">
<value>4-6-6 Express</value>
</Data>
<Data name="notes">
<value>4 nights, 6-all times, 6 Express-weekdays AM southbound, PM northbound</value>
</Data>
<Data name="objectid">
<value>1</value>
</Data>
</ExtendedData>
<Point>
<coordinates>
-73.99106999861966,40.73005400028978
</coordinates>
</Point>
</Placemark>
<Placemark>
<styleUrl>#defaultStyle</styleUrl>
<name>Canal St</name>
<ExtendedData>
<Data name="line">
<value>4-6-6 Express</value>
</Data>
<Data name="notes">
<value>4 nights, 6-all times, 6 Express-weekdays AM southbound, PM northbound</value>
</Data>
<Data name="objectid">
<value>2</value>
</Data>
</ExtendedData>
<Point>
<coordinates>
-74.00019299927328,40.71880300107709
</coordinates>
</Point>
</Placemark>
<Placemark>
<styleUrl>#defaultStyle</styleUrl>
<name>50th St</name>
<ExtendedData>
<Data name="line">
<value>1-2</value>
</Data>
<Data name="notes">
<value>1-all times, 2-nights</value>
</Data>
<Data name="objectid">
<value>3</value>
</Data>
</ExtendedData>
<Point>
<coordinates>
-73.98384899986625,40.76172799961419
</coordinates>
</Point>
</Placemark>
<Placemark>
<styleUrl>#defaultStyle</styleUrl>
<name>Bergen St</name>
<ExtendedData>
<Data name="line">
<value>2-3-4</value>
</Data>
<Data name="notes">
<value>4-nights, 3-all other times, 2-all times</value>
</Data>
<Data name="objectid">
<value>4</value>
</Data>
</ExtendedData>
<Point>
<coordinates>
-73.97499915116808,40.68086213682956
</coordinates>
</Point>
</Placemark>
<Placemark>
<styleUrl>#defaultStyle</styleUrl>
<name>Pennsylvania Ave</name>
<ExtendedData>
<Data name="line">
<value>3-4</value>
</Data>
<Data name="notes">
<value>4-nights, 3-all other times</value>
</Data>
<Data name="objectid">
<value>5</value>
</Data>
</ExtendedData>
<Point>
<coordinates>
-73.89488591154061,40.66471445143568
</coordinates>
</Point>
</Placemark>
<Placemark>
<styleUrl>#defaultStyle</styleUrl>
<name>Morrison Av - Soundview</name>
<ExtendedData>
<Data name="line">
<value>6</value>
</Data>
<Data name="notes">
<value>6-all times</value>
</Data>
<Data name="objectid">
<value>51</value>
</Data>
</ExtendedData>
<Point>
<coordinates>
-73.87451599929486,40.82952100156747
</coordinates>
</Point>
</Placemark>
<Placemark>
<styleUrl>#defaultStyle</styleUrl>
<name>96th St</name>
<ExtendedData>
<Data name="line">
<value>Q</value>
</Data>
<Data name="notes">
<value>Q-all times</value>
</Data>
<Data name="objectid">
<value>643</value>
</Data>
</ExtendedData>
<description>This is the description text.</description>
<Point>
<coordinates>
-73.9470660219183,40.784236650177654
</coordinates>
</Point>
</Placemark>
</Folder>
</Document>
</kml>
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
/// <reference types="Cypress" />
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) {
var $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');
});
});
7 changes: 7 additions & 0 deletions cypress/support/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -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\']',
Expand Down Expand Up @@ -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.\']',
Expand Down
3 changes: 2 additions & 1 deletion src/os/ui/descriptioninfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '<descriptioninfo description="description"></descriptioninfo>';
Expand Down
2 changes: 1 addition & 1 deletion views/descriptioninfo.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="flex-fill w-100 d-flex flex-column">
<div class="modal-body flex-fill u-overflow-y-auto card d-flex">
<iframe class="card flex-fill bg-light"></iframe>
<iframe class="card flex-fill bg-light" data-testid="descriptioninfocontent"></iframe>
</div>
</div>
2 changes: 1 addition & 1 deletion views/windows/featurelist.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="d-flex flex-column flex-fill">
<div class="d-flex flex-column flex-fill" data-testid="featurelist">
<div class="d-flex flex-column flex-fill modal-body">
<div class="d-flex flex-row align-items-center mb-2">
<div class="custom-control custom-checkbox mr-4"
Expand Down

0 comments on commit 265200d

Please sign in to comment.