-
Notifications
You must be signed in to change notification settings - Fork 916
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
Changes from 32 commits
14af74b
e28f4a9
3d860e2
4b7a368
2bf47e1
272b57f
afb5a25
97505a9
3b94759
3fe0e7b
6b98eeb
7c19205
31a87ee
55d8213
ac75a01
c136b48
7d33f1b
b0b1b85
17ec17f
432c5cd
b9906d5
da3996d
ed7c13a
040b5e1
55e9f02
6dbcbea
a0b4243
3f6247c
7a535e3
9292fe7
4651d44
a0c8f94
d58a9ca
d266ca8
ed8bff2
668bf70
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
feat: | ||
- Update permission settings appearance ([#7652](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/7652)) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ const setup = (options?: Partial<WorkspacePermissionSettingInputProps>) => { | |
const onGroupOrUserIdChangeMock = jest.fn(); | ||
const onPermissionModesChangeMock = jest.fn(); | ||
const onDeleteMock = jest.fn(); | ||
const onTypeChangeMock = jest.fn(); | ||
const renderResult = render( | ||
<WorkspacePermissionSettingInput | ||
index={0} | ||
|
@@ -24,6 +25,7 @@ const setup = (options?: Partial<WorkspacePermissionSettingInputProps>) => { | |
onGroupOrUserIdChange={onGroupOrUserIdChangeMock} | ||
onPermissionModesChange={onPermissionModesChangeMock} | ||
onDelete={onDeleteMock} | ||
onTypeChange={onTypeChangeMock} | ||
{...options} | ||
/> | ||
); | ||
|
@@ -32,6 +34,7 @@ const setup = (options?: Partial<WorkspacePermissionSettingInputProps>) => { | |
onGroupOrUserIdChangeMock, | ||
onPermissionModesChangeMock, | ||
onDeleteMock, | ||
onTypeChangeMock, | ||
}; | ||
}; | ||
|
||
|
@@ -44,9 +47,6 @@ describe('WorkspacePermissionSettingInput', () => { | |
|
||
expect(renderResult.getByText('foo')).toBeInTheDocument(); | ||
expect(renderResult.getByText('Read')).toBeInTheDocument(); | ||
expect( | ||
renderResult.getByText('Read').closest('.euiButtonGroupButton-isSelected') | ||
).toBeInTheDocument(); | ||
}); | ||
it('should render consistent group id and permission modes', () => { | ||
const { renderResult } = setup({ | ||
|
@@ -57,19 +57,16 @@ describe('WorkspacePermissionSettingInput', () => { | |
|
||
expect(renderResult.getByText('bar')).toBeInTheDocument(); | ||
expect(renderResult.getByText('Read & Write')).toBeInTheDocument(); | ||
expect( | ||
renderResult.getByText('Read & Write').closest('.euiButtonGroupButton-isSelected') | ||
).toBeInTheDocument(); | ||
}); | ||
it('should call onGroupOrUserIdChange with user id', () => { | ||
const { renderResult, onGroupOrUserIdChangeMock } = setup(); | ||
|
||
expect(onGroupOrUserIdChangeMock).not.toHaveBeenCalled(); | ||
fireEvent.click(renderResult.getByText('Select a user')); | ||
fireEvent.input(renderResult.getByTestId('comboBoxSearchInput'), { | ||
fireEvent.input(renderResult.getAllByTestId('comboBoxSearchInput')[0], { | ||
target: { value: 'user1' }, | ||
}); | ||
fireEvent.blur(renderResult.getByTestId('comboBoxSearchInput')); | ||
fireEvent.blur(renderResult.getAllByTestId('comboBoxSearchInput')[0]); | ||
expect(onGroupOrUserIdChangeMock).toHaveBeenCalledWith({ type: 'user', userId: 'user1' }, 0); | ||
}); | ||
it('should call onGroupOrUserIdChange with group', () => { | ||
|
@@ -79,10 +76,10 @@ describe('WorkspacePermissionSettingInput', () => { | |
|
||
expect(onGroupOrUserIdChangeMock).not.toHaveBeenCalled(); | ||
fireEvent.click(renderResult.getByText('Select a user group')); | ||
fireEvent.input(renderResult.getByTestId('comboBoxSearchInput'), { | ||
fireEvent.input(renderResult.getAllByTestId('comboBoxSearchInput')[0], { | ||
target: { value: 'group' }, | ||
}); | ||
fireEvent.blur(renderResult.getByTestId('comboBoxSearchInput')); | ||
fireEvent.blur(renderResult.getAllByTestId('comboBoxSearchInput')[0]); | ||
expect(onGroupOrUserIdChangeMock).toHaveBeenCalledWith({ type: 'group', group: 'group' }, 0); | ||
}); | ||
|
||
|
@@ -100,6 +97,10 @@ describe('WorkspacePermissionSettingInput', () => { | |
const { renderResult, onPermissionModesChangeMock } = setup({}); | ||
|
||
expect(onPermissionModesChangeMock).not.toHaveBeenCalled(); | ||
const permissionToggleListButton = renderResult | ||
.getAllByTestId('comboBoxToggleListButton') | ||
.filter((button) => button.closest('[data-test-subj="workspace-permissionModeOptions"]'))[0]; | ||
fireEvent.click(permissionToggleListButton); | ||
fireEvent.click(renderResult.getByText('Owner')); | ||
expect(onPermissionModesChangeMock).toHaveBeenCalledWith(['library_write', 'write'], 0); | ||
}); | ||
|
@@ -111,4 +112,21 @@ describe('WorkspacePermissionSettingInput', () => { | |
fireEvent.click(renderResult.getByLabelText('Delete permission setting')); | ||
expect(onDeleteMock).toHaveBeenCalledWith(0); | ||
}); | ||
|
||
it('should call onTypeChange with types after types changed', () => { | ||
const { renderResult, onTypeChangeMock } = setup({}); | ||
Object.defineProperty(HTMLElement.prototype, 'offsetHeight', { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should reset offset value after test case completed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shall we use beforeEach and afterEach here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we don't need put them in before / after if there only one test case use it. |
||
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); | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shall we refactor to below code?
That look more clarify to me.