@liqngliz/browser-coding-agent 0.0.0-stage → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (133) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +132 -2
  3. package/app/.playwright/package/LICENSE +202 -0
  4. package/app/.playwright/package/NOTICE +5 -0
  5. package/app/.playwright/package/README.md +3 -0
  6. package/app/.playwright/package/ThirdPartyNotices.txt +13 -0
  7. package/app/.playwright/package/bin/install_media_pack.ps1 +5 -0
  8. package/app/.playwright/package/bin/install_webkit_wsl.ps1 +33 -0
  9. package/app/.playwright/package/bin/reinstall_chrome_beta_linux.sh +42 -0
  10. package/app/.playwright/package/bin/reinstall_chrome_beta_mac.sh +13 -0
  11. package/app/.playwright/package/bin/reinstall_chrome_beta_win.ps1 +24 -0
  12. package/app/.playwright/package/bin/reinstall_chrome_stable_linux.sh +42 -0
  13. package/app/.playwright/package/bin/reinstall_chrome_stable_mac.sh +12 -0
  14. package/app/.playwright/package/bin/reinstall_chrome_stable_win.ps1 +24 -0
  15. package/app/.playwright/package/bin/reinstall_msedge_beta_linux.sh +48 -0
  16. package/app/.playwright/package/bin/reinstall_msedge_beta_mac.sh +11 -0
  17. package/app/.playwright/package/bin/reinstall_msedge_beta_win.ps1 +23 -0
  18. package/app/.playwright/package/bin/reinstall_msedge_dev_linux.sh +48 -0
  19. package/app/.playwright/package/bin/reinstall_msedge_dev_mac.sh +11 -0
  20. package/app/.playwright/package/bin/reinstall_msedge_dev_win.ps1 +23 -0
  21. package/app/.playwright/package/bin/reinstall_msedge_stable_linux.sh +48 -0
  22. package/app/.playwright/package/bin/reinstall_msedge_stable_mac.sh +11 -0
  23. package/app/.playwright/package/bin/reinstall_msedge_stable_win.ps1 +24 -0
  24. package/app/.playwright/package/browsers.json +52 -0
  25. package/app/.playwright/package/cli.js +21 -0
  26. package/app/.playwright/package/index.d.ts +17 -0
  27. package/app/.playwright/package/index.js +17 -0
  28. package/app/.playwright/package/index.mjs +28 -0
  29. package/app/.playwright/package/lib/bootstrap.js +88 -0
  30. package/app/.playwright/package/lib/coreBundle.js +75813 -0
  31. package/app/.playwright/package/lib/entry/cliDaemon.js +5 -0
  32. package/app/.playwright/package/lib/entry/dashboardApp.js +3 -0
  33. package/app/.playwright/package/lib/entry/mcp.js +10 -0
  34. package/app/.playwright/package/lib/entry/oopBrowserDownload.js +3 -0
  35. package/app/.playwright/package/lib/package.js +50 -0
  36. package/app/.playwright/package/lib/server/chromium/appIcon.png +0 -0
  37. package/app/.playwright/package/lib/server/electron/loader.js +116 -0
  38. package/app/.playwright/package/lib/serverRegistry.js +1939 -0
  39. package/app/.playwright/package/lib/serverRegistry.js.LICENSE +65 -0
  40. package/app/.playwright/package/lib/tools/cli-client/channelSessions.js +141 -0
  41. package/app/.playwright/package/lib/tools/cli-client/cli.js +6 -0
  42. package/app/.playwright/package/lib/tools/cli-client/help.json +721 -0
  43. package/app/.playwright/package/lib/tools/cli-client/minimist.js +128 -0
  44. package/app/.playwright/package/lib/tools/cli-client/output.js +351 -0
  45. package/app/.playwright/package/lib/tools/cli-client/program.js +418 -0
  46. package/app/.playwright/package/lib/tools/cli-client/registry.js +180 -0
  47. package/app/.playwright/package/lib/tools/cli-client/session.js +259 -0
  48. package/app/.playwright/package/lib/tools/dashboard/appIcon.png +0 -0
  49. package/app/.playwright/package/lib/tools/skills/playwright-cli/SKILL.md +425 -0
  50. package/app/.playwright/package/lib/tools/skills/playwright-cli/references/element-attributes.md +23 -0
  51. package/app/.playwright/package/lib/tools/skills/playwright-cli/references/playwright-tests.md +39 -0
  52. package/app/.playwright/package/lib/tools/skills/playwright-cli/references/request-mocking.md +87 -0
  53. package/app/.playwright/package/lib/tools/skills/playwright-cli/references/running-code.md +241 -0
  54. package/app/.playwright/package/lib/tools/skills/playwright-cli/references/session-management.md +225 -0
  55. package/app/.playwright/package/lib/tools/skills/playwright-cli/references/storage-state.md +275 -0
  56. package/app/.playwright/package/lib/tools/skills/playwright-cli/references/test-generation.md +433 -0
  57. package/app/.playwright/package/lib/tools/skills/playwright-cli/references/tracing.md +139 -0
  58. package/app/.playwright/package/lib/tools/skills/playwright-cli/references/video-recording.md +143 -0
  59. package/app/.playwright/package/lib/tools/skills/playwright-component-testing/SKILL.md +136 -0
  60. package/app/.playwright/package/lib/tools/skills/playwright-component-testing/references/gallery-spec.md +144 -0
  61. package/app/.playwright/package/lib/tools/skills/playwright-component-testing/references/migration.md +89 -0
  62. package/app/.playwright/package/lib/tools/skills/playwright-component-testing/references/react.md +69 -0
  63. package/app/.playwright/package/lib/tools/skills/playwright-component-testing/references/typing.md +173 -0
  64. package/app/.playwright/package/lib/tools/skills/playwright-component-testing/references/vue.md +77 -0
  65. package/app/.playwright/package/lib/tools/skills/playwright-trace/SKILL.md +174 -0
  66. package/app/.playwright/package/lib/tools/utils/extension.js +112 -0
  67. package/app/.playwright/package/lib/tools/utils/socketConnection.js +108 -0
  68. package/app/.playwright/package/lib/utilsBundle.js +85357 -0
  69. package/app/.playwright/package/lib/utilsBundle.js.LICENSE +1890 -0
  70. package/app/.playwright/package/lib/vite/dashboard/assets/codeMirrorModule--QdMvsKi.css +1 -0
  71. package/app/.playwright/package/lib/vite/dashboard/assets/codeMirrorModule-CQ8RZGBm.js +32 -0
  72. package/app/.playwright/package/lib/vite/dashboard/assets/codicon-DCmgc-ay.ttf +0 -0
  73. package/app/.playwright/package/lib/vite/dashboard/assets/firefox-1bWoP6pv.svg +1 -0
  74. package/app/.playwright/package/lib/vite/dashboard/assets/firefox-beta-k3eOH_eK.svg +1 -0
  75. package/app/.playwright/package/lib/vite/dashboard/assets/firefox-nightly-Cp5nfeDT.svg +1 -0
  76. package/app/.playwright/package/lib/vite/dashboard/assets/index-AwgwcYie.css +1 -0
  77. package/app/.playwright/package/lib/vite/dashboard/assets/index-hRvO4yU2.js +12 -0
  78. package/app/.playwright/package/lib/vite/dashboard/assets/safari-na3_-uQk.svg +1 -0
  79. package/app/.playwright/package/lib/vite/dashboard/index.html +29 -0
  80. package/app/.playwright/package/lib/vite/dashboard/playwright-logo.svg +24 -0
  81. package/app/.playwright/package/lib/vite/htmlReport/index.html +16 -0
  82. package/app/.playwright/package/lib/vite/htmlReport/report.css +2 -0
  83. package/app/.playwright/package/lib/vite/htmlReport/report.js +32 -0
  84. package/app/.playwright/package/lib/vite/recorder/assets/codeMirrorModule--QdMvsKi.css +1 -0
  85. package/app/.playwright/package/lib/vite/recorder/assets/codeMirrorModule-CVQWJZAA.js +32 -0
  86. package/app/.playwright/package/lib/vite/recorder/assets/codicon-DCmgc-ay.ttf +0 -0
  87. package/app/.playwright/package/lib/vite/recorder/assets/index-BZpYJZ-P.css +1 -0
  88. package/app/.playwright/package/lib/vite/recorder/assets/index-hrlLqLtq.js +129 -0
  89. package/app/.playwright/package/lib/vite/recorder/index.html +29 -0
  90. package/app/.playwright/package/lib/vite/recorder/playwright-logo.svg +9 -0
  91. package/app/.playwright/package/lib/vite/traceViewer/assets/codeMirrorModule-BbkfBe3n.js +32 -0
  92. package/app/.playwright/package/lib/vite/traceViewer/assets/defaultSettingsView-Ds6CBOo0.js +182 -0
  93. package/app/.playwright/package/lib/vite/traceViewer/assets/urlMatch-L3liM589.js +1 -0
  94. package/app/.playwright/package/lib/vite/traceViewer/assets/xtermModule-DywYcAf8.js +7 -0
  95. package/app/.playwright/package/lib/vite/traceViewer/codeMirrorModule.-QdMvsKi.css +1 -0
  96. package/app/.playwright/package/lib/vite/traceViewer/codicon.DCmgc-ay.ttf +0 -0
  97. package/app/.playwright/package/lib/vite/traceViewer/defaultSettingsView.Bqk9acqE.css +1 -0
  98. package/app/.playwright/package/lib/vite/traceViewer/index.B4cLoZK3.js +1 -0
  99. package/app/.playwright/package/lib/vite/traceViewer/index.B_TqY17P.css +1 -0
  100. package/app/.playwright/package/lib/vite/traceViewer/index.html +44 -0
  101. package/app/.playwright/package/lib/vite/traceViewer/manifest.webmanifest +16 -0
  102. package/app/.playwright/package/lib/vite/traceViewer/playwright-logo.svg +9 -0
  103. package/app/.playwright/package/lib/vite/traceViewer/snapshot.B_Jk1wbt.js +1 -0
  104. package/app/.playwright/package/lib/vite/traceViewer/snapshot.html +10 -0
  105. package/app/.playwright/package/lib/vite/traceViewer/sw.bundle.js +4 -0
  106. package/app/.playwright/package/lib/vite/traceViewer/uiMode.CU5KtEkS.js +5 -0
  107. package/app/.playwright/package/lib/vite/traceViewer/uiMode.CyMfwkXJ.css +1 -0
  108. package/app/.playwright/package/lib/vite/traceViewer/uiMode.html +18 -0
  109. package/app/.playwright/package/lib/vite/traceViewer/xtermModule.kHJ-D0s7.css +1 -0
  110. package/app/.playwright/package/lib/webp_codec.LICENSE +173 -0
  111. package/app/.playwright/package/lib/webp_codec.wasm +0 -0
  112. package/app/.playwright/package/lib/xdg-open +1267 -0
  113. package/app/.playwright/package/package.json +34 -0
  114. package/app/.playwright/package/types/protocol.d.ts +24645 -0
  115. package/app/.playwright/package/types/structs.d.ts +52 -0
  116. package/app/.playwright/package/types/types.d.ts +26632 -0
  117. package/app/BrowserCodingAgent.Api.deps.json +109 -0
  118. package/app/BrowserCodingAgent.Api.dll +0 -0
  119. package/app/BrowserCodingAgent.Api.pdb +0 -0
  120. package/app/BrowserCodingAgent.Api.runtimeconfig.json +20 -0
  121. package/app/BrowserCodingAgent.Api.staticwebassets.endpoints.json +1 -0
  122. package/app/Microsoft.AspNetCore.OpenApi.dll +0 -0
  123. package/app/Microsoft.Bcl.AsyncInterfaces.dll +0 -0
  124. package/app/Microsoft.OpenApi.dll +0 -0
  125. package/app/Microsoft.Playwright.dll +0 -0
  126. package/app/Swashbuckle.AspNetCore.SwaggerUI.dll +0 -0
  127. package/app/appsettings.Development.json +8 -0
  128. package/app/appsettings.json +16 -0
  129. package/app/playwright.ps1 +7 -0
  130. package/app/replacements.json +48 -0
  131. package/app/web.config +11 -0
  132. package/browser-coding-agent.cjs +99 -0
  133. package/package.json +34 -4
@@ -0,0 +1,69 @@
1
+ # React setup
2
+
3
+ Follow the setup workflow in `SKILL.md`. Implement the gallery per `references/gallery-spec.md` (which has a React worked example); this page covers React-specific details.
4
+
5
+ ## Files
6
+
7
+ - `playwright/gallery/` — the gallery you implement to `references/gallery-spec.md` (an `index.html` + a `main.tsx` module). Requires `react` and `react-dom` 18+ (`createRoot`).
8
+ - Stories: `src/**/*.story.tsx` (the glob also picks up `.story.jsx`); example in `templates/react/Button.story.tsx`.
9
+
10
+ ## StrictMode
11
+
12
+ Wrap the rendered story in `<React.StrictMode>` in your gallery to match how most apps render. In development builds StrictMode intentionally double-invokes render functions and effects. This matters for stories that record events with counters set in effects — recording via state updates from event handlers (like the `CountsClicks` example story) is unaffected. If a story misbehaves under StrictMode, that is usually a real finding about the component; drop the wrapper only if the app itself does not use StrictMode.
13
+
14
+ ## Global providers
15
+
16
+ If components require context (theme, store, i18n, router), create one shared decorator and use it in stories, so each story states its scenario and nothing more:
17
+
18
+ ```tsx
19
+ // src/stories/decorators.tsx
20
+ import { ThemeProvider } from '../theme';
21
+ import { MemoryRouter } from 'react-router-dom';
22
+
23
+ export function AppScaffold({ children, route = '/' }: { children: React.ReactNode, route?: string }) {
24
+ return (
25
+ <ThemeProvider theme="light">
26
+ <MemoryRouter initialEntries={[route]}>{children}</MemoryRouter>
27
+ </ThemeProvider>
28
+ );
29
+ }
30
+ ```
31
+
32
+ ```tsx
33
+ // src/components/ProfilePage.story.tsx
34
+ export const LoggedIn = () => (
35
+ <AppScaffold route="/profile/42">
36
+ <ProfilePage user={{ id: 42, name: 'Test User' }} />
37
+ </AppScaffold>
38
+ );
39
+ ```
40
+
41
+ Do not build the decorator into the gallery — keeping it in story files makes the wrapping visible and lets stories opt out.
42
+
43
+ ## Typed props
44
+
45
+ `mount` is generic over the story: pass the story type as a template argument to type-check per-test props (and `update()`). Props are inferred from the component signature; function and class components both work.
46
+
47
+ ```tsx
48
+ // src/components/Button.story.tsx
49
+ export const WithTitle = ({ title = 'Default' }: { title?: string }) =>
50
+ <Button title={title} />;
51
+ ```
52
+
53
+ ```ts
54
+ // src/components/button.spec.ts
55
+ import type { WithTitle } from './Button.story';
56
+
57
+ const component = await mount<typeof WithTitle>('components/Button/WithTitle', { title: 'Hello' });
58
+ ```
59
+
60
+ Alternatively, generate gallery types so the id itself is typed and no type import is needed: `mount('acme-ui/components/Button/WithTitle', { title: 'Hello' })` — see `references/typing.md`.
61
+
62
+ ## CSS
63
+
64
+ - Global stylesheets: import them in your gallery entry (`playwright/gallery/main.tsx`, e.g. `import '../../src/index.css'`), mirroring the app's own entry point.
65
+ - Tailwind: if content scanning is path-based, make sure `*.story.tsx` files are covered.
66
+
67
+ ## Data fetching
68
+
69
+ For libraries with client objects (React Query, Apollo), create the client inside the story or decorator so each navigation starts fresh.
@@ -0,0 +1,173 @@
1
+ # Typing `mount()`
2
+
3
+ `mount(storyId, props?)` accepts any string id and any serializable props. Two optional layers
4
+ add type checking on top; both are supported and can be mixed in one project.
5
+
6
+ | | Explicit story type | Gallery types |
7
+ |---|---|---|
8
+ | Call | `mount<typeof WithTitle>('components/Button/WithTitle', { title })` | `mount('acme-ui/components/Button/WithTitle', { title })` |
9
+ | Checks | props and `update()` | props, `update()`, and the id itself (autocomplete, rename safety) |
10
+ | Needs | `import type { WithTitle } from './Button.story'` in the spec | a generated `stories.d.ts` kept in sync by a gallery plugin |
11
+ | Id grammar | any suffix the gallery resolves | full id, prefixed with the package name |
12
+
13
+ ## Explicit story type
14
+
15
+ Pass the story type as a template argument. Nothing to set up; works in every project.
16
+
17
+ ```ts
18
+ import type { WithTitle } from './Button.story';
19
+
20
+ const component = await mount<typeof WithTitle>('components/Button/WithTitle', { title: 'Hello' });
21
+ await component.update({ title: 'Again' });
22
+ ```
23
+
24
+ Use `import type` so the story (and with it React/Vue and CSS imports) is never loaded into the
25
+ Node test process. Function components, class components and `defineComponent` stories all infer
26
+ their props; see the `Typed props` sections in `react.md` / `vue.md` for framework details.
27
+
28
+ ## Gallery types
29
+
30
+ `@playwright/test` exports an empty `interface Stories {}`. When a story id is a key of `Stories`,
31
+ `mount` types the props from that entry; any other string keeps untyped props, so adoption can be
32
+ partial. A tiny Vite plugin next to the gallery generates `stories.d.ts`, which fills `Stories` in
33
+ via module augmentation:
34
+
35
+ ```ts
36
+ // playwright/gallery/stories.d.ts (generated)
37
+ type StoriesOf<Prefix extends string, Mod> = { [K in keyof Mod & string as `${Prefix}/${K}`]: Mod[K] };
38
+
39
+ declare module '@playwright/test' {
40
+ interface Stories extends
41
+ StoriesOf<'acme-ui/components/Button', typeof import('../../src/components/Button.story')>,
42
+ StoriesOf<'acme-ui/components/Expandable', typeof import('../../src/components/Expandable.story')> {}
43
+ }
44
+
45
+ export {};
46
+ ```
47
+
48
+ One line per story file; export names and prop types come from the story module itself, so the
49
+ file only changes when a story file is added, removed or moved. Specs then need no type imports:
50
+
51
+ ```ts
52
+ const component = await mount('acme-ui/components/Button/WithTitle', { title: 'Hello' });
53
+ // ^ autocompletes registered ids ^ checked against WithTitle's props
54
+ ```
55
+
56
+ ### Namespace ids with the package name
57
+
58
+ `Stories` is merged per TypeScript program. In a monorepo whose packages share one `tsconfig`,
59
+ two packages both registering `components/Button/Default` with different props fail with
60
+ `TS2320: Interface 'Stories' cannot simultaneously extend types ...` at the `Stories` declaration,
61
+ and even distinct ids leak into each other's autocomplete. Prefix every id with the package name,
62
+ `<package>/<path under src>/<Export>`, from the start, so the convention holds when a project
63
+ becomes a package. Read the name from `package.json` in both places that derive ids, so they
64
+ cannot drift:
65
+
66
+ ```ts
67
+ // playwright/gallery/main.tsx
68
+ import packageJSON from '../../package.json';
69
+
70
+ const id = (f: string) => packageJSON.name + '/' + f.replace(/^(\.\.\/)+src\//, '').replace(/\.story\.\w+$/, '');
71
+ ```
72
+
73
+ Suffix resolution keeps working at runtime, so `mount('Button/Primary')` still renders; only the
74
+ full prefixed id is typed.
75
+
76
+ ### The plugin
77
+
78
+ Framework-agnostic: it only lists story files. Adjust `storyFile` to match the gallery's glob.
79
+
80
+ ```ts
81
+ // playwright/gallery/storyTypes.ts
82
+ import fs from 'fs';
83
+ import path from 'path';
84
+ import type { Plugin } from 'vite';
85
+
86
+ const storyFile = /\.story\.(tsx|jsx)$/;
87
+
88
+ export function storyTypes(options: { prefix: string, src: string, outFile: string }): Plugin {
89
+ const generate = () => {
90
+ const content = render(listStoryFiles(options.src), options);
91
+ if (fs.existsSync(options.outFile) && fs.readFileSync(options.outFile, 'utf8') === content)
92
+ return;
93
+ fs.writeFileSync(options.outFile, content);
94
+ };
95
+ return {
96
+ name: 'story-types',
97
+ buildStart() {
98
+ this.addWatchFile(options.src);
99
+ generate();
100
+ },
101
+ configureServer(server) {
102
+ const onFile = (file: string) => {
103
+ if (storyFile.test(file))
104
+ generate();
105
+ };
106
+ server.watcher.on('add', onFile);
107
+ server.watcher.on('unlink', onFile);
108
+ },
109
+ };
110
+ }
111
+
112
+ function listStoryFiles(dir: string): string[] {
113
+ const result: string[] = [];
114
+ for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
115
+ const file = path.join(dir, entry.name);
116
+ if (entry.isDirectory())
117
+ result.push(...listStoryFiles(file));
118
+ else if (storyFile.test(entry.name))
119
+ result.push(file);
120
+ }
121
+ return result.sort();
122
+ }
123
+
124
+ function render(files: string[], { prefix, src, outFile }: { prefix: string, src: string, outFile: string }): string {
125
+ const outDir = path.dirname(outFile);
126
+ const posix = (p: string) => p.split(path.sep).join('/');
127
+ const entries = files.map(file => {
128
+ const id = prefix + '/' + posix(path.relative(src, file)).replace(storyFile, '');
129
+ const specifier = posix(path.relative(outDir, file)).replace(/\.\w+$/, '');
130
+ return ` StoriesOf<'${id}', typeof import('${specifier.startsWith('.') ? specifier : './' + specifier}')>`;
131
+ });
132
+ const stories = entries.length ? `interface Stories extends\n${entries.join(',\n')} {}` : 'interface Stories {}';
133
+ return `// Generated by storyTypes.ts, do not edit.
134
+
135
+ type StoriesOf<Prefix extends string, Mod> = { [K in keyof Mod & string as \`\${Prefix}/\${K}\`]: Mod[K] };
136
+
137
+ declare module '@playwright/test' {
138
+ ${stories}
139
+ }
140
+
141
+ export {};
142
+ `;
143
+ }
144
+ ```
145
+
146
+ Register it on whichever Vite server serves the gallery (the app's `vite.config.ts`, or the
147
+ standalone `playwright/vite.config.ts`):
148
+
149
+ ```ts
150
+ import packageJSON from './package.json';
151
+ import { storyTypes } from './playwright/gallery/storyTypes';
152
+
153
+ export default defineConfig({
154
+ plugins: [
155
+ react(),
156
+ storyTypes({
157
+ prefix: packageJSON.name,
158
+ src: path.resolve(__dirname, 'src'),
159
+ outFile: path.resolve(__dirname, 'playwright/gallery/stories.d.ts'),
160
+ }),
161
+ ],
162
+ });
163
+ ```
164
+
165
+ The file is regenerated on every dev-server start and build, and while the server runs, whenever
166
+ a story file appears or disappears. Its content is deterministic, so **commit it**: type-checking
167
+ in CI or an editor must not depend on a running dev server. Nothing imports the file, so list it
168
+ explicitly in the project's `tsconfig` (`"files": ["playwright/gallery/stories.d.ts"]`) so that
169
+ `tsc` and editors load it.
170
+
171
+ For `.story.vue` single-file components, map the `default` export to the bare path in
172
+ `StoriesOf` (`K extends 'default' ? Prefix : \`${Prefix}/${K}\``) and rely on `vue-tsc` for the
173
+ SFC's types; a story without inferable props types as `unknown` props, which accepts anything.
@@ -0,0 +1,77 @@
1
+ # Vue setup
2
+
3
+ Follow the setup workflow in `SKILL.md`. Implement the gallery per `references/gallery-spec.md`, exposing `window.mount`/`window.unmount` — in Vue, mount with `app = createApp(h(story, props)); app.mount('#root')` and unmount with `app.unmount()`; this page covers Vue-specific details.
4
+
5
+ ## Files
6
+
7
+ - `playwright/gallery/` — the gallery you implement to `references/gallery-spec.md` (an `index.html` + a `main.ts` module). Requires Vue 3.
8
+ - Stories: `src/**/*.story.{ts,js,vue}`; example in `templates/vue/Button.story.ts`.
9
+
10
+ ## Two ways to write stories
11
+
12
+ **Render-function stories** (`Button.story.ts`) — several scenarios per file, one named export each; see `templates/vue/Button.story.ts`. Uses `defineComponent` + `h()`, no SFC compilation involved.
13
+
14
+ **Single-file-component stories** (`Button.primary.story.vue`) — one story per file, full template syntax:
15
+
16
+ ```vue
17
+ <script setup lang="ts">
18
+ import { ref } from 'vue';
19
+ import Button from './Button.vue';
20
+ const clicks = ref(0);
21
+ </script>
22
+
23
+ <template>
24
+ <Button title="Submit" @click="clicks++" />
25
+ <form hidden><input data-testid="click-count" readonly :value="String(clicks)" /></form>
26
+ </template>
27
+ ```
28
+
29
+ An SFC story is addressed by its path without the extension: `mount('components/Button.primary')`. Prefer SFC stories when the scenario needs slots or non-trivial templates.
30
+
31
+ ## Global plugins
32
+
33
+ Apps that rely on plugins (Pinia, vue-router, i18n) should wrap components with a decorator story helper that creates a fresh instance per story:
34
+
35
+ ```ts
36
+ // src/stories/decorators.ts
37
+ import { defineComponent, h, type Component } from 'vue';
38
+ import { createPinia } from 'pinia';
39
+
40
+ export function withStore(story: Component) {
41
+ return defineComponent(() => {
42
+ const pinia = createPinia();
43
+ return () => h(story, { pinia });
44
+ });
45
+ }
46
+ ```
47
+
48
+ For plugins that must be installed on the app instance (`app.use(...)`), add them in your gallery right after `createApp(...)` — that is the equivalent of the app's own bootstrap.
49
+
50
+ ## Typed props
51
+
52
+ A story that takes per-test props declares them twice: in the setup signature (for the type) and in the `props` option (so Vue delivers them as props rather than `attrs`):
53
+
54
+ ```ts
55
+ // src/components/Button.story.ts
56
+ export const WithTitle = defineComponent(
57
+ (props: { title?: string }) => () => h(Button, { title: props.title ?? 'Default' }),
58
+ { props: ['title'] },
59
+ );
60
+ ```
61
+
62
+ `mount` is generic over the story: pass the story type as a template argument to type-check the props (and `update()`):
63
+
64
+ ```ts
65
+ // src/components/button.spec.ts
66
+ import type { WithTitle } from './Button.story';
67
+
68
+ const component = await mount<typeof WithTitle>('components/Button/WithTitle', { title: 'Hello' });
69
+ ```
70
+
71
+ Alternatively, generate gallery types so the id itself is typed and no type import is needed: `mount('acme-ui/components/Button/WithTitle', { title: 'Hello' })` — see `references/typing.md`.
72
+
73
+ Options-API stories (`defineComponent({ props: { ... } })`) infer props the same way. For `.story.vue` SFC stories, prop types are only inferable when the setup generates SFC types (Volar/vue-tsc); otherwise pass the props type directly: `mount<{ title?: string }>('components/Button.primary', { title: 'Hello' })`.
74
+
75
+ ## CSS
76
+
77
+ Import global stylesheets in your gallery entry (`playwright/gallery/main.ts`, e.g. `import '../../src/assets/main.css'`), mirroring the app's entry point.
@@ -0,0 +1,174 @@
1
+ ---
2
+ name: playwright-trace
3
+ description: Inspect Playwright trace files from the command line — list actions, view requests, console, errors, snapshots and screenshots.
4
+ allowed-tools: Bash(npx:*)
5
+ ---
6
+
7
+ # Playwright Trace CLI
8
+
9
+ Inspect `.zip` trace files produced by Playwright tests without opening a browser.
10
+
11
+ ## Workflow
12
+
13
+ 1. Start with `trace open <trace.zip>` to extract the trace and see its metadata.
14
+ 2. Use `trace actions` to see all actions with their action IDs.
15
+ 3. Use `trace action <action-id>` to drill into a specific action — see parameters, logs, source location, and available snapshots.
16
+ 4. Use `trace requests`, `trace console`, or `trace errors` for cross-cutting views.
17
+ 5. Use `trace snapshot <action-id>` to get the DOM snapshot, or run a browser command against it.
18
+ 6. Use `trace close` to remove the extracted trace data when done.
19
+
20
+ All commands after `open` operate on the currently opened trace — no need to pass the trace file again. Opening a new trace replaces the previous one.
21
+
22
+ ## Commands
23
+
24
+ ### Open a trace
25
+
26
+ ```bash
27
+ # Extract trace and show metadata: browser, viewport, duration, action/error counts
28
+ npx playwright trace open <trace.zip>
29
+ ```
30
+
31
+ ### Close a trace
32
+
33
+ ```bash
34
+ # Remove extracted trace data
35
+ npx playwright trace close
36
+ ```
37
+
38
+ ### Actions
39
+
40
+ ```bash
41
+ # List all actions as a tree with action IDs and timing
42
+ npx playwright trace actions
43
+
44
+ # Filter by action title (regex, case-insensitive)
45
+ npx playwright trace actions --grep "click"
46
+
47
+ # Only failed actions
48
+ npx playwright trace actions --errors-only
49
+ ```
50
+
51
+ ### Action details
52
+
53
+ ```bash
54
+ # Show full details for one action: params, result, logs, source, snapshots
55
+ npx playwright trace action <action-id>
56
+ ```
57
+
58
+ The `action` command displays available snapshot phases (before, action, after) and the exact command to extract them.
59
+
60
+ ### Requests
61
+
62
+ ```bash
63
+ # All network requests: start time (on the `trace actions` clock), method, status, URL, duration, size
64
+ npx playwright trace requests
65
+
66
+ # Filter by URL pattern
67
+ npx playwright trace requests --grep "api"
68
+
69
+ # Filter by HTTP method
70
+ npx playwright trace requests --method POST
71
+
72
+ # Only failed requests (status >= 400)
73
+ npx playwright trace requests --failed
74
+ ```
75
+
76
+ ### Request details
77
+
78
+ ```bash
79
+ # Show full details for one request: headers, body, security
80
+ npx playwright trace request <request-id>
81
+ ```
82
+
83
+ ### Console
84
+
85
+ ```bash
86
+ # All console messages and stdout/stderr
87
+ npx playwright trace console
88
+
89
+ # Only errors
90
+ npx playwright trace console --errors-only
91
+
92
+ # Only browser console (no stdout/stderr)
93
+ npx playwright trace console --browser
94
+
95
+ # Only stdout/stderr (no browser console)
96
+ npx playwright trace console --stdio
97
+
98
+ # Filter by message text pattern
99
+ npx playwright trace console --grep "failed to fetch"
100
+ ```
101
+
102
+ ### Errors
103
+
104
+ ```bash
105
+ # All errors with stack traces and associated actions
106
+ npx playwright trace errors
107
+ ```
108
+
109
+ ### Snapshots
110
+
111
+ The `snapshot` command loads the DOM snapshot for an action into a headless browser and runs a single browser command against it. Without a browser command, it returns the accessibility snapshot.
112
+
113
+ ```bash
114
+ # Get the accessibility snapshot (default)
115
+ npx playwright trace snapshot <action-id>
116
+
117
+ # Use a specific phase
118
+ npx playwright trace snapshot <action-id> --phase before
119
+
120
+ # Run eval to query the DOM
121
+ npx playwright trace snapshot <action-id> -- eval "document.title"
122
+ npx playwright trace snapshot <action-id> -- eval "document.querySelector('#error').textContent"
123
+
124
+ # Eval on a specific element ref (from the snapshot)
125
+ npx playwright trace snapshot <action-id> -- eval "el => el.getAttribute('data-testid')" e5
126
+
127
+ # Take a screenshot of the snapshot
128
+ npx playwright trace snapshot <action-id> -- screenshot
129
+
130
+ # Redirect output to a file
131
+ npx playwright trace snapshot <action-id> -- eval "document.body.outerHTML" --filename=page.html
132
+ npx playwright trace snapshot <action-id> -- screenshot --filename=screenshot.png
133
+ ```
134
+
135
+ Only three browser commands are useful on a frozen snapshot: `snapshot`, `eval`, and `screenshot`.
136
+
137
+ ### Attachments
138
+
139
+ ```bash
140
+ # List all trace attachments
141
+ npx playwright trace attachments
142
+
143
+ # Extract an attachment by its number
144
+ npx playwright trace attachment 1
145
+ npx playwright trace attachment 1 -o out.png
146
+ ```
147
+
148
+ ## Typical investigation
149
+
150
+ ```bash
151
+ # 1. Open the trace and see what's inside
152
+ npx playwright trace open test-results/my-test/trace.zip
153
+
154
+ # 2. What actions ran?
155
+ npx playwright trace actions
156
+
157
+ # 3. Which action failed?
158
+ npx playwright trace actions --errors-only
159
+
160
+ # 4. What went wrong?
161
+ npx playwright trace action 12
162
+
163
+ # 5. What did the page look like at that moment?
164
+ npx playwright trace snapshot 12
165
+
166
+ # 6. Query the DOM for more detail
167
+ npx playwright trace snapshot 12 -- eval "document.querySelector('.error-message').textContent"
168
+
169
+ # 7. Any relevant network failures?
170
+ npx playwright trace requests --failed
171
+
172
+ # 8. Any console errors?
173
+ npx playwright trace console --errors-only
174
+ ```
@@ -0,0 +1,112 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var extension_exports = {};
30
+ __export(extension_exports, {
31
+ findPlaywrightExtensionProfile: () => findPlaywrightExtensionProfile,
32
+ isExtensionInstalledInProfile: () => isExtensionInstalledInProfile,
33
+ isPlaywrightExtensionInstalled: () => isPlaywrightExtensionInstalled,
34
+ playwrightExtensionId: () => playwrightExtensionId,
35
+ playwrightExtensionInstallUrl: () => playwrightExtensionInstallUrl
36
+ });
37
+ module.exports = __toCommonJS(extension_exports);
38
+ var import_fs = __toESM(require("fs"));
39
+ var import_path = __toESM(require("path"));
40
+ const playwrightExtensionId = "mmlmfjhmonkocbjadbfplnigmagldckm";
41
+ const playwrightExtensionInstallUrl = `https://chromewebstore.google.com/detail/playwright-extension/${playwrightExtensionId}`;
42
+ async function findPlaywrightExtensionProfile(userDataDir) {
43
+ const profiles = await listProfileDirectories(userDataDir);
44
+ const lastUsed = await readLastUsedProfile(userDataDir);
45
+ const ordered = lastUsed && profiles.includes(lastUsed) ? [lastUsed, ...profiles.filter((profile) => profile !== lastUsed)] : profiles;
46
+ for (const profile of ordered) {
47
+ if (await isExtensionInstalledInProfile(import_path.default.join(userDataDir, profile)))
48
+ return profile;
49
+ }
50
+ return void 0;
51
+ }
52
+ async function listProfileDirectories(userDataDir) {
53
+ let entries;
54
+ try {
55
+ entries = await import_fs.default.promises.readdir(userDataDir);
56
+ } catch {
57
+ return [];
58
+ }
59
+ const profiles = entries.filter((entry) => entry === "Default" || /^Profile \d+$/.test(entry));
60
+ profiles.sort((a, b) => profileRank(a) - profileRank(b));
61
+ return profiles;
62
+ }
63
+ function profileRank(profile) {
64
+ return profile === "Default" ? -1 : parseInt(profile.slice("Profile ".length), 10);
65
+ }
66
+ async function readLastUsedProfile(userDataDir) {
67
+ try {
68
+ const localState = JSON.parse(await import_fs.default.promises.readFile(import_path.default.join(userDataDir, "Local State"), "utf-8"));
69
+ const lastUsed = localState?.profile?.last_used;
70
+ return typeof lastUsed === "string" ? lastUsed : void 0;
71
+ } catch {
72
+ return void 0;
73
+ }
74
+ }
75
+ async function isPlaywrightExtensionInstalled(userDataDir) {
76
+ return await findPlaywrightExtensionProfile(userDataDir) !== void 0;
77
+ }
78
+ async function isExtensionInstalledInProfile(profileDir) {
79
+ if (await pathExists(import_path.default.join(profileDir, "Extensions", playwrightExtensionId)))
80
+ return true;
81
+ for (const fileName of ["Preferences", "Secure Preferences"]) {
82
+ if (await hasExtensionSettingsRecord(import_path.default.join(profileDir, fileName)))
83
+ return true;
84
+ }
85
+ return false;
86
+ }
87
+ async function hasExtensionSettingsRecord(prefsPath) {
88
+ let prefs;
89
+ try {
90
+ prefs = JSON.parse(await import_fs.default.promises.readFile(prefsPath, "utf-8"));
91
+ } catch {
92
+ return false;
93
+ }
94
+ const record = prefs?.extensions?.settings?.[playwrightExtensionId];
95
+ return !!record && typeof record === "object" && Object.keys(record).length > 0;
96
+ }
97
+ async function pathExists(p) {
98
+ try {
99
+ await import_fs.default.promises.access(p);
100
+ return true;
101
+ } catch {
102
+ return false;
103
+ }
104
+ }
105
+ // Annotate the CommonJS export names for ESM import in node:
106
+ 0 && (module.exports = {
107
+ findPlaywrightExtensionProfile,
108
+ isExtensionInstalledInProfile,
109
+ isPlaywrightExtensionInstalled,
110
+ playwrightExtensionId,
111
+ playwrightExtensionInstallUrl
112
+ });