mirror of
https://github.com/langgenius/dify.git
synced 2026-07-20 09:38:32 +08:00
test: simplify dify ui browser test setup (#39028)
This commit is contained in:
parent
79662d49af
commit
abb9972e19
@ -9,7 +9,8 @@
|
||||
"src/**/*.ts",
|
||||
"src/**/*.tsx",
|
||||
"vite.config.ts",
|
||||
"vitest.config.ts"
|
||||
"vitest.config.ts",
|
||||
"vitest.setup.ts"
|
||||
],
|
||||
"exclude": ["node_modules", "dist", "storybook-static", "coverage"]
|
||||
}
|
||||
|
||||
@ -49,7 +49,6 @@ export default defineConfig({
|
||||
provider: playwright(),
|
||||
instances: [{ browser: 'chromium' }],
|
||||
headless: true,
|
||||
testerHtmlPath: './vitest.tester.html',
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
6
packages/dify-ui/vitest.css
Normal file
6
packages/dify-ui/vitest.css
Normal file
@ -0,0 +1,6 @@
|
||||
@import 'tailwindcss';
|
||||
@import './src/styles/styles.css';
|
||||
|
||||
@plugin './src/plugins/icons.ts';
|
||||
|
||||
@source './src';
|
||||
@ -1,3 +1,7 @@
|
||||
import './vitest.css'
|
||||
|
||||
document.documentElement.dataset.theme = 'light'
|
||||
|
||||
;(
|
||||
globalThis as typeof globalThis & {
|
||||
BASE_UI_ANIMATIONS_DISABLED: boolean
|
||||
|
||||
@ -1,10 +0,0 @@
|
||||
<!doctype html>
|
||||
<html lang="en" data-theme="light">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<link rel="stylesheet" href="./.storybook/storybook.css" />
|
||||
<title>Dify UI Tests</title>
|
||||
</head>
|
||||
<body></body>
|
||||
</html>
|
||||
@ -99,6 +99,7 @@ Mocks must preserve the public contract needed by the test. Do not replace Dify
|
||||
## Dify Test Setup
|
||||
|
||||
- Tests under `web/` run in `happy-dom` through `web/vite.config.ts` and load `web/vitest.setup.ts`.
|
||||
- Tests under `packages/dify-ui/` use separate Vitest Browser Mode projects: unit specs load the package styles through `vitest.setup.ts`, while Storybook tests run stories through `@storybook/addon-vitest`.
|
||||
- New component and feature specs should generally use a sibling `__tests__/` directory. Existing colocated utility and hook specs may follow their owning module's convention. Cross-feature integration specs belong in `web/__tests__/`.
|
||||
- The shared `react-i18next` mock is loaded globally. Use `createReactI18nextMock` from `web/test/i18n-mock` only when a test needs custom translations.
|
||||
- For `nuqs` behavior, use the helpers in `web/test/nuqs-testing.tsx` and assert URL updates. Mock `nuqs` only when URL synchronization is explicitly outside the test contract.
|
||||
@ -148,12 +149,14 @@ vp test run --coverage path/to/spec-or-directory
|
||||
- [Vitest documentation]
|
||||
- [Vitest Browser Mode documentation]
|
||||
- [Vitest Browser Mode locators]
|
||||
- [Storybook Vitest addon]
|
||||
- [Testing Library guiding principles]
|
||||
- [React Testing Library documentation]
|
||||
- [Testing Library query guidance]
|
||||
- [Testing Library user-event guidance]
|
||||
|
||||
[React Testing Library documentation]: https://testing-library.com/docs/react-testing-library/intro
|
||||
[Storybook Vitest addon]: https://storybook.js.org/docs/writing-tests/integrations/vitest-addon
|
||||
[Testing Library guiding principles]: https://testing-library.com/docs/guiding-principles
|
||||
[Testing Library query guidance]: https://testing-library.com/docs/queries/about
|
||||
[Testing Library user-event guidance]: https://testing-library.com/docs/user-event/intro
|
||||
|
||||
Loading…
Reference in New Issue
Block a user