|
1 | | -/* |
2 | | - * Copyright OpenSearch Contributors |
3 | | - * SPDX-License-Identifier: Apache-2.0 |
4 | | - */ |
5 | | - |
6 | | -import { BASE_PATH } from '../../../utils/constants'; |
7 | | -import sampleQueryLevelMonitorForAlertSummary from '../../../fixtures/plugins/alerting-dashboards-plugin/sample_query_level_monitor_for_alert_summary.json'; |
8 | 1 | import { ADMIN_AUTH } from '../../../utils/commands'; |
9 | | -import workspaceTestUser from '../../../fixtures/dashboard/opensearch_dashboards/workspace/workspaceTestUser.json'; |
10 | | -import workspaceTestRole from '../../../fixtures/dashboard/opensearch_dashboards/workspace/workspaceTestRole.json'; |
11 | | - |
12 | | -const workspaceName = `test_workspace_${Math.random() |
13 | | - .toString(36) |
14 | | - .substring(7)}`; |
15 | | - |
16 | | -const toggleOnAIFeature = () => { |
17 | | - cy.getElementByTestId('advancedSetting-resetField-enableAIFeatures').click(); |
18 | | - cy.getElementByTestId('advancedSetting-editField-enableAIFeatures').should( |
19 | | - 'have.attr', |
20 | | - 'aria-checked', |
21 | | - 'true' |
22 | | - ); |
23 | | - cy.getElementByTestId('advancedSetting-saveButton') |
24 | | - .should('be.visible') |
25 | | - .click(); |
26 | | -}; |
27 | | - |
28 | | -const toggleOffAIFeature = () => { |
29 | | - cy.getElementByTestId('advancedSetting-editField-enableAIFeatures').click(); |
30 | | - cy.getElementByTestId('advancedSetting-editField-enableAIFeatures').should( |
31 | | - 'have.attr', |
32 | | - 'aria-checked', |
33 | | - 'false' |
34 | | - ); |
35 | | - cy.getElementByTestId('advancedSetting-saveButton') |
36 | | - .should('be.visible') |
37 | | - .click(); |
38 | | -}; |
39 | | - |
40 | | -function dashboardsAssistantFeatureFlagTestCases() { |
41 | | - describe('Dashboards assistant feature flag', () => { |
42 | | - let workspaceId; |
43 | | - let dataSourceId; |
44 | | - before(() => { |
45 | | - cy.createDataSourceNoAuth().then((result) => { |
46 | | - dataSourceId = result[0]; |
47 | | - cy.createWorkspace({ |
48 | | - name: workspaceName, |
49 | | - description: 'Workspace for cypress testing', |
50 | | - features: ['use-case-all'], |
51 | | - settings: { |
52 | | - permissions: { |
53 | | - library_write: { users: ['%me%'] }, |
54 | | - write: { users: ['%me%'] }, |
55 | | - }, |
56 | | - dataSources: [dataSourceId], |
57 | | - }, |
58 | | - }) |
59 | | - .then((wsId) => { |
60 | | - workspaceId = wsId; |
61 | | - }) |
62 | | - .then(() => |
63 | | - cy.loadSampleDataForWorkspace( |
64 | | - 'ecommerce', |
65 | | - workspaceId, |
66 | | - dataSourceId |
67 | | - ) |
68 | | - ); |
69 | | - }); |
70 | | - }); |
71 | | - |
72 | | - after(() => { |
73 | | - if (workspaceId) { |
74 | | - if (dataSourceId) { |
75 | | - cy.removeSampleDataForWorkspace( |
76 | | - 'ecommerce', |
77 | | - workspaceId, |
78 | | - dataSourceId |
79 | | - ); |
80 | | - } |
81 | | - cy.deleteWorkspaceById(workspaceId); |
82 | | - } |
83 | | - if (dataSourceId) { |
84 | | - cy.deleteDataSource(dataSourceId); |
85 | | - } |
86 | | - }); |
87 | | - |
88 | | - describe('AI feature flag enabled', () => { |
89 | | - it('AI feature flag toggle on advanced settings page should be enabled', () => { |
90 | | - cy.visit(`${BASE_PATH}/app/settings`); |
91 | | - |
92 | | - cy.getElementByTestId( |
93 | | - 'advancedSetting-editField-enableAIFeatures' |
94 | | - ).then(($el) => { |
95 | | - if ($el.attr('aria-checked') === 'false') { |
96 | | - toggleOnAIFeature(); |
97 | | - } else { |
98 | | - cy.getElementByTestId( |
99 | | - 'advancedSetting-resetField-enableAIFeatures' |
100 | | - ).should('not.exist'); |
101 | | - } |
102 | | - }); |
103 | | - }); |
104 | | - |
105 | | - it('Data2summary and suggested AD should be available on the discover', () => { |
106 | | - cy.visit(`w/${workspaceId}/app/discover`); |
107 | | - |
108 | | - cy.get('.languageSelector__button').should('be.visible').click(); |
109 | | - cy.contains('button', 'PPL').should('be.visible').click(); |
110 | | - cy.getElementByTestId('languageReferenceButton') |
111 | | - .should('be.visible') |
112 | | - .click(); |
113 | | - cy.getElementByTestId('queryAssist__summary').should('be.visible'); |
114 | | - |
115 | | - cy.get('button[aria-label="OpenSearch assistant trigger button', { |
116 | | - timeout: 60000, |
117 | | - }).click(); |
118 | | - cy.contains('Suggest anomaly detector').click(); |
119 | | - cy.get('.add-anomaly-detector').should('be.visible'); |
120 | | - }); |
121 | | - |
122 | | - it('Chatbot should be available on the overview page', () => { |
123 | | - cy.visit(`w/${workspaceId}/app/all_overview`); |
124 | | - |
125 | | - cy.openAssistantChatbot(); |
126 | | - }); |
127 | | - |
128 | | - it('Alert summary should be available on the alert', () => { |
129 | | - const dataSourceUrl = Cypress.env('remoteDataSourceBasicAuthUrl'); |
130 | | - cy.createMonitor(sampleQueryLevelMonitorForAlertSummary, dataSourceUrl); |
131 | | - |
132 | | - cy.wait(80000); |
133 | | - |
134 | | - cy.visit(`w/${workspaceId}/app/alerts`); |
135 | | - cy.get('.incontextInsightAnchorIcon', { timeout: 60000 }).should( |
136 | | - 'be.visible' |
137 | | - ); |
138 | | - |
139 | | - cy.deleteAllAlerts(dataSourceUrl); |
140 | | - cy.deleteAllMonitors(dataSourceUrl); |
141 | | - }); |
142 | | - }); |
143 | | - |
144 | | - describe('AI feature flag disabled', () => { |
145 | | - after(() => { |
146 | | - cy.visit(`${BASE_PATH}/app/settings`); |
147 | | - |
148 | | - cy.reload(); |
149 | | - |
150 | | - cy.getElementByTestId('advancedSetting-editField-enableAIFeatures') |
151 | | - .should('exist') |
152 | | - .and('be.visible') |
153 | | - .click(); |
154 | | - cy.getElementByTestId('advancedSetting-saveButton') |
155 | | - .should('be.visible') |
156 | | - .click(); |
157 | | - }); |
158 | | - |
159 | | - it('AI feature flag on advanced settings page can be toggle off', () => { |
160 | | - cy.visit(`${BASE_PATH}/app/settings`); |
161 | | - |
162 | | - cy.contains('Enable AI features'); |
163 | | - cy.getElementByTestId( |
164 | | - 'advancedSetting-editField-enableAIFeatures' |
165 | | - ).then(($el) => { |
166 | | - if ($el.attr('aria-checked') === 'true') { |
167 | | - toggleOffAIFeature(); |
168 | | - } else { |
169 | | - cy.getElementByTestId( |
170 | | - 'advancedSetting-resetField-enableAIFeatures' |
171 | | - ).should('be.visible'); |
172 | | - } |
173 | | - }); |
174 | | - cy.getElementByTestId( |
175 | | - 'advancedSetting-resetField-enableAIFeatures' |
176 | | - ).should('be.visible'); |
177 | | - }); |
178 | 2 |
|
179 | | - it('Data2summary and suggested AD should be unavailable on the discover', () => { |
180 | | - cy.visit(`w/${workspaceId}/app/discover`); |
181 | 3 |
|
182 | | - cy.get('.languageSelector__button').should('be.visible').click(); |
183 | | - cy.contains('button', 'PPL').should('be.visible').click(); |
184 | | - cy.getElementByTestId('languageReferenceButton') |
185 | | - .should('be.visible') |
186 | | - .click(); |
187 | | - |
188 | | - cy.getElementByTestId('queryAssist__summary').should('not.exist'); |
189 | | - cy.get('button[aria-label="OpenSearch assistant trigger button').should( |
190 | | - 'not.exist' |
191 | | - ); |
192 | | - }); |
193 | | - |
194 | | - it('Chatbot should be unavailable on the overview page', () => { |
195 | | - cy.visit(`w/${workspaceId}/app/all_overview`); |
196 | | - |
197 | | - cy.get('button[aria-label="toggle chat flyout icon').should( |
198 | | - 'not.exist' |
199 | | - ); |
200 | | - }); |
201 | | - |
202 | | - it('Alert summary should be unavailable on the alert', () => { |
203 | | - const dataSourceUrl = Cypress.env('remoteDataSourceBasicAuthUrl'); |
204 | | - cy.createMonitor(sampleQueryLevelMonitorForAlertSummary); |
205 | | - |
206 | | - cy.wait(80000); |
207 | | - |
208 | | - cy.visit(`w/${workspaceId}/app/alerts`); |
209 | | - cy.get('.euiTableRow').should('exist').and('be.visible'); |
210 | | - cy.get('.incontextInsightAnchorIcon').should('not.exist'); |
211 | | - |
212 | | - cy.deleteAllAlerts(dataSourceUrl); |
213 | | - cy.deleteAllMonitors(dataSourceUrl); |
214 | | - }); |
215 | | - }); |
| 4 | +describe('Workflow Test', () => { |
| 5 | + beforeEach(() => { |
| 6 | + // This runs before each test case |
| 7 | + // Common setup like visiting your application URL |
| 8 | + cy.visit('/'); // Replace with your application's URL |
216 | 9 | }); |
217 | | -} |
218 | | - |
219 | | -function dashboardAdminUiSettingsTestCases() { |
220 | | - describe('Dashboard admin UI settings', () => { |
221 | | - describe('Dashboard amin user', () => { |
222 | | - it('can toggle AI feature flag', () => { |
223 | | - cy.visit(`${BASE_PATH}/app/settings`); |
224 | | - |
225 | | - cy.contains('Enable AI features'); |
226 | | - |
227 | | - cy.getElementByTestId( |
228 | | - 'advancedSetting-editField-enableAIFeatures' |
229 | | - ).then(($el) => { |
230 | | - if ($el.attr('aria-checked') === 'false') { |
231 | | - toggleOnAIFeature(); |
232 | | - |
233 | | - cy.reload(); |
234 | | - } |
235 | | - toggleOffAIFeature(); |
236 | | - }); |
237 | | - }); |
238 | 10 |
|
239 | | - it('can delete dashboard admin settings saved object', () => { |
240 | | - cy.visit(`${BASE_PATH}/app/objects`); |
| 11 | + it('should complete the basic workflow', () => { |
| 12 | + // Your test steps will go here |
| 13 | + // This is an empty test that will pass |
| 14 | + cy.log('Starting workflow test' + ADMIN_AUTH.username); |
241 | 15 |
|
242 | | - cy.getElementByTestId('savedObjectsTableRow row-_dashboard_admin') |
243 | | - .contains('_dashboard_admin') |
244 | | - .getElementByTestId('checkboxSelectRow-_dashboard_admin') |
245 | | - .click(); |
| 16 | + // Example placeholder steps (commented out) |
| 17 | + // cy.get('#username').type('testuser'); |
| 18 | + // cy.get('#password').type('password123'); |
| 19 | + // cy.get('#login-button').click(); |
246 | 20 |
|
247 | | - cy.getElementByTestId('savedObjectsManagementDelete') |
248 | | - .should('exist') |
249 | | - .click(); |
250 | | - cy.getElementByTestId('confirmModalConfirmButton') |
251 | | - .should('exist') |
252 | | - .click(); |
253 | | - |
254 | | - cy.visit(`${BASE_PATH}/app/settings`); |
255 | | - }); |
256 | | - }); |
257 | | - |
258 | | - describe('Non-dashboard admin user', () => { |
259 | | - const NONE_DASHBOARDS_ADMIN_USERNAME = 'workspace-test'; |
260 | | - const WORKSPACE_TEST_ROLE_NAME = 'workspace-test-role'; |
261 | | - const originalUser = ADMIN_AUTH.username; |
262 | | - const originalPassword = ADMIN_AUTH.password; |
263 | | - |
264 | | - before(() => { |
265 | | - cy.createInternalUser( |
266 | | - NONE_DASHBOARDS_ADMIN_USERNAME, |
267 | | - workspaceTestUser |
268 | | - ); |
269 | | - cy.createRole(WORKSPACE_TEST_ROLE_NAME, workspaceTestRole); |
270 | | - cy.createRoleMapping(WORKSPACE_TEST_ROLE_NAME, { |
271 | | - users: [NONE_DASHBOARDS_ADMIN_USERNAME], |
272 | | - }); |
273 | | - }); |
274 | | - |
275 | | - beforeEach(() => { |
276 | | - // Login as non OSD admin user |
277 | | - ADMIN_AUTH.newUser = NONE_DASHBOARDS_ADMIN_USERNAME; |
278 | | - ADMIN_AUTH.newPassword = workspaceTestUser.password; |
279 | | - }); |
280 | | - |
281 | | - after(() => { |
282 | | - ADMIN_AUTH.newUser = originalUser; |
283 | | - ADMIN_AUTH.newPassword = originalPassword; |
284 | | - cy.deleteRoleMapping(WORKSPACE_TEST_ROLE_NAME); |
285 | | - cy.deleteInternalUser(NONE_DASHBOARDS_ADMIN_USERNAME); |
286 | | - cy.deleteRole(WORKSPACE_TEST_ROLE_NAME); |
287 | | - }); |
288 | | - |
289 | | - it('cannot toggle AI feature flag', () => { |
290 | | - cy.visit(`${BASE_PATH}/app/settings`); |
291 | | - |
292 | | - cy.contains('Enable AI features'); |
293 | | - cy.getElementByTestId( |
294 | | - 'advancedSetting-editField-enableAIFeatures' |
295 | | - ).should('be.disabled'); |
296 | | - }); |
297 | | - |
298 | | - it('cannot see admin settings saved object in assets page', () => { |
299 | | - cy.visit(`${BASE_PATH}/app/objects`); |
300 | | - |
301 | | - cy.getElementByTestId('savedObjectsTable').within(() => { |
302 | | - cy.get('.euiTableRow').should('be.visible'); |
303 | | - cy.contains('_dashboard_admin').should('not.exist'); |
304 | | - }); |
305 | | - }); |
306 | | - }); |
| 21 | + cy.log('Workflow test completed'); |
307 | 22 | }); |
308 | | -} |
309 | 23 |
|
310 | | -if (Cypress.env('DASHBOARDS_ASSISTANT_ENABLED')) { |
311 | | - dashboardsAssistantFeatureFlagTestCases(); |
312 | | - |
313 | | - if (Cypress.env('SECURITY_ENABLED')) { |
314 | | - dashboardAdminUiSettingsTestCases(); |
315 | | - } |
316 | | -} |
| 24 | + // You can add more test cases within this describe block |
| 25 | + it('should handle edge case in workflow', () => { |
| 26 | + cy.log('Testing edge case'); |
| 27 | + // Add your test steps for edge cases |
| 28 | + }); |
| 29 | +}); |
0 commit comments