Skip to content
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

Show message when snapshotting is disabled for story #300

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
27 changes: 27 additions & 0 deletions src/screens/VisualTests/NoBuild.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Loader } from "@storybook/components";
import { PlayIcon } from "@storybook/icons";
import { useParameter } from "@storybook/manager-api";
import { styled } from "@storybook/theming";
import React from "react";
import { CombinedError } from "urql";
Expand Down Expand Up @@ -44,6 +45,7 @@ export const NoBuild = ({
}: NoBuildProps) => {
const { setAccessToken } = useAuthState();
const { isRunning, startBuild } = useRunBuildState();
const { disable, disableSnapshot, docsOnly } = useParameter("chromatic", {} as any);

const getDetails = () => {
const button = (
Expand Down Expand Up @@ -133,6 +135,31 @@ export const NoBuild = ({
);
}

if (disable || disableSnapshot || docsOnly) {
// eslint-disable-next-line no-nested-ternary
const param = disable ? "disable" : disableSnapshot ? "disableSnapshot" : "docsOnly";
return (
<Container>
<Stack>
<div>
<Heading>Visual Tests disabled for this story</Heading>
<Text center muted>
Update <code>parameters.chromatic.{param}</code> to enable snapshots for this story.
</Text>
</div>

<ButtonStackLink
withArrow
href="https://www.chromatic.com/docs/ignoring-elements/#ignore-stories"
target="_blank"
>
Read more
</ButtonStackLink>
</Stack>
</Container>
);
}

if (!hasSelectedBuild) {
return (
<Container>
Expand Down
16 changes: 16 additions & 0 deletions src/screens/VisualTests/VisualTests.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ type StoryArgs = Parameters<typeof VisualTestsWithoutSelectedBuildId>[0] & {
togglePanelPosition: () => void;
setSelectedPanel: () => void;
getCurrentStoryData: () => any;
getCurrentParameter: () => any;
once: () => void;
$graphql?: { AddonVisualTestsBuild?: QueryInput };
};
Expand All @@ -131,6 +132,7 @@ const meta = {
togglePanelPosition: { type: "function", target: "manager-api" },
setSelectedPanel: { type: "function", target: "manager-api" },
getCurrentStoryData: { type: "function", target: "manager-api" },
getCurrentParameter: { type: "function", target: "manager-api" },
once: { type: "function", target: "manager-api" },
$graphql: {
AddonVisualTestsBuild: { map: mapQuery },
Expand Down Expand Up @@ -160,6 +162,7 @@ const meta = {
togglePanelPosition: fn(),
setSelectedPanel: fn(),
getCurrentStoryData: () => ({ type: "story" }),
getCurrentParameter: () => ({}),
once: fn(),
$graphql: { AddonVisualTestsBuild: {} },
},
Expand Down Expand Up @@ -818,6 +821,19 @@ export const Accepted = {
},
} satisfies Story;

export const Disabled = {
args: {
storyId: "button--tertiary",
selectedBuildInfo: { buildId: pendingBuild.id, storyId: meta.args.storyId },
getCurrentParameter: () => ({ disableSnapshot: true }),
},
parameters: {
...withFigmaDesign(
"https://www.figma.com/file/GFEbCgCVDtbZhngULbw2gP/Visual-testing-in-Storybook?type=design&node-id=2255-42087&t=a8NRPgQk3kXMyxqZ-0"
),
},
} satisfies Story;

export const Skipped = {
args: {
storyId: "button--tertiary",
Expand Down
Loading