Skip to content

Commit

Permalink
Merge branch '2.16' into fix-security-notifs
Browse files Browse the repository at this point in the history
  • Loading branch information
riysaxen-amzn authored Aug 2, 2024
2 parents 91f9676 + e046bf9 commit dbb754f
Show file tree
Hide file tree
Showing 16 changed files with 279 additions and 591 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ describe('index pattern without field spec', () => {
testFixtureHandler.clearJSONMapping(
'cypress/fixtures/dashboard/opensearch_dashboards/data_explorer/index_pattern_without_timefield/mappings.json.txt'
);
cy.deleteSavedObjectByType('index-pattern');
});

it('should not display a timepicker', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ if (Cypress.env('WORKSPACE_ENABLED')) {
cy.getElementByTestId(
'euiColorPickerAnchor workspaceForm-workspaceDetails-colorPicker'
).type('#000000');
cy.getElementByTestId('workspaceUseCase-observability').check({
cy.getElementByTestId('workspaceUseCase-observability').click({
force: true,
});
cy.getElementByTestId('workspaceForm-bottomBar-createButton').click({
Expand All @@ -52,17 +52,13 @@ if (Cypress.env('WORKSPACE_ENABLED')) {

cy.location('pathname', { timeout: 6000 }).should(
'include',
'app/workspace_overview'
'app/workspace_detail'
);

const expectedWorkspace = {
name: workspaceName,
description: 'test_workspace_description.+~!',
features: [
'workspace_update',
'workspace_overview',
'use-case-observability',
],
features: ['workspace_detail', 'use-case-observability'],
};
cy.checkWorkspace(workspaceId, expectedWorkspace);
});
Expand All @@ -77,7 +73,7 @@ if (Cypress.env('WORKSPACE_ENABLED')) {
cy.getElementByTestId('workspaceForm-bottomBar-createButton').click({
force: true,
});
cy.contains("Name can't be empty").should('exist');
cy.contains('Name is required. Enter a name.').should('exist');
});

it('workspace name is not valid', () => {
Expand All @@ -90,7 +86,7 @@ if (Cypress.env('WORKSPACE_ENABLED')) {
cy.getElementByTestId('workspaceForm-bottomBar-createButton').click({
force: true,
});
cy.contains('Invalid workspace name').should('exist');
cy.contains('Name is invalid. Enter a valid name.').should('exist');
});

it('workspace name cannot use an existing name', () => {
Expand All @@ -100,7 +96,7 @@ if (Cypress.env('WORKSPACE_ENABLED')) {
cy.getElementByTestId(
'workspaceForm-workspaceDetails-descriptionInputText'
).type('test_workspace_description');
cy.getElementByTestId('workspaceUseCase-observability').check({
cy.getElementByTestId('workspaceUseCase-observability').click({
force: true,
});
cy.getElementByTestId('workspaceForm-bottomBar-createButton').click({
Expand Down Expand Up @@ -139,14 +135,15 @@ if (Cypress.env('WORKSPACE_ENABLED')) {
cy.getElementByTestId(
'euiColorPickerAnchor workspaceForm-workspaceDetails-colorPicker'
).type('#000000');
cy.getElementByTestId('workspaceUseCase-observability').check({
cy.getElementByTestId('workspaceUseCase-observability').click({
force: true,
});
cy.getElementByTestId(
'workspaceForm-permissionSettingPanel-user-addNew'
).click();
cy.getElementByTestId('comboBoxSearchInput')
.last()
cy.contains('.euiComboBoxPlaceholder', 'Select a user')
.parent()
.find('input')
.type('test_user_sfslja260');
cy.getElementByTestId('workspaceForm-bottomBar-createButton').click({
force: true,
Expand All @@ -158,16 +155,12 @@ if (Cypress.env('WORKSPACE_ENABLED')) {
workspaceId = interception.response.body.result.id;
cy.location('pathname', { timeout: 6000 }).should(
'include',
'app/workspace_overview'
'app/workspace_detail'
);
const expectedWorkspace = {
name: workspaceName,
description: 'test_workspace_description',
features: [
'workspace_update',
'workspace_overview',
'use-case-observability',
],
features: ['workspace_detail', 'use-case-observability'],
permissions: {
read: {
users: ['test_user_sfslja260'],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,197 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import { MiscUtils } from '@opensearch-dashboards-test/opensearch-dashboards-test-library';
const miscUtils = new MiscUtils(cy);
const workspaceName = 'test_workspace_320sdfouAz';
let workspaceDescription = 'This is a workspace description.';
let workspaceId;

if (Cypress.env('WORKSPACE_ENABLED')) {
describe('Workspace detail', () => {
before(() => {
cy.deleteWorkspaceByName(workspaceName);
cy.createWorkspace({
name: workspaceName,
description: workspaceDescription,
features: ['workspace_detail', 'use-case-observability'],
settings: {
permissions: {
library_write: { users: ['%me%'] },
write: { users: ['%me%'] },
},
},
}).then((value) => (workspaceId = value));
});

beforeEach(() => {
// Visit workspace update page
miscUtils.visitPage(`w/${workspaceId}/app/workspace_detail`);

cy.intercept('PUT', `/w/${workspaceId}/api/workspaces/${workspaceId}`).as(
'updateWorkspaceRequest'
);
});

after(() => {
cy.deleteWorkspaceById(workspaceId);
});

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');

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

describe('settings tab', () => {
beforeEach(() => {
cy.contains('Settings').click();
});

describe('Validate workspace name and description', () => {
it('workspace name is required', () => {
cy.getElementByTestId(
'workspaceForm-workspaceDetails-nameInputText'
).clear({
force: true,
});
cy.getElementByTestId(
'workspaceForm-workspaceDetails-descriptionInputText'
).clear({
force: true,
});
cy.getElementByTestId(
'workspaceForm-workspaceDetails-descriptionInputText'
).type('test_workspace_description');
cy.getElementByTestId('workspaceForm-bottomBar-updateButton').click({
force: true,
});
cy.contains('Name is required. Enter a name.').should('exist');
});

it('workspace name is not valid', () => {
cy.getElementByTestId(
'workspaceForm-workspaceDetails-nameInputText'
).clear({
force: true,
});
cy.getElementByTestId(
'workspaceForm-workspaceDetails-descriptionInputText'
).clear({
force: true,
});
cy.getElementByTestId(
'workspaceForm-workspaceDetails-nameInputText'
).type('./+');
cy.getElementByTestId(
'workspaceForm-workspaceDetails-descriptionInputText'
).type('test_workspace_description');
cy.getElementByTestId('workspaceForm-bottomBar-updateButton').click({
force: true,
});
cy.contains('Name is invalid. Enter a valid name.').should('exist');
});
});

describe('Update a workspace successfully', () => {
it('should successfully update a workspace', () => {
cy.getElementByTestId(
'workspaceForm-workspaceDetails-nameInputText'
).clear({
force: true,
});
cy.getElementByTestId(
'workspaceForm-workspaceDetails-descriptionInputText'
).clear({
force: true,
});
cy.getElementByTestId(
'workspaceForm-workspaceDetails-nameInputText'
).type(workspaceName);
workspaceDescription = 'test_workspace_description.+~!';
cy.getElementByTestId(
'workspaceForm-workspaceDetails-descriptionInputText'
).type(workspaceDescription);
cy.getElementByTestId(
'euiColorPickerAnchor workspaceForm-workspaceDetails-colorPicker'
).type('#D36086');
cy.getElementByTestId('workspaceUseCase-observability').click({
force: true,
});
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: 'test_workspace_description.+~!',
features: ['workspace_detail', 'use-case-observability'],
};
cy.checkWorkspace(workspaceId, expectedWorkspace);
});
});
});

if (
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);
});
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'],
},
write: {
users: [`${Cypress.env('username')}`],
},
library_write: {
users: [`${Cypress.env('username')}`],
},
},
};
cy.checkWorkspace(workspaceId, expectedWorkspace);
});
});
}
});
}
Loading

0 comments on commit dbb754f

Please sign in to comment.