test(firms): pin the refresh call count and read sources from production

Review follow-up for #1552:
- environmentProviders: assert exactly 3 upstream calls per refresh again,
  so a returning fourth source would fail the test.
- firmsProxy: build the test's SOURCES from server/providers/firms.js, so
  there is one list instead of a mirrored copy.
- firmsProxy: drop the unused fourth count entry.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Itallo BrandãoandClaude Opus 5.5 committed 2026-11-05 02:57:27 -03:00
1 parent b342e405d7
commit b37025414d
2 files changed
+8 -9

No files matched your search

+6 -7
View File
@@ -21,7 +21,10 @@ assert.notEqual(start, -1, 'FIRMS refresh function exists');
const end = config.indexOf('\n }', start);
assert.notEqual(end, -1, 'FIRMS refresh function closes');
const refreshSource = config.slice(start, end + 4);
const SOURCES = ['VIIRS_NOAA20_NRT', 'VIIRS_NOAA21_NRT', 'MODIS_NRT'];
// Read the source list from production so these tests share one source of truth.
const listed = config.match(/const SOURCES = \[([^\]]*)\];/);
assert.ok(listed, 'FIRMS source list exists');
const SOURCES = [...listed[1].matchAll(/'([A-Z0-9_]+)'/g)].map((m) => m[1]);
const NOW = Date.UTC(2026, 8, 11, 12);
const recent = { acqDate: '2026-09-11', acqTime: '1100' };
@@ -54,7 +57,7 @@ test('FIRMS retains large sources in order and filters expired rows', async () =
assert.equal(result.fires[199_999], large.at(-1));
assert.equal(result.fires.at(-1), last);
assert.deepEqual(result.sources, SOURCES.map((source, index) => ({
source, count: [200_000, 1, 0, 0][index], ok: true,
source, count: [200_000, 1, 0][index], ok: true,
})));
});
@@ -309,11 +312,7 @@ test('every FIRMS upstream request goes through the IPv4 fallback', async () =>
});
test('FIRMS requests only the satellites NASA still delivers', () => {
const listed = config.match(/const SOURCES = \[([^\]]*)\];/);
assert.ok(listed, 'FIRMS source list exists');
const production = [...listed[1].matchAll(/'([A-Z0-9_]+)'/g)].map((m) => m[1]);
assert.deepEqual(production, SOURCES, 'the test mirrors the production source list');
// NASA stopped delivering Suomi NPP data on 2026-11-02 (#849): requesting it
// returns no rows and still spends a MAP_KEY transaction on every refresh.
assert.ok(!production.includes('VIIRS_SNPP_NRT'));
assert.ok(!SOURCES.includes('VIIRS_SNPP_NRT'));
});
+2 -2
View File
@@ -313,9 +313,9 @@ test('FIRMS retains a large successful source during partial failure and filters
const first = json(await request());
assert.equal(first.count, 130001);
assert.equal(first.sources.filter((s) => s.ok).length, 1);
assert.equal(calls, first.sources.length);
assert.equal(calls, 3);
assert.equal(json(await request()).count, 130001);
assert.equal(calls, first.sources.length);
assert.equal(calls, 3);
assert.deepEqual(json(await request('/status')).transactions, {
used: 3,
limit: 5000,