Skip to content

Commit c0d1cac

Browse files
fix(site): fix storybook error and inconsistent snapshots (#9010)
1 parent fb5e0c4 commit c0d1cac

File tree

3 files changed

+49
-22
lines changed

3 files changed

+49
-22
lines changed

site/src/components/Resources/AgentMetadata.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,8 @@ const StaticWidth = (props: BoxProps) => {
201201
const ref = useRef<HTMLDivElement>(null)
202202

203203
useEffect(() => {
204-
if (!ref.current) {
204+
// Ignore this in storybook
205+
if (!ref.current || process.env.STORYBOOK === "true") {
205206
return
206207
}
207208

Original file line numberDiff line numberDiff line change
@@ -1,46 +1,67 @@
1-
import { ComponentMeta, Story } from "@storybook/react"
1+
import { Meta, StoryObj } from "@storybook/react"
22
import { mockApiError, MockDeploymentDAUResponse } from "testHelpers/entities"
3-
import {
4-
GeneralSettingsPageView,
5-
GeneralSettingsPageViewProps,
6-
} from "./GeneralSettingsPageView"
3+
import { GeneralSettingsPageView } from "./GeneralSettingsPageView"
74

8-
export default {
5+
const meta: Meta<typeof GeneralSettingsPageView> = {
96
title: "pages/GeneralSettingsPageView",
107
component: GeneralSettingsPageView,
118
args: {
129
deploymentOptions: [
1310
{
1411
name: "Access URL",
1512
description:
16-
"External URL to access your deployment. This must be accessible by all provisioned workspaces.",
13+
"The URL that users will use to access the Coder deployment.",
14+
flag: "access-url",
15+
flag_shorthand: "",
1716
value: "https://dev.coder.com",
17+
hidden: false,
1818
},
1919
{
2020
name: "Wildcard Access URL",
2121
description:
2222
'Specifies the wildcard hostname to use for workspace applications in the form "*.example.com".',
23+
flag: "wildcard-access-url",
24+
flag_shorthand: "",
2325
value: "*--apps.dev.coder.com",
26+
hidden: false,
27+
},
28+
{
29+
name: "Experiments",
30+
description:
31+
"Enable one or more experiments. These are not ready for production. Separate multiple experiments with commas, or enter '*' to opt-in to all available experiments.",
32+
flag: "experiments",
33+
value: [
34+
"*",
35+
"moons",
36+
"workspace_actions",
37+
"single_tailnet",
38+
"deployment_health_page",
39+
"template_parameters_insights",
40+
],
41+
flag_shorthand: "",
42+
hidden: false,
2443
},
2544
],
2645
deploymentDAUs: MockDeploymentDAUResponse,
2746
},
28-
} as ComponentMeta<typeof GeneralSettingsPageView>
47+
}
48+
49+
export default meta
50+
type Story = StoryObj<typeof GeneralSettingsPageView>
2951

30-
const Template: Story<GeneralSettingsPageViewProps> = (args) => (
31-
<GeneralSettingsPageView {...args} />
32-
)
33-
export const Page = Template.bind({})
52+
export const Page: Story = {}
3453

35-
export const NoDAUs = Template.bind({})
36-
NoDAUs.args = {
37-
deploymentDAUs: undefined,
54+
export const NoDAUs: Story = {
55+
args: {
56+
deploymentDAUs: undefined,
57+
},
3858
}
3959

40-
export const DAUError = Template.bind({})
41-
DAUError.args = {
42-
deploymentDAUs: undefined,
43-
getDeploymentDAUsError: mockApiError({
44-
message: "Error fetching DAUs.",
45-
}),
60+
export const DAUError: Story = {
61+
args: {
62+
deploymentDAUs: undefined,
63+
getDeploymentDAUsError: mockApiError({
64+
message: "Error fetching DAUs.",
65+
}),
66+
},
4667
}

site/src/pages/WorkspacePage/WorkspaceBuildLogsSection.tsx

+5
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ export const WorkspaceBuildLogsSection = ({
1212
const scrollRef = useRef<HTMLDivElement>(null)
1313

1414
useEffect(() => {
15+
// Auto scrolling makes hard to snapshot test using Chromatic
16+
if (process.env.STORYBOOK === "true") {
17+
return
18+
}
19+
1520
const scrollEl = scrollRef.current
1621
if (scrollEl) {
1722
scrollEl.scrollTop = scrollEl.scrollHeight

0 commit comments

Comments
 (0)