-
Notifications
You must be signed in to change notification settings - Fork 142
Expand file tree
/
Copy path1_query_compare.spec.js
More file actions
101 lines (91 loc) · 2.78 KB
/
Copy path1_query_compare.spec.js
File metadata and controls
101 lines (91 loc) · 2.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/
/// <reference types="cypress" />
import {
SEARCH_RELEVANCE_PLUGIN_NAME,
SAMPLE_INDEX,
SAMPLE_SEARCH_TEXT,
SAMPLE_QUERY_TEXT,
NO_RESULTS,
} from '../../../utils/plugins/search-relevance-dashboards/constants';
import { BASE_PATH } from '../../../utils/base_constants';
describe('Compare queries', () => {
before(() => {
// visit base url
cy.visit(Cypress.config().baseUrl, { timeout: 10000 });
cy.deleteAllIndices();
// Use API-based sample data loading to bypass modal popups on tutorial page
cy.loadSampleData('ecommerce');
cy.loadSampleData('flights');
cy.loadSampleData('logs');
cy.wait(10000);
});
after(() => {
// Remove sample data via API
cy.request({
method: 'DELETE',
headers: { 'osd-xsrf': 'opensearch-dashboards' },
url: `${BASE_PATH}/api/sample_data/ecommerce`,
failOnStatusCode: false,
});
cy.request({
method: 'DELETE',
headers: { 'osd-xsrf': 'opensearch-dashboards' },
url: `${BASE_PATH}/api/sample_data/flights`,
failOnStatusCode: false,
});
cy.request({
method: 'DELETE',
headers: { 'osd-xsrf': 'opensearch-dashboards' },
url: `${BASE_PATH}/api/sample_data/logs`,
failOnStatusCode: false,
});
});
it('Should get comparison results', () => {
// Navigate directly to single query comparison page
cy.visit(
`${BASE_PATH}/app/${SEARCH_RELEVANCE_PLUGIN_NAME}#/experiment/create/queryAnalysis`
);
cy.wait(5000);
// Type search text in search box
cy.get('input[type="search"]', { timeout: 30000 }).type(
SAMPLE_SEARCH_TEXT,
{
force: true,
}
);
// Select index 1
cy.get('div.search-relevance-config:nth-child(1) select').select(
SAMPLE_INDEX
);
// Select index 2
cy.get('div.search-relevance-config:nth-child(2) select').select(
SAMPLE_INDEX
);
// Type query 1
cy.get(
'div.search-relevance-config:nth-child(1) div[data-test-subj="codeEditorContainer"]'
).type(SAMPLE_QUERY_TEXT, {
parseSpecialCharSequences: false,
});
// Type query 2
cy.get(
'div.search-relevance-config:nth-child(2) div[data-test-subj="codeEditorContainer"]'
).type(SAMPLE_QUERY_TEXT, {
parseSpecialCharSequences: false,
});
// Click search button
cy.get('button[aria-label="searchRelevance-searchButton"]').click({
force: true,
});
// Confirm get results on both result panel
cy.get(
'.search-relevance-result-panel:nth-child(1) > div > div:nth-child(2) > h2'
).should('not.equal', NO_RESULTS);
cy.get(
'.search-relevance-result-panel:nth-child(2) > div > div:nth-child(2) > h2'
).should('not.equal', NO_RESULTS);
});
});