fix: fix regex on mcp server tab test (#8175)
* Fixed MCP Server Tab Test * Fixed mcp server tab test * Added timeout to test * Added retry to mcp server tab test
This commit is contained in:
parent
984b172d5d
commit
f8e8ad64b9
1 changed files with 228 additions and 207 deletions
|
|
@ -6,7 +6,12 @@ test(
|
|||
"user should be able to manage MCP server actions and configuration",
|
||||
{ tag: ["@release", "@workspace", "@components"] },
|
||||
async ({ page }) => {
|
||||
const maxRetries = 5;
|
||||
|
||||
for (let attempt = 1; attempt <= maxRetries; attempt++) {
|
||||
try {
|
||||
console.log(`Attempt ${attempt} of ${maxRetries}`);
|
||||
|
||||
await awaitBootstrapTest(page);
|
||||
|
||||
// Create a new flow
|
||||
|
|
@ -122,7 +127,9 @@ test(
|
|||
await expect(page.getByTestId("div-mcp-server-tools")).toBeVisible();
|
||||
|
||||
// Generate API key if not in auto login mode
|
||||
const isAutoLogin = await page.getByText("Generate API key").isVisible();
|
||||
const isAutoLogin = await page
|
||||
.getByText("Generate API key")
|
||||
.isVisible();
|
||||
if (isAutoLogin) {
|
||||
await page.getByText("Generate API key").click();
|
||||
await expect(page.getByText("API key generated")).toBeVisible();
|
||||
|
|
@ -135,12 +142,12 @@ test(
|
|||
// Get the SSE URL from the configuration
|
||||
const configJson = await page.locator("pre").textContent();
|
||||
expect(configJson).toContain("mcpServers");
|
||||
expect(configJson).toContain("supergateway");
|
||||
expect(configJson).toContain("sse");
|
||||
expect(configJson).toContain("mcp-proxy");
|
||||
expect(configJson).toContain("uvx");
|
||||
|
||||
// Extract the SSE URL from the configuration
|
||||
const sseUrlMatch = configJson?.match(
|
||||
/"args":\s*\[\s*"-y",\s*"supergateway",\s*"--sse",\s*"([^"]+)"/,
|
||||
/"args":\s*\[\s*"mcp-proxy"\s*,\s*"([^"]+)"/,
|
||||
);
|
||||
expect(sseUrlMatch).not.toBeNull();
|
||||
const sseUrl = sseUrlMatch![1];
|
||||
|
|
@ -180,8 +187,11 @@ test(
|
|||
state: "visible",
|
||||
timeout: 30000,
|
||||
});
|
||||
await page.waitForTimeout(2000);
|
||||
|
||||
await page.getByTestId("textarea_str_sse_url").fill("");
|
||||
await page.getByTestId("textarea_str_sse_url").fill(sseUrl);
|
||||
|
||||
await page.waitForTimeout(2000);
|
||||
|
||||
// Wait for the tools to become available
|
||||
|
|
@ -208,11 +218,9 @@ test(
|
|||
}
|
||||
|
||||
if (!dropdownEnabled) {
|
||||
test.skip(
|
||||
true,
|
||||
throw new Error(
|
||||
"Dropdown did not become enabled after multiple refresh attempts",
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
// Verify tools are available
|
||||
|
|
@ -221,9 +229,22 @@ test(
|
|||
|
||||
const fetchOptionCount = await page.getByText("mcp_test_name").count();
|
||||
expect(fetchOptionCount).toBeGreaterThan(0);
|
||||
|
||||
// If we get here, the test passed
|
||||
console.log(`Test passed on attempt ${attempt}`);
|
||||
return;
|
||||
} catch (error) {
|
||||
console.log(`Test failed with error: ${error.message}`);
|
||||
test.skip(true, `Skipping test due to error: ${error.message}`);
|
||||
error = error as Error;
|
||||
console.log(`Attempt ${attempt} failed:`, error);
|
||||
|
||||
if (attempt === maxRetries) {
|
||||
console.log(`All ${maxRetries} attempts failed. Last error:`, error);
|
||||
throw error;
|
||||
}
|
||||
|
||||
// Wait a bit before retrying
|
||||
await page.waitForTimeout(2000);
|
||||
}
|
||||
}
|
||||
},
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue