Skip to content

Commit 554ddb1

Browse files
chore(site): refactor stories and test from page components (#9603)
* Refactor AuditPage * Refactor CliAuthPageView stories * Refactor CreateTemplateForm stories * Refactor CreateUserPage test * Refactor CreateWorkspacePage tests * Fix stories name * Refactor AppereancePageView stories * Refactor GitAuthSettingsPageView stories * Refactor NetworkSettingsPageView stories * Refactor SecuritySettingsPageView stories * Refactor UserAuthSettingsPageView stories * Refactor GroupsPage stories * Refactor LoginPage tests * Refactor SetupPage stories * Refactor StarterTemplatePageView stories * Refactor StarterTemplatesPage tests * Refactor TemplatePage tests * RefactorTemplateSettingsPage tests * Refactor TemplatesPage tests * Flat TemplateVersionEditorPage * Refactor TemplateVersionPage stories * Refactor UserSettingsPage stories * Refactor UsersPage stories * Simplify IndexPage * Refactor WorkspaceSettingsPage stories * Refactor WorkspacePage stories * Refactor Conditionals stories * Fix typo * Fix imports * Fix ChooseOne story * Fix UserAuthSettingsPageView stories
1 parent 9e5a59e commit 554ddb1

File tree

90 files changed

+1776
-2160
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+1776
-2160
lines changed

site/src/AppRouter.tsx

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { FullScreenLoader } from "components/Loader/FullScreenLoader";
22
import { TemplateLayout } from "components/TemplateLayout/TemplateLayout";
33
import { UsersLayout } from "components/UsersLayout/UsersLayout";
4-
import IndexPage from "pages";
54
import AuditPage from "pages/AuditPage/AuditPage";
65
import GroupsPage from "pages/GroupsPage/GroupsPage";
76
import LoginPage from "pages/LoginPage/LoginPage";
@@ -11,7 +10,12 @@ import TemplatesPage from "pages/TemplatesPage/TemplatesPage";
1110
import UsersPage from "pages/UsersPage/UsersPage";
1211
import WorkspacesPage from "pages/WorkspacesPage/WorkspacesPage";
1312
import { FC, lazy, Suspense } from "react";
14-
import { Route, Routes, BrowserRouter as Router } from "react-router-dom";
13+
import {
14+
Route,
15+
Routes,
16+
BrowserRouter as Router,
17+
Navigate,
18+
} from "react-router-dom";
1519
import { DashboardLayout } from "./components/Dashboard/DashboardLayout";
1620
import { RequireAuth } from "./components/RequireAuth/RequireAuth";
1721
import { SettingsLayout } from "./components/SettingsLayout/SettingsLayout";
@@ -195,7 +199,7 @@ export const AppRouter: FC = () => {
195199
{/* Dashboard routes */}
196200
<Route element={<RequireAuth />}>
197201
<Route element={<DashboardLayout />}>
198-
<Route index element={<IndexPage />} />
202+
<Route index element={<Navigate to="/workspaces" replace />} />
199203

200204
<Route path="health" element={<HealthPage />} />
201205

Original file line numberDiff line numberDiff line change
@@ -1,46 +1,71 @@
1-
import { Story } from "@storybook/react";
1+
import { Meta, StoryObj } from "@storybook/react";
22
import { ChooseOne, Cond } from "./ChooseOne";
33

4-
export default {
4+
const meta: Meta<typeof ChooseOne> = {
55
title: "components/Conditionals/ChooseOne",
66
component: ChooseOne,
7-
subcomponents: { Cond },
87
};
98

10-
export const FirstIsTrue: Story = () => (
11-
<ChooseOne>
12-
<Cond condition>The first one shows.</Cond>
13-
<Cond condition={false}>The second one does not show.</Cond>
14-
<Cond>The default does not show.</Cond>
15-
</ChooseOne>
16-
);
9+
export default meta;
10+
type Story = StoryObj<typeof ChooseOne>;
1711

18-
export const SecondIsTrue: Story = () => (
19-
<ChooseOne>
20-
<Cond condition={false}>The first one does not show.</Cond>
21-
<Cond condition>The second one shows.</Cond>
22-
<Cond>The default does not show.</Cond>
23-
</ChooseOne>
24-
);
12+
export const FirstIsTrue: Story = {
13+
args: {
14+
children: [
15+
<Cond key="1" condition>
16+
The first one shows.
17+
</Cond>,
18+
<Cond key="2" condition={false}>
19+
The second one does not show.
20+
</Cond>,
21+
<Cond key="3">The default does not show.</Cond>,
22+
],
23+
},
24+
};
2525

26-
export const AllAreTrue: Story = () => (
27-
<ChooseOne>
28-
<Cond condition>Only the first one shows.</Cond>
29-
<Cond condition>The second one does not show.</Cond>
30-
<Cond>The default does not show.</Cond>
31-
</ChooseOne>
32-
);
26+
export const SecondIsTrue: Story = {
27+
args: {
28+
children: [
29+
<Cond key="1" condition={false}>
30+
The first one does not show.
31+
</Cond>,
32+
<Cond key="2" condition>
33+
The second one shows.
34+
</Cond>,
35+
<Cond key="3">The default does not show.</Cond>,
36+
],
37+
},
38+
};
39+
export const AllAreTrue: Story = {
40+
args: {
41+
children: [
42+
<Cond key="1" condition>
43+
Only the first one shows.
44+
</Cond>,
45+
<Cond key="2" condition>
46+
The second one does not show.
47+
</Cond>,
48+
<Cond key="3">The default does not show.</Cond>,
49+
],
50+
},
51+
};
3352

34-
export const NoneAreTrue: Story = () => (
35-
<ChooseOne>
36-
<Cond condition={false}>The first one does not show.</Cond>
37-
<Cond condition={false}>The second one does not show.</Cond>
38-
<Cond>The default shows.</Cond>
39-
</ChooseOne>
40-
);
53+
export const NoneAreTrue: Story = {
54+
args: {
55+
children: [
56+
<Cond key="1" condition={false}>
57+
The first one does not show.
58+
</Cond>,
59+
<Cond key="2" condition={false}>
60+
The second one does not show.
61+
</Cond>,
62+
<Cond key="3">The default shows.</Cond>,
63+
],
64+
},
65+
};
4166

42-
export const OneCond: Story = () => (
43-
<ChooseOne>
44-
<Cond>An only child renders.</Cond>
45-
</ChooseOne>
46-
);
67+
export const OneCond: Story = {
68+
args: {
69+
children: <Cond>An only child renders.</Cond>,
70+
},
71+
};
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,25 @@
1-
import { Story } from "@storybook/react";
2-
import { Maybe, MaybeProps } from "./Maybe";
1+
import { StoryObj, Meta } from "@storybook/react";
2+
import { Maybe } from "./Maybe";
33

4-
export default {
4+
const meta: Meta<typeof Maybe> = {
55
title: "components/Conditionals/Maybe",
66
component: Maybe,
7+
args: {
8+
children: "Now you see me",
9+
},
710
};
811

9-
const Template: Story<MaybeProps> = (args: MaybeProps) => (
10-
<Maybe {...args}>Now you see me</Maybe>
11-
);
12+
export default meta;
13+
type Story = StoryObj<typeof Maybe>;
1214

13-
export const ConditionIsTrue = Template.bind({});
14-
ConditionIsTrue.args = {
15-
condition: true,
15+
export const ConditionIsTrue: Story = {
16+
args: {
17+
condition: true,
18+
},
1619
};
1720

18-
export const ConditionIsFalse = Template.bind({});
19-
ConditionIsFalse.args = {
20-
condition: false,
21+
export const ConditionIsFalse: Story = {
22+
args: {
23+
condition: false,
24+
},
2125
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import type { Meta, StoryObj } from "@storybook/react";
2+
import { AuditLogDescription } from "./AuditLogDescription";
3+
import {
4+
MockAuditLog,
5+
MockAuditLogSuccessfulLogin,
6+
MockAuditLogUnsuccessfulLoginKnownUser,
7+
MockAuditLogWithWorkspaceBuild,
8+
MockWorkspaceCreateAuditLogForDifferentOwner,
9+
} from "testHelpers/entities";
10+
11+
const meta: Meta<typeof AuditLogDescription> = {
12+
title: "components/AuditLogDescription",
13+
component: AuditLogDescription,
14+
};
15+
16+
export default meta;
17+
type Story = StoryObj<typeof AuditLogDescription>;
18+
19+
export const WorkspaceCreate: Story = {
20+
args: {
21+
auditLog: MockAuditLog,
22+
},
23+
};
24+
25+
export const WorkspaceBuildStop: Story = {
26+
args: {
27+
auditLog: MockAuditLogWithWorkspaceBuild,
28+
},
29+
};
30+
31+
export const WorkspaceBuildDuplicatedWord: Story = {
32+
args: {
33+
auditLog: {
34+
...MockAuditLogWithWorkspaceBuild,
35+
additional_fields: {
36+
workspace_name: "workspace",
37+
},
38+
},
39+
},
40+
};
41+
42+
export const CreateWorkspaceWithDiffOwner: Story = {
43+
args: {
44+
auditLog: MockWorkspaceCreateAuditLogForDifferentOwner,
45+
},
46+
};
47+
48+
export const SuccessLogin: Story = {
49+
args: {
50+
auditLog: MockAuditLogSuccessfulLogin,
51+
},
52+
};
53+
54+
export const UnsuccessfulLoginForUnknownUser: Story = {
55+
args: {
56+
auditLog: MockAuditLogUnsuccessfulLoginKnownUser,
57+
},
58+
};

site/src/pages/AuditPage/AuditLogRow/AuditLogDescription/AuditLogDescription.test.tsx

-106
This file was deleted.

site/src/pages/AuditPage/AuditLogRow/AuditLogDescription/index.ts

-1
This file was deleted.

site/src/pages/AuditPage/AuditLogRow/AuditLogDiff/index.ts

-2
This file was deleted.

0 commit comments

Comments
 (0)