Skip to content

Commit ea2f65b

Browse files
committed
add stories
1 parent add4d6f commit ea2f65b

File tree

3 files changed

+70
-34
lines changed

3 files changed

+70
-34
lines changed
Lines changed: 49 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,52 @@
1-
// import { ExternalAuthSettingsPageView } from "./ExternalAuthSettingsPageView";
2-
// import type { Meta, StoryObj } from "@storybook/react";
1+
import {
2+
MockGithubAuthLink,
3+
MockGithubExternalProvider,
4+
} from "testHelpers/entities";
5+
import { UserExternalAuthSettingsPageView } from "./UserExternalAuthSettingsPageView";
6+
import type { Meta, StoryObj } from "@storybook/react";
37

4-
// const meta: Meta<typeof ExternalAuthSettingsPageView> = {
5-
// title: "pages/DeploySettingsPage/ExternalAuthSettingsPageView",
6-
// component: ExternalAuthSettingsPageView,
7-
// args: {
8-
// config: {
9-
// external_auth: [
10-
// {
11-
// id: "0000-1111",
12-
// type: "GitHub",
13-
// client_id: "client_id",
14-
// regex: "regex",
15-
// auth_url: "",
16-
// token_url: "",
17-
// validate_url: "",
18-
// app_install_url: "https://github.com/apps/coder/installations/new",
19-
// app_installations_url: "",
20-
// no_refresh: false,
21-
// scopes: [],
22-
// extra_token_keys: [],
23-
// device_flow: true,
24-
// device_code_url: "",
25-
// display_icon: "",
26-
// display_name: "GitHub",
27-
// },
28-
// ],
29-
// },
30-
// },
31-
// };
8+
const meta: Meta<typeof UserExternalAuthSettingsPageView> = {
9+
title: "pages/UserExternalAuthSettingsPage/UserExternalAuthSettingsPageView",
10+
component: UserExternalAuthSettingsPageView,
11+
args: {
12+
isLoading: false,
13+
getAuthsError: undefined,
14+
unlinked: 0,
15+
auths: {
16+
providers: [],
17+
links: [],
18+
},
19+
onUnlinkExternalAuth: () => {},
20+
onValidateExternalAuth: () => {},
21+
},
22+
};
3223

33-
// export default meta;
34-
// type Story = StoryObj<typeof ExternalAuthSettingsPageView>;
24+
export default meta;
25+
type Story = StoryObj<typeof UserExternalAuthSettingsPageView>;
3526

36-
// export const Page: Story = {};
27+
export const NoProviders: Story = {};
28+
29+
export const Authenticated: Story = {
30+
args: {
31+
...meta.args,
32+
auths: {
33+
providers: [MockGithubExternalProvider],
34+
links: [MockGithubAuthLink],
35+
},
36+
},
37+
};
38+
39+
export const UnAuthenticated: Story = {
40+
args: {
41+
...meta.args,
42+
auths: {
43+
providers: [MockGithubExternalProvider],
44+
links: [
45+
{
46+
...MockGithubAuthLink,
47+
authenticated: false,
48+
},
49+
],
50+
},
51+
},
52+
};

site/src/pages/UserExternalAuthSettingsPage/UserExternalAuthSettingsPageView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ const useExternalAuth = (providerID: string, unlinked: number) => {
209209
if (unlinked > 0) {
210210
void refetch();
211211
}
212-
}, [unlinked]);
212+
}, [refetch, unlinked]);
213213

214214
useEffect(() => {
215215
if (signedIn) {

site/src/testHelpers/entities.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2931,3 +2931,23 @@ export const DeploymentHealthUnhealthy: TypesGen.HealthcheckReport = {
29312931
},
29322932
},
29332933
};
2934+
2935+
export const MockGithubExternalProvider: TypesGen.ExternalAuthLinkProvider = {
2936+
id: "github",
2937+
type: "github",
2938+
device: false,
2939+
display_icon: "/icon/github.svg",
2940+
display_name: "GitHub",
2941+
allow_refresh: true,
2942+
allow_validate: true,
2943+
};
2944+
2945+
export const MockGithubAuthLink: TypesGen.ExternalAuthLink = {
2946+
provider_id: "github",
2947+
created_at: "",
2948+
updated_at: "",
2949+
has_refresh_token: true,
2950+
expires: "",
2951+
authenticated: true,
2952+
validate_error: "",
2953+
};

0 commit comments

Comments
 (0)