-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathbuild-server-instructions.test.ts
More file actions
146 lines (110 loc) · 6.33 KB
/
build-server-instructions.test.ts
File metadata and controls
146 lines (110 loc) · 6.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
import { describe, it, expect } from 'vitest';
import { buildServerInstructions } from './build-server-instructions.ts';
describe('buildServerInstructions', () => {
it('builds a coherent instruction set when all toolsets are enabled', () => {
const instructions = buildServerInstructions({
devEnabled: true,
testEnabled: true,
docsEnabled: true,
});
expect(instructions).toMatchInlineSnapshot(`
"Follow these workflows when working with UI and/or Storybook.
## UI Building and Story Writing Workflow
- Before creating or editing components or stories, call **get-storybook-story-instructions**.
- Treat that tool's output as the source of truth for framework-specific imports, story patterns, and testing conventions.
- After changing any component or story, call **get-changed-stories** to discover new/modified/related stories, then call **preview-stories** to retrieve preview URLs.
- Always include every returned preview URL in your user-facing response so the user can verify the visual result.
## Validation Workflow
- After each component or story change, run **run-story-tests**.
- Use focused runs while iterating, then run a broad pass before final handoff when scope is unclear or wide.
- Fix failing tests before reporting success. Do not report completion while story tests are failing.
## Documentation Workflow
1. Call **list-all-documentation** once at the start of the task to discover available component and docs IDs.
2. Call **get-documentation** with an \`id\` from that list to retrieve full component docs, props, usage examples, and stories.
3. Call **get-documentation-for-story** when you need additional docs from a specific story variant that was not included in the initial component documentation.
Use \`withStoryIds: true\` on **list-all-documentation** when you also need story IDs for inputs to other tools.
## Verification Rules
- Never assume component props, variants, or API shape. Retrieve documentation before using a component.
- If a component or prop is not documented, do not invent it. Report that it was not found.
- Only reference IDs returned by **list-all-documentation**. Do not guess IDs.
## Multi-Source Requests
- When multiple Storybook sources are configured, **list-all-documentation** returns entries from all sources.
- Use \`storybookId\` in **get-documentation** when you need to scope a request to one source."
`);
});
it('builds a coherent instruction set for dev only', () => {
const instructions = buildServerInstructions({
devEnabled: true,
testEnabled: false,
docsEnabled: false,
});
expect(instructions).toMatchInlineSnapshot(`
"Follow these workflows when working with UI and/or Storybook.
## UI Building and Story Writing Workflow
- Before creating or editing components or stories, call **get-storybook-story-instructions**.
- Treat that tool's output as the source of truth for framework-specific imports, story patterns, and testing conventions.
- After changing any component or story, call **get-changed-stories** to discover new/modified/related stories, then call **preview-stories** to retrieve preview URLs.
- Always include every returned preview URL in your user-facing response so the user can verify the visual result."
`);
});
it('omits get-changed-stories step when change detection is disabled', () => {
const instructions = buildServerInstructions({
devEnabled: true,
testEnabled: false,
docsEnabled: false,
changeDetectionEnabled: false,
});
expect(instructions).toMatchInlineSnapshot(`
"Follow these workflows when working with UI and/or Storybook.
## UI Building and Story Writing Workflow
- Before creating or editing components or stories, call **get-storybook-story-instructions**.
- Treat that tool's output as the source of truth for framework-specific imports, story patterns, and testing conventions.
- After changing any component or story, call **preview-stories** to retrieve preview URLs.
- Always include every returned preview URL in your user-facing response so the user can verify the visual result."
`);
});
it('builds a coherent instruction set for docs only', () => {
const instructions = buildServerInstructions({
devEnabled: false,
testEnabled: false,
docsEnabled: true,
});
expect(instructions).toMatchInlineSnapshot(`
"Follow these workflows when working with UI and/or Storybook.
## Documentation Workflow
1. Call **list-all-documentation** once at the start of the task to discover available component and docs IDs.
2. Call **get-documentation** with an \`id\` from that list to retrieve full component docs, props, usage examples, and stories.
3. Call **get-documentation-for-story** when you need additional docs from a specific story variant that was not included in the initial component documentation.
Use \`withStoryIds: true\` on **list-all-documentation** when you also need story IDs for inputs to other tools.
## Verification Rules
- Never assume component props, variants, or API shape. Retrieve documentation before using a component.
- If a component or prop is not documented, do not invent it. Report that it was not found.
- Only reference IDs returned by **list-all-documentation**. Do not guess IDs.
## Multi-Source Requests
- When multiple Storybook sources are configured, **list-all-documentation** returns entries from all sources.
- Use \`storybookId\` in **get-documentation** when you need to scope a request to one source."
`);
});
it('builds a coherent instruction set for test only', () => {
const instructions = buildServerInstructions({
devEnabled: false,
testEnabled: true,
docsEnabled: false,
});
expect(instructions).toMatchInlineSnapshot(`
"Follow these workflows when working with UI and/or Storybook.
## Validation Workflow
- After each component or story change, run **run-story-tests**.
- Use focused runs while iterating, then run a broad pass before final handoff when scope is unclear or wide.
- Fix failing tests before reporting success. Do not report completion while story tests are failing."
`);
});
it('returns empty instructions when all toolsets are disabled', () => {
const instructions = buildServerInstructions({
devEnabled: false,
testEnabled: false,
docsEnabled: false,
});
expect(instructions).toBe('');
});
});