Skip to content

Commit 8508e69

Browse files
committed
Add storybook for visual testing
1 parent 98aa054 commit 8508e69

File tree

2 files changed

+61
-0
lines changed

2 files changed

+61
-0
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import type { Meta, StoryObj } from "@storybook/react";
2+
import { chromatic } from "testHelpers/chromatic";
3+
import { TemplateFileTree } from "./TemplateFileTree";
4+
import { FileTree } from "utils/filetree";
5+
import { useTheme } from "@emotion/react";
6+
7+
const fileTree: FileTree = {
8+
"main.tf": "resource aws_instance my_instance {}",
9+
"variables.tf": "variable my_var {}",
10+
"outputs.tf": "output my_output {}",
11+
folder: {
12+
"nested.tf": "resource aws_instance my_instance {}",
13+
},
14+
};
15+
16+
const meta: Meta<typeof TemplateFileTree> = {
17+
title: "modules/templates/TemplateFileTree",
18+
parameters: { chromatic },
19+
component: TemplateFileTree,
20+
args: {
21+
fileTree,
22+
activePath: "main.tf",
23+
},
24+
decorators: [
25+
(Story) => {
26+
const theme = useTheme();
27+
return (
28+
<div
29+
css={{
30+
maxWidth: 260,
31+
borderRadius: 8,
32+
border: `1px solid ${theme.palette.divider}`,
33+
}}
34+
>
35+
<Story />
36+
</div>
37+
);
38+
},
39+
],
40+
};
41+
42+
export default meta;
43+
type Story = StoryObj<typeof TemplateFileTree>;
44+
45+
export const Example: Story = {};
46+
47+
export const NestedOpen: Story = {
48+
args: {
49+
activePath: "folder/nested.tf",
50+
},
51+
};

site/src/modules/templates/TemplateFiles/TemplateFiles.stories.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,14 @@ type Story = StoryObj<typeof TemplateFiles>;
2626

2727
const Example: Story = {};
2828

29+
export const WithDiff: Story = {
30+
args: {
31+
currentFiles: {
32+
...exampleFiles,
33+
"main.tf": `${exampleFiles["main.tf"]} - with changes`,
34+
},
35+
baseFiles: exampleFiles,
36+
},
37+
};
38+
2939
export { Example as TemplateFiles };

0 commit comments

Comments
 (0)