Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion site/src/components/Resources/AgentMetadata.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,46 +1,67 @@
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: {
deploymentOptions: [
{
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>
}

export default meta
type Story = StoryObj<typeof GeneralSettingsPageView>

const Template: Story<GeneralSettingsPageViewProps> = (args) => (
<GeneralSettingsPageView {...args} />
)
export const Page = Template.bind({})
export const Page: Story = {}

export const NoDAUs = Template.bind({})
NoDAUs.args = {
deploymentDAUs: undefined,
export const NoDAUs: Story = {
args: {
deploymentDAUs: undefined,
},
}

export const DAUError = Template.bind({})
DAUError.args = {
deploymentDAUs: undefined,
getDeploymentDAUsError: mockApiError({
message: "Error fetching DAUs.",
}),
export const DAUError: Story = {
args: {
deploymentDAUs: undefined,
getDeploymentDAUsError: mockApiError({
message: "Error fetching DAUs.",
}),
},
}
5 changes: 5 additions & 0 deletions site/src/pages/WorkspacePage/WorkspaceBuildLogsSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down