Skip to content

Commit 29dc62b

Browse files
committed
implement James's suggestions
1 parent a219e06 commit 29dc62b

File tree

2 files changed

+22
-55
lines changed

2 files changed

+22
-55
lines changed

src/routes/__tests__/route-workspace.test.tsx

Lines changed: 20 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -48,35 +48,10 @@ test("renders title", () => {
4848
const { getByRole } = renderComponent();
4949

5050
expect(
51-
getByRole("heading", { name: 'Workspace settings for "foo"', level: 4 }),
51+
getByRole("heading", { name: "Workspace settings for foo", level: 4 }),
5252
).toBeVisible();
5353
});
5454

55-
test("has a badge when editing the active workspace", () => {
56-
(useParams as unknown as ReturnType<typeof vi.fn>).mockReturnValue({
57-
name: "baz",
58-
});
59-
60-
const { getByRole } = renderComponent();
61-
62-
const heading = getByRole("heading", {
63-
name: /.*workspace settings.*/i,
64-
level: 4,
65-
});
66-
67-
expect(within(heading).getByText(/active/i)).toBeVisible();
68-
});
69-
70-
test("has no 'active workspace' badge when it's not the active workspace", () => {
71-
(useParams as unknown as ReturnType<typeof vi.fn>).mockReturnValue({
72-
name: "another",
73-
});
74-
75-
const { queryByText } = renderComponent();
76-
77-
expect(queryByText(/active/i)).toBeNull();
78-
});
79-
8055
test("renders workspace name input", () => {
8156
const { getByRole } = renderComponent();
8257

@@ -105,6 +80,25 @@ test("has breadcrumbs", () => {
10580
expect(within(breadcrumbs).getByText(/workspace settings/i)).toBeVisible();
10681
});
10782

83+
test("rename workspace", async () => {
84+
(useParams as unknown as ReturnType<typeof vi.fn>).mockReturnValue({
85+
name: "foo",
86+
});
87+
const { getByRole, getByTestId } = renderComponent();
88+
89+
const workspaceName = getByRole("textbox", {
90+
name: /workspace name/i,
91+
});
92+
await userEvent.type(workspaceName, "_renamed");
93+
94+
const saveBtn = within(getByTestId("workspace-name")).getByRole("button", {
95+
name: /save/i,
96+
});
97+
await userEvent.click(saveBtn);
98+
await waitFor(() => expect(mockNavigate).toHaveBeenCalledTimes(1));
99+
expect(mockNavigate).toHaveBeenCalledWith("/workspace/foo_renamed");
100+
});
101+
108102
test("revert changes button", async () => {
109103
(useParams as unknown as ReturnType<typeof vi.fn>).mockReturnValue({
110104
name: "foo",
@@ -152,22 +146,3 @@ test("revert changes button", async () => {
152146
}),
153147
).toHaveValue("foo");
154148
});
155-
156-
test("rename workspace", async () => {
157-
(useParams as unknown as ReturnType<typeof vi.fn>).mockReturnValue({
158-
name: "foo",
159-
});
160-
const { getByRole, getByTestId } = renderComponent();
161-
162-
const workspaceName = getByRole("textbox", {
163-
name: /workspace name/i,
164-
});
165-
await userEvent.type(workspaceName, "_renamed");
166-
167-
const saveBtn = within(getByTestId("workspace-name")).getByRole("button", {
168-
name: /save/i,
169-
});
170-
await userEvent.click(saveBtn);
171-
await waitFor(() => expect(mockNavigate).toHaveBeenCalledTimes(1));
172-
expect(mockNavigate).toHaveBeenCalledWith("/workspace/foo_renamed");
173-
});

src/routes/route-workspace.tsx

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@ import { ArchiveWorkspace } from "@/features/workspace/components/archive-worksp
33

44
import { WorkspaceHeading } from "@/features/workspace/components/workspace-heading";
55
import { WorkspaceName } from "@/features/workspace/components/workspace-name";
6-
import { Alert, Badge, Breadcrumb, Breadcrumbs } from "@stacklok/ui-kit";
6+
import { Alert, Breadcrumb, Breadcrumbs } from "@stacklok/ui-kit";
77
import { useParams } from "react-router-dom";
88
import { useArchivedWorkspaces } from "@/features/workspace/hooks/use-archived-workspaces";
99
import { useRestoreWorkspaceButton } from "@/features/workspace/hooks/use-restore-workspace-button";
1010
import { WorkspaceCustomInstructions } from "@/features/workspace/components/workspace-custom-instructions";
1111
import { WorkspacePreferredModel } from "@/features/workspace/components/workspace-preferred-model";
12-
import { useActiveWorkspaceName } from "@/features/workspace/hooks/use-active-workspace-name";
1312

1413
function WorkspaceArchivedBanner({ name }: { name: string }) {
1514
const restoreButtonProps = useRestoreWorkspaceButton({ workspaceName: name });
@@ -37,8 +36,6 @@ export function RouteWorkspace() {
3736
data?.workspaces.find((w) => w.name === name) !== undefined,
3837
});
3938

40-
const { data: activeWorkspaceName } = useActiveWorkspaceName();
41-
4239
return (
4340
<>
4441
<Breadcrumbs>
@@ -50,12 +47,7 @@ export function RouteWorkspace() {
5047
<WorkspaceHeading
5148
title={
5249
<div className="flex gap-2 items-center">
53-
Workspace settings for "{name}"
54-
{activeWorkspaceName === name && (
55-
<Badge size="sm" variant="inverted">
56-
Active
57-
</Badge>
58-
)}
50+
Workspace settings for {name}
5951
</div>
6052
}
6153
/>

0 commit comments

Comments
 (0)