Skip to content
Merged
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
8 changes: 7 additions & 1 deletion src/daemon/handlers/__tests__/find.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,13 @@ test('handleFindCommands wait captures fresh snapshots while polling', async ()
if (!response.ok) {
expect(response.error.message).toContain('find wait timed out');
}
expect(mockDispatch).toHaveBeenCalledTimes(2);
// What this test guards is that every poll re-captures instead of reusing the first tree.
// The exact poll count is a timing artifact and is not assertable: the loop's last sleep
// consumes whatever remains of the budget, so it lands on `remainingMs() === 0`, and a
// sleep that returns a millisecond early admits one more poll. Pinning this to 2 made the
// test fail under CI load on unrelated PRs. Assert the property, not the artifact.
expect(mockDispatch.mock.calls.length).toBeGreaterThanOrEqual(2);
expect(mockDispatch.mock.calls.every(([, command]) => command === 'snapshot')).toBe(true);
});

test('handleFindCommands click omits refsGeneration — a mutating find never issues a pinnable ref (ADR 0014)', async () => {
Expand Down
20 changes: 14 additions & 6 deletions src/platforms/apple/core/__tests__/apps.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,11 @@ test('screenshotIos retries simulator capture timeouts and eventually succeeds',
const outPath = path.join(tmpDir, 'screen.png');
const sourcePngPath = path.join(tmpDir, 'source.png');

await fs.writeFile(sourcePngPath, PNG.sync.write(new PNG({ width: 1206, height: 2622 })));
// Dimensions divisible by 3 so the implicit density-1 rescale (against the stub's native
// scale 3) stays exact. This test is about capture retry, not resolution, so the source is
// small rather than the 1206x2622 iPhone 16 Pro frame it used to allocate and resize —
// 3.2 megapixels to prove arithmetic that 34k pixels prove just as well (1176ms -> 233ms).
await fs.writeFile(sourcePngPath, PNG.sync.write(new PNG({ width: 126, height: 273 })));

await fs.writeFile(
xcrunPath,
Expand Down Expand Up @@ -205,8 +209,8 @@ test('screenshotIos retries simulator capture timeouts and eventually succeeds',
try {
await screenshotIos(IOS_TEST_SIMULATOR, outPath);
const png = PNG.sync.read(await fs.readFile(outPath));
assert.equal(png.width, 402);
assert.equal(png.height, 874);
assert.equal(png.width, 42);
assert.equal(png.height, 91);
assert.equal(await fs.readFile(screenshotCountPath, 'utf8'), '3\n');

const logLines = (await fs.readFile(commandLogPath, 'utf8')).trim().split('\n').filter(Boolean);
Expand Down Expand Up @@ -246,7 +250,11 @@ test('screenshotIos keeps requested simulator pixel density', async () => {
const outPath = path.join(tmpDir, 'screen.png');
const sourcePngPath = path.join(tmpDir, 'source.png');

await fs.writeFile(sourcePngPath, PNG.sync.write(new PNG({ width: 1206, height: 2622 })));
// Both dimensions divisible by 3 so the 2/3 rescale (density 2 against the stub's native
// scale 3) stays exact. What this pins is that ratio, not an absolute resolution: it used
// to allocate and resize a 1206x2622 iPhone 16 Pro frame — 3.2 megapixels, ~90x more than
// the arithmetic needs (1021ms -> 34ms).
await fs.writeFile(sourcePngPath, PNG.sync.write(new PNG({ width: 126, height: 273 })));
await fs.writeFile(
xcrunPath,
[
Expand Down Expand Up @@ -279,8 +287,8 @@ test('screenshotIos keeps requested simulator pixel density', async () => {
try {
await screenshotIos(IOS_TEST_SIMULATOR, outPath, { pixelDensity: 2 });
const png = PNG.sync.read(await fs.readFile(outPath));
assert.equal(png.width, 804);
assert.equal(png.height, 1748);
assert.equal(png.width, 84);
assert.equal(png.height, 182);
} finally {
process.env.PATH = previousPath;
if (previousScreenshotSourceFile === undefined)
Expand Down
Loading