mirror of
https://github.com/4gray/iptvnator.git
synced 2026-10-10 10:06:15 -08:00
test(perf): count every layout shift next to the capped list
Review follow-up (Greptile): the score counts every shift but the evidence lists only the first 20, so a reader could not tell that later shifts were omitted. The probe now keeps shiftCount, and J2 writes it beside evidence.layoutShift.shifts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
f6af34af5f
commit
4da77f8530
7 files changed
+14
-1
No files matched your search
@@ -848,6 +848,7 @@ test('drops performance entries from before the click and keeps recent-input shi
|
||||
[false, 0.125, []],
|
||||
]
|
||||
);
|
||||
assert.equal(state.shiftCount, 2);
|
||||
assert.ok(state.shifts.every((shift) => shift.sinceStartMs >= 0));
|
||||
assert.match(state.shifts[0]?.sources[0]?.node ?? '', /^[a-z-]+/);
|
||||
// J2 has no settle window: the observers close at the cutoff.
|
||||
@@ -896,6 +897,7 @@ test('rejects a click start whose sentinel could not be sent', async () => {
|
||||
const started = {
|
||||
...state,
|
||||
sentinel: { epochMs: 1, status: 'sent' as const },
|
||||
shiftCount: 0,
|
||||
shifts: [],
|
||||
};
|
||||
assert.throws(
|
||||
|
||||
@@ -249,6 +249,8 @@ export interface JourneyRendererProbeState {
|
||||
readonly epochMs: number | null;
|
||||
readonly status: 'bridge-missing' | 'failed' | 'not-sent' | 'sent';
|
||||
};
|
||||
/** Every shift counted until the cutoff; `shifts` keeps the first 20. */
|
||||
shiftCount: number;
|
||||
/**
|
||||
* The first 20 shifts counted until the cutoff, with the nodes that
|
||||
* moved, so a layout-shift score can be traced to its components.
|
||||
@@ -346,6 +348,7 @@ export function journeyRendererProbeScript(
|
||||
preStart: { domMutations: 0, lastMutationEpochMs: null },
|
||||
schemaVersion: 1,
|
||||
sentinel: { epochMs: null, status: 'not-sent' },
|
||||
shiftCount: 0,
|
||||
shifts: [],
|
||||
settle: {
|
||||
domMutations: 0,
|
||||
@@ -416,6 +419,7 @@ export function journeyRendererProbeScript(
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
state.shiftCount += 1;
|
||||
if (state.shifts.length < 20) {
|
||||
state.shifts.push({
|
||||
hadRecentInput: shift.hadRecentInput === true,
|
||||
|
||||
@@ -54,6 +54,7 @@ function measurement(
|
||||
preStart: { domMutations: 0, lastMutationEpochMs: null },
|
||||
schemaVersion: 1,
|
||||
sentinel: { epochMs: 2_601, status: 'sent' },
|
||||
shiftCount: 0,
|
||||
shifts: [],
|
||||
settle: {
|
||||
domMutations: 37,
|
||||
|
||||
@@ -59,6 +59,7 @@ function measurement(
|
||||
preStart: { domMutations: 4, lastMutationEpochMs: 9_100 },
|
||||
schemaVersion: 1,
|
||||
sentinel: { epochMs: 10_080.5, status: 'sent' },
|
||||
shiftCount: 23,
|
||||
shifts: [
|
||||
{
|
||||
hadRecentInput: true,
|
||||
@@ -163,6 +164,8 @@ test('maps the click-started probe, IPC window and mock ledger to exact counters
|
||||
});
|
||||
assert.deepEqual(record.evidence['layoutShift'], {
|
||||
recentInput: 0.221,
|
||||
// More shifts were counted than listed.
|
||||
shiftCount: 23,
|
||||
shifts: [
|
||||
{
|
||||
hadRecentInput: true,
|
||||
|
||||
@@ -184,6 +184,8 @@ export function toOpenSourceIterationRecord(
|
||||
recentInput: roundThousandth(
|
||||
renderer.counters.recentInputLayoutShiftScore
|
||||
),
|
||||
// Every counted shift; `shifts` lists the first 20.
|
||||
shiftCount: renderer.shiftCount,
|
||||
// The first 20 counted shifts and the nodes that moved.
|
||||
shifts: renderer.shifts.map((shift) =>
|
||||
Object.freeze({
|
||||
|
||||
@@ -74,6 +74,7 @@ function measurement(
|
||||
preStart: { domMutations: 53, lastMutationEpochMs: 8_900 },
|
||||
schemaVersion: 1,
|
||||
sentinel: { epochMs: 10_350, status: 'sent' },
|
||||
shiftCount: 0,
|
||||
shifts: [],
|
||||
settle: {
|
||||
domMutations: 0,
|
||||
|
||||
@@ -719,7 +719,7 @@ strings and stream paths carry credentials and are never stored.
|
||||
| `renderer.ipcCallsToFirstPage` | Bridge `start` trace events between the start and end sentinels, counted by a second `journey-main-ipc-capture.ts` instance installed with `startSentinelId`. Calls before the start marker are tallied separately (`callsBeforeStart`); a start marker that is missing, repeated or received after the end sentinel fails the iteration. |
|
||||
| `renderer.domMutationsToFirstPage` | `MutationRecord`s from the click until the terminal batch. Records produced before the click (hover, settling) are taken from the observer at the start and counted under `evidence.settle` instead. |
|
||||
| `renderer.cdTicksToFirstPage` | `ApplicationRef` ticks from the click until the terminal batch: the counter's running total read in the capture-phase click listener, before the app handles the click, subtracted from its value at the terminal batch (see [Change-detection ticks](#change-detection-ticks)). |
|
||||
| `renderer.layoutShiftScore` | Sum of all `layout-shift` entries from the click until the post-paint cutoff, rounded to three decimals. Unlike J1 it includes entries with `hadRecentInput === true`: the journey is a response to the click and runs inside the 500 ms input window, so the CLS filter would always read 0. The split is under `evidence.layoutShift`, and `evidence.layoutShift.shifts` lists the first 20 counted shifts with their value, `hadRecentInput`, time since the click and the nodes that moved (`tag.class[data-test-id]` and their `deltaX`, `deltaY`, `deltaWidth` and `deltaHeight`, as J1's late shifts). |
|
||||
| `renderer.layoutShiftScore` | Sum of all `layout-shift` entries from the click until the post-paint cutoff, rounded to three decimals. Unlike J1 it includes entries with `hadRecentInput === true`: the journey is a response to the click and runs inside the 500 ms input window, so the CLS filter would always read 0. The split is under `evidence.layoutShift`, and `evidence.layoutShift.shifts` lists the first 20 counted shifts (`shiftCount` is the total) with their value, `hadRecentInput`, time since the click and the nodes that moved (`tag.class[data-test-id]` and their `deltaX`, `deltaY`, `deltaWidth` and `deltaHeight`, as J1's late shifts). |
|
||||
| `renderer.longTasks` | `longtask` entries over 50 ms whose time range overlaps the window from the click to the cutoff. The task that dispatches the click began before the event's timestamp and still counts; buffered J1 tasks that ended before the click are dropped. Evidence until it is shown to be stable on the CI runner, as for J1. |
|
||||
| `main.mockHttpRequestsToSettled` | Requests the proxy received from the click until, after the terminal batch, no new request had arrived for 1 s and none was in flight (a response slower than that, and what it triggers, stays inside the window). The window ends at the ledger position read by that accepted quiet sample; a request arriving after it was never seen in flight, so it goes to `evidence.httpRequestsAfterSettledByRoute` instead of the counter. The ledger is read 1 s after that sample, so that late traffic is actually observed. The window starts at the renderer's click stamp, the same boundary as every other J2 counter, not when Playwright began its actionability checks; the proxy stamps requests with the test process's wall clock, and both processes read the same host clock. Bounding by the terminal would compare the test process's clock with the renderer's, so the count up to the terminal epoch is evidence only (`evidence.httpRequestsToFirstPage`); `evidence.httpRequestsByRoute` names the requests. |
|
||||
|
||||
|
||||
Reference in new issue
Block a user