diff --git a/e2e/specs/mock/db.ts b/e2e/specs/mock/db.ts index 80516da780..40127f7135 100644 --- a/e2e/specs/mock/db.ts +++ b/e2e/specs/mock/db.ts @@ -81,6 +81,38 @@ export async function deleteConversations(conversationIds: string[]): Promise { + return withMongo(async (db) => { + const user = await resolveUserId(db, userEmail); + const now = new Date(); + const result = await db.collection('chatprojects').insertMany( + names.map((name) => ({ + name, + user, + description: '', + instructions: '', + contextRevision: 0, + file_ids: [], + conversationCount: 0, + lastConversationAt: null, + lastConversationId: null, + createdAt: now, + updatedAt: now, + })), + ); + return Object.values(result.insertedIds).map((id) => id.toHexString()); + }); +} + +export async function deleteProjects(projectIds: string[]): Promise { + await withMongo((db) => + db + .collection('chatprojects') + .deleteMany({ _id: { $in: projectIds.map((id) => new ObjectId(id)) } }), + ); +} + export interface SeedMessage { messageId: string; parentMessageId: string; diff --git a/e2e/specs/mock/scenarios/ui-scale-layout.spec.ts b/e2e/specs/mock/scenarios/ui-scale-layout.spec.ts index 87170afc4c..b576aab2b8 100644 --- a/e2e/specs/mock/scenarios/ui-scale-layout.spec.ts +++ b/e2e/specs/mock/scenarios/ui-scale-layout.spec.ts @@ -2,7 +2,13 @@ import { randomUUID } from 'crypto'; import { expect, test } from '@playwright/test'; import type { Locator, Page } from '@playwright/test'; import { getE2EUser } from '../../../setup/user'; -import { clearUserConversations, deleteConversations, seedConversations } from '../db'; +import { + clearUserConversations, + deleteConversations, + deleteProjects, + seedConversations, + seedProjects, +} from '../db'; import { BASE_FONT_PX, MAX_SCALE, @@ -208,16 +214,23 @@ test.describe('UI scale layout', () => { }) => { const user = getE2EUser(); const conversationIds = [randomUUID(), randomUUID(), randomUUID()]; + const now = Date.now(); + await page.setViewportSize({ width: 1280, height: 720 }); await clearUserConversations(user.email); await seedConversations( user.email, conversationIds.map((conversationId, index) => ({ conversationId, title: `Scaled row ${index + 1}`, - updatedAt: new Date(), + updatedAt: new Date(now + index * 1000), })), ); + const projectIds = await seedProjects( + user.email, + Array.from({ length: 8 }, (_, index) => `Scale project ${index + 1}`), + ); + try { await page.goto('/c/new', { timeout: 10000 }); /* Below the drawer breakpoint the list lives in a drawer that is not @@ -228,8 +241,18 @@ test.describe('UI scale layout', () => { await withStoredScale(page, MAX_SCALE); await page.reload({ timeout: 15000 }); - firstRow = await conversationRow(page, 'Scaled row 1'); + await accountButton(page); await expectRootFontPx(page, unscaledFont * MAX_SCALE); + const offscreenRow = page + .getByTestId('convo-item') + .filter({ hasText: 'Scaled row 1' }) + .first(); + await expect(offscreenRow).toBeVisible(); + await expect( + offscreenRow, + 'expanded projects should push the scaled conversation below the viewport', + ).not.toBeInViewport(); + firstRow = await conversationRow(page, 'Scaled row 1'); const scaled = await box(firstRow); /* The rows are measured into a CellMeasurerCache; a cache that is not @@ -241,7 +264,7 @@ test.describe('UI scale layout', () => { ); expect(clipped, 'the scaled row clips its own content').toBe(false); } finally { - await deleteConversations(conversationIds); + await Promise.all([deleteConversations(conversationIds), deleteProjects(projectIds)]); } }); }); diff --git a/e2e/specs/mock/scenarios/ui-scale.helpers.ts b/e2e/specs/mock/scenarios/ui-scale.helpers.ts index 76e94d49ff..4a667d454c 100644 --- a/e2e/specs/mock/scenarios/ui-scale.helpers.ts +++ b/e2e/specs/mock/scenarios/ui-scale.helpers.ts @@ -57,7 +57,11 @@ export async function expectRootFontPx(page: Page, expected: number) { * and CSS-visible while translated off-canvas, so "visible" alone can hand back * a control no one can click. */ -async function reachable(page: Page, candidates: Locator): Promise { +async function reachable( + page: Page, + candidates: Locator, + scrollIntoView = false, +): Promise { const viewport = page.viewportSize(); if (!viewport) { return null; @@ -65,7 +69,20 @@ async function reachable(page: Page, candidates: Locator): Promise 0 && + bounds.height > 0 && + bounds.x + bounds.width > 0 && + bounds.x < viewport.width + ) { + await candidate.scrollIntoViewIfNeeded(); + bounds = await candidate.boundingBox(); + } /* Intersection, not containment: the off-canvas rail sits entirely beside the viewport, while an on-screen control may legitimately bleed a pixel. */ if ( @@ -95,12 +112,13 @@ async function reachableInSidebar( page: Page, candidates: Locator, label: string, + scrollIntoView = false, ): Promise { let found: Locator | null = null; await expect .poll( async () => { - found = await reachable(page, candidates); + found = await reachable(page, candidates, scrollIntoView); if (found) { return true; } @@ -137,6 +155,7 @@ export async function conversationRow(page: Page, title: string): Promise