|
| 1 | +import { test, expect } from "@playwright/test"; |
| 2 | + |
| 3 | +// Adjust the URL if your dev server runs on a different port |
| 4 | +const APP_URL = "http://localhost:6274/"; |
| 5 | + |
| 6 | +test.describe("Transport Type Dropdown", () => { |
| 7 | + test("should have options for STDIO, SSE, and Streamable HTTP", async ({ |
| 8 | + page, |
| 9 | + }) => { |
| 10 | + await page.goto(APP_URL); |
| 11 | + |
| 12 | + // Wait for the Transport Type dropdown to be visible |
| 13 | + const selectTrigger = page.getByLabel("Transport Type"); |
| 14 | + await expect(selectTrigger).toBeVisible(); |
| 15 | + |
| 16 | + // Open the dropdown |
| 17 | + await selectTrigger.click(); |
| 18 | + |
| 19 | + // Check for the three options |
| 20 | + await expect(page.getByRole("option", { name: "STDIO" })).toBeVisible(); |
| 21 | + await expect(page.getByRole("option", { name: "SSE" })).toBeVisible(); |
| 22 | + await expect( |
| 23 | + page.getByRole("option", { name: "Streamable HTTP" }), |
| 24 | + ).toBeVisible(); |
| 25 | + }); |
| 26 | + |
| 27 | + test("should show Command and Arguments fields and hide URL field when Transport Type is STDIO", async ({ |
| 28 | + page, |
| 29 | + }) => { |
| 30 | + await page.goto(APP_URL); |
| 31 | + |
| 32 | + // Wait for the Transport Type dropdown to be visible |
| 33 | + const selectTrigger = page.getByLabel("Transport Type"); |
| 34 | + await expect(selectTrigger).toBeVisible(); |
| 35 | + |
| 36 | + // Open the dropdown and select STDIO |
| 37 | + await selectTrigger.click(); |
| 38 | + await page.getByRole("option", { name: "STDIO" }).click(); |
| 39 | + |
| 40 | + // Wait for the form to update |
| 41 | + await page.waitForTimeout(100); |
| 42 | + |
| 43 | + // Check that Command and Arguments fields are visible |
| 44 | + await expect(page.locator("#command-input")).toBeVisible(); |
| 45 | + await expect(page.locator("#arguments-input")).toBeVisible(); |
| 46 | + |
| 47 | + // Check that URL field is not visible |
| 48 | + await expect(page.locator("#sse-url-input")).not.toBeVisible(); |
| 49 | + |
| 50 | + // Also verify the labels are present |
| 51 | + await expect(page.getByText("Command")).toBeVisible(); |
| 52 | + await expect(page.getByText("Arguments")).toBeVisible(); |
| 53 | + await expect(page.getByText("URL")).not.toBeVisible(); |
| 54 | + }); |
| 55 | + |
| 56 | + test("should show URL field and hide Command and Arguments fields when Transport Type is SSE", async ({ |
| 57 | + page, |
| 58 | + }) => { |
| 59 | + await page.goto(APP_URL); |
| 60 | + |
| 61 | + // Wait for the Transport Type dropdown to be visible |
| 62 | + const selectTrigger = page.getByLabel("Transport Type"); |
| 63 | + await expect(selectTrigger).toBeVisible(); |
| 64 | + |
| 65 | + // Open the dropdown and select SSE |
| 66 | + await selectTrigger.click(); |
| 67 | + await page.getByRole("option", { name: "SSE" }).click(); |
| 68 | + |
| 69 | + // Wait for the form to update |
| 70 | + await page.waitForTimeout(100); |
| 71 | + |
| 72 | + // Check that URL field is visible |
| 73 | + await expect(page.locator("#sse-url-input")).toBeVisible(); |
| 74 | + |
| 75 | + // Check that Command and Arguments fields are not visible |
| 76 | + await expect(page.locator("#command-input")).not.toBeVisible(); |
| 77 | + await expect(page.locator("#arguments-input")).not.toBeVisible(); |
| 78 | + |
| 79 | + // Also verify the labels are present/absent |
| 80 | + await expect(page.getByText("URL")).toBeVisible(); |
| 81 | + await expect(page.getByText("Command")).not.toBeVisible(); |
| 82 | + await expect(page.getByText("Arguments")).not.toBeVisible(); |
| 83 | + }); |
| 84 | + |
| 85 | + test("should show URL field and hide Command and Arguments fields when Transport Type is Streamable HTTP", async ({ |
| 86 | + page, |
| 87 | + }) => { |
| 88 | + await page.goto(APP_URL); |
| 89 | + |
| 90 | + // Wait for the Transport Type dropdown to be visible |
| 91 | + const selectTrigger = page.getByLabel("Transport Type"); |
| 92 | + await expect(selectTrigger).toBeVisible(); |
| 93 | + |
| 94 | + // Open the dropdown and select Streamable HTTP |
| 95 | + await selectTrigger.click(); |
| 96 | + await page.getByRole("option", { name: "Streamable HTTP" }).click(); |
| 97 | + |
| 98 | + // Wait for the form to update |
| 99 | + await page.waitForTimeout(100); |
| 100 | + |
| 101 | + // Check that URL field is visible |
| 102 | + await expect(page.locator("#sse-url-input")).toBeVisible(); |
| 103 | + |
| 104 | + // Check that Command and Arguments fields are not visible |
| 105 | + await expect(page.locator("#command-input")).not.toBeVisible(); |
| 106 | + await expect(page.locator("#arguments-input")).not.toBeVisible(); |
| 107 | + |
| 108 | + // Also verify the labels are present/absent |
| 109 | + await expect(page.getByText("URL")).toBeVisible(); |
| 110 | + await expect(page.getByText("Command")).not.toBeVisible(); |
| 111 | + await expect(page.getByText("Arguments")).not.toBeVisible(); |
| 112 | + }); |
| 113 | +}); |
0 commit comments