fix(site): fix storybook error and inconsistent snapshots (#9010)

This commit is contained in:
Bruno Quaresma
2023-08-09 21:22:13 +00:00
committed by GitHub
parent fb5e0c4bba
commit c0d1cacc49
3 changed files with 51 additions and 24 deletions
@@ -201,7 +201,8 @@ const StaticWidth = (props: BoxProps) => {
const ref = useRef<HTMLDivElement>(null)
useEffect(() => {
if (!ref.current) {
// Ignore this in storybook
if (!ref.current || process.env.STORYBOOK === "true") {
return
}
@@ -1,11 +1,8 @@
import { ComponentMeta, Story } from "@storybook/react"
import { Meta, StoryObj } from "@storybook/react"
import { mockApiError, MockDeploymentDAUResponse } from "testHelpers/entities"
import {
GeneralSettingsPageView,
GeneralSettingsPageViewProps,
} from "./GeneralSettingsPageView"
import { GeneralSettingsPageView } from "./GeneralSettingsPageView"
export default {
const meta: Meta<typeof GeneralSettingsPageView> = {
title: "pages/GeneralSettingsPageView",
component: GeneralSettingsPageView,
args: {
@@ -13,34 +10,58 @@ export default {
{
name: "Access URL",
description:
"External URL to access your deployment. This must be accessible by all provisioned workspaces.",
"The URL that users will use to access the Coder deployment.",
flag: "access-url",
flag_shorthand: "",
value: "https://dev.coder.com",
hidden: false,
},
{
name: "Wildcard Access URL",
description:
'Specifies the wildcard hostname to use for workspace applications in the form "*.example.com".',
flag: "wildcard-access-url",
flag_shorthand: "",
value: "*--apps.dev.coder.com",
hidden: false,
},
{
name: "Experiments",
description:
"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.",
flag: "experiments",
value: [
"*",
"moons",
"workspace_actions",
"single_tailnet",
"deployment_health_page",
"template_parameters_insights",
],
flag_shorthand: "",
hidden: false,
},
],
deploymentDAUs: MockDeploymentDAUResponse,
},
} as ComponentMeta<typeof GeneralSettingsPageView>
const Template: Story<GeneralSettingsPageViewProps> = (args) => (
<GeneralSettingsPageView {...args} />
)
export const Page = Template.bind({})
export const NoDAUs = Template.bind({})
NoDAUs.args = {
deploymentDAUs: undefined,
}
export const DAUError = Template.bind({})
DAUError.args = {
deploymentDAUs: undefined,
getDeploymentDAUsError: mockApiError({
message: "Error fetching DAUs.",
}),
export default meta
type Story = StoryObj<typeof GeneralSettingsPageView>
export const Page: Story = {}
export const NoDAUs: Story = {
args: {
deploymentDAUs: undefined,
},
}
export const DAUError: Story = {
args: {
deploymentDAUs: undefined,
getDeploymentDAUsError: mockApiError({
message: "Error fetching DAUs.",
}),
},
}
@@ -12,6 +12,11 @@ export const WorkspaceBuildLogsSection = ({
const scrollRef = useRef<HTMLDivElement>(null)
useEffect(() => {
// Auto scrolling makes hard to snapshot test using Chromatic
if (process.env.STORYBOOK === "true") {
return
}
const scrollEl = scrollRef.current
if (scrollEl) {
scrollEl.scrollTop = scrollEl.scrollHeight