Stream reader results and navigate with cursors [skip ci]

This commit is contained in:
2026-11-07 17:27:31 +08:00
parent b5b1994993
commit ae4a505d70
10 changed files with 149 additions and 46 deletions
+18
View File
@@ -42,3 +42,21 @@ test("malformed research responses do not become empty results or sample mode",
await expect(page.getByRole("textbox", { name: "搜索论文", exact: true })).toHaveValue("keep-this-query");
await expect(page.locator(".paper-row, .sample-note, .index-heading h2 span, .pagination")).toHaveCount(0);
});
test("slow results stream after usable search controls and searches retain the document", async ({ page, request }) => {
await control(request, { paperDelay: 3000 });
await page.goto("/", { waitUntil: "commit" });
await expect(page.getByRole("textbox", {name:"搜索论文",exact:true})).toBeVisible({timeout:2000});
await expect(page.getByRole("status")).toContainText("正在读取论文索引");
await expect(page.locator(".paper-row")).toHaveCount(8);
await page.evaluate(() => { window.__readerDocument = "preserved"; });
let documents = 0, sessions = 0;
page.on("request", req => { if(req.isNavigationRequest() && req.frame() === page.mainFrame()) documents++; if(new URL(req.url()).pathname.endsWith("/auth/me")) sessions++; });
await page.getByRole("textbox", {name:"搜索论文",exact:true}).fill("graph");
await page.getByRole("button", {name:"搜索论文",exact:true}).click();
await expect(page).toHaveURL(/q=graph/);
await expect(page.locator(".paper-row")).toHaveCount(8);
expect(await page.evaluate(() => window.__readerDocument)).toBe("preserved");
expect(documents).toBe(0); expect(sessions).toBe(0);
});