Skip to content

Commit

Permalink
Fix workspace detail failed
Browse files Browse the repository at this point in the history
Signed-off-by: Lin Wang <wonglam@amazon.com>
  • Loading branch information
wanglam committed Sep 9, 2024
1 parent 09d2c3c commit 7435ee6
Showing 1 changed file with 70 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@
*/

import { MiscUtils } from '@opensearch-dashboards-test/opensearch-dashboards-test-library';

const MDSEnabled = Cypress.env('DATASOURCE_MANAGEMENT_ENABLED');
const miscUtils = new MiscUtils(cy);
const workspaceName = 'test_workspace_320sdfouAz';
let workspaceDescription = 'This is a workspace description.';
let workspaceId;
let workspaceFeatures = ['use-case-observability'];

if (Cypress.env('WORKSPACE_ENABLED')) {
describe('Workspace detail', () => {
Expand All @@ -16,7 +19,7 @@ if (Cypress.env('WORKSPACE_ENABLED')) {
cy.createWorkspace({
name: workspaceName,
description: workspaceDescription,
features: ['workspace_detail', 'use-case-observability'],
features: workspaceFeatures,
settings: {
permissions: {
library_write: { users: ['%me%'] },
Expand All @@ -41,17 +44,20 @@ if (Cypress.env('WORKSPACE_ENABLED')) {

it('should successfully load the page', () => {
cy.contains(workspaceName, { timeout: 60000 }).should('be.visible');
cy.contains('Overview', { timeout: 60000 }).should('be.visible');
cy.contains('Settings', { timeout: 60000 }).should('be.visible');
cy.contains('Details', { timeout: 60000 }).should('be.visible');
if (MDSEnabled) {
cy.contains('Data sources', { timeout: 60000 }).should('be.visible');
}

if (Cypress.env('SAVED_OBJECTS_PERMISSION_ENABLED')) {
cy.contains('Collaborators', { timeout: 60000 }).should('be.visible');
}
});

describe('settings tab', () => {
describe('Details tab', () => {
beforeEach(() => {
cy.contains('Settings').click();
cy.contains('Details').click();
cy.getElementByTestId('workspaceForm-workspaceDetails-edit').click();
});

describe('Validate workspace name and description', () => {
Expand Down Expand Up @@ -121,9 +127,16 @@ if (Cypress.env('WORKSPACE_ENABLED')) {
cy.getElementByTestId(
'euiColorPickerAnchor workspaceForm-workspaceDetails-colorPicker'
).type('#D36086');
cy.getElementByTestId('workspaceUseCase-observability').click({
force: true,
});
cy.get('button.euiSuperSelectControl')
.contains('Observability')
.click({
force: true,
});
cy.get('button.euiSuperSelect__item')
.contains('Analytics (All)')
.click({
force: true,
});
cy.getElementByTestId('workspaceForm-bottomBar-updateButton').click({
force: true,
});
Expand All @@ -137,9 +150,11 @@ if (Cypress.env('WORKSPACE_ENABLED')) {
const expectedWorkspace = {
name: workspaceName,
description: 'test_workspace_description.+~!',
features: ['workspace_detail', 'use-case-observability'],
features: ['use-case-all'],
};
cy.checkWorkspace(workspaceId, expectedWorkspace);
// Update features after updated
workspaceFeatures = expectedWorkspace.features;
});
});
});
Expand All @@ -148,48 +163,54 @@ if (Cypress.env('WORKSPACE_ENABLED')) {
Cypress.env('SAVED_OBJECTS_PERMISSION_ENABLED') &&
Cypress.env('SECURITY_ENABLED')
) {
describe('Update a workspace with permissions successfully', () => {
beforeEach(() => {
cy.contains('Collaborators').click();
});
it('should successfully update a workspace with permissions', () => {
cy.getElementByTestId(
'workspaceForm-permissionSettingPanel-user-addNew'
).click();
cy.contains('.euiComboBoxPlaceholder', 'Select a user')
.parent()
.find('input')
.type('test_user_Fnxs972xC');
cy.getElementByTestId('workspaceForm-bottomBar-updateButton').click({
force: true,
});
cy.wait('@updateWorkspaceRequest').then((interception) => {
expect(interception.response.statusCode).to.equal(200);
describe('Collaborators tab', () => {
describe('Update a workspace with permissions successfully', () => {
beforeEach(() => {
cy.contains('Collaborators').click();
cy.getElementByTestId(
'workspaceForm-workspaceDetails-edit'
).click();
});
cy.location('pathname', { timeout: 6000 }).should(
'include',
'app/workspace_detail'
);
const expectedWorkspace = {
name: workspaceName,
description: workspaceDescription,
features: ['workspace_detail', 'use-case-observability'],
permissions: {
read: {
users: ['test_user_Fnxs972xC'],
},
library_read: {
users: ['test_user_Fnxs972xC'],
it('should successfully update a workspace with permissions', () => {
cy.getElementByTestId(
'workspaceForm-permissionSettingPanel-addNew'
).click();
cy.getElementByTestId('workspaceFormUserIdOrGroupInput')
.last()
.type('test_user_Fnxs972xC');
cy.getElementByTestId('workspaceForm-bottomBar-updateButton').click(
{
force: true,
}
);
cy.wait('@updateWorkspaceRequest').then((interception) => {
expect(interception.response.statusCode).to.equal(200);
});
cy.location('pathname', { timeout: 6000 }).should(
'include',
'app/workspace_detail'
);
const expectedWorkspace = {
name: workspaceName,
description: workspaceDescription,
features: workspaceFeatures,
permissions: {
read: {
users: ['test_user_Fnxs972xC'],
},
library_read: {
users: ['test_user_Fnxs972xC'],
},
write: {
users: [`${Cypress.env('username')}`],
},
library_write: {
users: [`${Cypress.env('username')}`],
},
},
write: {
users: [`${Cypress.env('username')}`],
},
library_write: {
users: [`${Cypress.env('username')}`],
},
},
};
cy.checkWorkspace(workspaceId, expectedWorkspace);
};
cy.checkWorkspace(workspaceId, expectedWorkspace);
});
});
});
}
Expand Down

0 comments on commit 7435ee6

Please sign in to comment.