storybook-addon-playwright 5.2.0 → 5.4.0

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 (44) hide show
  1. package/README.md +42 -0
  2. package/dist/api/server/routes.d.mts +2 -2
  3. package/dist/api/server/routes.d.ts +2 -2
  4. package/dist/api/server/routes.js +11 -11
  5. package/dist/api/server/routes.js.map +1 -1
  6. package/dist/api/server/routes.mjs +11 -11
  7. package/dist/api/server/routes.mjs.map +1 -1
  8. package/dist/get-screenshots.d.mts +1 -1
  9. package/dist/get-screenshots.d.ts +1 -1
  10. package/dist/get-screenshots.js +3 -3
  11. package/dist/get-screenshots.js.map +1 -1
  12. package/dist/get-screenshots.mjs +3 -3
  13. package/dist/get-screenshots.mjs.map +1 -1
  14. package/dist/{image-diff-Dg_Di4zv.d.mts → image-diff-DeB-XSUP.d.mts} +1 -1
  15. package/dist/{image-diff-BSb7XwJb.d.ts → image-diff-DwK_Ui8E.d.ts} +1 -1
  16. package/dist/index.d.mts +39 -3
  17. package/dist/index.d.ts +39 -3
  18. package/dist/index.js +4 -3
  19. package/dist/index.js.map +1 -1
  20. package/dist/index.mjs +4 -3
  21. package/dist/index.mjs.map +1 -1
  22. package/dist/register.js +9 -9
  23. package/dist/register.js.map +1 -1
  24. package/dist/register.mjs +9 -9
  25. package/dist/register.mjs.map +1 -1
  26. package/dist/{request-CyuY6GGO.d.mts → request-B60Gnj7P.d.mts} +2 -0
  27. package/dist/{request-CyuY6GGO.d.ts → request-B60Gnj7P.d.ts} +2 -0
  28. package/dist/run-image-diff.d.mts +3 -2
  29. package/dist/run-image-diff.d.ts +3 -2
  30. package/dist/run-image-diff.js +3 -3
  31. package/dist/run-image-diff.js.map +1 -1
  32. package/dist/run-image-diff.mjs +3 -3
  33. package/dist/run-image-diff.mjs.map +1 -1
  34. package/dist/to-match-screenshots.js +3 -3
  35. package/dist/to-match-screenshots.js.map +1 -1
  36. package/dist/to-match-screenshots.mjs +3 -3
  37. package/dist/to-match-screenshots.mjs.map +1 -1
  38. package/dist/trpc/router.d.mts +14 -2
  39. package/dist/trpc/router.d.ts +14 -2
  40. package/dist/trpc/router.js +11 -11
  41. package/dist/trpc/router.js.map +1 -1
  42. package/dist/trpc/router.mjs +11 -11
  43. package/dist/trpc/router.mjs.map +1 -1
  44. package/package.json +2 -1
package/README.md CHANGED
@@ -86,6 +86,48 @@ module.exports = function (router) {
86
86
  For a full list of available options with detailed descriptions, see the [`Config` interface in `src/typings/config.ts`](src/typings/config.ts).
87
87
  Every option is documented with a JSDoc comment explaining its purpose, parameters, and usage.
88
88
 
89
+ ### AI prompt helper for `getScreenshotTitle`
90
+
91
+ This package exports `createScreenshotTitlePrompt(data, options)` so you can build a strict LLM prompt for title generation and reuse it across projects.
92
+
93
+ The helper is designed for small models too. It asks the model to:
94
+
95
+ - parse the provided data as JSON,
96
+ - understand each field,
97
+ - generate a concise title,
98
+ - return JSON only in this shape: `{ "title": "..." }`.
99
+
100
+ Example:
101
+
102
+ ```js
103
+ const { setConfig } = require('storybook-addon-playwright/configs');
104
+ const { createScreenshotTitlePrompt } = require('storybook-addon-playwright');
105
+
106
+ async function askLlm(prompt) {
107
+ // Call your LLM provider here and return parsed JSON.
108
+ // The model response must match: { title: string }
109
+ return { title: 'Button / primary / loading' };
110
+ }
111
+
112
+ setConfig({
113
+ storybookEndpoint: 'http://localhost:6006/',
114
+ getPage: async () => {
115
+ throw new Error('Example only: implement getPage');
116
+ },
117
+ getScreenshotTitle: async (data) => {
118
+ const prompt = createScreenshotTitlePrompt(data, {
119
+ maxTitleLength: 72,
120
+ fallbackTitle: 'Should render correctly.',
121
+ includeBrowserType: true,
122
+ includeStoryId: false,
123
+ });
124
+
125
+ const result = await askLlm(prompt);
126
+ return result.title;
127
+ },
128
+ });
129
+ ```
130
+
89
131
  ## How it works
90
132
 
91
133
  The addon is an interface between Playwright and Storybook stories. It executes user-defined action sequences on the Playwright page provided in the configuration.
@@ -2,12 +2,12 @@ import { appRouter } from '../../trpc/router.mjs';
2
2
  import '@material-ui/core';
3
3
  import 'playwright';
4
4
  import 'ts-to-json';
5
- import '../../request-CyuY6GGO.mjs';
5
+ import '../../request-B60Gnj7P.mjs';
6
6
  import 'zod';
7
7
  import '@trpc/server';
8
8
  import 'node:http';
9
9
  import 'jest-image-snapshot';
10
- import '../../image-diff-Dg_Di4zv.mjs';
10
+ import '../../image-diff-DeB-XSUP.mjs';
11
11
  import '../../get-screenshot-paths-BhXNedbs.mjs';
12
12
 
13
13
 
@@ -2,12 +2,12 @@ import { appRouter } from '../../trpc/router.js';
2
2
  import '@material-ui/core';
3
3
  import 'playwright';
4
4
  import 'ts-to-json';
5
- import '../../request-CyuY6GGO.js';
5
+ import '../../request-B60Gnj7P.js';
6
6
  import 'zod';
7
7
  import '@trpc/server';
8
8
  import 'node:http';
9
9
  import 'jest-image-snapshot';
10
- import '../../image-diff-BSb7XwJb.js';
10
+ import '../../image-diff-DwK_Ui8E.js';
11
11
  import '../../get-screenshot-paths-BhXNedbs.js';
12
12
 
13
13