-
Notifications
You must be signed in to change notification settings - Fork 892
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 <wanjinch@amazon.com>
Signed-off-by: Kapian1234 <wanjinch@amazon.com>
Signed-off-by: Kapian1234 <wanjinch@amazon.com>
Signed-off-by: Kapian1234 <wanjinch@amazon.com>
Signed-off-by: Kapian1234 <wanjinch@amazon.com>
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 <wanjinch@amazon.com>
…apian1234/OpenSearch-Dashboards into workspace_permission_setting_panel_dev
Signed-off-by: Kapian1234 <wanjinch@amazon.com>
Signed-off-by: Kapian1234 <wanjinch@amazon.com>
…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 <wanjinch@amazon.com>
@@ -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 <wanjinch@amazon.com>
…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 <wanjinch@amazon.com>
Signed-off-by: Kapian1234 <wanjinch@amazon.com>
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 <wanjinch@amazon.com>
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 <wanjinch@amazon.com> * Merged the group section and user section, and added type switching. Signed-off-by: Kapian1234 <wanjinch@amazon.com> * Added isDisabled for permission control Signed-off-by: Kapian1234 <wanjinch@amazon.com> * Modified styles and added descriptions for permission control Signed-off-by: Kapian1234 <wanjinch@amazon.com> * / Signed-off-by: Kapian1234 <wanjinch@amazon.com> * Modified tests Signed-off-by: Kapian1234 <wanjinch@amazon.com> * Changeset file for PR #7652 created/updated * Modified tests Signed-off-by: Kapian1234 <wanjinch@amazon.com> * Modified tests Signed-off-by: Kapian1234 <wanjinch@amazon.com> * / Signed-off-by: Kapian1234 <wanjinch@amazon.com> * Modified tests Signed-off-by: Kapian1234 <wanjinch@amazon.com> * Remove the doc updates Signed-off-by: Kapian1234 <wanjinch@amazon.com> * Remove the doc updates Signed-off-by: Kapian1234 <wanjinch@amazon.com> * Resolve some issues Signed-off-by: Kapian1234 <wanjinch@amazon.com> * resolve some issues Signed-off-by: Kapian1234 <wanjinch@amazon.com> * Change type switch to popover style Signed-off-by: Kapian1234 <wanjinch@amazon.com> * Change type switch to popover style Signed-off-by: Kapian1234 <wanjinch@amazon.com> * Change type switch to popover style Signed-off-by: Kapian1234 <wanjinch@amazon.com> * Change type switch to popover style Signed-off-by: Kapian1234 <wanjinch@amazon.com> * Modify tests Signed-off-by: Kapian1234 <wanjinch@amazon.com> * Resolve some issues Signed-off-by: Kapian1234 <wanjinch@amazon.com> * Modify tests Signed-off-by: Kapian1234 <wanjinch@amazon.com> * Modify tests to increase coverage Signed-off-by: Kapian1234 <wanjinch@amazon.com> * Modify tests Signed-off-by: Kapian1234 <wanjinch@amazon.com> * Modify tests Signed-off-by: Kapian1234 <wanjinch@amazon.com> * Modify tests Signed-off-by: Kapian1234 <wanjinch@amazon.com> * Modify tests Signed-off-by: Kapian1234 <wanjinch@amazon.com> --------- Signed-off-by: Kapian1234 <wanjinch@amazon.com> 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 <wanjinch@amazon.com> 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