Skip to content

Commit f47f656

Browse files
committed
Refactor UsersPage stories
1 parent b1aa401 commit f47f656

File tree

3 files changed

+38
-53
lines changed

3 files changed

+38
-53
lines changed
Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,20 @@
1-
import { action } from "@storybook/addon-actions";
2-
import { Story } from "@storybook/react";
1+
import { Meta, StoryObj } from "@storybook/react";
32
import { MockUser } from "testHelpers/entities";
43

5-
import {
6-
ResetPasswordDialog,
7-
ResetPasswordDialogProps,
8-
} from "./ResetPasswordDialog";
4+
import { ResetPasswordDialog } from "./ResetPasswordDialog";
95

10-
export default {
6+
const meta: Meta<typeof ResetPasswordDialog> = {
117
title: "components/Dialogs/ResetPasswordDialog",
128
component: ResetPasswordDialog,
13-
argTypes: {
14-
onClose: { action: "onClose", defaultValue: action("onClose") },
15-
onConfirm: { action: "onConfirm", defaultValue: action("onConfirm") },
16-
},
179
};
1810

19-
const Template: Story<ResetPasswordDialogProps> = (
20-
args: ResetPasswordDialogProps,
21-
) => <ResetPasswordDialog {...args} />;
11+
export default meta;
12+
type Story = StoryObj<typeof ResetPasswordDialog>;
2213

23-
export const Example = Template.bind({});
24-
Example.args = {
25-
open: true,
26-
user: MockUser,
27-
newPassword: "somerandomstringhere",
14+
export const Example: Story = {
15+
args: {
16+
open: true,
17+
user: MockUser,
18+
newPassword: "somerandomstringhere",
19+
},
2820
};

site/src/pages/UsersPage/UsersPage.test.tsx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -179,12 +179,6 @@ const updateUserRole = async (setupActionSpies: () => void, role: Role) => {
179179
};
180180

181181
describe("UsersPage", () => {
182-
it("shows users", async () => {
183-
renderPage();
184-
const users = await screen.findAllByText(/.*@coder.com/);
185-
expect(users.length).toEqual(3);
186-
});
187-
188182
describe("suspend user", () => {
189183
describe("when it is success", () => {
190184
it("shows a success message and refresh the page", async () => {
Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,41 @@
1-
import { ComponentMeta, Story } from "@storybook/react";
21
import {
32
MockOwnerRole,
43
MockSiteRoles,
54
MockUserAdminRole,
65
} from "testHelpers/entities";
7-
import { EditRolesButtonProps, EditRolesButton } from "./EditRolesButton";
6+
import { EditRolesButton } from "./EditRolesButton";
7+
import type { Meta, StoryObj } from "@storybook/react";
88

9-
export default {
9+
const meta: Meta<typeof EditRolesButton> = {
1010
title: "components/EditRolesButton",
1111
component: EditRolesButton,
12-
argTypes: {
13-
defaultIsOpen: {
14-
defaultValue: true,
15-
},
12+
args: {
13+
defaultIsOpen: true,
1614
},
17-
} as ComponentMeta<typeof EditRolesButton>;
15+
};
1816

19-
const Template: Story<EditRolesButtonProps> = (args) => (
20-
<EditRolesButton {...args} />
21-
);
17+
export default meta;
18+
type Story = StoryObj<typeof EditRolesButton>;
2219

23-
export const Open = Template.bind({});
24-
Open.args = {
25-
roles: MockSiteRoles,
26-
selectedRoles: [MockUserAdminRole, MockOwnerRole],
27-
};
28-
Open.parameters = {
29-
chromatic: { delay: 300 },
20+
export const Open: Story = {
21+
args: {
22+
roles: MockSiteRoles,
23+
selectedRoles: [MockUserAdminRole, MockOwnerRole],
24+
},
25+
parameters: {
26+
chromatic: { delay: 300 },
27+
},
3028
};
3129

32-
export const Loading = Template.bind({});
33-
Loading.args = {
34-
isLoading: true,
35-
roles: MockSiteRoles,
36-
selectedRoles: [MockUserAdminRole, MockOwnerRole],
37-
userLoginType: "password",
38-
oidcRoleSync: false,
39-
};
40-
Loading.parameters = {
41-
chromatic: { delay: 300 },
30+
export const Loading: Story = {
31+
args: {
32+
isLoading: true,
33+
roles: MockSiteRoles,
34+
selectedRoles: [MockUserAdminRole, MockOwnerRole],
35+
userLoginType: "password",
36+
oidcRoleSync: false,
37+
},
38+
parameters: {
39+
chromatic: { delay: 300 },
40+
},
4241
};

0 commit comments

Comments
 (0)