|
| 1 | +import { test, expect } from "@playwright/test"; |
| 2 | + |
| 3 | +const APP_URL = "http://localhost:6275/"; |
| 4 | +const CORS_FAIL_URL = |
| 5 | + "https://adb-7405613454306346.6.azuredatabricks.net/api/2.0/mcp/dbsql"; |
| 6 | + |
| 7 | +test.describe("Auth Debugger CORS Full Flow", () => { |
| 8 | + test("should show all failed requests as steps, not dismiss the flow", async ({ |
| 9 | + page, |
| 10 | + }) => { |
| 11 | + page.on("console", (msg) => { |
| 12 | + console.log(`[Browser ${msg.type()}]: ${msg.text()}`); |
| 13 | + }); |
| 14 | + |
| 15 | + await page.goto(APP_URL); |
| 16 | + await expect(page.getByText("MCP Inspector")).toBeVisible(); |
| 17 | + |
| 18 | + // Setup |
| 19 | + const transportDropdown = page.getByRole("combobox", { |
| 20 | + name: "Transport Type", |
| 21 | + }); |
| 22 | + await transportDropdown.click(); |
| 23 | + await page.getByRole("option", { name: "Streamable HTTP" }).click(); |
| 24 | + |
| 25 | + const urlInput = page.getByRole("textbox", { name: "URL" }); |
| 26 | + await urlInput.fill(CORS_FAIL_URL); |
| 27 | + |
| 28 | + await page.getByRole("button", { name: "Open Auth Settings" }).click(); |
| 29 | + await expect( |
| 30 | + page.getByRole("heading", { name: "Authentication Settings" }), |
| 31 | + ).toBeVisible(); |
| 32 | + |
| 33 | + // Start Debug Flow |
| 34 | + await page.getByRole("button", { name: "Debug Flow" }).click(); |
| 35 | + |
| 36 | + // Step through all failed requests |
| 37 | + for (let i = 1; i <= 10; i++) { |
| 38 | + await page.waitForTimeout(2000); |
| 39 | + |
| 40 | + // Take screenshot |
| 41 | + await page.screenshot({ path: `cors-step-${i}.png`, fullPage: true }); |
| 42 | + |
| 43 | + // Count visible steps |
| 44 | + const stepCount = await page |
| 45 | + .locator('[class*="flex items-center p-2 rounded-md cursor-pointer"]') |
| 46 | + .count(); |
| 47 | + console.log(`Iteration ${i}: ${stepCount} step(s) visible`); |
| 48 | + |
| 49 | + // Check for warning icons |
| 50 | + const warningIcons = await page |
| 51 | + .locator("svg.lucide-alert-triangle") |
| 52 | + .count(); |
| 53 | + console.log(`Iteration ${i}: ${warningIcons} warning icon(s)`); |
| 54 | + |
| 55 | + // Check if there's a Continue button |
| 56 | + const continueButton = page.getByRole("button", { name: "Continue" }); |
| 57 | + const isVisible = await continueButton |
| 58 | + .isVisible({ timeout: 500 }) |
| 59 | + .catch(() => false); |
| 60 | + |
| 61 | + if (isVisible) { |
| 62 | + const isEnabled = await continueButton.isEnabled(); |
| 63 | + if (isEnabled) { |
| 64 | + console.log(`Iteration ${i}: Clicking Continue`); |
| 65 | + await continueButton.click(); |
| 66 | + } else { |
| 67 | + console.log(`Iteration ${i}: Continue button disabled, stopping`); |
| 68 | + break; |
| 69 | + } |
| 70 | + } else { |
| 71 | + console.log(`Iteration ${i}: No Continue button visible`); |
| 72 | + |
| 73 | + // Check if flow shows complete state |
| 74 | + const completeIndicator = await page |
| 75 | + .locator("text=/complete|success/i") |
| 76 | + .count(); |
| 77 | + if (completeIndicator > 0) { |
| 78 | + console.log(`Iteration ${i}: Flow complete`); |
| 79 | + break; |
| 80 | + } |
| 81 | + |
| 82 | + // Check for error message (old behavior we're fixing) |
| 83 | + const errorMessage = await page.locator(".bg-red-50").count(); |
| 84 | + if (errorMessage > 0) { |
| 85 | + console.log( |
| 86 | + `Iteration ${i}: ERROR - Flow dismissed with error message (old behavior)`, |
| 87 | + ); |
| 88 | + } |
| 89 | + break; |
| 90 | + } |
| 91 | + } |
| 92 | + |
| 93 | + // Final screenshot |
| 94 | + await page.screenshot({ path: `cors-final.png`, fullPage: true }); |
| 95 | + |
| 96 | + // Check final state - should still show the flow with steps |
| 97 | + const finalStepCount = await page |
| 98 | + .locator('[class*="flex items-center p-2 rounded-md"]') |
| 99 | + .count(); |
| 100 | + console.log(`Final: ${finalStepCount} step(s) visible`); |
| 101 | + |
| 102 | + // Flow should NOT have been dismissed |
| 103 | + const flowHeading = await page.locator('text="OAuth Debug Flow"').count(); |
| 104 | + console.log(`Final: OAuth Debug Flow heading visible: ${flowHeading > 0}`); |
| 105 | + }); |
| 106 | +}); |
0 commit comments