Files
penguin-harness/packages/web/e2e/sheet.spec.mjs
T
Yaowei Zheng 45bfae6e94 Initialize repository with harness code and assets
Initial import of all source code, config, and README assets: the
packages workspace (cli, core, server, web, docs, landing, skills),
build scripts, tooling config, and CI workflows.

Includes the data-layout revision made on this branch: the local data
root defaults to ~/.penguin/data (PENGUIN_HOME still overrides; the
installer keeps its binaries in ~/.penguin), and every Agent lives
under <project>/agents/<agent>/ — path helpers, the three
agent-enumeration scans, the system prompt, built-in Skills, tests
and docs all follow the new layout.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018ihk8iQuo3kv2aPjAYEPuR
2026-07-19 14:06:53 +08:00

67 lines
2.4 KiB
JavaScript

/**
* Narrow viewport (<1024px, below use-files-panel's isDocked breakpoint): the Files panel
* uses a bottom Sheet: open → drill into a directory → Markdown renders by default → Esc
* closes and unmounts.
* Upload uses a nested path (notes/demo.md): also covers the server's sandbox auto-creating
* a missing parent directory.
*/
import { test, expect } from "@playwright/test";
import { provisionAndLogin } from "./auth.mjs";
const BASE = process.env.BASE_URL;
const MOCK = process.env.MOCK_URL;
test.use({ viewport: { width: 412, height: 915 } });
test("mobile Files sheet: open → nested dir → md rendered preview → esc close", async ({
page,
}) => {
await provisionAndLogin(page.request, "sheetuser", "password123");
const projects = await (await page.request.get(`${BASE}/api/projects`)).json();
const projectId = projects.projects[0].projectId;
const put = await page.request.put(`${BASE}/api/projects/${projectId}/models`, {
data: {
defaultModel: { provider: "custom", modelId: "claude-4-8" },
models: [
{
provider: "custom",
modelId: "claude-4-8",
apiKey: "sk-mock",
baseUrl: MOCK,
contextWindow: 200000,
},
],
},
});
expect(put.ok(), "put models").toBeTruthy();
const sess = await (
await page.request.post(`${BASE}/api/projects/${projectId}/agents/default_agent/sessions`, {
data: { provider: "custom", modelId: "claude-4-8" },
})
).json();
const sessionId = sess.session.sessionId;
const md = Buffer.from("# Sheet 标题\n\n正文段落。").toString("base64");
const up = await page.request.put(
`${BASE}/api/sessions/${sessionId}/files/content?path=notes/demo.md`,
{ data: { dataBase64: md } },
);
expect(up.ok(), "upload nested md").toBeTruthy();
await page.goto(`${BASE}/chat/${sessionId}`);
await page.getByRole("button", { name: "打开工作区" }).click();
const sheet = page.getByRole("dialog");
await expect(sheet).toBeVisible();
// Drill into the directory → open the md → default rendered view (h1 shown, not source).
await sheet.getByText("notes").first().click();
await sheet.getByText("demo.md").first().click();
await expect(sheet.getByRole("heading", { name: "Sheet 标题" })).toBeVisible();
// Esc closes: unmounts entirely once the exit animation finishes.
await page.keyboard.press("Escape");
await expect(sheet).toBeHidden();
});