Skip to content

Commit

Permalink
Add test cases to dashboards maps
Browse files Browse the repository at this point in the history
Signed-off-by: Junqiu Lei <[email protected]>
  • Loading branch information
junqiu-lei committed Aug 29, 2024
1 parent 1ceb4c9 commit 14aaac3
Show file tree
Hide file tree
Showing 7 changed files with 142 additions and 55 deletions.
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,47 @@
/*
* 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';

const miscUtils = new MiscUtils(cy);

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

cy.visit(`${BASE_PATH}/app/visualize#/`);

// Click on "Create Visualization" tab
cy.contains('Create visualization').click({ force: true });

// Click on "Region Map" icon
cy.contains('Region Map').click({ force: true });

// Select index source - [Flights] Flight Log
cy.contains('[Flights] Flight Log').click({ force: true });
});

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('sample_geojson.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();
});
});

0 comments on commit 14aaac3

Please sign in to comment.