mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-20 18:26:40 +01:00
Keep native tasks with declared pull request deliverables active until
GitHub verifies every deliverable is merged. Preserve delivery guidance
in follow-up contracts and recheck the current outputs under task locks.
Use bounded incomplete-work feedback during reassessment, including for
saved non-Done reports. Serialize work-product restoration and identity
changes with completion. Preserve configured reviews and conversations.
Add regression coverage and repair the CI fixtures exposed during
qualification. All CI checks pass on afee630120. Greptile is 5/5 with no
unresolved review threads.
Co-Authored-By: Paperclip <noreply@paperclip.ing>
200 lines
8.3 KiB
TypeScript
200 lines
8.3 KiB
TypeScript
import { expect, test } from "@playwright/test";
|
|
import { mockOnboardingLocalAiConnection } from "./helpers/onboarding-ai-connection";
|
|
import {
|
|
expectLandsOnChatWithoutDashboardBounce,
|
|
instrumentNavLog,
|
|
} from "./helpers/onboarding-landing";
|
|
|
|
/** The name the CEO role fills in — see AGENT_ROLE_LABELS. */
|
|
const AGENT_NAME = "CEO";
|
|
const TASK_TITLE = "Paperclip onboarding";
|
|
|
|
/** Wait for the saved question before checking its dismissed presentation. */
|
|
async function expectOpeningQuestionDismissed(page: import("@playwright/test").Page) {
|
|
await expect(page.getByTestId("task-chat-unanswered-question")).toBeVisible({ timeout: 30_000 });
|
|
await expect(page.getByTestId("task-chat-composer-takeover")).toHaveCount(0);
|
|
await expect(page.getByTestId("task-chat-pending-input-indicator")).toHaveCount(0);
|
|
await expect(page.getByTestId("task-chat-composer-mode")).toBeVisible({ timeout: 30_000 });
|
|
}
|
|
|
|
/** The opening question arrives after the interactions fetch. Dismiss it once. */
|
|
async function dismissOpeningCard(page: import("@playwright/test").Page) {
|
|
const takeover = page.getByTestId("task-chat-composer-takeover");
|
|
await expect(takeover).toBeVisible({ timeout: 30_000 });
|
|
await takeover.getByRole("button", { name: "Cancel", exact: true }).click();
|
|
await expectOpeningQuestionDismissed(page);
|
|
}
|
|
|
|
test("captures planning mode UI for desktop and mobile", async ({ page }) => {
|
|
const timestamp = Date.now();
|
|
const companyName = `PAP-3413-${timestamp}`;
|
|
const screenshotDir = "test-results/planning-mode";
|
|
|
|
await instrumentNavLog(page);
|
|
await mockOnboardingLocalAiConnection(page);
|
|
await page.route("**/onboarding/greeting", route => route.fulfill({ json: { started: false } }));
|
|
|
|
await page.route("**/test-environment", (route) =>
|
|
route.fulfill({
|
|
contentType: "application/json",
|
|
body: JSON.stringify({ status: "pass", checks: [] }),
|
|
}),
|
|
);
|
|
|
|
await page.route("**/agent-hires", async (route) => {
|
|
const req = route.request();
|
|
const body = JSON.parse(req.postData() || "{}");
|
|
const auth = req.headers().authorization;
|
|
const real = await fetch(new URL(req.url()).toString(), {
|
|
method: "POST",
|
|
headers: {
|
|
"Content-Type": "application/json",
|
|
...(auth ? { Authorization: auth } : {}),
|
|
},
|
|
body: JSON.stringify({
|
|
name: body.name,
|
|
role: body.role,
|
|
adapterType: "http",
|
|
adapterConfig: { url: "http://127.0.0.1:1/dead" },
|
|
runtimeConfig: { heartbeat: { enabled: false } },
|
|
}),
|
|
});
|
|
await route.fulfill({
|
|
status: real.status,
|
|
contentType: "application/json",
|
|
body: await real.text(),
|
|
});
|
|
});
|
|
|
|
await page.goto("/onboarding");
|
|
const startBtn = page.getByRole("button", { name: /Start Onboarding|New Organization|Add Agent/ });
|
|
if (await startBtn.count()) await startBtn.first().click();
|
|
|
|
const createCard = page.getByRole("button", { name: /Build a new organization/ });
|
|
if (await createCard.count()) await createCard.first().click();
|
|
|
|
await expect(page.getByRole("heading", { name: "What is the name of your organization?" })).toBeVisible({ timeout: 15_000 });
|
|
|
|
await page.locator('input[placeholder="e.g. Northwind Labs"]').fill(companyName);
|
|
await page.getByRole("button", { name: /^Continue/ }).click();
|
|
|
|
// Naming the company creates it and goes straight to the agent step.
|
|
|
|
// The agent step asks for a name and nothing else; the name is what gates
|
|
// "Next", and the hire is filed under the neutral `general` role.
|
|
await page.waitForSelector("#onboarding-agent-name", { timeout: 30_000 });
|
|
await page.locator("#onboarding-agent-name").fill(AGENT_NAME);
|
|
|
|
await page.getByRole("button", { name: /^Next$/ }).click();
|
|
|
|
// The connect step arrives with no source selected — the tile row is a
|
|
// question, not a confirmation — so its CTA stays disabled until one is
|
|
// pressed. The simulated verified account then advances automatically.
|
|
const source = page.getByRole("radio").first();
|
|
await source.waitFor({ timeout: 30_000 });
|
|
await source.click();
|
|
|
|
// The review step names the agent rather than the step.
|
|
await expect(
|
|
page.getByRole("heading", { name: "Let's get started..." }),
|
|
).toBeVisible({ timeout: 30_000 });
|
|
await page.getByRole("button", { name: /Get started/ }).click();
|
|
// The wizard opens the standing chat,
|
|
// and must not bounce through the dashboard (PAP-404).
|
|
await expectLandsOnChatWithoutDashboardBounce(page);
|
|
|
|
const baseOrigin = new URL(page.url()).origin;
|
|
const companyRes = await page.request.get(`${baseOrigin}/api/companies`);
|
|
expect(companyRes.ok()).toBe(true);
|
|
const companies = await companyRes.json();
|
|
const company = companies.find((c: { name: string }) => c.name === companyName);
|
|
expect(company).toBeTruthy();
|
|
const issueRes = await page.request.get(`${baseOrigin}/api/companies/${company.id}/issues`);
|
|
expect(issueRes.ok()).toBe(true);
|
|
const issues = await issueRes.json();
|
|
expect(issues).toEqual([]);
|
|
const agentsRes = await page.request.get(`${baseOrigin}/api/companies/${company.id}/agents`);
|
|
const [agent] = await agentsRes.json();
|
|
// This suite explicitly creates its legacy planning/question fixture; the
|
|
// onboarding wizard itself must leave execution work empty.
|
|
const created = await page.request.post(`${baseOrigin}/api/companies/${company.id}/issues`, {
|
|
data: { title: TASK_TITLE, assigneeAgentId: agent.id, onboardingFirstTask: true, status: "todo" },
|
|
});
|
|
expect(created.ok()).toBe(true);
|
|
const issue = await created.json();
|
|
const issueIdentifier = issue.identifier ?? issue.id;
|
|
const issuePath = `/${company.issuePrefix ?? company.id}/issues/${issueIdentifier}`;
|
|
const companyPrefix = company.issuePrefix ?? company.id;
|
|
const issueRow = page.locator(`[data-issue-row-details="${issue.id}"]`);
|
|
|
|
const setMode = async (mode: "standard" | "planning") => {
|
|
const patchRes = await page.request.patch(`${baseOrigin}/api/issues/${issue.id}`, {
|
|
data: { workMode: mode },
|
|
});
|
|
expect(patchRes.ok()).toBe(true);
|
|
await expect
|
|
.poll(async () => {
|
|
const currentRes = await page.request.get(`${baseOrigin}/api/issues/${issue.id}`);
|
|
expect(currentRes.ok()).toBe(true);
|
|
const current = await currentRes.json();
|
|
return current.workMode;
|
|
}, { timeout: 10_000 })
|
|
.toBe(mode);
|
|
};
|
|
|
|
await setMode("planning");
|
|
|
|
await page.goto(issuePath);
|
|
await dismissOpeningCard(page);
|
|
await page.reload();
|
|
await expectOpeningQuestionDismissed(page);
|
|
await expect(page.getByText("Plan mode").first()).toBeVisible();
|
|
const desktopPlanningToggle = page.getByTestId("task-chat-composer-mode");
|
|
await expect(desktopPlanningToggle).toBeVisible();
|
|
await expect(desktopPlanningToggle).toHaveAttribute("data-pending-work-mode", "planning");
|
|
|
|
await page.screenshot({
|
|
path: `${screenshotDir}/desktop-planning-detail-${timestamp}.png`,
|
|
fullPage: true,
|
|
});
|
|
|
|
await page.goto(`/${companyPrefix}/issues`);
|
|
await expect(issueRow).toBeVisible();
|
|
await expect(issueRow).not.toContainText("Plan mode");
|
|
await page.screenshot({
|
|
path: `${screenshotDir}/desktop-planning-row-${timestamp}.png`,
|
|
fullPage: true,
|
|
});
|
|
|
|
await page.goto(issuePath);
|
|
await expectOpeningQuestionDismissed(page);
|
|
await page.getByTestId("task-chat-composer-mode").click();
|
|
await expect(page.getByTestId("task-chat-composer-mode")).toHaveCount(0);
|
|
await expect(page.getByTestId("task-chat-composer-add")).toBeVisible();
|
|
await page.screenshot({
|
|
path: `${screenshotDir}/desktop-standard-toggle-${timestamp}.png`,
|
|
fullPage: true,
|
|
});
|
|
|
|
await setMode("planning");
|
|
await page.setViewportSize({ width: 390, height: 844 });
|
|
await page.goto(issuePath);
|
|
await expectOpeningQuestionDismissed(page);
|
|
await expect(page.getByText("Plan mode").first()).toBeVisible();
|
|
const mobilePlanningToggle = page.getByTestId("task-chat-composer-mode");
|
|
await expect(mobilePlanningToggle).toBeVisible();
|
|
await expect(mobilePlanningToggle).toHaveAttribute("data-pending-work-mode", "planning");
|
|
await page.screenshot({
|
|
path: `${screenshotDir}/mobile-planning-detail-${timestamp}.png`,
|
|
fullPage: true,
|
|
});
|
|
|
|
await page.goto(`/${companyPrefix}/issues`);
|
|
await expect(issueRow).toBeVisible();
|
|
await expect(issueRow).not.toContainText("Plan mode");
|
|
await page.screenshot({
|
|
path: `${screenshotDir}/mobile-planning-row-${timestamp}.png`,
|
|
fullPage: true,
|
|
});
|
|
});
|