Skip to content

Commit 73a744d

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 Particailly Resolved: opensearch-project/opensearch-build#705 Signed-off-by: Anan Zhuang <[email protected]>
1 parent 38ace12 commit 73a744d

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

cypress/plugins/index.js

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

cypress/support/commands.js

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

0 commit comments

Comments
 (0)