Skip to content
Open
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
24 changes: 23 additions & 1 deletion tests/e2e/requirements-support.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,28 @@ export async function expectRequirementsFit(page: Page) {
.toBeGreaterThanOrEqual(0);
}

/**
* The automatic fit runs once, frames after the cards appear, at whatever size
* the canvas then has. A mode round trip makes its completion observable.
*/
export async function consumeRequirementAutomaticFit(page: Page) {
const camera = () =>
page
.getByRole('region', { name: 'Diagram', exact: true })
.locator('.react-flow__viewport')
.evaluate((viewport) => getComputedStyle(viewport).transform);
await expectRequirementsFit(page);
const fitted = await camera();
await page.getByRole('button', { name: 'Split', exact: true }).click();
await expect
.poll(camera, { message: 'Split mode fits the narrower canvas' })
.not.toBe(fitted);
await page.getByRole('button', { name: 'Diagram', exact: true }).click();
await expect
.poll(camera, { message: 'Diagram mode restores the full-canvas fit' })
.toBe(fitted);
}

/** Center the focused card with a real canvas pan, retaining model-space geometry. */
export async function centerRequirementCard(page: Page, card: Locator) {
await settledRequirementViewport(page);
Expand Down Expand Up @@ -267,7 +289,7 @@ async function settledRequirementViewport(page: Page) {
/**
* Normalize through the visible maximum-zoom endpoint, then five real zoom-out
* actions. React Flow documents each zoom-out as 1/1.2 of the previous scale.
* This does not depend on whether initial fit finished before a panel resize.
* This fixes the scale only; the pan still depends on the size at initial fit.
*/
export async function zoomRequirementForReading(page: Page, card: Locator) {
const zoomIn = page.getByRole('button', { name: 'Zoom in', exact: true });
Expand Down
3 changes: 3 additions & 0 deletions tests/e2e/visual.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
importRequirementsTraceability,
waitForRequirements,
centerRequirementCard,
consumeRequirementAutomaticFit,
zoomRequirementForReading,
requirementCard,
} from './requirements-support';
Expand Down Expand Up @@ -592,6 +593,8 @@ for (const theme of ['light', 'dark']) {
await expect(
page.getByRole('region', { name: 'Issues', exact: true }),
).not.toBeVisible();
// A fit after the resize leaves a pan remainder integer drags cannot remove.
await consumeRequirementAutomaticFit(page);
await page.setViewportSize({ width, height: 900 });
await page
.getByRole('button', { name: 'Appearance', exact: true })
Expand Down
Loading