Skip to content

Commit ac063ec

Browse files
committed
Refactor MCP Composition E2E tests to remove reliance on hasRemoteSource variable. Simplified assertions for local and remote sources, ensuring all necessary checks are performed directly without conditional logic.
1 parent 825c292 commit ac063ec

1 file changed

Lines changed: 10 additions & 24 deletions

File tree

apps/internal-storybook/tests/mcp-composition.e2e.test.ts

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ const MCP_ENDPOINT = `http://localhost:${PORT}/mcp`;
1414
const STARTUP_TIMEOUT = 30_000;
1515

1616
let storybookProcess: ReturnType<typeof x> | null = null;
17-
let hasRemoteSource = false;
1817

1918
async function mcpRequest(method: string, params: any = {}) {
2019
const response = await fetch(MCP_ENDPOINT, {
@@ -41,7 +40,7 @@ describe('MCP Composition E2E Tests', () => {
4140
arguments: {},
4241
});
4342
const docsText = docsResponse.result.content[0].text as string;
44-
hasRemoteSource = docsText.includes('id: storybook-ui');
43+
expect(docsText).toContain('id: storybook-ui');
4544
}, STARTUP_TIMEOUT);
4645

4746
afterAll(async () => {
@@ -59,16 +58,12 @@ describe('MCP Composition E2E Tests', () => {
5958
const text = response.result.content[0].text;
6059

6160
// Should contain Local source
62-
if (hasRemoteSource) {
63-
expect(text).toContain('# Local');
64-
expect(text).toContain('id: local');
65-
}
61+
expect(text).toContain('# Local');
62+
expect(text).toContain('id: local');
6663

6764
// Should contain remote Storybook UI source
68-
if (hasRemoteSource) {
69-
expect(text).toContain('# Storybook UI');
70-
expect(text).toContain('id: storybook-ui');
71-
}
65+
expect(text).toContain('# Storybook UI');
66+
expect(text).toContain('id: storybook-ui');
7267

7368
// Local components should be present
7469
expect(text).toContain('Button (example-button)');
@@ -182,11 +177,6 @@ describe('MCP Composition E2E Tests', () => {
182177
});
183178

184179
it('should fetch documentation for a component from remote source', async () => {
185-
if (!hasRemoteSource) {
186-
expect(true).toBe(true);
187-
return;
188-
}
189-
190180
// Get documentation for a component that exists in the remote Storybook UI
191181
const response = await mcpRequest('tools/call', {
192182
name: 'get-documentation',
@@ -340,15 +330,11 @@ describe('MCP Composition E2E Tests', () => {
340330
const getDocTool = response.result.tools.find((t: any) => t.name === 'get-documentation');
341331

342332
expect(getDocTool).toBeDefined();
343-
if (hasRemoteSource) {
344-
expect(getDocTool.inputSchema.properties).toHaveProperty('storybookId');
345-
expect(getDocTool.inputSchema.properties.storybookId).toMatchObject({
346-
type: 'string',
347-
description: expect.stringContaining('source'),
348-
});
349-
} else {
350-
expect(getDocTool.inputSchema.properties).not.toHaveProperty('storybookId');
351-
}
333+
expect(getDocTool.inputSchema.properties).toHaveProperty('storybookId');
334+
expect(getDocTool.inputSchema.properties.storybookId).toMatchObject({
335+
type: 'string',
336+
description: expect.stringContaining('source'),
337+
});
352338
});
353339
});
354340
});

0 commit comments

Comments
 (0)