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

[WIP] エンジンのモック作成+それを使ったコンポーネントテスト #2152

Draft
wants to merge 20 commits into
base: main
Choose a base branch
from
Draft
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
9 changes: 9 additions & 0 deletions .storybook/main.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { StorybookConfig } from "@storybook/vue3-vite";
import { assetsPath, dicPath } from "@/mock/engineMock";

const config: StorybookConfig = {
stories: ["../src/**/*.mdx", "../src/**/*.stories.@(js|jsx|mjs|ts|tsx)"],
Expand All @@ -8,12 +9,20 @@ const config: StorybookConfig = {
"@chromatic-com/storybook",
"@storybook/addon-interactions",
],
core: {
builder: "@storybook/builder-vite",
},
framework: {
name: "@storybook/vue3-vite",
options: {
docgen: "vue-component-meta",
},
},
staticDirs: [
// モックエンジン用のファイル
{ from: "../node_modules/kuromoji/dict", to: dicPath },
{ from: "../tests/assets", to: assetsPath },
],
};

export default config;
3 changes: 3 additions & 0 deletions .storybook/preview-head.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<!-- %BROWSER_PRELOAD% -->
<!-- FIXME: 色取得のために必要。DIできるようにしたい。 -->
<script type="module" src="/src/backend/browser/preload.ts"></script>
6 changes: 5 additions & 1 deletion .storybook/preview.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { setup, Preview } from "@storybook/vue3";
import { Quasar, Dialog, Loading, Notify } from "quasar";
import iconSet from "quasar/icon-set/material-icons";
import { addActionsWithEmits } from "./utils/argTypesEnhancers";

Check failure on line 4 in .storybook/preview.ts

View workflow job for this annotation

GitHub Actions / build-test

Cannot find module './utils/argTypesEnhancers' or its corresponding type declarations.

Check failure on line 4 in .storybook/preview.ts

View workflow job for this annotation

GitHub Actions / lint

Cannot find module './utils/argTypesEnhancers' or its corresponding type declarations.
import { markdownItPlugin } from "@/plugins/markdownItPlugin";
import { resetMockMode } from "@/helpers/random";

import "@quasar/extras/material-icons/material-icons.css";
import "quasar/dist/quasar.sass";
Expand Down Expand Up @@ -34,7 +35,10 @@
toc: true,
},
},
argTypesEnhancers: [addActionsWithEmits],

beforeEach() {
resetMockMode();
},
};

export default preview;
18 changes: 18 additions & 0 deletions .storybook/test-runner.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { type TestRunnerConfig } from "@storybook/test-runner";

const config: TestRunnerConfig = {
async preVisit(page) {
// テスト用のスナップショット関数を追加する。
// *.stories.ts内で`window.storybookTestSnapshot`を使って呼び出せる。
if (await page.evaluate(() => !("storybookTestSnapshot" in window))) {
await page.exposeBinding(
"storybookTestSnapshot",
async (_, obj: unknown) => {
expect(obj).toMatchSnapshot();
},
);
}
},
};

export default config;
34 changes: 0 additions & 34 deletions .storybook/utils/argTypesEnhancers.ts

This file was deleted.

5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ Storybook を使ってコンポーネントを開発することができます
npm run storybook
```

また、main ブランチの Storybook が Chromatic から見れます。
<https://main--667d9c007418420dbb5b0f75.chromatic.com/>

### ブラウザ版の実行(開発中)

別途音声合成エンジンを起動し、以下を実行して表示された localhost へアクセスします。
Expand All @@ -96,7 +99,7 @@ npm run storybook
npm run browser:serve
```

また、main ブランチのビルド結果がこちらにデプロイされています <https://voicevox-browser-dev.netlify.app/>
また、main ブランチのビルド結果がこちらにデプロイされています <https://voicevox-browser-dev.netlify.app/>
今はローカル PC 上で音声合成エンジンを起動する必要があります。

## ビルド
Expand Down
Loading
Loading