Skip to content

Commit c5b4eb5

Browse files
committed
Refactor CreateWorkspacePage tests
1 parent cd5b40f commit c5b4eb5

File tree

3 files changed

+63
-77
lines changed

3 files changed

+63
-77
lines changed

site/src/pages/CreateWorkspacePage/CreateWorkspacePage.test.tsx

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -54,30 +54,6 @@ Object.defineProperty(window, "BroadcastChannel", {
5454
});
5555

5656
describe("CreateWorkspacePage", () => {
57-
it("renders", async () => {
58-
jest
59-
.spyOn(API, "getTemplateVersionRichParameters")
60-
.mockResolvedValueOnce([MockTemplateVersionParameter1]);
61-
renderCreateWorkspacePage();
62-
63-
const element = await screen.findByText(createWorkspaceText);
64-
expect(element).toBeDefined();
65-
});
66-
67-
it("renders with rich parameter", async () => {
68-
jest
69-
.spyOn(API, "getTemplateVersionRichParameters")
70-
.mockResolvedValueOnce([MockTemplateVersionParameter1]);
71-
renderCreateWorkspacePage();
72-
73-
const element = await screen.findByText(createWorkspaceText);
74-
expect(element).toBeDefined();
75-
const firstParameter = await screen.findByText(
76-
MockTemplateVersionParameter1.description,
77-
);
78-
expect(firstParameter).toBeDefined();
79-
});
80-
8157
it("succeeds with default owner", async () => {
8258
jest
8359
.spyOn(API, "getUsers")
Lines changed: 45 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,66 @@
1-
import { Story } from "@storybook/react";
2-
import { GitAuth, GitAuthProps } from "./GitAuth";
1+
import { GitAuth } from "./GitAuth";
2+
import type { Meta, StoryObj } from "@storybook/react";
33

4-
export default {
4+
const meta: Meta<typeof GitAuth> = {
55
title: "components/GitAuth",
66
component: GitAuth,
77
};
88

9-
const Template: Story<GitAuthProps> = (args) => <GitAuth {...args} />;
9+
export default meta;
10+
type Story = StoryObj<typeof GitAuth>;
1011

11-
export const GithubNotAuthenticated = Template.bind({});
12-
GithubNotAuthenticated.args = {
13-
type: "github",
14-
authenticated: false,
12+
export const GithubNotAuthenticated: Story = {
13+
args: {
14+
type: "github",
15+
authenticated: false,
16+
},
1517
};
1618

17-
export const GithubAuthenticated = Template.bind({});
18-
GithubAuthenticated.args = {
19-
type: "github",
20-
authenticated: true,
19+
export const GithubAuthenticated: Story = {
20+
args: {
21+
type: "github",
22+
authenticated: true,
23+
},
2124
};
2225

23-
export const GitlabNotAuthenticated = Template.bind({});
24-
GitlabNotAuthenticated.args = {
25-
type: "gitlab",
26-
authenticated: false,
26+
export const GitlabNotAuthenticated: Story = {
27+
args: {
28+
type: "gitlab",
29+
authenticated: false,
30+
},
2731
};
2832

29-
export const GitlabAuthenticated = Template.bind({});
30-
GitlabAuthenticated.args = {
31-
type: "gitlab",
32-
authenticated: true,
33+
export const GitlabAuthenticated: Story = {
34+
args: {
35+
type: "gitlab",
36+
authenticated: true,
37+
},
3338
};
3439

35-
export const AzureDevOpsNotAuthenticated = Template.bind({});
36-
AzureDevOpsNotAuthenticated.args = {
37-
type: "azure-devops",
38-
authenticated: false,
40+
export const AzureDevOpsNotAuthenticated: Story = {
41+
args: {
42+
type: "azure-devops",
43+
authenticated: false,
44+
},
3945
};
4046

41-
export const AzureDevOpsAuthenticated = Template.bind({});
42-
AzureDevOpsAuthenticated.args = {
43-
type: "azure-devops",
44-
authenticated: true,
47+
export const AzureDevOpsAuthenticated: Story = {
48+
args: {
49+
type: "azure-devops",
50+
authenticated: true,
51+
},
4552
};
4653

47-
export const BitbucketNotAuthenticated = Template.bind({});
48-
BitbucketNotAuthenticated.args = {
49-
type: "bitbucket",
50-
authenticated: false,
54+
export const BitbucketNotAuthenticated: Story = {
55+
args: {
56+
type: "bitbucket",
57+
authenticated: false,
58+
},
5159
};
5260

53-
export const BitbucketAuthenticated = Template.bind({});
54-
BitbucketAuthenticated.args = {
55-
type: "bitbucket",
56-
authenticated: true,
61+
export const BitbucketAuthenticated: Story = {
62+
args: {
63+
type: "bitbucket",
64+
authenticated: true,
65+
},
5766
};
Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,29 @@
1-
import { ComponentMeta, Story } from "@storybook/react";
21
import { MockTemplate } from "../../testHelpers/entities";
3-
import { SelectedTemplate, SelectedTemplateProps } from "./SelectedTemplate";
2+
import { SelectedTemplate } from "./SelectedTemplate";
3+
import type { Meta, StoryObj } from "@storybook/react";
44

5-
export default {
5+
const meta: Meta<typeof SelectedTemplate> = {
66
title: "components/SelectedTemplate",
77
component: SelectedTemplate,
8-
} as ComponentMeta<typeof SelectedTemplate>;
8+
};
99

10-
const Template: Story<SelectedTemplateProps> = (args) => (
11-
<SelectedTemplate {...args} />
12-
);
10+
export default meta;
11+
type Story = StoryObj<typeof SelectedTemplate>;
1312

14-
export const WithIcon = Template.bind({});
15-
WithIcon.args = {
16-
template: {
17-
...MockTemplate,
18-
icon: "/icon/docker.png",
13+
export const WithIcon: Story = {
14+
args: {
15+
template: {
16+
...MockTemplate,
17+
icon: "/icon/docker.png",
18+
},
1919
},
2020
};
2121

22-
export const WithoutIcon = Template.bind({});
23-
WithoutIcon.args = {
24-
template: {
25-
...MockTemplate,
26-
icon: "",
22+
export const WithoutIcon: Story = {
23+
args: {
24+
template: {
25+
...MockTemplate,
26+
icon: "",
27+
},
2728
},
2829
};

0 commit comments

Comments
 (0)