Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apps/desktop/e2e-budget.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@
"electron": "observation seeding, reconnect and settle are Host subscriptions surviving a renderer remount"
},
"transcript-scroll-cost.spec.ts": {
"tests": 3,
"electron": "the perf budget is measured from CDP wheel input and the browser's own render skipping"
"tests": 4,
"electron": "the perf budget is measured from CDP wheel input and the browser's own render skipping, and reader displacement only exists against a real layout"
},
"workhub-layout.spec.ts": {
"tests": 2,
Expand Down
69 changes: 31 additions & 38 deletions apps/desktop/e2e/partial-history-notice.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,64 +21,57 @@ import { expect, test } from './fixtures';

const GAP = '.maka-transcript-gap-row';
const TURN = '.maka-transcript-turn';
/** Turns the partial-history fixture seeds. */
const PARTIAL_HISTORY_TURN_COUNT = 18;

test('bounded transcript ranges expose only their truthful boundary gaps', async ({
test('a bounded transcript range reaches its whole history without a control to ask', async ({
partialHistoryWindow: page,
}) => {
await page.setViewportSize({ width: 1_400, height: 800 });

const olderGap = page.locator('[data-transcript-gap="older"]');
const newerGap = page.locator('[data-transcript-gap="newer"]');
await expect(olderGap).toBeVisible();
await expect(olderGap.getByRole('button', {
name: /^(?:加载较早消息|Load earlier messages)$/,
})).toBeVisible();
await expect(newerGap).toHaveCount(0);
// The window is bounded, and its boundaries are not something the reader is
// shown or has to act on: the transcript renders Turns and nothing else.
await expect(page.locator(TURN).first()).toBeVisible();
await expect(page.locator(GAP)).toHaveCount(0);
await expect(page.locator('[data-transcript-gap]')).toHaveCount(0);
await expect(page.locator('.maka-transcript-history-controls')).toHaveCount(0);
expect(await page.locator(TURN).count()).toBeLessThan(PARTIAL_HISTORY_TURN_COUNT);

const oldestPrompt = page.locator(
'.maka-prompt-rail-tick[data-prompt-turn-id="turn-partial-history-1"]',
);
await expect(oldestPrompt).toBeVisible();
await oldestPrompt.click();

const firstTurn = page.locator('[data-turn-id="turn-partial-history-1"]');
await expect(firstTurn).toBeVisible();
await expect(firstTurn).toHaveAttribute('data-search-highlight', 'true');
await expect(olderGap).toHaveCount(0);
await expect(newerGap).toBeVisible();
await expect(newerGap.getByRole('button', {
name: /^(?:加载较新消息|Load newer messages)$/,
})).toBeVisible();
await expect(page.locator(GAP)).toHaveCount(1);
expect(await page.locator(TURN).count()).toBeLessThanOrEqual(10);
await expect(page.locator('[data-turn-id="turn-partial-history-1"]')).toBeVisible();
// Where the jump landed, read from the reading position rather than from
// `data-search-highlight`: that highlight clears itself 2.2s after the
// command lands, so waiting for the Turn to mount and then asserting it
// fails whenever loading the page around it takes longer than the flash —
// measured here as a 3s pass turning into an 18s timeout under load.
await expect(oldestPrompt).toHaveAttribute('data-active', 'true');
// A jump lands on its own page, not on the whole history.
expect(await page.locator(TURN).count()).toBeLessThan(PARTIAL_HISTORY_TURN_COUNT);
await expect(page.locator('[data-transcript-gap]')).toHaveCount(0);

const loadNewer = newerGap.getByRole('button', {
name: /^(?:加载较新消息|Load newer messages)$/,
});
await loadNewer.click();
await expect(page.locator('[data-turn-id="turn-partial-history-2"]')).toBeVisible();
await expect(olderGap).toHaveCount(0);
await expect(newerGap).toBeVisible();
await expect(loadNewer).toBeEnabled();

await loadNewer.click();
await expect(page.locator('[data-turn-id="turn-partial-history-3"]')).toBeVisible();
await expect(olderGap).toBeVisible();
await expect(newerGap).toBeVisible();
await expect(loadNewer).toBeEnabled();
await expect(oldestPrompt).toBeVisible();
await expect(page.locator(GAP)).toHaveCount(2);
expect(await page.locator(TURN).count()).toBeLessThanOrEqual(10);
// The newer side of the jump fills on its own as the reader moves into it.
await page.mouse.move(700, 400);
await expect(async () => {
await page.mouse.wheel(0, 400);
await expect(page.locator('[data-turn-id="turn-partial-history-3"]')).toBeVisible();
}).toPass({ timeout: 30_000 });
await expect(page.locator('[data-transcript-gap]')).toHaveCount(0);

const returnToLatest = page.getByRole('button', {
name: /^(?:滚动主对话到底部|Scroll main conversation to bottom)$/,
});
await expect(returnToLatest).toBeVisible();
await returnToLatest.click();

await expect(page.locator('[data-turn-id="turn-partial-history-18"]')).toBeVisible();
await expect(newerGap).toHaveCount(0);
// Reading the tail page and rebuilding the window around it is slower than
// the paging above, and measured past the suite's 10s expect timeout here.
await expect(page.locator(`[data-turn-id="turn-partial-history-${PARTIAL_HISTORY_TURN_COUNT}"]`))
.toBeVisible({ timeout: 30_000 });
await expect(oldestPrompt).toBeVisible();
expect(await page.locator(TURN).count()).toBeLessThanOrEqual(10);
expect(await page.locator(TURN).count()).toBeLessThan(PARTIAL_HISTORY_TURN_COUNT);
});
Loading
Loading