Skip to content

Commit ba5dfb5

Browse files
committed
Add test for multi-selection
1 parent 064a5be commit ba5dfb5

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

webview/src/experiments/components/App.test.tsx

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -897,6 +897,42 @@ describe('App', () => {
897897
type: MessageFromWebviewType.TOGGLE_EXPERIMENT_STAR
898898
})
899899
})
900+
901+
it('should toggle the star status of multiple experiments by clicking the ctx menu options', () => {
902+
render(<App />)
903+
904+
fireEvent(
905+
window,
906+
new MessageEvent('message', {
907+
data: {
908+
data: {
909+
...tableDataFixture,
910+
hasRunningExperiment: false
911+
},
912+
type: MessageToWebviewType.SET_DATA
913+
}
914+
})
915+
)
916+
917+
mockPostMessage.mockReset()
918+
const mainRow = getRow('main')
919+
fireEvent.click(mainRow)
920+
921+
const firstTipRow = getRow('4fb124a')
922+
fireEvent.click(firstTipRow)
923+
924+
fireEvent.contextMenu(mainRow, { bubbles: true })
925+
jest.advanceTimersByTime(100)
926+
927+
const starOption = screen.getByText('Star Experiments (2)')
928+
fireEvent.click(starOption)
929+
930+
expect(mockPostMessage).toBeCalledTimes(1)
931+
expect(mockPostMessage).toBeCalledWith({
932+
payload: ['main', 'exp-e7a67'],
933+
type: MessageFromWebviewType.TOGGLE_EXPERIMENT_STAR
934+
})
935+
})
900936
})
901937

902938
describe('Context Menu Suppression', () => {

0 commit comments

Comments
 (0)