|
| 1 | +import { expect, test } from "@playwright/test"; |
| 2 | + |
| 3 | +const bundleUrl = "https://share.openwork.software/b/test-skill"; |
| 4 | + |
| 5 | +test.beforeEach(async ({ page }) => { |
| 6 | + await page.route("**/b/test-skill*", async (route) => { |
| 7 | + const url = new URL(route.request().url()); |
| 8 | + if (url.searchParams.get("format") !== "json") { |
| 9 | + await route.fulfill({ |
| 10 | + status: 404, |
| 11 | + headers: { |
| 12 | + "content-type": "application/json", |
| 13 | + "access-control-allow-origin": "*", |
| 14 | + }, |
| 15 | + body: JSON.stringify({ message: "Not found" }), |
| 16 | + }); |
| 17 | + return; |
| 18 | + } |
| 19 | + |
| 20 | + await route.fulfill({ |
| 21 | + status: 200, |
| 22 | + headers: { |
| 23 | + "content-type": "application/json", |
| 24 | + "access-control-allow-origin": "*", |
| 25 | + }, |
| 26 | + body: JSON.stringify({ |
| 27 | + schemaVersion: 1, |
| 28 | + type: "skill", |
| 29 | + name: "test-skill", |
| 30 | + content: "# Test skill\n\nUse this test skill.", |
| 31 | + description: "Playwright fixture skill", |
| 32 | + }), |
| 33 | + }); |
| 34 | + }); |
| 35 | + |
| 36 | + await page.goto("/skills-launcher-harness.html"); |
| 37 | +}); |
| 38 | + |
| 39 | +test("both create entry points open the launcher modal", async ({ page }) => { |
| 40 | + await page.getByRole("button", { name: "New skill" }).click(); |
| 41 | + const createDialog = page.getByRole("dialog", { name: "Create a skill" }); |
| 42 | + await expect(createDialog).toBeVisible(); |
| 43 | + await expect(createDialog.getByRole("button", { name: "Upload the skill" })).toBeVisible(); |
| 44 | + await expect(createDialog.getByRole("button", { name: "Create/edit in skill editor" })).toBeVisible(); |
| 45 | + await expect(createDialog.getByRole("button", { name: "Install from link" })).toBeVisible(); |
| 46 | + await expect(createDialog.getByRole("button", { name: "Create a skill in chat" })).toBeVisible(); |
| 47 | + |
| 48 | + await createDialog.getByRole("button", { name: "Close create skill modal" }).click(); |
| 49 | + |
| 50 | + await page.getByRole("button", { name: "Create skill in chat" }).click(); |
| 51 | + await expect(page.getByRole("dialog", { name: "Create a skill" })).toBeVisible(); |
| 52 | +}); |
| 53 | + |
| 54 | +test("launcher actions route into the shared flows", async ({ page }) => { |
| 55 | + await page.getByRole("button", { name: "New skill" }).click(); |
| 56 | + let dialog = page.getByRole("dialog", { name: "Create a skill" }); |
| 57 | + |
| 58 | + await dialog.getByRole("button", { name: "Upload the skill" }).click(); |
| 59 | + await expect(page.getByTestId("import-count")).toHaveText("1"); |
| 60 | + |
| 61 | + await page.getByRole("button", { name: "New skill" }).click(); |
| 62 | + dialog = page.getByRole("dialog", { name: "Create a skill" }); |
| 63 | + await dialog.getByRole("button", { name: "Create a skill in chat" }).click(); |
| 64 | + await expect(page.getByTestId("session-count")).toHaveText("1"); |
| 65 | + await expect(page.getByTestId("prompt-value")).toHaveText("/skill-creator"); |
| 66 | + |
| 67 | + await page.getByRole("button", { name: "New skill" }).click(); |
| 68 | + dialog = page.getByRole("dialog", { name: "Create a skill" }); |
| 69 | + await dialog.getByRole("button", { name: "Create/edit in skill editor" }).click(); |
| 70 | + const installDialog = page.getByRole("dialog", { name: "Install from link" }); |
| 71 | + await expect(page.getByTestId("opened-url")).toHaveText("https://share.openworklabs.com"); |
| 72 | + await expect(installDialog.getByText("Paste the share link from the editor to install it here.")).toBeVisible(); |
| 73 | + |
| 74 | + await installDialog.getByLabel("Skill bundle link").fill(bundleUrl); |
| 75 | + await installDialog.getByRole("button", { name: "Preview" }).click(); |
| 76 | + await expect(installDialog.getByText("Skill:")).toBeVisible(); |
| 77 | + await installDialog.getByRole("button", { name: "Install", exact: true }).click(); |
| 78 | + await expect(page.getByTestId("saved-skills")).toContainText("test-skill"); |
| 79 | +}); |
| 80 | + |
| 81 | +test("toolbar install shortcut opens the shared install flow directly", async ({ page }) => { |
| 82 | + await page.getByRole("button", { name: "Install from link" }).last().click(); |
| 83 | + const installDialog = page.getByRole("dialog", { name: "Install from link" }); |
| 84 | + await expect(installDialog).toBeVisible(); |
| 85 | + await expect(installDialog.getByText("Paste a skill bundle URL, preview it, then install.")).toBeVisible(); |
| 86 | +}); |
0 commit comments