Files
iptvnator/apps/electron-backend-e2e/src/performance/xtream-worker-request-inventory.spec.ts
T
4gray a2fafcfc08 test(performance): add end-to-end Xtream benchmark harness (#1300)
* docs(performance): plan Xtream benchmark

* feat(xtream-mock-server): add deterministic 100k fixture

* style(xtream-mock-server): apply repository formatting

* fix(xtream-mock-server): harden performance fixture data

* feat(xtream-mock-server): add performance control plane

* docs(performance): correct Xtream capture plan

* fix(xtream-mock-server): harden performance controls

* fix(xtream-mock-server): harden control lifecycle

* feat(performance): add Xtream preload markers

* feat(performance): trace Xtream main phases

* feat(performance): mark Xtream store publications

* feat(performance): trace Xtream database phases

* feat(performance): trace Xtream delete cancellation

* feat(performance): capture Xtream phase attribution

* feat(performance): mark Sources Xtream refresh

* test(performance): define Xtream benchmark evidence contracts

* test(performance): add Xtream benchmark runner

* test(performance): surface failure evidence writes

* test(performance): align database read clock

* test(performance): preserve capture failure contracts
2026-07-28 08:08:07 +02:00

85 lines
3.2 KiB
TypeScript

import assert from 'node:assert/strict';
import { describe, it } from 'node:test';
import {
expectedXtreamWorkerRequestInventory,
XTREAM_SCENARIO_ID,
} from './xtream-benchmark-contract';
describe('Xtream database-worker request inventory', () => {
it('defines the exact operation, outcome, and phase multiset for every scenario', () => {
const expectedTotals = new Map([
[XTREAM_SCENARIO_ID.INITIAL_IMPORT_LARGE, 30],
[XTREAM_SCENARIO_ID.REFRESH_LARGE, 51],
[XTREAM_SCENARIO_ID.DELETE_LARGE, 2],
[XTREAM_SCENARIO_ID.CANCEL_IMPORT, 24],
[XTREAM_SCENARIO_ID.BACKGROUND_UI, 54],
]);
for (const scenarioId of Object.values(XTREAM_SCENARIO_ID)) {
const inventory = expectedXtreamWorkerRequestInventory(scenarioId);
assert.equal(
inventory.reduce((total, entry) => total + entry.count, 0),
expectedTotals.get(scenarioId)
);
assert.ok(
inventory.every(
({ count, operation, success, phases }) =>
Number.isSafeInteger(count) &&
count > 0 &&
operation.startsWith('DB_') &&
typeof success === 'boolean' &&
phases.every((phase) => phase.length > 0)
)
);
}
});
it('includes the route hydration requests observed after refresh commit', () => {
for (const scenarioId of [
XTREAM_SCENARIO_ID.REFRESH_LARGE,
XTREAM_SCENARIO_ID.BACKGROUND_UI,
]) {
const counts = new Map(
expectedXtreamWorkerRequestInventory(scenarioId).map(
({ count, operation }) => [operation, count]
)
);
assert.equal(counts.get('DB_GET_PLAYLIST'), 2);
assert.equal(counts.get('DB_GET_APP_STATE'), 12);
assert.equal(counts.get('DB_GET_CATEGORIES'), 9);
assert.equal(counts.get('DB_GET_CONTENT'), 9);
assert.equal(counts.get('DB_SET_APP_STATE'), 6);
}
});
it('attributes portal-route hydration without accepting dashboard work', () => {
for (const scenarioId of [
XTREAM_SCENARIO_ID.INITIAL_IMPORT_LARGE,
XTREAM_SCENARIO_ID.REFRESH_LARGE,
XTREAM_SCENARIO_ID.CANCEL_IMPORT,
XTREAM_SCENARIO_ID.BACKGROUND_UI,
]) {
const operations = expectedXtreamWorkerRequestInventory(
scenarioId
).map(({ operation }) => operation);
assert.ok(operations.includes('DB_GET_PLAYLIST'));
}
for (const scenarioId of [
XTREAM_SCENARIO_ID.INITIAL_IMPORT_LARGE,
XTREAM_SCENARIO_ID.CANCEL_IMPORT,
]) {
const operations = expectedXtreamWorkerRequestInventory(
scenarioId
).map(({ operation }) => operation);
assert.ok(operations.includes('DB_GET_ALL_PLAYBACK_POSITIONS'));
assert.equal(
operations.includes('DB_GET_GLOBAL_RECENTLY_ADDED'),
false
);
}
});
});