diff --git a/tests/runner-e2e/PRODUCT-JOURNEYS.md b/tests/runner-e2e/PRODUCT-JOURNEYS.md index 1c843de2043..9ea5d2d39ea 100644 --- a/tests/runner-e2e/PRODUCT-JOURNEYS.md +++ b/tests/runner-e2e/PRODUCT-JOURNEYS.md @@ -592,3 +592,12 @@ or a 408, 429, 502, 503 or 504 response, inside the caller's original timeout. I honors a `Retry-After` of up to five seconds. It never repeats a write or a binary download (`bytes`). The observed reader opts out, so its own retry loop records every transient failure in `observation-read-failures.json`. + + +The shared Skill Studio edit story reports a closed `skill_studio__failed` +code when a browser or saved-file read step fails. The code identifies opening +the card, reading its preview, opening Studio, loading or editing the file, +saving, saved-content verification, reload, returning to the task, or reopening +the card. Raw browser errors, URLs and skill contents are excluded. Both classic +and Cloud callers use this helper. These codes locate a failed step; they do +not establish a product cause or change the failed grade. diff --git a/tests/runner-e2e/product-journeys/journey-failure.test.ts b/tests/runner-e2e/product-journeys/journey-failure.test.ts index 1f103302d2a..6665918d66b 100644 --- a/tests/runner-e2e/product-journeys/journey-failure.test.ts +++ b/tests/runner-e2e/product-journeys/journey-failure.test.ts @@ -1,5 +1,6 @@ import { describe, expect, it } from "vitest"; import { ConnectionFailure } from "../connection-config.js"; +import { editCreatedSkillThroughStudio } from "../skill-studio-flow.js"; import { journeyFailure } from "./launch.js"; describe("journeyFailure", () => { @@ -19,6 +20,15 @@ describe("journeyFailure", () => { expect(journeyFailure(new ConnectionFailure("api_status_502"))).toEqual({ outcome: "failed", code: "api_status_502" }); }); + it("keeps the Studio step through final journey grading without browser details", async () => { + const page = { getByRole() { throw new Error("https://private.example/?token=secret skill-body"); } }; + const error = await editCreatedSkillThroughStudio({ page: page as never, skillId: "owned", skillName: "owned", + marker: "marker", deadlineAt: Date.now() + 1000, read: async () => ({}) }).catch(error => error); + expect(journeyFailure(error)).toEqual({ outcome: "failed", code: "skill_studio_open_card_failed" }); + expect(JSON.stringify(error)).not.toMatch(/private|token|secret|skill-body/); + expect(error.cause).toBeUndefined(); + }); + it("never retains free-form messages", () => { expect(journeyFailure(new ConnectionFailure("api_status_500 https://example.test/?token=secret"))).toEqual({ outcome: "failed", code: "journey_operation_failed" }); expect(journeyFailure(new Error("api_status_500"))).toEqual({ outcome: "failed", code: "journey_operation_failed" }); diff --git a/tests/runner-e2e/skill-studio-flow.spec.ts b/tests/runner-e2e/skill-studio-flow.spec.ts index a27c3ff32b8..286e094b5c9 100644 --- a/tests/runner-e2e/skill-studio-flow.spec.ts +++ b/tests/runner-e2e/skill-studio-flow.spec.ts @@ -39,7 +39,17 @@ test("Studio never edits or saves an unhydrated file", async ({ page }) => { ` })); await page.goto("https://fixture.test/QA/issues/QA-1"); await expect(editCreatedSkillThroughStudio({ page, skillId: "id", skillName: "owned", marker: "New content", deadlineAt: Date.now() + 7000, - read: async () => ({}) })).rejects.toThrow(); + read: async () => ({}) })).rejects.toMatchObject({ outcome: "failed", code: "skill_studio_load_file_failed", message: "skill_studio_load_file_failed" }); expect(inputs).toBe(0); expect(saves).toBe(0); }); + + +test("Studio identifies a missing task card without retaining browser text", async ({ page }) => { + await page.route("https://fixture.test/**", route => route.fulfill({ contentType: "text/html", body: "

No skill card

" })); + await page.goto("https://fixture.test/QA/issues/QA-1?token=private-fixture-value"); + const failure = await editCreatedSkillThroughStudio({ page, skillId: "owned", skillName: "private-skill-name", + marker: "private-marker", deadlineAt: Date.now() + 7000, read: async () => ({}) }).catch(error => error); + expect(failure).toMatchObject({ outcome: "failed", code: "skill_studio_open_card_failed", message: "skill_studio_open_card_failed" }); + expect(JSON.stringify(failure)).not.toMatch(/private|fixture.test|token=/); +}); diff --git a/tests/runner-e2e/skill-studio-flow.ts b/tests/runner-e2e/skill-studio-flow.ts index 686bfa1a0e4..53c79987404 100644 --- a/tests/runner-e2e/skill-studio-flow.ts +++ b/tests/runner-e2e/skill-studio-flow.ts @@ -1,38 +1,65 @@ import { expect, type Page } from "@playwright/test"; +type StudioStep = "open_card" | "read_preview" | "open_studio" | "load_file" | "edit_file" + | "save_file" | "verify_saved" | "reload_file" | "return_task" | "reopen_card"; + +class SkillStudioFlowError extends Error { + readonly outcome = "failed"; + readonly code: string; + constructor(step: StudioStep) { + const code = `skill_studio_${step}_failed`; + super(code); + this.code = code; + } +} + /** Shared browser story for classic and Cloud: activity card -> Studio -> saved task readback. */ export async function editCreatedSkillThroughStudio(input: { page: Page; skillId: string; skillName: string; marker: string; deadlineAt: number; read(): Promise; }) { - const { page, skillName } = input; - const card = page.getByRole("article", { name: `Skill created: ${skillName}`, exact: true }); - await expect(card).toHaveCount(1); - await expect(card).toBeVisible(); - await card.getByRole("button").click(); - await expect(page.getByRole("heading", { name: skillName, exact: true })).toBeVisible(); - await expect(page.getByText("Verify checks.", { exact: true })).toBeVisible(); - await page.getByRole("button", { name: "Open in Skill Studio", exact: true }).click(); - await expect(page).toHaveURL(new RegExp(`/skills/studio/${input.skillId}$`)); - await expect(page.getByRole("combobox").filter({ hasText: skillName })).toBeVisible(); - const editor = page.getByRole("textbox", { name: "editable markdown", exact: true }); - // Studio mounts the editor before its file query completes. Wait for the - // saved body, otherwise hydration can replace edits made to the empty draft. - await expect(editor).toContainText("Verify checks."); - await editor.click(); - await editor.press("ControlOrMeta+End"); - await editor.press("Enter"); - await editor.press("Enter"); - await editor.pressSequentially(input.marker); - await page.getByRole("button", { name: /^Save$/ }).click(); - await expect.poll(async () => JSON.stringify(await input.read()).includes(input.marker), - { timeout: Math.max(1, Math.min(30_000, input.deadlineAt - Date.now())) }).toBe(true); - await page.reload(); - await expect(editor).toContainText(input.marker); - await page.goBack(); - await expect(page).toHaveURL(/\/issues\//); - await expect(card).toBeVisible(); - await card.getByRole("button").click(); - await expect(page.getByRole("heading", { name: skillName, exact: true })).toBeVisible(); - await expect(page.getByText(input.marker, { exact: true })).toBeVisible(); + let step: StudioStep = "open_card"; + try { + const { page, skillName } = input; + const card = page.getByRole("article", { name: `Skill created: ${skillName}`, exact: true }); + await expect(card).toHaveCount(1); + await expect(card).toBeVisible(); + await card.getByRole("button").click(); + step = "read_preview"; + await expect(page.getByRole("heading", { name: skillName, exact: true })).toBeVisible(); + await expect(page.getByText("Verify checks.", { exact: true })).toBeVisible(); + step = "open_studio"; + await page.getByRole("button", { name: "Open in Skill Studio", exact: true }).click(); + await expect(page).toHaveURL(new RegExp(`/skills/studio/${input.skillId}$`)); + await expect(page.getByRole("combobox").filter({ hasText: skillName })).toBeVisible(); + const editor = page.getByRole("textbox", { name: "editable markdown", exact: true }); + // Studio mounts the editor before its file query completes. Wait for the + // saved body, otherwise hydration can replace edits made to the empty draft. + step = "load_file"; + await expect(editor).toContainText("Verify checks."); + step = "edit_file"; + await editor.click(); + await editor.press("ControlOrMeta+End"); + await editor.press("Enter"); + await editor.press("Enter"); + await editor.pressSequentially(input.marker); + step = "save_file"; + await page.getByRole("button", { name: /^Save$/ }).click(); + step = "verify_saved"; + await expect.poll(async () => JSON.stringify(await input.read()).includes(input.marker), + { timeout: Math.max(1, Math.min(30_000, input.deadlineAt - Date.now())) }).toBe(true); + step = "reload_file"; + await page.reload(); + await expect(editor).toContainText(input.marker); + step = "return_task"; + await page.goBack(); + await expect(page).toHaveURL(/\/issues\//); + step = "reopen_card"; + await expect(card).toBeVisible(); + await card.getByRole("button").click(); + await expect(page.getByRole("heading", { name: skillName, exact: true })).toBeVisible(); + await expect(page.getByText(input.marker, { exact: true })).toBeVisible(); + } catch { + throw new SkillStudioFlowError(step); + } }