mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-18 17:22:19 +00:00
From gekh's review of #768, each bug with a test that fails before: - P2: a failed sequence load clears the previous sequence's cones, resets the selection and can be retried; a second click while loading starts no second lookup. sequences.js had no tests: sequences.test.mjs now covers failure and retry, a superseded late answer, the cache and clearSelection. - P2: closing a photo stops MapillaryJS sequence playback, which kept the hidden viewer stepping and downloading images. - openNearest without the panel reports it instead of loading forever, and stops if the layer (or its provider) went off during the lookup; the mesh sampler's misses are bounded and forgotten with its samples; the sequence count is the union of ids across tiles; a provider withdraws only its own error, so a sequence error cannot mask KEY REJECTED; hover stays on (throttled) under an orbiting camera and re-picks when it stops; "since N days" follows the clock in a long-open tab. - A prewarm waits for one in flight and then builds if it gave up. - New coverage for the layer core (credits, KEY REJECTED vs REQUIRED, switching a provider off), the refresh wiring of the tilted-view fix and the draped-to-cast swap completion. - Cleanup: loading is derived from pending; freshStreet(); tile ranking computes distances once and shares one path for the date line; shared metresBetween / whenIdle / redrawTile; one NEAREST_RADIUS_M and one source method list; unused contract fields, exports, getImage and the decoder's image branch removed; PROVIDER_COLORS lists only Mapillary. Co-Authored-By: Claude Opus 5.5 <[email protected]>
99 lines
2.7 KiB
JavaScript
99 lines
2.7 KiB
JavaScript
import assert from 'node:assert/strict';
|
|
import test from 'node:test';
|
|
import { requiresKeyIdFor, validateProviders } from './registry.js';
|
|
|
|
const def = (overrides = {}) => ({
|
|
id: 'mapillary',
|
|
name: 'Mapillary',
|
|
label: 'MAPILLARY',
|
|
requiresKeyId: 'mapillary',
|
|
pickPrefix: 'mly:',
|
|
colors: { coverage: '#05cb63' },
|
|
credit: { html: 'Mapillary' },
|
|
create: () => ({}),
|
|
...overrides,
|
|
});
|
|
|
|
test('a valid list is frozen in registration order', () => {
|
|
const list = validateProviders([
|
|
def(),
|
|
def({ id: 'panoramax', pickPrefix: 'pnx:', requiresKeyId: null }),
|
|
]);
|
|
assert.ok(Object.isFrozen(list));
|
|
assert.deepEqual(
|
|
list.map((p) => p.id),
|
|
['mapillary', 'panoramax'],
|
|
);
|
|
});
|
|
|
|
test('an empty list, duplicate ids and malformed ids are rejected', () => {
|
|
assert.throws(() => validateProviders([]), /at least one/);
|
|
assert.throws(() => validateProviders(null), /at least one/);
|
|
assert.throws(() => validateProviders([def(), def()]), /Duplicate/);
|
|
assert.throws(() => validateProviders([def({ id: 'Bad Id' })]), /slug/);
|
|
});
|
|
|
|
test('every required field is checked by name', () => {
|
|
for (const key of [
|
|
'name',
|
|
'label',
|
|
'pickPrefix',
|
|
'colors',
|
|
'credit',
|
|
'create',
|
|
])
|
|
assert.throws(
|
|
() => validateProviders([def({ [key]: undefined })]),
|
|
new RegExp(`lacks ${key}`),
|
|
key,
|
|
);
|
|
assert.throws(() => validateProviders([def({ create: 1 })]), /create/);
|
|
assert.throws(() => validateProviders([def({ credit: {} })]), /credit/);
|
|
assert.throws(
|
|
() => validateProviders([def({ colors: { pano: '#f0f' } })]),
|
|
/coverage colour/,
|
|
);
|
|
assert.throws(
|
|
() => validateProviders([def({ pickPrefix: '' })]),
|
|
/pick prefix/,
|
|
);
|
|
});
|
|
|
|
test('overlapping pick prefixes are rejected either way round', () => {
|
|
assert.throws(
|
|
() => validateProviders([def(), def({ id: 'other', pickPrefix: 'mly:x' })]),
|
|
/overlaps/,
|
|
);
|
|
assert.throws(
|
|
() =>
|
|
validateProviders([def({ pickPrefix: 'mly:x' }), def({ id: 'other' })]),
|
|
/overlaps/,
|
|
);
|
|
assert.doesNotThrow(() =>
|
|
validateProviders([def(), def({ id: 'other', pickPrefix: 'ml:' })]),
|
|
);
|
|
});
|
|
|
|
test('requiresKeyIdFor is the shared key, or null once providers differ', () => {
|
|
assert.equal(requiresKeyIdFor([def()]), 'mapillary');
|
|
assert.equal(
|
|
requiresKeyIdFor([def(), def({ id: 'b', pickPrefix: 'b:' })]),
|
|
'mapillary',
|
|
);
|
|
assert.equal(
|
|
requiresKeyIdFor([
|
|
def(),
|
|
def({ id: 'b', pickPrefix: 'b:', requiresKeyId: null }),
|
|
]),
|
|
null,
|
|
);
|
|
assert.equal(
|
|
requiresKeyIdFor([
|
|
def(),
|
|
def({ id: 'b', pickPrefix: 'b:', requiresKeyId: 'google-maps' }),
|
|
]),
|
|
null,
|
|
);
|
|
assert.equal(requiresKeyIdFor([def({ requiresKeyId: null })]), null);
|
|
});
|