|
| 1 | +/* |
| 2 | + * Copyright OpenSearch Contributors |
| 3 | + * SPDX-License-Identifier: Apache-2.0 |
| 4 | + */ |
| 5 | + |
| 6 | +import { MiscUtils } from '@opensearch-dashboards-test/opensearch-dashboards-test-library'; |
| 7 | + |
| 8 | +const miscUtils = new MiscUtils(cy); |
| 9 | +const workspaceName = `test_workspace_search_${Math.random() |
| 10 | + .toString(36) |
| 11 | + .substring(7)}`; |
| 12 | +let workspaceId; |
| 13 | +let datasourceId; |
| 14 | + |
| 15 | +if (Cypress.env('WORKSPACE_ENABLED')) { |
| 16 | + const createWorkspace = (datasourceId) => { |
| 17 | + cy.createWorkspace({ |
| 18 | + name: workspaceName, |
| 19 | + features: ['use-case-search'], |
| 20 | + settings: { |
| 21 | + permissions: { |
| 22 | + library_write: { users: ['%me%'] }, |
| 23 | + write: { users: ['%me%'] }, |
| 24 | + }, |
| 25 | + ...(datasourceId ? { dataSources: [datasourceId] } : {}), |
| 26 | + }, |
| 27 | + }).then((value) => { |
| 28 | + workspaceId = value; |
| 29 | + }); |
| 30 | + }; |
| 31 | + |
| 32 | + describe('Search card', () => { |
| 33 | + before(() => { |
| 34 | + cy.deleteWorkspaceByName(workspaceName); |
| 35 | + if (Cypress.env('DATASOURCE_MANAGEMENT_ENABLED')) { |
| 36 | + cy.deleteAllDataSources(); |
| 37 | + cy.createDataSourceNoAuth().then((result) => { |
| 38 | + datasourceId = result[0]; |
| 39 | + expect(datasourceId).to.be.a('string').that.is.not.empty; |
| 40 | + createWorkspace(datasourceId); |
| 41 | + }); |
| 42 | + } else { |
| 43 | + createWorkspace(); |
| 44 | + } |
| 45 | + }); |
| 46 | + |
| 47 | + after(() => { |
| 48 | + if (workspaceId) { |
| 49 | + cy.deleteWorkspaceById(workspaceId); |
| 50 | + } |
| 51 | + cy.deleteAllDataSources(); |
| 52 | + }); |
| 53 | + |
| 54 | + beforeEach(() => { |
| 55 | + // Visit workspace overview page |
| 56 | + miscUtils.visitPage(`w/${workspaceId}/app/search_overview`); |
| 57 | + // wait for page load |
| 58 | + cy.contains('h1', 'Overview'); |
| 59 | + }); |
| 60 | + |
| 61 | + it('Configure and evaluate search cards should display correctly', () => { |
| 62 | + cy.contains('Compare search results').should('be.visible').click(); |
| 63 | + cy.url().should('contains', 'app/searchRelevance'); |
| 64 | + }); |
| 65 | + }); |
| 66 | +} |
0 commit comments