Skip to content

Commit

Permalink
Add tests for the new homepage
Browse files Browse the repository at this point in the history
Signed-off-by: Miki <miki@amazon.com>
  • Loading branch information
AMoo-Miki committed Jan 18, 2024
1 parent 6cba7a6 commit 212d410
Show file tree
Hide file tree
Showing 3 changed files with 147 additions and 1 deletion.
74 changes: 73 additions & 1 deletion cypress/integration/common/dashboard_sample_data_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,80 @@ export function dashboardSanityTests() {
);
});

it('checking sections display', () => {
// Check that we have two homepageSection
commonUI.checkElementExists(`[data-test-subj="homepageSection"]`, 2);
});

it('checking tutorial_directory display', () => {
// Check that tutorial_directory is visable
commonUI.checkElementExists(
`a[href="${path}/app/home#/tutorial_directory"]`,
2
);
});

it('checking management display', () => {
// Check that management is visable
commonUI.checkElementExists(`a[href="${path}/app/management"]`, 1);
});

it('checking dev_tools display', () => {
// Check that dev_tools is visable
commonUI.checkElementExists(
`a[href="${path}/app/dev_tools#/console"]`,
1
);
});

it('settings display', () => {
// Check that settings is visable
commonUI.checkElementExists(
`a[href="${path}/app/management/opensearch-dashboards/settings#defaultRoute"]`,
1
);
});

it('checking feature_directory display', () => {
// Check that feature_directory is visable
commonUI.checkElementExists(
`a[href="${path}/app/home#/feature_directory"]`,
1
);
});

it('checking navigation display', () => {
// Check that navigation is visable
commonUI.checkElementExists(
'button[data-test-subj="toggleNavButton"]',
1
);
});

it('checking Help menu display', () => {
// Check that Help menu is visable
commonUI.checkElementExists('button[aria-label="Help menu"]', 1);
});
});

describe('checking legacy home page', () => {
before(() => {
// Go to the home page
miscUtils.visitPage('app/home#/legacy');
cy.window().then((win) =>
win.localStorage.setItem('home:welcome:show', false)
);
cy.reload(true);
});

after(() => {
cy.window().then((win) =>
win.localStorage.removeItem('home:welcome:show')
);
});

it('checking opensearch_dashboards_overview display', () => {
// Check that opensearch_dashboards_overview is visable
// Check that opensearch_dashboards_overview is visible
commonUI.checkElementExists(
`a[href="${path}/app/opensearch_dashboards_overview"]`,
1
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import { MiscUtils } from '@opensearch-dashboards-test/opensearch-dashboards-test-library';

const miscUtils = new MiscUtils(cy);

describe('home sections', { scrollBehavior: false }, () => {
before(() => {
// Go to the home page
miscUtils.visitPage('app/home#');
});

it('should all appear expanded', function () {
cy.getElementsByTestIds('homepageSection').each((element) => {
const $content = element.find(
'[data-test-subj="homepageSectionContent"]'
);
expect($content).to.have.length(1);
});
});

it('should toggle correctly', function () {
cy.getElementsByTestIds('homepageSection').each((element) => {
const $button = element.find('button').first();

const $preClick1 = element.find(
'[data-test-subj="homepageSectionContent"]'
);
expect($preClick1).to.have.length(1);

$button.trigger('click');

const $postClick1 = element.find(
'[data-test-subj="homepageSectionContent"]'
);
expect($postClick1).to.have.length(0);

$button.trigger('click');

const $postClick2 = element.find(
'[data-test-subj="homepageSectionContent"]'
);
expect($postClick2).to.have.length(1);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,31 @@ if (Cypress.env('DATASOURCE_MANAGEMENT_ENABLED')) {
});
});

describe('checking legacy home page', () => {
before(() => {
// Go to the home page
miscUtils.visitPage('app/home#/legacy');
cy.window().then((win) =>
win.localStorage.setItem('home:welcome:show', false)
);
cy.reload(true);
});

after(() => {
cy.window().then((win) =>
win.localStorage.removeItem('home:welcome:show')
);
});

it('checking tutorial_directory display', () => {
// Check that tutorial_directory is visible
commonUI.checkElementExists(
`a[href="${path}/app/home#/tutorial_directory"]`,
2
);
});
});

describe('adding sample data', () => {
before(() => {
miscUtils.addSampleData();
Expand Down

0 comments on commit 212d410

Please sign in to comment.