fix(fuselage-ui-kit): `MultiStaticSelectElement` not working as expected (#32999)
Co-authored-by: Tasso Evangelista <2263066+tassoevan@users.noreply.github.com>pull/33011/head
parent
3ba185443e
commit
78e6ba4820
@ -0,0 +1,6 @@ |
||||
--- |
||||
"@rocket.chat/meteor": patch |
||||
"@rocket.chat/fuselage-ui-kit": patch |
||||
--- |
||||
|
||||
Fixes multiple selection for MultiStaticSelectElement in UiKit |
||||
@ -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']); |
||||
}); |
||||
}); |
||||
Loading…
Reference in new issue