mirror of
https://github.com/expo/explore.git
synced 2026-11-15 13:18:16 -10:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
61a061a67d | ||
|
|
cd6a9a4908 | ||
|
|
2fd6a17a26 | ||
|
|
3f100ab15c |
No files matched your search
@@ -1458,3 +1458,146 @@ test("local run ZIP opens and reloads without a fabricated GitHub identity", asy
|
||||
await expect(localRun).toHaveText("Local");
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test("the Inspector stacks Before over After for a landscape screenshot; Swipe and Flip keep one frame", async t => {
|
||||
// An opened iPhone Duo's inner display, as a screenshot: wider than tall.
|
||||
const picture = new PNG({ width: 951, height: 669 });
|
||||
picture.data.fill(255);
|
||||
const capture = PNG.sync.write(picture);
|
||||
const report = reportFixture();
|
||||
for (const side of ["baseImage", "headImage"]) Object.assign(report.review.surfaces[0][side], { width: 951, height: 669 });
|
||||
const { bytes } = await imageArchive([capture], 0, report);
|
||||
const { page, errors } = await harness(t, Buffer.from(bytes), { app: true, fault: holdScreenshotHashes(capture.length) });
|
||||
await expect(page.locator(".app-shell")).toBeVisible();
|
||||
const stage = page.locator(".sidebar-review-stage");
|
||||
const box = locator => locator.evaluate(element => {
|
||||
const { left, top, width, height } = element.getBoundingClientRect();
|
||||
return { left, top, width, height };
|
||||
});
|
||||
const frames = page.locator(".sidebar-review .compare-frame");
|
||||
await expect(frames).toHaveCount(2);
|
||||
// The report's recorded size shapes the pair before the screenshots load: no side-by-side flash.
|
||||
await expect(frames.first().locator("img")).toHaveAttribute("data-screenshot-state", "loading");
|
||||
await expect(stage).toHaveClass(/landscape/);
|
||||
const waiting = await Promise.all([box(frames.nth(0)), box(frames.nth(1))]);
|
||||
await page.evaluate(() => window.releaseScreenshotHashes());
|
||||
await expect(frames.first().locator("img")).toHaveAttribute("data-screenshot-state", "ready");
|
||||
await expect(stage).toHaveClass(/landscape/);
|
||||
const [before, after] = await Promise.all([box(frames.nth(0)), box(frames.nth(1))]);
|
||||
assert.deepEqual([before, after], waiting, "The frames do not move or resize when the screenshots load");
|
||||
const panel = await box(stage);
|
||||
// Each frame takes the review's width; After sits under Before, not beside it.
|
||||
assert.ok(Math.abs(before.width - panel.width) <= 2, `Before spans the panel: ${JSON.stringify({ before, panel })}`);
|
||||
assert.ok(Math.abs(after.width - panel.width) <= 2, `After spans the panel: ${JSON.stringify({ after, panel })}`);
|
||||
assert.ok(after.top >= before.top + before.height, `After is under Before: ${JSON.stringify({ before, after })}`);
|
||||
assert.ok(Math.abs(before.width / before.height - 951 / 669) < 0.02, `The frame keeps the screenshot's shape: ${JSON.stringify(before)}`);
|
||||
// Swipe and Flip show one frame the panel's width, as before.
|
||||
for (const mode of ["Swipe", "Flip"]) {
|
||||
await page.locator(".sidebar-review-modes").getByRole("button", { name: mode, exact: true }).click();
|
||||
const frame = await box(page.locator(".sidebar-review :is(.visual-swipe, .compare-frame)").first());
|
||||
assert.ok(Math.abs(frame.width - panel.width) <= 2, `${mode} spans the panel: ${JSON.stringify({ frame, panel })}`);
|
||||
}
|
||||
await page.locator(".sidebar-review-modes").getByRole("button", { name: "Split", exact: true }).click();
|
||||
await expect(frames).toHaveCount(2);
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test("the Inspector keeps a portrait pair side by side", async t => {
|
||||
const { page, errors } = await harness(t, await archive(), { app: true });
|
||||
await expect(page.locator(".app-shell")).toBeVisible();
|
||||
const frames = page.locator(".sidebar-review .compare-frame");
|
||||
await expect(frames).toHaveCount(2);
|
||||
await expect(frames.first().locator("img")).toHaveAttribute("data-screenshot-state", "ready");
|
||||
await expect(page.locator(".sidebar-review-stage")).not.toHaveClass(/landscape/);
|
||||
const box = locator => locator.evaluate(element => {
|
||||
const { left, top, width } = element.getBoundingClientRect();
|
||||
return { left, top, width };
|
||||
});
|
||||
const [before, after] = await Promise.all([box(frames.nth(0)), box(frames.nth(1))]);
|
||||
assert.equal(after.top, before.top, `Before and After share a row: ${JSON.stringify({ before, after })}`);
|
||||
assert.ok(after.left >= before.left + before.width, `After is beside Before: ${JSON.stringify({ before, after })}`);
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
/** A white PNG of `width` × `height`, and the asset entry and record fields a report gives it. */
|
||||
function sizedCapture(width, height) {
|
||||
const picture = new PNG({ width, height });
|
||||
picture.data.fill(255);
|
||||
const bytes = PNG.sync.write(picture);
|
||||
const digest = createHash("sha256").update(bytes).digest("hex");
|
||||
return { bytes, sha256: digest, path: `assets/${digest}.png`,
|
||||
record: { url: `https://artifact.expo-explore.invalid/${digest}.png`, sha256: digest, width, height } };
|
||||
}
|
||||
|
||||
test("the Inspector takes a pair's shape from After, whichever side loads last", async t => {
|
||||
// A screen that turned landscape: Before is the 32×64 portrait fixture, After is landscape.
|
||||
const landscape = sizedCapture(951, 669);
|
||||
const report = reportFixture();
|
||||
Object.assign(report.review.surfaces[0].headImage, landscape.record);
|
||||
report.assets.push({ sha256: landscape.sha256, path: landscape.path });
|
||||
// Before's screenshot is held until After's has loaded, so it loads last.
|
||||
const { page, errors } = await harness(t, await archive(report, [{ name: landscape.path, bytes: landscape.bytes }]),
|
||||
{ app: true, fault: holdScreenshotHashes(png.length) });
|
||||
await expect(page.locator(".app-shell")).toBeVisible();
|
||||
const stage = page.locator(".sidebar-review-stage");
|
||||
const frames = page.locator(".sidebar-review .compare-frame");
|
||||
await expect(frames).toHaveCount(2);
|
||||
await expect(frames.nth(1).locator("img")).toHaveAttribute("data-screenshot-state", "ready");
|
||||
await expect(stage).toHaveClass(/landscape/);
|
||||
await page.evaluate(() => window.releaseScreenshotHashes());
|
||||
await expect(frames.nth(0).locator("img")).toHaveAttribute("data-screenshot-state", "ready");
|
||||
await expect(stage).toHaveClass(/landscape/);
|
||||
const ratio = await frames.nth(0).evaluate(element => element.getBoundingClientRect().width / element.getBoundingClientRect().height);
|
||||
assert.ok(Math.abs(ratio - 951 / 669) < 0.02, `Both frames keep After's shape: ${ratio}`);
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test("Swipe takes the loaded screenshot's shape when it differs from the recorded one", async t => {
|
||||
// The record says portrait; the screenshot is landscape. Swipe's frame follows the image, as
|
||||
// Split's and Flip's do, so a capture whose size the report does not hold is not cropped.
|
||||
const landscape = sizedCapture(951, 669);
|
||||
const { bytes } = await imageArchive([landscape.bytes]);
|
||||
const { page, errors } = await harness(t, Buffer.from(bytes), { app: true, fault: holdScreenshotHashes(landscape.bytes.length) });
|
||||
await expect(page.locator(".app-shell")).toBeVisible();
|
||||
// Swipe is chosen before any screenshot loads, so only Swipe's images report a size.
|
||||
await page.locator(".sidebar-review-modes").getByRole("button", { name: "Swipe", exact: true }).click();
|
||||
const swipe = page.locator(".sidebar-review .visual-swipe");
|
||||
await expect(swipe).toBeVisible();
|
||||
await page.evaluate(() => window.releaseScreenshotHashes());
|
||||
await expect(swipe.locator("img.visual-swipe-after")).toHaveAttribute("data-screenshot-state", "ready");
|
||||
await expect.poll(() => swipe.evaluate(element => {
|
||||
const { width, height } = element.getBoundingClientRect();
|
||||
return Math.abs(width / height - 951 / 669) < 0.02;
|
||||
})).toBe(true);
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test("a near-square landscape pair in a short window keeps both halves on screen, centred", async t => {
|
||||
// An unfolded foldable's inner display on its side: barely wider than tall.
|
||||
const foldable = sizedCapture(960, 800);
|
||||
const report = reportFixture();
|
||||
for (const side of ["baseImage", "headImage"]) Object.assign(report.review.surfaces[0][side], { width: 960, height: 800 });
|
||||
const { bytes } = await imageArchive([foldable.bytes], 0, report);
|
||||
const { page, errors } = await harness(t, Buffer.from(bytes), { app: true });
|
||||
await page.setViewportSize({ width: 1440, height: 760 });
|
||||
await expect(page.locator(".app-shell")).toBeVisible();
|
||||
const stage = page.locator(".sidebar-review-stage");
|
||||
await expect(stage).toHaveClass(/landscape/);
|
||||
const frames = page.locator(".sidebar-review .compare-frame");
|
||||
await expect(frames).toHaveCount(2);
|
||||
await expect(frames.nth(1).locator("img")).toHaveAttribute("data-screenshot-state", "ready");
|
||||
const box = locator => locator.evaluate(element => {
|
||||
const { left, top, width, height, bottom } = element.getBoundingClientRect();
|
||||
return { left, top, width, height, bottom };
|
||||
});
|
||||
const [before, after, panel] = await Promise.all([box(frames.nth(0)), box(frames.nth(1)), box(stage)]);
|
||||
const viewport = page.viewportSize();
|
||||
assert.ok(after.top >= before.top + before.height, `After is under Before: ${JSON.stringify({ before, after })}`);
|
||||
assert.ok(before.top >= 0 && after.bottom <= viewport.height, `Both halves are on screen: ${JSON.stringify({ before, after, viewport })}`);
|
||||
for (const frame of [before, after]) {
|
||||
assert.ok(frame.width < panel.width - 2, `The frame is held under the panel's width: ${JSON.stringify({ frame, panel })}`);
|
||||
assert.ok(Math.abs(frame.left + frame.width / 2 - (panel.left + panel.width / 2)) <= 1, `The frame is centred: ${JSON.stringify({ frame, panel })}`);
|
||||
assert.ok(Math.abs(frame.width / frame.height - 960 / 800) < 0.02, `The frame keeps the screenshot's shape: ${JSON.stringify(frame)}`);
|
||||
}
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
@@ -94,6 +94,31 @@ test("reviewed build diff preserves exact cross-build evidence and split/merge s
|
||||
);
|
||||
});
|
||||
|
||||
test("a screen diff carries the compared screenshot's recorded shape, After's first", async () => {
|
||||
const fixture = await createBuildWorkspaceFixture();
|
||||
const currentBuild = fixture.catalog.builds.find((build) => build.id === "build-2.0.0");
|
||||
const baselineBuild = fixture.catalog.builds.find((build) => build.id === "build-1.0.0");
|
||||
const artifact = (map, id) => map.artifacts.find((entry) => entry.id === `artifact-observation-${id}`);
|
||||
// The reviewed After turned landscape; Before stays portrait.
|
||||
Object.assign(artifact(fixture.currentMap, "build-2.0.0-current-profile-reviewed"), { width: 60, height: 30 });
|
||||
// A capture without a recorded size (not a PNG) gives the frame nothing to take.
|
||||
const added = artifact(fixture.currentMap, "build-2.0.0-current-added-primary");
|
||||
delete added.width;
|
||||
delete added.height;
|
||||
|
||||
const diff = diffModel.buildDiff({
|
||||
currentBuild,
|
||||
currentMap: fixture.currentMap,
|
||||
baselineBuild,
|
||||
baselineMap: fixture.baselineMap,
|
||||
comparison: fixture.comparison,
|
||||
});
|
||||
|
||||
assert.equal(diff.screens.get("current-profile")?.screenshotAspect, 2);
|
||||
assert.equal(diff.screens.get(removedScreenId("build-1.0.0", "baseline-legacy"))?.screenshotAspect, 0.5);
|
||||
assert.equal(diff.screens.get("current-added")?.screenshotAspect, undefined);
|
||||
});
|
||||
|
||||
test("catalog route context contains only the two real builds", async () => {
|
||||
const fixture = await createBuildWorkspaceFixture();
|
||||
assert.deepEqual(diffModel.routeContextForCatalog(fixture.catalog), {
|
||||
|
||||
@@ -308,11 +308,14 @@
|
||||
.compare-frame-wrap { position: relative; }
|
||||
/* Flip: one frame, centred under its Before/After names, in Compare and in the Inspector. The wrap
|
||||
is a flex row because a block sized by height + aspect-ratio does not shrink-wrap in every engine
|
||||
(WebKit left the frame at the left edge). */
|
||||
(WebKit left the frame at the left edge). A stacked landscape pair whose frames are held to part
|
||||
of the window's height centres them the same way. */
|
||||
.compare-stage.mode-flip .compare-side,
|
||||
.sidebar-review-stage.mode-flip .compare-side { width: 100%; align-items: center; }
|
||||
.sidebar-review-stage.mode-flip .compare-side,
|
||||
.sidebar-review-stage.mode-split.landscape .compare-side { width: 100%; align-items: center; }
|
||||
.compare-stage.mode-flip .compare-frame-wrap,
|
||||
.sidebar-review-stage.mode-flip .compare-frame-wrap { display: flex; justify-content: center; }
|
||||
.sidebar-review-stage.mode-flip .compare-frame-wrap,
|
||||
.sidebar-review-stage.mode-split.landscape .compare-frame-wrap { display: flex; justify-content: center; }
|
||||
.compare-frame {
|
||||
position: relative;
|
||||
display: block;
|
||||
@@ -496,6 +499,15 @@
|
||||
.sidebar-review-stage.mode-flip {
|
||||
--compare-frame-height: min(calc(100cqw / var(--compare-aspect)), 70dvh);
|
||||
}
|
||||
/* A landscape screenshot (an opened iPhone Duo, an iPad on its side) is too wide for two frames to
|
||||
share the panel: Before stacks over After, each the panel's width, up to about a third of
|
||||
the window's height (half of Swipe's and Flip's one frame), so a near-square pair (an unfolded
|
||||
foldable) and a short window still show both. */
|
||||
.sidebar-review-stage.mode-split.landscape {
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
--compare-frame-height: min(calc(100cqw / var(--compare-aspect)), 35dvh);
|
||||
}
|
||||
/* Split's labels sit inside the frames here, as Swipe's do. */
|
||||
.compare-side-tag {
|
||||
position: absolute;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useEffect, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore, type CSSProperties, type ReactNode, type RefObject } from "react";
|
||||
import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore, type CSSProperties, type ReactNode, type RefObject } from "react";
|
||||
import { ImageOff, ScanSearch } from "lucide-react";
|
||||
import type { ChangesMenuData } from "../panels/changes-menu";
|
||||
import { diffLabel, ACCESSIBILITY_ONLY_HIGHLIGHT, type BuildDiff, type ScreenDiff } from "../../utils/build-diff";
|
||||
@@ -135,7 +135,19 @@ export function useCompareController(options: CompareControllerOptions) {
|
||||
const [flipSide, setFlipSide] = useState<"before" | "after">("after");
|
||||
const [swipePosition, setSwipePosition] = useState(50);
|
||||
const [factsOpen, setFactsOpen] = useState(false);
|
||||
const [aspect, setAspect] = useState(DEFAULT_SCREENSHOT_RATIO);
|
||||
// The frame takes the recorded screenshot's shape at once, then the loaded image's (they agree
|
||||
// unless the report's record is off), so a landscape pair stacks before its pixels arrive. A
|
||||
// screen with no recorded size keeps the last screen's shape until its own image loads. After
|
||||
// decides, as it does for the recorded shape: Before's image counts only on a screen without one,
|
||||
// so a pair whose shape changed does not take whichever side loaded last.
|
||||
const [loadedAspect, setLoadedAspect] = useState<{ screenId: string; aspect: number }>();
|
||||
const aspect = (loadedAspect?.screenId === options.screenId ? loadedAspect.aspect : undefined)
|
||||
?? screenDiff?.screenshotAspect ?? loadedAspect?.aspect ?? DEFAULT_SCREENSHOT_RATIO;
|
||||
const hasAfter = Boolean(screenDiff?.afterScreenshot);
|
||||
const setAspect = useCallback((value: number, side: "before" | "after") => {
|
||||
if (side === "before" && hasAfter) return;
|
||||
setLoadedAspect({ screenId: options.screenId, aspect: value });
|
||||
}, [options.screenId, hasAfter]);
|
||||
|
||||
// Each screen starts whole: no area selected, After showing, the facts closed.
|
||||
useEffect(() => {
|
||||
@@ -449,7 +461,8 @@ type StageProps = {
|
||||
swipePosition: number;
|
||||
onSwipePosition: (position: number) => void;
|
||||
aspect: number;
|
||||
onAspect: (aspect: number) => void;
|
||||
/** A screenshot of the stage loaded: its width over its height, and which side it shows. */
|
||||
onAspect: (aspect: number, side: "before" | "after") => void;
|
||||
};
|
||||
|
||||
export function CompareStage(props: StageProps) {
|
||||
@@ -474,6 +487,7 @@ export function CompareStage(props: StageProps) {
|
||||
before={before}
|
||||
after={after}
|
||||
imageAspect={props.aspect}
|
||||
onAspect={props.onAspect}
|
||||
changes={props.areas}
|
||||
activeIndex={props.activeArea}
|
||||
showOutlines={props.showOutlines}
|
||||
@@ -514,7 +528,7 @@ export function CompareStage(props: StageProps) {
|
||||
<button type="button" className="compare-frame compare-flip-frame" data-side={showing}
|
||||
aria-label={`Show ${showing === "after" ? "Before" : "After"}`} onClick={props.onFlip}>
|
||||
<CompareImage src={showing === "after" ? after : before} alt={`${props.title}, ${showing}`}
|
||||
placeholder="No screenshot" onAspect={props.onAspect} />
|
||||
placeholder="No screenshot" side={showing} onAspect={props.onAspect} />
|
||||
{props.overlay}
|
||||
</button>
|
||||
</div>
|
||||
@@ -535,7 +549,7 @@ export function CompareStage(props: StageProps) {
|
||||
<div className="compare-frame-wrap">
|
||||
<div className="compare-frame">
|
||||
<CompareImage src={src} alt={`${props.title}, ${showing}`}
|
||||
placeholder={placeholderFor(showing, diff.status, diff.captureNotes)} onAspect={props.onAspect} />
|
||||
placeholder={placeholderFor(showing, diff.status, diff.captureNotes)} side={showing} onAspect={props.onAspect} />
|
||||
</div>
|
||||
</div>
|
||||
</figure>
|
||||
@@ -558,7 +572,7 @@ export function CompareStage(props: StageProps) {
|
||||
<div className="compare-frame">
|
||||
{src ? (
|
||||
<CompareImage src={src} alt={`${props.title}, ${side}`}
|
||||
placeholder={placeholderFor(side, diff.status, diff.captureNotes)} onAspect={props.onAspect} />
|
||||
placeholder={placeholderFor(side, diff.status, diff.captureNotes)} side={side} onAspect={props.onAspect} />
|
||||
) : (
|
||||
<ScreenshotPlaceholder label={placeholderFor(side, diff.status, diff.captureNotes)} />
|
||||
)}
|
||||
@@ -575,7 +589,10 @@ export function CompareStage(props: StageProps) {
|
||||
);
|
||||
}
|
||||
|
||||
function CompareImage(props: { src: string; alt: string; placeholder: string; onAspect: (aspect: number) => void }) {
|
||||
function CompareImage(props: {
|
||||
src: string; alt: string; placeholder: string; side: "before" | "after";
|
||||
onAspect: (aspect: number, side: "before" | "after") => void;
|
||||
}) {
|
||||
return (
|
||||
<ScreenshotImage
|
||||
src={props.src}
|
||||
@@ -586,7 +603,7 @@ function CompareImage(props: { src: string; alt: string; placeholder: string; on
|
||||
fallback={<ScreenshotPlaceholder label={props.placeholder} />}
|
||||
onLoad={(event) => {
|
||||
const { naturalWidth, naturalHeight } = event.currentTarget;
|
||||
if (naturalWidth > 0 && naturalHeight > 0) props.onAspect(naturalWidth / naturalHeight);
|
||||
if (naturalWidth > 0 && naturalHeight > 0) props.onAspect(naturalWidth / naturalHeight, props.side);
|
||||
}}
|
||||
/>
|
||||
);
|
||||
|
||||
@@ -123,7 +123,7 @@ export function SidebarReview(props: CompareControllerOptions) {
|
||||
<section className="sidebar-review" aria-label={`Changes in ${route}`}>
|
||||
<ReviewModes value={compare.chosenMode} disabled={compare.modesDisabled} onChange={compare.chooseMode} />
|
||||
|
||||
<div className={`compare-stage sidebar-review-stage mode-${mode}`}
|
||||
<div className={`compare-stage sidebar-review-stage mode-${mode}${compare.aspect > 1 ? " landscape" : ""}`}
|
||||
style={{ "--compare-aspect": compare.aspect } as CSSProperties}>
|
||||
{/* Before and After are named above the frames in every mode, as in Compare. */}
|
||||
<CompareStage
|
||||
|
||||
@@ -88,6 +88,8 @@ export function SwipeCompare(props: {
|
||||
before: string;
|
||||
after: string;
|
||||
imageAspect: number;
|
||||
/** After's screenshot loaded: its width over its height, for a frame shaped before it arrived. */
|
||||
onAspect?: (aspect: number, side: "after") => void;
|
||||
changes: readonly VisualChange[];
|
||||
activeIndex?: number | undefined;
|
||||
showOutlines?: boolean;
|
||||
@@ -150,7 +152,11 @@ export function SwipeCompare(props: {
|
||||
onPointerUp={onPointerUp}
|
||||
onPointerCancel={onPointerUp}>
|
||||
<ScreenshotImage className="visual-swipe-after" src={props.after} alt={`${props.title}, after`}
|
||||
loading="eager" draggable={false} />
|
||||
loading="eager" draggable={false}
|
||||
onLoad={(event) => {
|
||||
const { naturalWidth, naturalHeight } = event.currentTarget;
|
||||
if (naturalWidth > 0 && naturalHeight > 0) props.onAspect?.(naturalWidth / naturalHeight, "after");
|
||||
}} />
|
||||
<ScreenshotImage className="visual-swipe-before" src={props.before} alt={`${props.title}, before`}
|
||||
loading="eager" draggable={false} />
|
||||
{props.showOutlines === false ? null : <ChangeOutlines changes={props.changes} activeIndex={props.activeIndex} />}
|
||||
|
||||
@@ -52,6 +52,8 @@ export type ScreenDiff = {
|
||||
note?: string;
|
||||
beforeScreenshot?: string;
|
||||
afterScreenshot?: string;
|
||||
/** The compared screenshot's recorded width over its height (After's when it has one), so a frame takes its shape before it loads. */
|
||||
screenshotAspect?: number;
|
||||
/** The CI pixel comparison of the two screenshots, when both captures were verified. */
|
||||
visual?: ReviewVisualDiff;
|
||||
/** Why a side that exists in its revision has no screenshot. */
|
||||
@@ -335,6 +337,7 @@ export function buildDiff(options: {
|
||||
const after = screen.after
|
||||
? artifactUrl(screen.after.artifact, screen.after.buildId)
|
||||
: undefined;
|
||||
const recorded = recordedAspect(screen.after?.artifact) ?? recordedAspect(screen.before?.artifact);
|
||||
const reviewSurface = reviewSurfaceFor(review, [
|
||||
screen.id,
|
||||
screen.sourceScreenId,
|
||||
@@ -354,10 +357,15 @@ export function buildDiff(options: {
|
||||
};
|
||||
const baseDestination = destinationIn(baselineIndex);
|
||||
const headDestination = destinationIn(index);
|
||||
const borrowed = {
|
||||
before: baseDestination ? artifactUrl(screenshotForScreen(baseDestination, baselineIndex), baselineBuild.id) : undefined,
|
||||
after: headDestination ? artifactUrl(screenshotForScreen(headDestination, index)) : undefined,
|
||||
const borrowedArtifacts = {
|
||||
before: baseDestination ? screenshotForScreen(baseDestination, baselineIndex) : undefined,
|
||||
after: headDestination ? screenshotForScreen(headDestination, index) : undefined,
|
||||
};
|
||||
const borrowed = {
|
||||
before: baseDestination ? artifactUrl(borrowedArtifacts.before, baselineBuild.id) : undefined,
|
||||
after: headDestination ? artifactUrl(borrowedArtifacts.after) : undefined,
|
||||
};
|
||||
const screenshotAspect = recorded ?? recordedAspect(borrowedArtifacts.after) ?? recordedAspect(borrowedArtifacts.before);
|
||||
screens.set(screen.id, {
|
||||
status: screen.status,
|
||||
changeSummary: screen.changeSummary,
|
||||
@@ -370,6 +378,7 @@ export function buildDiff(options: {
|
||||
...(screen.status === "modified" && reviewSurface?.pixelsUnchanged ? { accessibilityOnly: true as const } : {}),
|
||||
...(before ?? borrowed.before ? { beforeScreenshot: (before ?? borrowed.before)! } : {}),
|
||||
...(after ?? borrowed.after ? { afterScreenshot: (after ?? borrowed.after)! } : {}),
|
||||
...(screenshotAspect ? { screenshotAspect } : {}),
|
||||
...(redirectTo && (borrowed.before || borrowed.after) ? { redirectTo } : {}),
|
||||
...(redirectTargets?.length ? { redirectTargets } : {}),
|
||||
...(screen.baselineScreenId ? { baselineScreenId: screen.baselineScreenId } : {}),
|
||||
@@ -384,12 +393,14 @@ export function buildDiff(options: {
|
||||
}
|
||||
|
||||
for (const screen of baselineContext) {
|
||||
const before = artifactUrl(screenshotForScreen(screen, baselineIndex), baselineBuild.id);
|
||||
const artifact = screenshotForScreen(screen, baselineIndex);
|
||||
const before = artifactUrl(artifact, baselineBuild.id);
|
||||
const screenshotAspect = recordedAspect(artifact);
|
||||
const reviewSurface = reviewSurfaceFor(review, [screen.id]);
|
||||
screens.set(baselineContextScreenId(baselineBuild.id, screen.id), {
|
||||
status: "not-compared", changeSummary: "Captured as navigation context in the previous revision; not compared.",
|
||||
...(reviewSurface?.note ? { note: reviewSurface.note } : {}),
|
||||
...(before ? { beforeScreenshot: before } : {}), baselineScreenId: screen.id,
|
||||
...(before ? { beforeScreenshot: before } : {}), ...(screenshotAspect ? { screenshotAspect } : {}), baselineScreenId: screen.id,
|
||||
reviewerChanges: reviewSurface?.reviewerChanges ?? [], runtimeEvidenceRefs: reviewSurface?.runtimeEvidenceRefs ?? [],
|
||||
noVisibleChange: false,
|
||||
});
|
||||
@@ -398,3 +409,8 @@ export function buildDiff(options: {
|
||||
return { baselineId: baselineBuild.id, screens, map, index,
|
||||
counts: { ...projection.counts, "not-compared": projection.counts["not-compared"] + baselineContext.length } };
|
||||
}
|
||||
|
||||
/** A screenshot's recorded width over its height, when the report recorded both. */
|
||||
function recordedAspect(artifact: Pick<Artifact, "width" | "height"> | undefined): number | undefined {
|
||||
return artifact?.width && artifact.height && artifact.width > 0 && artifact.height > 0 ? artifact.width / artifact.height : undefined;
|
||||
}
|
||||
@@ -235,6 +235,7 @@ function familyEvidence(diffs: readonly ScreenDiff[]): {
|
||||
note?: string;
|
||||
beforeScreenshot?: string;
|
||||
afterScreenshot?: string;
|
||||
screenshotAspect?: number;
|
||||
visual?: ReviewVisualDiff;
|
||||
captureNotes?: CaptureNotes;
|
||||
redirectTo?: string;
|
||||
@@ -264,6 +265,7 @@ function familyEvidence(diffs: readonly ScreenDiff[]): {
|
||||
)];
|
||||
const metadata = {
|
||||
...(primary.note ? { note: primary.note } : {}),
|
||||
...(primary.screenshotAspect ? { screenshotAspect: primary.screenshotAspect } : {}),
|
||||
reviewerChanges,
|
||||
runtimeEvidenceRefs,
|
||||
noVisibleChange: diffs.some((diff) => diff.noVisibleChange),
|
||||
|
||||
Reference in new issue
Block a user