This repository was archived by the owner on Jul 8, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +29
-5
lines changed
Expand file tree Collapse file tree 4 files changed +29
-5
lines changed Original file line number Diff line number Diff line change 1+ import { WorkspaceCreation } from "../workspace-creation" ;
2+ import { render } from "@/lib/test-utils" ;
3+ import userEvent from "@testing-library/user-event" ;
4+ import { screen , waitFor } from "@testing-library/react" ;
5+
6+ const mockNavigate = vi . fn ( ) ;
7+ vi . mock ( "react-router-dom" , async ( ) => {
8+ const original =
9+ await vi . importActual < typeof import ( "react-router-dom" ) > (
10+ "react-router-dom" ,
11+ ) ;
12+ return {
13+ ...original ,
14+ useNavigate : ( ) => mockNavigate ,
15+ } ;
16+ } ) ;
17+
18+ test ( "create workspace" , async ( ) => {
19+ render ( < WorkspaceCreation /> ) ;
20+
21+ expect ( screen . getByText ( / n a m e / i) ) . toBeVisible ( ) ;
22+
23+ screen . logTestingPlaygroundURL ( ) ;
24+ await userEvent . type ( screen . getByRole ( "textbox" ) , "workspaceA" ) ;
25+ await userEvent . click ( screen . getByRole ( "button" , { name : / c r e a t e / i } ) ) ;
26+ await waitFor ( ( ) => expect ( mockNavigate ) . toBeCalled ( ) ) ;
27+ } ) ;
Original file line number Diff line number Diff line change @@ -6,9 +6,6 @@ export function useCreateWorkspace() {
66 const navigate = useNavigate ( ) ;
77 return useMutation ( {
88 ...v1CreateWorkspaceMutation ( ) ,
9- onError ( error ) {
10- return error ?. detail ;
11- } ,
129 onSuccess : ( ) => navigate ( "/workspaces" ) ,
1310 } ) ;
1411}
Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ export const handlers = [
3333 http . get ( "*/api/v1/workspaces" , ( ) => {
3434 return HttpResponse . json ( mockedWorkspaces ) ;
3535 } ) ,
36- http . post ( "*/api/v1/workspace " , ( ) => {
36+ http . post ( "*/api/v1/workspaces " , ( ) => {
3737 return HttpResponse . json ( mockedWorkspaces ) ;
3838 } ) ,
3939] ;
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ import { WorkspaceHeading } from "@/features/workspace/components/workspace-head
44export function RouteWorkspaceCreation ( ) {
55 return (
66 < >
7- < WorkspaceHeading title = "Workspace settings " />
7+ < WorkspaceHeading title = "Create Workspace " />
88 < WorkspaceCreation />
99 </ >
1010 ) ;
You can’t perform that action at this time.
0 commit comments