Files
gods-eye-view/src/perfTestRunner.test.mjs
T
Yehe LiuandClaude Opus 5.5 14f88b3e08 feat: Wildlife Sightings layer from iNaturalist and Acartia
Recent community wildlife observations, as a new Wildlife group in the
layer panel.

- Server: keyless iNaturalist proxy (v2 observations with only the
  projected fields; undocumented v1 UTFGrid density tiles, decoded on the
  server) sharing one paced queue (burst 4, ~1/s, 60/min, 8,000/day budget,
  up to four in flight), in-memory caches and upstream-only cooldowns;
  Acartia Salish Sea marine-mammal feed rounded to 0.01 degrees with
  comments dropped.
- Layer: grid counts drawn as a soft view-ranked density glow; real sampled
  sightings as taxon badges at their true positions with ambient photo
  thumbnails and labels; obscured records stay privacy cells; a clicked
  sighting stays pinned through camera moves and refreshes.
- Anchored photo card per selection with the single iNaturalist link;
  attribution in the layer row and the Data attribution popover.
- Filters (CONFIRMED, taxa presets) round-trip in share links with token 9.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-05 16:17:12 -05:00

82 lines
2.4 KiB
JavaScript

import test from 'node:test';
import assert from 'node:assert/strict';
import {
mkdtempSync,
mkdirSync,
readFileSync,
rmSync,
writeFileSync,
} from 'node:fs';
import { tmpdir } from 'node:os';
import path from 'node:path';
import {
discoverPerfTestFiles,
perfBudgetTestOptions,
perfTestArgs,
runPerfTests,
} from '../scripts/run-perf-tests.mjs';
test('timing assertions are skipped with an actionable message unless explicitly enabled', () => {
for (const env of [
{},
{ GEV_PERF_BUDGETS: '0' },
{ GEV_PERF_BUDGETS: 'true' },
])
assert.match(
perfBudgetTestOptions(env).skip,
/Timing budgets are opt-in; run npm run test:perf/,
);
assert.deepEqual(perfBudgetTestOptions({ GEV_PERF_BUDGETS: '1' }), {
skip: false,
});
});
test('test:perf discovers every benchmark and enables timing budgets in a serial process', (t) => {
const root = mkdtempSync(path.join(tmpdir(), 'gev-perf-runner-'));
t.after(() => rmSync(root, { recursive: true, force: true }));
const expected = [
'server/providers/example/provider.perf.test.mjs',
'src/layers/anotherLayer/model.perf.test.mjs',
'src/layers/wildlifeSightings/model.perf.test.mjs',
];
for (const file of [
...expected,
'src/layers/anotherLayer/functional.test.mjs',
]) {
mkdirSync(path.dirname(path.join(root, file)), { recursive: true });
writeFileSync(path.join(root, file), '');
}
assert.deepEqual(discoverPerfTestFiles(root), expected);
const calls = [];
const run = (...args) => {
calls.push(args);
return { status: 7 };
};
assert.equal(
runPerfTests({
root,
env: { GEV_PERF_BUDGETS: '0', SENTINEL: 'kept' },
run,
}),
7,
);
assert.equal(calls.length, 1);
const [command, args, options] = calls[0];
assert.equal(command, process.execPath);
assert.deepEqual(args, perfTestArgs(expected));
assert.ok(args.includes('--test-concurrency=1'));
assert.ok(args.includes('--test-isolation=none'));
assert.equal(options.cwd, root);
assert.equal(options.env.GEV_PERF_BUDGETS, '1');
assert.equal(options.env.SENTINEL, 'kept');
assert.throws(
() =>
runPerfTests({ root, run: () => ({ error: new Error('spawn failed') }) }),
/spawn failed/,
);
const pkg = JSON.parse(
readFileSync(new URL('../package.json', import.meta.url), 'utf8'),
);
assert.equal(pkg.scripts['test:perf'], 'node scripts/run-perf-tests.mjs');
});