50 lines
2.1 KiB
TypeScript
50 lines
2.1 KiB
TypeScript
import { test, expect } from "../../fixtures/test-base";
|
|
import {
|
|
expectCompactionCount,
|
|
expectSourceRightOfTokenCount,
|
|
seedContextWindowTask,
|
|
} from "./context-window-source-helpers";
|
|
|
|
test("context source help is reachable by touch without overflow", async ({
|
|
testPage,
|
|
apiClient,
|
|
seedData,
|
|
}) => {
|
|
await seedContextWindowTask(testPage, apiClient, seedData);
|
|
|
|
const contextTrigger = testPage.getByRole("button", { name: "Context window: 21% used" });
|
|
await contextTrigger.tap();
|
|
const contextTooltip = testPage
|
|
.locator('[data-slot="tooltip-content"]:not([data-state="closed"])')
|
|
.filter({ has: testPage.getByTestId("context-window-usage") });
|
|
const contextUsage = contextTooltip.getByTestId("context-window-usage").first();
|
|
await expect(contextUsage).toBeVisible();
|
|
await expectSourceRightOfTokenCount(contextTooltip);
|
|
await expectCompactionCount(contextTooltip);
|
|
|
|
const sourceHelpButton = contextUsage.locator('button[aria-label="About context window source"]');
|
|
const sourceHelpId = await sourceHelpButton.getAttribute("aria-describedby");
|
|
if (!sourceHelpId) throw new Error("Expected source help to be described");
|
|
await sourceHelpButton.tap();
|
|
|
|
await expect(contextUsage).toBeVisible();
|
|
await expect(testPage.locator(`[id="${sourceHelpId}"]`)).toHaveCSS("opacity", "1");
|
|
|
|
const compactionHelpButton = contextUsage.locator(
|
|
'button[aria-label="About inferred compaction count"]',
|
|
);
|
|
const compactionHelpId = await compactionHelpButton.getAttribute("aria-describedby");
|
|
if (!compactionHelpId) throw new Error("Expected compaction help to be described");
|
|
await compactionHelpButton.tap();
|
|
|
|
await expect(contextUsage).toBeVisible();
|
|
await expect(testPage.locator(`[id="${compactionHelpId}"]`)).toHaveCSS("opacity", "1");
|
|
await compactionHelpButton.tap();
|
|
await expect(testPage.locator(`[id="${compactionHelpId}"]`)).toHaveCSS("opacity", "0");
|
|
const hasHorizontalOverflow = await testPage.evaluate(() => {
|
|
const root = document.scrollingElement ?? document.documentElement;
|
|
return root.scrollWidth > root.clientWidth + 1;
|
|
});
|
|
expect(hasHorizontalOverflow).toBe(false);
|
|
});
|