Skip to content

Commit

Permalink
Add new home ui test for 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 30, 2024
1 parent e06a6f2 commit cb0d2b7
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
*/

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);

Expand All @@ -17,21 +17,24 @@ describe('Add map to dashboard', () => {
cy.wait(15000);
});

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

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.visit(`${BASE_PATH}/app/dashboards#/create`);
cy.wait(5000)
.get('button[data-test-subj="addVisualizationButton"]')
.click();
cy.wait(5000)
.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();
cy.wait(5000).get('.embPanel__titleText').should('contain', testMapName);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/*
* 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);

// Enable the new home UI
cy.visit(`${BASE_PATH}/app/settings`);
cy.get(
'[data-test-subj="advancedSetting-editField-home:useNewHomePage"]'
).then(($switch) => {
if ($switch.attr('aria-checked') === 'false') {
cy.wrap($switch).click();
cy.get('[data-test-subj="advancedSetting-saveButton"]').click();
cy.get('button.euiButton--primary.euiButton--small', {
timeout: 15000,
}).click();
} else {
cy.log('The switch is already on.');
}
});
});

after(() => {
miscUtils.removeSampleData();
// Disable the new home UI
cy.visit(`${BASE_PATH}/app/settings`);
cy.get(
'[data-test-subj="advancedSetting-editField-home:useNewHomePage"]'
).then(($switch) => {
if ($switch.attr('aria-checked') === 'true') {
cy.wrap($switch).click();
cy.get('[data-test-subj="advancedSetting-saveButton"]').click();
cy.get('button.euiButton--primary.euiButton--small', {
timeout: 15000,
}).click();
} else {
cy.log('The switch is already off.');
}
});
});

it('Verify component in maps listing page', () => {
cy.visit(`${BASE_PATH}/app/maps-dashboards`);

// Verify the presence of the headerRightControl component
cy.get('[data-test-subj="headerRightControl"]').should('exist');

// Verify the presence of the maps createButton within the headerRightControl
cy.get('[data-test-subj="headerRightControl"]')
.find('[data-test-subj="createButton"]')
.should('exist');
});

it('Verify component in maps visualization page', () => {
cy.visit(`${BASE_PATH}/app/maps-dashboards/create`);

// Verify the presence of the top-nav component
cy.get('[data-test-subj="top-nav"]').should('exist');

// Verify the presence of the mapSaveButton inside the top-nav component
cy.get('[data-test-subj="top-nav"]')
.find('[data-test-subj="mapSaveButton"]')
.should('exist');
});
});

0 comments on commit cb0d2b7

Please sign in to comment.