-
Notifications
You must be signed in to change notification settings - Fork 142
Expand file tree
/
Copy path6_experiment_creation.spec.js
More file actions
229 lines (190 loc) · 8.18 KB
/
Copy path6_experiment_creation.spec.js
File metadata and controls
229 lines (190 loc) · 8.18 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/
/// <reference types="cypress" />
import { SEARCH_RELEVANCE_PLUGIN_NAME } from '../../../utils/plugins/search-relevance-dashboards/constants';
import { BASE_PATH } from '../../../utils/base_constants';
import {
initializeUbiIndices,
enableWorkbenchUI,
prepareSampleIndex,
} from '../../../utils/plugins/search-relevance-dashboards/common-setup';
describe('Experiment Create', () => {
before(() => {
cy.visit(Cypress.config().baseUrl, { timeout: 10000 });
// Initialize UBI indices required for tests
initializeUbiIndices();
// Enable the search relevance workbench UI
enableWorkbenchUI();
prepareSampleIndex();
// Generate unique names with timestamp
const timestamp = new Date().getTime();
const querySetName = `QS_Test_${timestamp}`;
const configName1 = `Config1_${timestamp}`;
const configName2 = `Config2_${timestamp}`;
const judgmentName = `UBI_Judgment_${timestamp}`;
// Store names in Cypress environment variables for later use
Cypress.env('querySetName', querySetName);
Cypress.env('configName1', configName1);
Cypress.env('configName2', configName2);
Cypress.env('judgmentName', judgmentName);
// Create a query set for testing
cy.visit(
`${BASE_PATH}/app/${SEARCH_RELEVANCE_PLUGIN_NAME}#/querySet/create`
);
cy.wait(3000);
// Use textarea selector with longer timeout
cy.get('[data-test-subj="querySetDescriptionInput"]')
.first()
.focus()
.type(querySetName);
cy.get('[data-test-subj="querySetDescriptionInput"]')
.last()
.focus()
.type('Test Query Set Description');
cy.get('[data-test-subj="querySetSamplingSelect"]').select('random');
cy.get('[data-test-subj="createQuerySetButton"]').click();
cy.contains(`Query set "${querySetName}" created successfully`, {
timeout: 10000,
});
// Create first search configuration for testing
cy.visit(
`${BASE_PATH}/app/${SEARCH_RELEVANCE_PLUGIN_NAME}#/searchConfiguration/create`
);
cy.wait(3000);
cy.get('[data-test-subj="searchConfigurationNameInput"]').type(configName1);
cy.get('[data-test-subj="codeEditorContainer"]').click();
cy.get('.ace_text-input').type('{ "query": { "match_all": {} } }', {
parseSpecialCharSequences: false,
});
cy.get('[data-test-subj="comboBoxInput"]').first().click();
cy.contains('.euiComboBoxOption__content', '00sample_index').click();
cy.get('[data-test-subj="createSearchConfigurationButton"]').click();
cy.contains(`Search configuration "${configName1}" created successfully`, {
timeout: 10000,
});
// Create second search configuration
cy.visit(
`${BASE_PATH}/app/${SEARCH_RELEVANCE_PLUGIN_NAME}#/searchConfiguration/create`
);
cy.wait(3000);
cy.get('[data-test-subj="searchConfigurationNameInput"]').type(configName2);
cy.get('[data-test-subj="codeEditorContainer"]').click();
cy.get('.ace_text-input').type('{ "query": { "match_all": {} } }', {
parseSpecialCharSequences: false,
});
cy.get('[data-test-subj="comboBoxInput"]').first().click();
cy.contains('.euiComboBoxOption__content', '00sample_index').click();
cy.get('[data-test-subj="createSearchConfigurationButton"]').click();
cy.contains(`Search configuration "${configName2}" created successfully`, {
timeout: 10000,
});
// Create a judgment for testing
cy.visit(
`${BASE_PATH}/app/${SEARCH_RELEVANCE_PLUGIN_NAME}#/judgment/create`
);
cy.wait(3000);
cy.get('input[name="name"]').type(judgmentName);
cy.get('select').first().select('UBI_JUDGMENT');
cy.get('select').eq(1).select('coec');
cy.get('input[type="number"]').clear().type('20');
cy.get('[data-test-subj="createJudgmentButton"]').click();
cy.contains(`Judgment created successfully`, { timeout: 10000 });
});
beforeEach(() => {
cy.visit(`${BASE_PATH}/app/${SEARCH_RELEVANCE_PLUGIN_NAME}`);
cy.wait(2000);
});
it('Should display all four experiment template cards', () => {
// Check that there are exactly 4 cards
cy.get('.euiCard').should('have.length', 4);
// Verify each card's title
cy.contains('.euiCard', 'Query Analysis').should('exist');
cy.contains('.euiCard', 'Query Set Comparison').should('exist');
cy.contains('.euiCard', 'Search Evaluation').should('exist');
cy.contains('.euiCard', 'Hybrid Search Optimizer').should('exist');
});
it('Should display correct descriptions for each card', () => {
// Verify card descriptions
cy.contains('Run and analyze a single query').should('exist');
cy.contains('Perform a comparison across an entire set of queries').should(
'exist'
);
cy.contains('Calculate search quality metrics').should('exist');
cy.contains(
'Find the best balance between neural and lexical hybrid search'
).should('exist');
});
it('Should display beaker icons for all cards', () => {
// Check that all cards have the beaker icon
cy.get('.euiCard .euiIcon').should('have.length', 4);
});
it('Should navigate to correct routes when clicked', () => {
// Click Single Query Comparison card and verify navigation
cy.contains('.euiCard', 'Query Analysis').click();
cy.url().should('include', '/experiment/create/queryAnalysis');
// Navigate back and test other cards
cy.go('back');
cy.contains('.euiCard', 'Query Set Comparison').click();
cy.url().should('include', '/experiment/create/querySetComparison');
cy.go('back');
cy.contains('.euiCard', 'Search Evaluation').click();
cy.url().should('include', '/experiment/create/searchEvaluation');
cy.go('back');
cy.contains('.euiCard', 'Hybrid Search Optimizer').click();
cy.url().should('include', '/experiment/create/hybridOptimizer');
});
it('Should create a query set comparison experiment', () => {
// Get stored resource names from environment variables
const querySetName = Cypress.env('querySetName');
const configName1 = Cypress.env('configName1');
const configName2 = Cypress.env('configName2');
// Navigate to query set comparison page
cy.visit(
`${BASE_PATH}/app/${SEARCH_RELEVANCE_PLUGIN_NAME}#/experiment/create/querySetComparison`
);
cy.wait(3000);
// Select query set from dropdown
cy.get('[data-test-subj="comboBoxInput"]').first().click();
cy.contains('.euiComboBoxOption__content', querySetName).click();
// Select search configurations
cy.get('[data-test-subj="comboBoxInput"]').eq(1).click();
cy.contains('.euiComboBoxOption__content', configName1).click();
cy.get('[data-test-subj="comboBoxInput"]').eq(1).click();
cy.contains('.euiComboBoxOption__content', configName2).click();
// Click start evaluation button
cy.contains('button', 'Start Evaluation').click();
// Verify success
cy.contains('created successfully', { timeout: 10000 });
});
it('Should create a search evaluation experiment', () => {
// Get stored resource names from environment variables
const querySetName = Cypress.env('querySetName');
const configName1 = Cypress.env('configName1');
const judgmentName = Cypress.env('judgmentName');
// Navigate to search evaluation page
cy.visit(
`${BASE_PATH}/app/${SEARCH_RELEVANCE_PLUGIN_NAME}#/experiment/create/searchEvaluation`
);
cy.wait(3000);
// Select query set from dropdown
cy.get('[data-test-subj="comboBoxInput"]').first().click();
cy.wait(500);
cy.contains('.euiComboBoxOption__content', querySetName).click();
// Select search configuration
cy.get('[data-test-subj="comboBoxInput"]').eq(1).click();
cy.wait(500);
cy.contains('.euiComboBoxOption__content', configName1).click();
cy.get('h2').first().click(); // Click on a blank area to close dropdown
cy.wait(500); // Wait for dropdown to close
// Select judgment
cy.get('[data-test-subj="comboBoxInput"]').eq(2).click();
cy.wait(500);
cy.contains('.euiComboBoxOption__content', judgmentName).click();
// Click start evaluation button
cy.contains('button', 'Start Evaluation').click();
// Verify success
cy.contains('created successfully', { timeout: 10000 });
});
});