-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(fuselage-ui-kit):
MultiStaticSelectElement
not working as expec…
…ted (#32999) Co-authored-by: Tasso Evangelista <[email protected]>
- Loading branch information
1 parent
3ba1854
commit 78e6ba4
Showing
4 changed files
with
87 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"@rocket.chat/meteor": patch | ||
"@rocket.chat/fuselage-ui-kit": patch | ||
--- | ||
|
||
Fixes multiple selection for MultiStaticSelectElement in UiKit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import { | ||
BlockContext, | ||
type MultiStaticSelectElement, | ||
} from '@rocket.chat/ui-kit'; | ||
import { act, renderHook } from '@testing-library/react'; | ||
|
||
import { useUiKitState } from './useUiKitState'; | ||
|
||
describe('state function', () => { | ||
const context = BlockContext.NONE; | ||
|
||
it('should handle arrays', async () => { | ||
const element: MultiStaticSelectElement = { | ||
type: 'multi_static_select', | ||
placeholder: { type: 'plain_text', text: '' }, | ||
options: [], | ||
initialValue: ['A', 'B'], | ||
appId: 'app-id', | ||
blockId: 'block-id', | ||
actionId: 'action-id', | ||
}; | ||
|
||
const { result } = renderHook(() => useUiKitState(element, context), { | ||
legacyRoot: true, | ||
}); | ||
|
||
await act(async () => { | ||
const [, state] = result.current; | ||
await state({ | ||
target: { | ||
value: ['C', 'D'], | ||
}, | ||
}); | ||
}); | ||
|
||
expect(result.current[0].value).toEqual(['C', 'D']); | ||
}); | ||
}); | ||
|
||
describe('action function', () => { | ||
const context = BlockContext.ACTION; | ||
|
||
it('should handle arrays', async () => { | ||
const element: MultiStaticSelectElement = { | ||
type: 'multi_static_select', | ||
placeholder: { type: 'plain_text', text: '' }, | ||
options: [], | ||
initialValue: ['A', 'B'], | ||
appId: 'app-id', | ||
blockId: 'block-id', | ||
actionId: 'action-id', | ||
}; | ||
|
||
const { result } = renderHook(() => useUiKitState(element, context), { | ||
legacyRoot: true, | ||
}); | ||
|
||
await act(async () => { | ||
const [, action] = result.current; | ||
await action({ | ||
target: { | ||
value: ['C', 'D'], | ||
}, | ||
}); | ||
}); | ||
|
||
expect(result.current[0].value).toEqual(['C', 'D']); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters