Skip to content

Commit

Permalink
Merge pull request #15 from DaleStudy/story-testing
Browse files Browse the repository at this point in the history
μŠ€ν† λ¦¬λΆ ν…ŒμŠ€νŒ… μ…‹μ—…
  • Loading branch information
DaleSeo authored Dec 11, 2024
2 parents 7723605 + 06d7734 commit eafebef
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 14 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/automation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Automation πŸ€–

on:
pull_request_target:
types: [opened, reopened]

jobs:
assign-author:
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- uses: toshimaru/auto-author-assign@v2.1.1
15 changes: 15 additions & 0 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Integration πŸ”€

on:
pull_request:

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v2
- run: bun install
- run: bun run lint
- run: bun run test run
- run: bun run build
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[![Chromatic 🎨](https://github.com/DaleStudy/dale-ui/actions/workflows/chromatic.yml/badge.svg)](https://github.com/DaleStudy/dale-ui/actions/workflows/chromatic.yml)
[![Integration πŸ”€](https://github.com/DaleStudy/dale-ui/actions/workflows/integration.yml/badge.svg)](https://github.com/DaleStudy/dale-ui/actions/workflows/integration.yml)

# λ‹¬λ ˆ UI

Expand Down
5 changes: 5 additions & 0 deletions chromatic.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"onlyChanged": true,
"projectId": "Project:675790d317ba346348aa3490",
"zip": true
}
26 changes: 13 additions & 13 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
import js from '@eslint/js'
import globals from 'globals'
import reactHooks from 'eslint-plugin-react-hooks'
import reactRefresh from 'eslint-plugin-react-refresh'
import tseslint from 'typescript-eslint'
import js from "@eslint/js";
import globals from "globals";
import reactHooks from "eslint-plugin-react-hooks";
import reactRefresh from "eslint-plugin-react-refresh";
import tseslint from "typescript-eslint";

export default tseslint.config(
{ ignores: ['dist'] },
{ ignores: ["dist", "styled-system"] },
{
extends: [js.configs.recommended, ...tseslint.configs.recommended],
files: ['**/*.{ts,tsx}'],
files: ["**/*.{ts,tsx}"],
languageOptions: {
ecmaVersion: 2020,
globals: globals.browser,
},
plugins: {
'react-hooks': reactHooks,
'react-refresh': reactRefresh,
"react-hooks": reactHooks,
"react-refresh": reactRefresh,
},
rules: {
...reactHooks.configs.recommended.rules,
'react-refresh/only-export-components': [
'warn',
"react-refresh/only-export-components": [
"warn",
{ allowConstantExport: true },
],
},
},
)
}
);
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
"lint": "eslint .",
"test": "vitest",
"preview": "vite preview",
"sb": "storybook dev -p 6006",
"storybook": "storybook dev -p 6006",
"build-storybook": "storybook build",
"test-storybook": "test-storybook",
"prepare": "panda codegen"
},
"dependencies": {
Expand All @@ -29,6 +31,7 @@
"@storybook/react": "^8.4.6",
"@storybook/react-vite": "^8.4.6",
"@storybook/test": "^8.4.6",
"@storybook/test-runner": "^0.20.1",
"@testing-library/jest-dom": "^6.6.3",
"@testing-library/react": "^16.0.1",
"@testing-library/user-event": "^14.5.2",
Expand Down
14 changes: 13 additions & 1 deletion src/components/Button/Button.stories.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Meta, StoryObj } from "@storybook/react";
import { fn } from "@storybook/test";
import { expect, fn, userEvent } from "@storybook/test";
import { Button } from "./Button";

const meta = {
Expand All @@ -19,6 +19,18 @@ export const Basic: Story = {
type: "button",
children: "Click",
},
play: async ({ args: { onClick }, canvas, step }) => {
const button = canvas.getByRole("button");

await step("renders a button with text", async () => {
expect(button).toHaveTextContent("Click");
});

await step("calls onClick handler when clicked", async () => {
await userEvent.click(button);
expect(onClick).toHaveBeenCalledTimes(1);
});
},
};

export const Submit: Story = {
Expand Down

0 comments on commit eafebef

Please sign in to comment.