From 8a2a5cb79aaace90ad8ac460af00d1e077515f25 Mon Sep 17 00:00:00 2001 From: gaobinlong Date: Thu, 21 Mar 2024 11:44:00 +0800 Subject: [PATCH] Add more unit test Signed-off-by: gaobinlong --- .../workspace_updater.test.tsx | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/plugins/workspace/public/components/workspace_updater/workspace_updater.test.tsx b/src/plugins/workspace/public/components/workspace_updater/workspace_updater.test.tsx index 30f15bf07a1..3c113a71e94 100644 --- a/src/plugins/workspace/public/components/workspace_updater/workspace_updater.test.tsx +++ b/src/plugins/workspace/public/components/workspace_updater/workspace_updater.test.tsx @@ -191,4 +191,21 @@ describe('WorkspaceUpdater', () => { }); expect(notificationToastsAddSuccess).not.toHaveBeenCalled(); }); + + it('should show danger toasts after update workspace threw error', async () => { + workspaceClientUpdate.mockImplementation(() => { + throw new Error('update workspace failed'); + }); + const { getByTestId } = render(); + const nameInput = getByTestId('workspaceForm-workspaceDetails-nameInputText'); + fireEvent.input(nameInput, { + target: { value: 'test workspace name' }, + }); + fireEvent.click(getByTestId('workspaceForm-bottomBar-updateButton')); + expect(workspaceClientUpdate).toHaveBeenCalled(); + await waitFor(() => { + expect(notificationToastsAddDanger).toHaveBeenCalled(); + }); + expect(notificationToastsAddSuccess).not.toHaveBeenCalled(); + }); });