Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update integration tests with privacy setting features #1665

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,21 @@

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

const updatePrivacySetting = (settingId) => {
cy.getElementByTestId('workspaceCollaborators-privacySetting-edit').click();
cy.getElementByTestId('workspacePrivacySettingSelector').click({
force: true,
});
cy.get(`#${settingId}`).click({ force: true });
cy.getElementByTestId('workspaceCollaborators-privacySetting-save').click({
force: true,
});

cy.getElementByTestId('workspaceCollaborators-privacySetting-save').should(
'not.exist'
);
};

export const WorkspaceCollaboratorsTestCases = () => {
const miscUtils = new MiscUtils(cy);
const workspaceName = 'test_workspace_collaborators';
Expand Down Expand Up @@ -209,6 +224,108 @@ export const WorkspaceCollaboratorsTestCases = () => {
};
cy.checkWorkspace(workspaceId, expectedWorkspace);
});

it('should change to "anyone can read" successfully', () => {
updatePrivacySetting('anyone-can-view');

const expectedWorkspace = {
name: workspaceName,
features: ['use-case-observability'],
description: 'test_description',
permissions: {
library_write: {
users: [`${Cypress.env('username')}`],
groups: ['admin_group'],
},
write: {
users: [`${Cypress.env('username')}`],
groups: ['admin_group'],
},
library_read: {
users: ['read_user', '*'],
},
read: {
users: ['read_user', '*'],
},
},
};
cy.checkWorkspace(workspaceId, expectedWorkspace);
});

it('should change to "anyone can edit" successfully', () => {
updatePrivacySetting('anyone-can-edit');

const expectedWorkspace = {
name: workspaceName,
features: ['use-case-observability'],
description: 'test_description',
permissions: {
library_write: {
users: [`${Cypress.env('username')}`, '*'],
groups: ['admin_group'],
},
write: {
users: [`${Cypress.env('username')}`],
groups: ['admin_group'],
},
library_read: {
users: ['read_user'],
},
read: {
users: ['read_user', '*'],
},
},
};
cy.checkWorkspace(workspaceId, expectedWorkspace);
});

it('should change back to "private to collaborators" successfully', () => {
updatePrivacySetting('anyone-can-view');
cy.checkWorkspace(workspaceId, {
name: workspaceName,
features: ['use-case-observability'],
description: 'test_description',
permissions: {
library_write: {
users: [`${Cypress.env('username')}`],
groups: ['admin_group'],
},
write: {
users: [`${Cypress.env('username')}`],
groups: ['admin_group'],
},
library_read: {
users: ['read_user', '*'],
},
read: {
users: ['read_user', '*'],
},
},
});

updatePrivacySetting('private-to-collaborators');
cy.checkWorkspace(workspaceId, {
name: workspaceName,
features: ['use-case-observability'],
description: 'test_description',
permissions: {
library_write: {
users: [`${Cypress.env('username')}`],
groups: ['admin_group'],
},
write: {
users: [`${Cypress.env('username')}`],
groups: ['admin_group'],
},
library_read: {
users: ['read_user'],
},
read: {
users: ['read_user'],
},
},
});
});
});
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,37 @@ export const WorkspaceCreateTestCases = () => {
cy.deleteWorkspaceByName(workspaceName);
inputWorkspaceName(workspaceName);
inputDataSourceWhenMDSEnabled(dataSourceTitle);
cy.getElementByTestId('jumpToCollaboratorsCheckbox').click({
force: true,
});
cy.getElementByTestId('workspaceForm-bottomBar-createButton').click(
{
force: true,
}
);

let workspaceId;
cy.wait('@createWorkspaceRequest').then((interception) => {
expect(interception.response.statusCode).to.equal(200);
workspaceId = interception.response.body.result.id;

cy.location('pathname', { timeout: 6000 }).should(
'include',
`w/${workspaceId}/app/workspace_collaborators`
);
});
});

it('should creating a workspace with privacy setting', () => {
cy.deleteWorkspaceByName(workspaceName);
inputWorkspaceName(workspaceName);
inputDataSourceWhenMDSEnabled(dataSourceTitle);
cy.get('#anyone-can-edit').click();
cy.getElementByTestId('jumpToCollaboratorsCheckbox')
.should('be.enabled')
.click({
force: true,
});
cy.getElementByTestId('workspaceForm-bottomBar-createButton').click(
{
force: true,
Expand All @@ -171,6 +202,8 @@ export const WorkspaceCreateTestCases = () => {
'include',
`w/${workspaceId}/app/workspace_collaborators`
);

cy.contains('Anyone can edit').should('be.exist');
});
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,20 @@ export const WorkspaceDetailTestCases = () => {
let workspaceDescription = 'This is a workspace description.';
let workspaceId;
let workspaceFeatures = ['use-case-observability'];
const workspaceBaseData = {
name: workspaceName,
description: workspaceDescription,
features: workspaceFeatures,
color: '#54B399',
settings: {
permissions: {
library_write: { users: ['%me%'] },
write: { users: ['%me%'] },
library_read: { users: [NONE_DASHBOARDS_ADMIN_USERNAME] },
read: { users: [NONE_DASHBOARDS_ADMIN_USERNAME] },
},
},
};

if (Cypress.env('WORKSPACE_ENABLED')) {
describe('Workspace detail', () => {
Expand All @@ -34,19 +48,9 @@ export const WorkspaceDetailTestCases = () => {
);
}
cy.deleteWorkspaceByName(workspaceName);
cy.createWorkspace({
name: workspaceName,
description: workspaceDescription,
features: workspaceFeatures,
settings: {
permissions: {
library_write: { users: ['%me%'] },
write: { users: ['%me%'] },
library_read: { users: [NONE_DASHBOARDS_ADMIN_USERNAME] },
read: { users: [NONE_DASHBOARDS_ADMIN_USERNAME] },
},
},
}).then((value) => (workspaceId = value));
cy.createWorkspace(workspaceBaseData).then(
(value) => (workspaceId = value)
);
});

after(() => {
Expand Down Expand Up @@ -294,6 +298,106 @@ export const WorkspaceDetailTestCases = () => {
});
});
});

describe('update with different privacy settings', () => {
before(() => {
// Visit workspace update page
miscUtils.visitPage(`w/${workspaceId}/app/workspace_detail`);
});

afterEach(() => {
cy.getElementByTestId(
'workspaceForm-workspaceDetails-edit'
).click();
cy.getElementByTestId('workspacePrivacySettingSelector').click({
force: true,
});
cy.get('#private-to-collaborators').click({ force: true });
cy.getElementByTestId('workspaceForm-bottomBar-updateButton').click(
{ force: true }
);
cy.getElementByTestId(
'workspaceForm-bottomBar-updateButton'
).should('not.exist');
cy.checkWorkspace(workspaceId, {
name: workspaceName,
description: workspaceDescription,
features: workspaceFeatures,
permissions: {
library_write: { users: ['%me%'] },
write: { users: ['%me%'] },
library_read: {
users: [NONE_DASHBOARDS_ADMIN_USERNAME],
},
read: { users: [NONE_DASHBOARDS_ADMIN_USERNAME] },
},
});
});

it('should able to update privacy setting to anyone can read', () => {
cy.getElementByTestId(
'workspaceForm-workspaceDetails-edit'
).click();
cy.getElementByTestId('workspacePrivacySettingSelector').click({
force: true,
});
cy.get('#anyone-can-view').click({ force: true });
cy.getElementByTestId('workspaceForm-bottomBar-updateButton').click(
{ force: true }
);

cy.getElementByTestId(
'workspaceForm-bottomBar-updateButton'
).should('not.exist');

const expectedWorkspace = {
name: workspaceName,
description: workspaceDescription,
features: workspaceFeatures,
permissions: {
library_write: { users: ['%me%'] },
write: { users: ['%me%'] },
library_read: {
users: [NONE_DASHBOARDS_ADMIN_USERNAME, '*'],
},
read: { users: [NONE_DASHBOARDS_ADMIN_USERNAME, '*'] },
},
};
cy.checkWorkspace(workspaceId, expectedWorkspace);
});

it('should able to update privacy setting to anyone can write', () => {
cy.getElementByTestId(
'workspaceForm-workspaceDetails-edit'
).click();
cy.getElementByTestId('workspacePrivacySettingSelector').click({
force: true,
});
cy.get('#anyone-can-edit').click({ force: true });
cy.getElementByTestId('workspaceForm-bottomBar-updateButton').click(
{ force: true }
);

cy.getElementByTestId(
'workspaceForm-bottomBar-updateButton'
).should('not.exist');

const expectedWorkspace = {
name: workspaceName,
description: workspaceDescription,
features: workspaceFeatures,
permissions: {
library_write: { users: ['%me%', '*'] },
write: { users: ['%me%'] },
library_read: {
users: [NONE_DASHBOARDS_ADMIN_USERNAME],
},
read: { users: [NONE_DASHBOARDS_ADMIN_USERNAME, '*'] },
},
};
cy.checkWorkspace(workspaceId, expectedWorkspace);
});
});
}
});
}
Expand Down
Loading