-
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
[Workspace] Updated permission settings appearance #7652
Conversation
Signed-off-by: Kapian1234 <[email protected]>
Signed-off-by: Kapian1234 <[email protected]>
Signed-off-by: Kapian1234 <[email protected]>
Signed-off-by: Kapian1234 <[email protected]>
Signed-off-by: Kapian1234 <[email protected]>
Signed-off-by: Kapian1234 <[email protected]>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #7652 +/- ##
=======================================
Coverage 63.79% 63.80%
=======================================
Files 3656 3656
Lines 81190 81205 +15
Branches 12945 12950 +5
=======================================
+ Hits 51794 51809 +15
+ Misses 26217 26215 -2
- Partials 3179 3181 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Signed-off-by: Kapian1234 <[email protected]>
…apian1234/OpenSearch-Dashboards into workspace_permission_setting_panel_dev
Signed-off-by: Kapian1234 <[email protected]>
Signed-off-by: Kapian1234 <[email protected]>
Signed-off-by: Kapian1234 <[email protected]>
…ch-Dashboards into workspace_permission_setting_panel_dev
const handleTypeChange = useCallback( | ||
(options: Array<EuiSelectableOption<any>>) => { | ||
for (const option of options) { | ||
if (option.checked === 'on') { | ||
onTypeChange(option.value, index); | ||
setIsTypeListOpen(false); | ||
return; | ||
} | ||
} | ||
}, | ||
[index, onTypeChange] | ||
); |
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.
We need a unit test for this function.
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.
It's added here, but it doesn't seem to work src/plugins/workspace/public/components/workspace_form/workspace_permission_setting_input.test.tsx:117
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.
The root cause should be missing await
for waitFor
. The waitFor
return a promise. The test case will be completed if doesn't await the promise object.
|
||
const handleDelete = useCallback( | ||
(index: number) => { | ||
onChange?.(permissionSettings.filter((_item, itemIndex) => itemIndex !== index)); | ||
handlePermissionSettingsChange?.( | ||
permissionSettings.filter((_item, itemIndex) => itemIndex !== index) |
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.
All the event are missing test coverage, can we add those?
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.
ok
Signed-off-by: Kapian1234 <[email protected]>
@@ -124,12 +132,20 @@ describe('WorkspacePermissionSettingInput', () => { | |||
}); | |||
}); | |||
it('should call onChange with new group type', () => { | |||
Object.defineProperty(HTMLElement.prototype, 'offsetHeight', { |
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 move these offset mocks to the beforeEach / afterEach? I think we should clear it after test case complete.
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.
ok
@@ -112,3 +113,20 @@ describe('WorkspacePermissionSettingInput', () => { | |||
expect(onDeleteMock).toHaveBeenCalledWith(0); | |||
}); | |||
}); | |||
|
|||
it('should call onTypeChange with types after types changed', () => { |
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.
Can we move this test case inside describe section?
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.
sorry I didn't notice that
Signed-off-by: Kapian1234 <[email protected]>
…apian1234/OpenSearch-Dashboards into workspace_permission_setting_panel_dev
|
||
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 comment
The 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 comment
The 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 comment
The 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.
Signed-off-by: Kapian1234 <[email protected]>
Signed-off-by: Kapian1234 <[email protected]>
const permissionToggleListButton = renderResult | ||
.getAllByTestId('comboBoxToggleListButton') | ||
.filter((button) => button.closest('[data-test-subj="workspace-permissionModeOptions"]'))[0]; | ||
fireEvent.click(permissionToggleListButton); |
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?
import { within } from '@testing-library/react';
const permissionToggleListButton = within(
renderResult.getAllByTestId('workspace-permissionModeOptions')[1]
).getByTestId('comboBoxToggleListButton');
fireEvent.click(permissionToggleListButton);
That look more clarify to me.
'offsetHeight' | ||
); | ||
const originalOffsetWidth = Object.getOwnPropertyDescriptor(HTMLElement.prototype, 'offsetWidth'); | ||
Object.defineProperty(HTMLElement.prototype, 'offsetHeight', { |
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 delete this Object.defineProperty
?
Signed-off-by: Kapian1234 <[email protected]>
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.
LGTM
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.
LGTM, good job!
* Changed permission control style Signed-off-by: Kapian1234 <[email protected]> * Merged the group section and user section, and added type switching. Signed-off-by: Kapian1234 <[email protected]> * Added isDisabled for permission control Signed-off-by: Kapian1234 <[email protected]> * Modified styles and added descriptions for permission control Signed-off-by: Kapian1234 <[email protected]> * / Signed-off-by: Kapian1234 <[email protected]> * Modified tests Signed-off-by: Kapian1234 <[email protected]> * Changeset file for PR #7652 created/updated * Modified tests Signed-off-by: Kapian1234 <[email protected]> * Modified tests Signed-off-by: Kapian1234 <[email protected]> * / Signed-off-by: Kapian1234 <[email protected]> * Modified tests Signed-off-by: Kapian1234 <[email protected]> * Remove the doc updates Signed-off-by: Kapian1234 <[email protected]> * Remove the doc updates Signed-off-by: Kapian1234 <[email protected]> * Resolve some issues Signed-off-by: Kapian1234 <[email protected]> * resolve some issues Signed-off-by: Kapian1234 <[email protected]> * Change type switch to popover style Signed-off-by: Kapian1234 <[email protected]> * Change type switch to popover style Signed-off-by: Kapian1234 <[email protected]> * Change type switch to popover style Signed-off-by: Kapian1234 <[email protected]> * Change type switch to popover style Signed-off-by: Kapian1234 <[email protected]> * Modify tests Signed-off-by: Kapian1234 <[email protected]> * Resolve some issues Signed-off-by: Kapian1234 <[email protected]> * Modify tests Signed-off-by: Kapian1234 <[email protected]> * Modify tests to increase coverage Signed-off-by: Kapian1234 <[email protected]> * Modify tests Signed-off-by: Kapian1234 <[email protected]> * Modify tests Signed-off-by: Kapian1234 <[email protected]> * Modify tests Signed-off-by: Kapian1234 <[email protected]> * Modify tests Signed-off-by: Kapian1234 <[email protected]> --------- Signed-off-by: Kapian1234 <[email protected]> Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com> (cherry picked from commit aed03fa) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
* Changed permission control style * Merged the group section and user section, and added type switching. * Added isDisabled for permission control * Modified styles and added descriptions for permission control * / * Modified tests * Changeset file for PR #7652 created/updated * Modified tests * Modified tests * / * Modified tests * Remove the doc updates * Remove the doc updates * Resolve some issues * resolve some issues * Change type switch to popover style * Change type switch to popover style * Change type switch to popover style * Change type switch to popover style * Modify tests * Resolve some issues * Modify tests * Modify tests to increase coverage * Modify tests * Modify tests * Modify tests * Modify tests --------- (cherry picked from commit aed03fa) Signed-off-by: Kapian1234 <[email protected]> Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
Description
Changed permission control selector style.
Merged user section and group section, and added type switching.
Issues Resolved
Screenshot
Testing the changes
Changelog
Check List
yarn test:jest
yarn test:jest_integration