Skip to content

Commit fbe8a9c

Browse files
committed
Add bwc sample tests
tests include the following cases: verify default page work verify advanced savings work verify filter and query work Disable eslint check Add eslint-disable comment Revise license content in plugins and support Particailly Resolved: opensearch-project/opensearch-build#705 Signed-off-by: Anan Zhuang <[email protected]>
1 parent 38ace12 commit fbe8a9c

File tree

6 files changed

+410
-0
lines changed

6 files changed

+410
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/*
2+
* SPDX-License-Identifier: Apache-2.0
3+
*
4+
* The OpenSearch Contributors require contributions made to
5+
* this file be licensed under the Apache-2.0 license or a
6+
* compatible open source license.
7+
*/
8+
9+
/*
10+
* Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
11+
*
12+
* Licensed under the Apache License, Version 2.0 (the "License").
13+
* You may not use this file except in compliance with the License.
14+
* A copy of the License is located at
15+
*
16+
* http://www.apache.org/licenses/LICENSE-2.0
17+
*
18+
* or in the "license" file accompanying this file. This file is distributed
19+
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
20+
* express or implied. See the License for the specific language governing
21+
* permissions and limitations under the License.
22+
*/
23+
24+
/*
25+
* Modifications Copyright OpenSearch Contributors. See
26+
* GitHub history for details.
27+
*/
28+
29+
/* es-lint-disable for missing definitions */
30+
/* eslint-disable */
31+
import {
32+
MiscUtils,
33+
LoginPage,
34+
} from '@opensearch-dashboards-test/opensearch-dashboards-test-library';
35+
36+
const miscUtils = new MiscUtils(cy);
37+
const loginPage = new LoginPage(cy);
38+
39+
describe('verify the advanced settings are saved', () => {
40+
beforeEach(() => {
41+
miscUtils.visitPage('app/management/opensearch-dashboards/settings');
42+
loginPage.enterUserName('admin');
43+
loginPage.enterPassword('admin');
44+
loginPage.submit();
45+
});
46+
47+
it('the dark mode is on', () => {
48+
cy.get('[data-test-subj="advancedSetting-editField-theme:darkMode"]')
49+
.invoke('attr', 'aria-checked')
50+
.should('eq', 'true');
51+
});
52+
53+
it('the Timeline default columns field is set to 4', () => {
54+
cy.get('[data-test-subj="advancedSetting-editField-timeline:default_columns"]').should(
55+
'have.value',
56+
4
57+
);
58+
});
59+
60+
it('the Timeline Maximum buckets field is set to 4', () => {
61+
cy.get('[data-test-subj="advancedSetting-editField-timeline:max_buckets"]').should(
62+
'have.value',
63+
4
64+
);
65+
});
66+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
* SPDX-License-Identifier: Apache-2.0
3+
*
4+
* The OpenSearch Contributors require contributions made to
5+
* this file be licensed under the Apache-2.0 license or a
6+
* compatible open source license.
7+
*/
8+
9+
/*
10+
* Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
11+
*
12+
* Licensed under the Apache License, Version 2.0 (the "License").
13+
* You may not use this file except in compliance with the License.
14+
* A copy of the License is located at
15+
*
16+
* http://www.apache.org/licenses/LICENSE-2.0
17+
*
18+
* or in the "license" file accompanying this file. This file is distributed
19+
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
20+
* express or implied. See the License for the specific language governing
21+
* permissions and limitations under the License.
22+
*/
23+
24+
/*
25+
* Modifications Copyright OpenSearch Contributors. See
26+
* GitHub history for details.
27+
*/
28+
29+
/* es-lint-disable for missing definitions */
30+
/* eslint-disable */
31+
import {
32+
MiscUtils,
33+
LoginPage,
34+
} from '@opensearch-dashboards-test/opensearch-dashboards-test-library';
35+
36+
const miscUtils = new MiscUtils(cy);
37+
const loginPage = new LoginPage(cy);
38+
39+
describe('verify default landing page work for bwc', () => {
40+
beforeEach(() => {
41+
miscUtils.visitPage('');
42+
loginPage.enterUserName('admin');
43+
loginPage.enterPassword('admin');
44+
loginPage.submit();
45+
});
46+
47+
it('the overview page is set as the default landing pag', () => {
48+
cy.url().should('include', '/app/opensearch_dashboards_overview#/');
49+
cy.contains('Display a different page on log in');
50+
});
51+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
/*
2+
* SPDX-License-Identifier: Apache-2.0
3+
*
4+
* The OpenSearch Contributors require contributions made to
5+
* this file be licensed under the Apache-2.0 license or a
6+
* compatible open source license.
7+
*/
8+
9+
/*
10+
* Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
11+
*
12+
* Licensed under the Apache License, Version 2.0 (the "License").
13+
* You may not use this file except in compliance with the License.
14+
* A copy of the License is located at
15+
*
16+
* http://www.apache.org/licenses/LICENSE-2.0
17+
*
18+
* or in the "license" file accompanying this file. This file is distributed
19+
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
20+
* express or implied. See the License for the specific language governing
21+
* permissions and limitations under the License.
22+
*/
23+
24+
/*
25+
* Modifications Copyright OpenSearch Contributors. See
26+
* GitHub history for details.
27+
*/
28+
29+
/* es-lint-disable for missing definitions */
30+
/* eslint-disable */
31+
import {
32+
MiscUtils,
33+
CommonUI,
34+
LoginPage,
35+
} from '@opensearch-dashboards-test/opensearch-dashboards-test-library';
36+
37+
const commonUI = new CommonUI(cy);
38+
const miscUtils = new MiscUtils(cy);
39+
const loginPage = new LoginPage(cy);
40+
41+
describe('verify dashboards filter and query work properly for bwc', () => {
42+
beforeEach(() => {
43+
miscUtils.visitPage('app/dashboards#');
44+
loginPage.enterUserName('admin');
45+
loginPage.enterPassword('admin');
46+
loginPage.submit();
47+
});
48+
49+
afterEach(() => {
50+
cy.clearCookies();
51+
});
52+
53+
it('tenant-switch-modal page should show and be clicked', () => {
54+
cy.get('[data-test-subj="tenant-switch-modal"]');
55+
cy.get('[data-test-subj="confirm"]').click();
56+
});
57+
58+
describe('osx filter and query should work in [Logs] Web Traffic dashboards', () => {
59+
beforeEach(() => {
60+
cy.get('[data-test-subj="dashboardListingTitleLink-[Logs]-Web-Traffic"]').click();
61+
cy.get('[data-test-subj="breadcrumb last"]')
62+
.invoke('attr', 'title')
63+
.should('eq', '[Logs] Web Traffic');
64+
});
65+
66+
it('osx filter and query should exist and be named correctly', () => {
67+
cy.get('[data-test-subj="saved-query-management-popover-button"]').click();
68+
cy.get('[data-test-subj="saved-query-management-popover"]')
69+
.find('[class="osdSavedQueryListItem__labelText"]')
70+
.should('have.text', 'test-query')
71+
.click();
72+
cy.get('[data-test-subj="queryInput"]').should('have.text', 'resp=200');
73+
cy.get(
74+
'[data-test-subj="filter filter-enabled filter-key-machine.os filter-value-osx filter-unpinned "]'
75+
)
76+
.should('have.text', 'osx filter')
77+
.click();
78+
cy.get('[data-test-subj="editFilter"]').click();
79+
cy.get('[data-test-subj="filterFieldSuggestionList"]')
80+
.find('[data-test-subj="comboBoxInput"]')
81+
.should('have.text', 'machine.os');
82+
cy.get('[data-test-subj="filterOperatorList"]')
83+
.find('[data-test-subj="comboBoxInput"]')
84+
.should('have.text', 'is');
85+
cy.get('[data-test-subj="filterParams"]').find('input').should('have.value', 'osx');
86+
});
87+
88+
it('osx filter and query should function correctly', () => {
89+
commonUI.setDateRange('Oct 10, 2021 @ 00:00:00.000', 'Oct 4, 2021 @ 00:00:00.000');
90+
cy.get('[data-test-subj="saved-query-management-popover-button"]').click();
91+
cy.get('[data-test-subj="saved-query-management-popover"]')
92+
.find('[class="osdSavedQueryListItem__labelText"]')
93+
.should('have.text', 'test-query')
94+
.click();
95+
cy.get('[data-test-subj="dashboardPanel"]').each((item) => {
96+
const vsLoader = item.get('[data-test-subj="visualizationLoader"]');
97+
//[Logs] unique visitors should be 211
98+
if (
99+
vsLoader &&
100+
vsLoader
101+
.get('[data-test-subj="visualizationLoader"]')
102+
.find('[class="chart-title"]')
103+
.should('have.text', 'Unique Visitors')
104+
) {
105+
vsLoader.should('have.class', 'chart-label').should('have.text', '211');
106+
}
107+
//[Logs] vistor chart should show osx 100%
108+
if (
109+
vsLoader &&
110+
vsLoader.get('[data-test-subj="visualizationLoader"]').invoke('css', 'data-title') ===
111+
'[Logs] Visitors by OS'
112+
) {
113+
vsLoader.should('have.class', 'label').should('have.text', 'osx (100%)');
114+
}
115+
//[Logs] Response chart should show 200 label
116+
if (
117+
vsLoader &&
118+
vsLoader.get('[data-test-subj="visualizationLoader"]').invoke('css', 'data-title') ===
119+
'[Logs] Response Codes Over Time + Annotations'
120+
) {
121+
vsLoader
122+
.should('have.class', 'echLegendItem__label echLegendItem__label--clickable')
123+
.should('have.text', '200');
124+
}
125+
});
126+
});
127+
});
128+
});

cypress/plugins/index.js

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* SPDX-License-Identifier: Apache-2.0
3+
*
4+
* The OpenSearch Contributors require contributions made to
5+
* this file be licensed under the Apache-2.0 license or a
6+
* compatible open source license.
7+
*/
8+
9+
/*
10+
* Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
11+
*
12+
* Licensed under the Apache License, Version 2.0 (the "License").
13+
* You may not use this file except in compliance with the License.
14+
* A copy of the License is located at
15+
*
16+
* http://www.apache.org/licenses/LICENSE-2.0
17+
*
18+
* or in the "license" file accompanying this file. This file is distributed
19+
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
20+
* express or implied. See the License for the specific language governing
21+
* permissions and limitations under the License.
22+
*/
23+
24+
/*
25+
* Modifications Copyright OpenSearch Contributors. See
26+
* GitHub history for details.
27+
*/
28+
29+
/* es-lint-disable for missing definitions */
30+
/* eslint-disable */
31+
/// <reference types="cypress" />
32+
// ***********************************************************
33+
// This example plugins/index.js can be used to load plugins
34+
//
35+
// You can change the location of this file or turn off loading
36+
// the plugins file with the 'pluginsFile' configuration option.
37+
//
38+
// You can read more here:
39+
// https://on.cypress.io/plugins-guide
40+
// ***********************************************************
41+
42+
// This function is called when a project is opened or re-opened (e.g. due to
43+
// the project's config changing)
44+
45+
/**
46+
* @type {Cypress.PluginConfig}
47+
*/
48+
// eslint-disable-next-line no-unused-vars
49+
module.exports = (on, config) => {
50+
// `on` is used to hook into various events Cypress emits
51+
// `config` is the resolved Cypress config
52+
};

cypress/support/commands.js

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
* SPDX-License-Identifier: Apache-2.0
3+
*
4+
* The OpenSearch Contributors require contributions made to
5+
* this file be licensed under the Apache-2.0 license or a
6+
* compatible open source license.
7+
*/
8+
9+
/*
10+
* Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
11+
*
12+
* Licensed under the Apache License, Version 2.0 (the "License").
13+
* You may not use this file except in compliance with the License.
14+
* A copy of the License is located at
15+
*
16+
* http://www.apache.org/licenses/LICENSE-2.0
17+
*
18+
* or in the "license" file accompanying this file. This file is distributed
19+
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
20+
* express or implied. See the License for the specific language governing
21+
* permissions and limitations under the License.
22+
*/
23+
24+
/*
25+
* Modifications Copyright OpenSearch Contributors. See
26+
* GitHub history for details.
27+
*/
28+
29+
/* es-lint-disable for missing definitions */
30+
/* eslint-disable */
31+
// ***********************************************
32+
// This example commands.js shows you how to
33+
// create various custom commands and overwrite
34+
// existing commands.
35+
//
36+
// For more comprehensive examples of custom
37+
// commands please read more here:
38+
// https://on.cypress.io/custom-commands
39+
// ***********************************************
40+
//
41+
//
42+
// -- This is a parent command --
43+
// Cypress.Commands.add('login', (email, password) => { ... })
44+
//
45+
//
46+
// -- This is a child command --
47+
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... })
48+
//
49+
//
50+
// -- This is a dual command --
51+
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... })
52+
//
53+
//
54+
// -- This will overwrite an existing command --
55+
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })

0 commit comments

Comments
 (0)