Skip to content
Merged
Show file tree
Hide file tree
Changes from 15 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
5 changes: 5 additions & 0 deletions .changeset/plain-hands-tap.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@storybook/addon-mcp': patch
---

improve handling of disableTelemetry option
23 changes: 20 additions & 3 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,26 @@ The `@storybook/mcp` package (in `packages/mcp`) is framework-agnostic:

**Testing:**

- Only `packages/mcp` has tests (Vitest with coverage)
- Run `pnpm test run --coverage` in mcp package
- Prefer TDD when adding new tools
- **Unit tests**: Both `packages/mcp` and `packages/addon-mcp` have unit tests (Vitest with coverage)
- Run `pnpm test run --coverage` in individual package directories
- Run `pnpm test:run` at root to run all unit tests
- Prefer TDD when adding new tools
- **E2E tests**: `apps/internal-storybook/tests` contains E2E tests for the addon
- Run `pnpm test` in `apps/internal-storybook` directory
- Tests verify MCP endpoint works with latest Storybook prereleases
- Uses inline snapshots for response validation
- **When to update E2E tests**:
- Adding or modifying MCP tools (update tool discovery snapshots)
- Changing MCP protocol implementation (update session init tests)
- Modifying tool responses or schemas (update tool-specific tests)
- Adding new toolsets or changing toolset behavior (update filtering tests)
- **Running tests**:
- `pnpm test` in apps/internal-storybook - run E2E tests
- `pnpm vitest run -u` - update snapshots when responses change
- Tests start Storybook server automatically, wait for MCP endpoint, then run
- **Test structure**:
- `mcp-endpoint.e2e.test.ts` - MCP protocol and tool tests
- `check-deps.e2e.test.ts` - Storybook version validation

**Type checking:**

Expand Down
2 changes: 2 additions & 0 deletions apps/internal-storybook/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"scripts": {
"build-storybook": "storybook build",
"storybook": "storybook dev --port 6006 --loglevel debug --no-open",
"test": "cd ../.. && pnpm vitest --project=e2e",
"typecheck": "tsc"
},
"devDependencies": {
Expand All @@ -18,6 +19,7 @@
"react": "^18.2.0",
"react-dom": "^18.2.0",
"storybook": "catalog:",
"tinyexec": "^1.0.2",
"vite": "catalog:"
}
}
55 changes: 55 additions & 0 deletions apps/internal-storybook/tests/check-deps.e2e.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { describe, it } from 'vitest';
import { x } from 'tinyexec';

const PACKAGES_TO_CHECK = [
'@storybook/addon-docs',
'@storybook/react-vite',
'storybook',
];

describe('Storybook Dependencies', () => {
it('should be using latest versions from registry', async () => {
const outdated: Array<{ pkg: string; current: string; latest: string }> =
[];

for (const pkg of PACKAGES_TO_CHECK) {
// Get local version
const listResult = await x('pnpm', ['list', pkg, '--json'], {
nodeOptions: { cwd: process.cwd() },
});
const listData = JSON.parse(listResult.stdout);
const currentVersion =
listData[0]?.devDependencies?.[pkg]?.version ||
listData[0]?.dependencies?.[pkg]?.version;

if (!currentVersion) {
continue;
}

// Get registry version for @next tag
const viewResult = await x('pnpm', ['view', `${pkg}@next`, 'version'], {
nodeOptions: { cwd: process.cwd() },
});
const latestVersion = viewResult.stdout.trim();

// Compare versions
if (currentVersion !== latestVersion) {
outdated.push({ pkg, current: currentVersion, latest: latestVersion });
}
}

// If there are outdated packages, fail the test with instructions
if (outdated.length > 0) {
const outdatedList = outdated
.map(({ pkg, current, latest }) => ` - ${pkg}: ${current} → ${latest}`)
.join('\n');

const currentVersion = outdated[0]!.current.replace(/\./g, '\\.');
const latestVersion = outdated[0]!.latest;

throw new Error(
`Storybook dependencies are outdated. Update the catalog in pnpm-workspace.yaml:\n\n sed -i '' 's/${currentVersion}/${latestVersion}/g' pnpm-workspace.yaml && pnpm install\n\nOutdated packages:\n${outdatedList}`,
);
}
});
});
Loading
Loading