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

[Workspace] Updated permission settings appearance #7652

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
14af74b
Changed permission control style
Kapian1234 Aug 2, 2024
e28f4a9
Merged the group section and user section, and added type switching.
Kapian1234 Aug 5, 2024
3d860e2
Added isDisabled for permission control
Kapian1234 Aug 5, 2024
4b7a368
Modified styles and added descriptions for permission control
Kapian1234 Aug 6, 2024
2bf47e1
/
Kapian1234 Aug 7, 2024
272b57f
Modified tests
Kapian1234 Aug 8, 2024
afb5a25
Changeset file for PR #7652 created/updated
opensearch-changeset-bot[bot] Aug 8, 2024
97505a9
Modified tests
Kapian1234 Aug 8, 2024
3b94759
Merge branch 'workspace_permission_setting_panel_dev' of github.com:K…
Kapian1234 Aug 8, 2024
3fe0e7b
Modified tests
Kapian1234 Aug 8, 2024
6b98eeb
Merge branch 'main' into workspace_permission_setting_panel_dev
Kapian1234 Aug 8, 2024
7c19205
Merge branch 'main' into workspace_permission_setting_panel_dev
Kapian1234 Aug 9, 2024
31a87ee
/
Kapian1234 Aug 9, 2024
55d8213
Modified tests
Kapian1234 Aug 9, 2024
ac75a01
Remove the doc updates
Kapian1234 Aug 9, 2024
c136b48
Remove the doc updates
Kapian1234 Aug 9, 2024
7d33f1b
Resolve some issues
Kapian1234 Aug 9, 2024
b0b1b85
resolve some issues
Kapian1234 Aug 14, 2024
17ec17f
Change type switch to popover style
Kapian1234 Aug 15, 2024
432c5cd
Change type switch to popover style
Kapian1234 Aug 15, 2024
b9906d5
Merge branch 'workspace_permission_setting_panel_dev' of github.com:K…
Kapian1234 Aug 15, 2024
da3996d
Change type switch to popover style
Kapian1234 Aug 15, 2024
ed7c13a
Change type switch to popover style
Kapian1234 Aug 15, 2024
040b5e1
Modify tests
Kapian1234 Aug 15, 2024
55e9f02
Resolve some issues
Kapian1234 Aug 16, 2024
6dbcbea
Resolve some conflicts
Kapian1234 Aug 16, 2024
a0b4243
Modify tests
Kapian1234 Aug 16, 2024
3f6247c
Merge branch 'main' of https://github.com/opensearch-project/OpenSear…
Kapian1234 Aug 16, 2024
7a535e3
Modify tests to increase coverage
Kapian1234 Aug 20, 2024
9292fe7
Merge branch 'main' into workspace_permission_setting_panel_dev
Kapian1234 Aug 20, 2024
4651d44
Modify tests
Kapian1234 Aug 20, 2024
a0c8f94
Merge branch 'workspace_permission_setting_panel_dev' of github.com:K…
Kapian1234 Aug 20, 2024
d58a9ca
Modify tests
Kapian1234 Aug 20, 2024
d266ca8
Modify tests
Kapian1234 Aug 20, 2024
ed8bff2
Modify tests
Kapian1234 Aug 20, 2024
668bf70
Merge branch 'main' into workspace_permission_setting_panel_dev
Kapian1234 Aug 21, 2024
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 @@ -4,7 +4,7 @@
*/

import React from 'react';
import { fireEvent, render, waitFor } from '@testing-library/react';
import { fireEvent, render } from '@testing-library/react';
import {
WorkspacePermissionSettingInput,
WorkspacePermissionSettingInputProps,
Expand Down Expand Up @@ -116,11 +116,17 @@ describe('WorkspacePermissionSettingInput', () => {

it('should call onTypeChange with types after types changed', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we move this test case inside describe section?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry I didn't notice that

const { renderResult, onTypeChangeMock } = setup({});

expect(onTypeChangeMock).not.toHaveBeenCalled();
waitFor(() => {
fireEvent.click(renderResult.getByTestId('workspace-typeOptions'));
fireEvent.click(renderResult.getByText('Group'));
expect(onTypeChangeMock).toHaveBeenCalledWith('group', 0);
Object.defineProperty(HTMLElement.prototype, 'offsetHeight', {
configurable: true,
value: 600,
});
Object.defineProperty(HTMLElement.prototype, 'offsetWidth', {
configurable: true,
value: 600,
});
expect(onTypeChangeMock).not.toHaveBeenCalled();

fireEvent.click(renderResult.getByTestId('workspace-typeOptions'));
fireEvent.click(renderResult.getByText('Group'));
expect(onTypeChangeMock).toHaveBeenCalledWith('group', 0);
});
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,20 @@ describe('WorkspacePermissionSettingInput', () => {
]);
});
it('should call onChange with new user type', () => {
Object.defineProperty(HTMLElement.prototype, 'offsetHeight', {
configurable: true,
value: 600,
});
Object.defineProperty(HTMLElement.prototype, 'offsetWidth', {
configurable: true,
value: 600,
});
const { renderResult, onChangeMock } = setup();
expect(onChangeMock).not.toHaveBeenCalled();

waitFor(() => {
expect(onChangeMock).not.toHaveBeenCalled();
fireEvent.click(renderResult.getAllByTestId('workspace-typeOptions')[1]);
fireEvent.click(renderResult.getByText('User'));
fireEvent.click(renderResult.getAllByText('User')[1]);
expect(onChangeMock).toHaveBeenCalledWith([
{
id: 0,
Expand All @@ -124,12 +132,20 @@ describe('WorkspacePermissionSettingInput', () => {
});
});
it('should call onChange with new group type', () => {
Object.defineProperty(HTMLElement.prototype, 'offsetHeight', {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we move these offset mocks to the beforeEach / afterEach? I think we should clear it after test case complete.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

configurable: true,
value: 600,
});
Object.defineProperty(HTMLElement.prototype, 'offsetWidth', {
configurable: true,
value: 600,
});
const { renderResult, onChangeMock } = setup();

expect(onChangeMock).not.toHaveBeenCalled();
waitFor(() => {
fireEvent.click(renderResult.getAllByTestId('workspace-typeOptions')[0]);
fireEvent.click(renderResult.getByText('Group'));
fireEvent.click(renderResult.getAllByText('Group')[0]);
expect(onChangeMock).toHaveBeenCalledWith([
{
id: 0,
Expand Down Expand Up @@ -162,6 +178,29 @@ describe('WorkspacePermissionSettingInput', () => {
]);
});

it('should call onChange with user permission setting after delete button click', () => {
const { renderResult, onChangeMock } = setup();

expect(onChangeMock).not.toHaveBeenCalled();
fireEvent.click(renderResult.getAllByLabelText('Delete permission setting')[0]);
expect(onChangeMock).toHaveBeenCalledWith([
{
id: 1,
type: WorkspacePermissionItemType.Group,
group: 'bar',
modes: [WorkspacePermissionMode.LibraryWrite, WorkspacePermissionMode.Read],
},
]);
});

it('should call onGroupOrUserIdChange without user id after clear button clicked', () => {
const { renderResult, onChangeMock } = setup();

expect(onChangeMock).not.toHaveBeenCalled();
fireEvent.click(renderResult.getAllByTestId('comboBoxClearButton')[0]);
expect(onChangeMock).toHaveBeenCalled();
});

it('should not able to edit user or group when disabled', () => {
const { renderResult } = setup({
permissionSettings: [
Expand Down
Loading