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 tests for the new homepage #996

Merged
merged 1 commit into from
Jan 23, 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
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
Loading