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

Add test cases to dashboards maps #1540

Merged
merged 1 commit into from
Aug 30, 2024
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"type": "FeatureCollection",
"name": "sample",
"features": [
{ "type": "Feature", "properties": { "iso2": "IN", "iso3": "IND", "name": "Abc" }, "geometry": { "type": "MultiPolygon", "coordinates": [[[[70.6640625,39.639537564366684],[69.78515625,37.020098201368114],[69.60937499999999,33.7243396617476],[69.9609375,29.99300228455108],[69.2578125,27.839076094777816],[69.60937499999999,26.588527147308614],[70.6640625,25.799891182088334],[70.13671875,24.206889622398023],[67.67578124999999,23.885837699862005],[69.78515625,21.616579336740603],[73.30078125,17.644022027872726],[75.76171875,13.581920900545844],[76.2890625,10.487811882056695],[77.51953125,8.233237111274565],[79.453125,11.178401873711785],[80.15625,16.97274101999902],[85.78125,19.973348786110602],[90.703125,21.616579336740603],[95.80078125,21.616579336740603],[96.85546875,26.27371402440643],[97.3828125,28.613459424004414],[92.98828125,30.14512718337613],[88.9453125,29.6880527498568],[83.84765625,30.14512718337613],[80.33203125,34.161818161230386],[81.2109375,37.020098201368114],[76.2890625,38.272688535980976],[71.54296874999999,39.774769485295465],[70.6640625,39.639537564366684]]]] } },
{ "type": "Feature", "properties": { "iso2": "CN", "iso3": "CHN", "name": "Xyz" }, "geometry": { "type": "MultiPolygon", "coordinates": [[ [ [ 113.36476, 22.1579 ], [ 113.35401, 22.13085 ], [ 113.33619, 22.10049 ], [ 113.31365, 22.0764 ], [ 113.28907, 22.06851 ], [ 113.27914, 22.07469 ], [ 113.26881, 22.08832 ], [ 113.26417, 22.10493 ], [ 113.27174, 22.12002 ], [ 113.27914, 22.1232 ], [ 113.28972, 22.12547 ], [ 113.29868, 22.12857 ], [ 113.30274, 22.13398 ], [ 113.30421, 22.14183 ], [ 113.30844, 22.14863 ], [ 113.31495, 22.154 ], [ 113.32309, 22.1579 ], [ 113.32797, 22.14582 ], [ 113.33546, 22.14887 ], [ 113.34718, 22.15644 ], [ 113.36476, 22.1579 ] ] ], [ [ [ 113.59352, 22.78482 ], [ 113.60288, 22.77245 ], [ 113.60279, 22.76264 ], [ 113.59457, 22.75609 ], [ 113.57984, 22.75373 ], [ 113.55828, 22.75788 ], [ 113.54461, 22.76878 ], [ 113.53566, 22.78433 ], [ 113.52858, 22.80215 ], [ 113.52117, 22.78791 ], [ 113.50611, 22.79804 ], [ 113.49529, 22.81387 ], [ 113.4808, 22.84931 ], [ 113.47397, 22.84931 ], [ 113.47316, 22.82538 ], [ 113.4559, 22.83076 ], [ 113.43409, 22.84907 ], [ 113.40211, 22.88288 ], [ 113.39617, 22.8981 ], [ 113.40512, 22.90811 ], [ 113.43295, 22.91201 ], [ 113.4756, 22.9007 ], [ 113.4878, 22.89281 ], [ 113.52703, 22.84663 ], [ 113.54672, 22.83487 ], [ 113.57301, 22.83006 ], [ 113.57643, 22.82392 ], [ 113.58766, 22.79462 ], [ 113.59352, 22.78482 ] ] ] ] } }
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import { BASE_PATH } from '../../../utils/constants';
import { MiscUtils } from '@opensearch-dashboards-test/opensearch-dashboards-test-library';
import { CURRENT_TENANT } from '../../../utils/commands';

const miscUtils = new MiscUtils(cy);

describe('Add flights dataset saved object', () => {
before(() => {
CURRENT_TENANT.newTenant = 'global';
cy.deleteAllIndices();
miscUtils.addSampleData();
cy.wait(10000);
});

after(() => {
miscUtils.removeSampleData();
});

it('check if maps saved object of flights dataset can be found and open', () => {
cy.visit(`${BASE_PATH}/app/maps-dashboards`);
cy.contains(
'[Flights] Flights Status on Maps Destination Location'
).click();
cy.get('[data-test-subj="layerControlPanel"]').should(
'contain',
'Flights On Time'
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,17 @@
/// <reference types="cypress" />

import { BASE_PATH } from '../../../utils/constants';
import { MiscUtils } from '@opensearch-dashboards-test/opensearch-dashboards-test-library';
import { CURRENT_TENANT } from '../../../utils/commands';
import { MiscUtils } from '@opensearch-dashboards-test/opensearch-dashboards-test-library';

const miscUtils = new MiscUtils(cy);

describe('Verify the presence of import custom map tab in region map plugin', () => {
before(() => {
CURRENT_TENANT.newTenant = 'global';
cy.deleteAllIndices();
miscUtils.addSampleData();
cy.wait(15000);

// Load region map visualization with sample data opensearch_dashboards_sample_data_flights
cy.visit(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,16 @@

import { BASE_PATH } from '../../../utils/constants';
import { CURRENT_TENANT } from '../../../utils/commands';
import { MiscUtils } from '@opensearch-dashboards-test/opensearch-dashboards-test-library';

const miscUtils = new MiscUtils(cy);

describe('Default OpenSearch base map layer', () => {
before(() => {
CURRENT_TENANT.newTenant = 'global';
cy.visit(`${BASE_PATH}/app/home#/tutorial_directory/sampleData`, {
retryOnStatusCodeFailure: true,
timeout: 60000,
});
cy.wait(5000);
cy.get('div[data-test-subj="sampleDataSetCardflights"]', {
timeout: 60000,
})
.contains(/(Add|View) data/)
.click();
cy.wait(60000);
cy.deleteAllIndices();
miscUtils.addSampleData();
cy.wait(15000);
});

it('check if default OpenSearch map layer can be open', () => {
Expand Down Expand Up @@ -49,10 +44,6 @@ describe('Default OpenSearch base map layer', () => {
});

after(() => {
cy.visit(`${BASE_PATH}/app/home#/tutorial_directory`);
cy.wait(5000);
cy.get('button[data-test-subj="removeSampleDataSetflights"]')
.should('be.visible')
.click();
miscUtils.removeSampleData();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,20 @@

import { BASE_PATH } from '../../../utils/constants';
import { CURRENT_TENANT } from '../../../utils/commands';
import { MiscUtils } from '@opensearch-dashboards-test/opensearch-dashboards-test-library';

const miscUtils = new MiscUtils(cy);

describe('Add flights dataset saved object', () => {
before(() => {
CURRENT_TENANT.newTenant = 'global';
cy.visit(`${BASE_PATH}/app/home#/tutorial_directory/sampleData`, {
retryOnStatusCodeFailure: true,
timeout: 60000,
});
cy.wait(5000);
cy.get('div[data-test-subj="sampleDataSetCardflights"]', {
timeout: 60000,
})
.contains(/Add data/)
.click();
cy.wait(60000);
cy.deleteAllIndices();
miscUtils.addSampleData();
cy.wait(15000);
});

after(() => {
cy.visit(`${BASE_PATH}/app/home#/tutorial_directory`);
cy.wait(5000);
cy.get('button[data-test-subj="removeSampleDataSetflights"]', {
timeout: 120000,
})
.should('be.visible')
.click();
miscUtils.removeSampleData();
});

it('check if maps saved object of flights dataset can be found and open', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,16 @@

import { BASE_PATH } from '../../../utils/constants';
import { CURRENT_TENANT } from '../../../utils/commands';
import { MiscUtils } from '@opensearch-dashboards-test/opensearch-dashboards-test-library';

const miscUtils = new MiscUtils(cy);

describe('Documents layer', () => {
before(() => {
CURRENT_TENANT.newTenant = 'global';
cy.visit(`${BASE_PATH}/app/home#/tutorial_directory/sampleData`, {
retryOnStatusCodeFailure: true,
timeout: 60000,
});
cy.wait(5000);
cy.get('div[data-test-subj="sampleDataSetCardflights"]', {
timeout: 60000,
})
.contains(/(Add|View) data/)
.click();
cy.wait(60000);
cy.deleteAllIndices();
miscUtils.addSampleData();
cy.wait(15000);
});

const uniqueName = 'saved-map-' + Date.now().toString();
Expand Down Expand Up @@ -76,10 +71,6 @@ describe('Documents layer', () => {
cy.wait(30000);
cy.visit(`${BASE_PATH}/app/maps-dashboards`);
cy.wait(10000);
cy.get('[data-test-subj="mapListingPage"]', { timeout: 120000 }).should(
'contain',
uniqueName
);
cy.contains(uniqueName).click();
cy.get('[data-test-subj="layerControlPanel"]').should(
'contain',
Expand All @@ -88,10 +79,6 @@ describe('Documents layer', () => {
});

after(() => {
cy.visit(`${BASE_PATH}/app/home#/tutorial_directory`);
cy.wait(5000);
cy.get('button[data-test-subj="removeSampleDataSetflights"]')
.should('be.visible')
.click();
miscUtils.removeSampleData();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import { BASE_PATH } from '../../../utils/constants';
import { MiscUtils } from '@opensearch-dashboards-test/opensearch-dashboards-test-library';
import { CURRENT_TENANT } from '../../../utils/commands';

const miscUtils = new MiscUtils(cy);

describe('Add map to dashboard', () => {
before(() => {
CURRENT_TENANT.newTenant = 'global';
cy.deleteAllIndices();
miscUtils.addSampleData();
cy.wait(15000);
});

it('Add new map to dashboard', () => {
const testMapName = 'saved-map-' + Date.now().toString();
cy.visit(`${BASE_PATH}/app/dashboards`);
cy.get('[data-test-subj="newItemButton"]').click();
cy.get('button[data-test-subj="dashboardAddNewPanelButton"]').click();
cy.get('button[data-test-subj="visType-customImportMap"]').click();
cy.wait(5000).get('button[data-test-subj="mapSaveButton"]').click();
cy.wait(5000).get('[data-test-subj="savedObjectTitle"]').type(testMapName);
cy.wait(5000)
.get('[data-test-subj="confirmSaveSavedObjectButton"]')
.click();
cy.get('.embPanel__titleText').should('contain', testMapName);
});

after(() => {
miscUtils.removeSampleData();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import { BASE_PATH } from '../../../utils/constants';
import { CURRENT_TENANT } from '../../../utils/commands';
import { MiscUtils } from '@opensearch-dashboards-test/opensearch-dashboards-test-library';
import 'cypress-file-upload';

const miscUtils = new MiscUtils(cy);

describe('Verify successful custom geojson file upload', () => {
before(() => {
CURRENT_TENANT.newTenant = 'global';
cy.deleteAllIndices();
miscUtils.addSampleData();
cy.wait(15000);

// Load region map visualization with sample data opensearch_dashboards_sample_data_flights
cy.visit(
`${BASE_PATH}/app/visualize#/create?type=region_map&indexPattern=d3d7af60-4c81-11e8-b3d7-01146121b73d`,
{
retryOnStatusCodeFailure: true,
timeout: 60000,
}
);
});

it('checks if the file uploaded successfully', () => {
// Click on "Import Vector Map" tab, which is part of customImportMap plugin
cy.contains('Import Vector Map').click({ force: true });

cy.get('[data-testId="filePicker"]').attachFile(
'plugins/custom-import-map-dashboards/sample_geo.json'
);
cy.get('[data-testId="customIndex"]').type('sample');
cy.contains('Import file').click({ force: true });
cy.contains(
'Successfully added 2 features to sample-map. Refresh to visualize the uploaded map.',
{ timeout: 240000 }
);
});

after(() => {
miscUtils.removeSampleData();
});
});
20 changes: 20 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"@faker-js/faker": "^7.6.0",
"commander": "^9.4.1",
"cypress": "9.5.4",
"cypress-file-upload": "^5.0.8",
"cypress-multi-reporters": "^1.5.0",
"cypress-real-events": "1.7.6",
"eslint": "^7.0.0",
Expand Down
Loading