diff --git a/code/e2e-tests/addon-mcp.spec.ts b/code/e2e-tests/addon-mcp.spec.ts index bcf7fef354b9..9e5a88c446ab 100644 --- a/code/e2e-tests/addon-mcp.spec.ts +++ b/code/e2e-tests/addon-mcp.spec.ts @@ -6,6 +6,7 @@ import process from 'process'; const storybookUrl = process.env.STORYBOOK_URL || 'http://localhost:8001'; const templateName = process.env.STORYBOOK_TEMPLATE_NAME || ''; const type = process.env.STORYBOOK_TYPE || 'dev'; +const sandboxDir = process.env.STORYBOOK_SANDBOX_DIR; const MCP_ENDPOINT = `${storybookUrl}/mcp`; @@ -187,26 +188,41 @@ test.describe('addon-mcp', () => { }); }); - test.describe('Tool: get-story-urls', () => { + test.describe('Tool: preview-stories', () => { test('should return story URLs for valid stories', async ({ request }) => { + const storyName = 'Primary'; + const expectedPreviewUrl = `${storybookUrl}/?path=/story/example-button--primary`; + // Use a path pattern that works regardless of sandbox location const response = await mcpRequest(request, 'tools/call', { - name: 'get-story-urls', + name: 'preview-stories', arguments: { stories: [ { - exportName: 'Primary', - // Use a relative-style path that the tool should recognize - absoluteStoryPath: '/src/stories/Button.stories.ts', + exportName: storyName, + absoluteStoryPath: `${sandboxDir}/src/stories/Button.stories.ts`, }, ], }, }); - expect(response.result).toHaveProperty('content'); - expect(response.result.content).toHaveLength(1); - // Should contain either a valid URL or an error message about the story - expect(response.result.content[0]).toHaveProperty('text'); + expect(response.result).toStrictEqual({ + content: [ + { + type: 'text', + text: expectedPreviewUrl, + }, + ], + structuredContent: { + stories: [ + { + name: storyName, + previewUrl: expectedPreviewUrl, + title: 'Example/Button', + }, + ], + }, + }); }); });