fix(browser): report mismatched event family selection as unknown in capture comparison (#2239)

* fix(browser): report mismatched event family selection as unknown in capture comparison

* fix(browser): retain selected event families and unknown coverage

Fold the complementary implementation from #2253 into the earlier #2239 proposal, retaining the original contribution history.

Co-authored-by: itsF4LCON <107556180+itsF4LCON@users.noreply.github.com>

---------

Co-authored-by: LouisChen <3361008+chqcjq@users.noreply.github.com>
Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
Co-authored-by: itsF4LCON <107556180+itsF4LCON@users.noreply.github.com>
This commit is contained in:
LouisChen
2026-10-13 02:36:45 +08:00
committed by GitHub
co-authored by LouisChen morluto itsF4LCON
parent aeee5074d1
commit 0043d9b134
13 changed files with 206 additions and 15 deletions
+20
View File
@@ -130,6 +130,26 @@ export const networkContentCoverageReason = (
: undefined;
};
/** Different or unrecorded event-family selection is missing comparability, not an observed website change. */
export const eventFamilyCoverageReason = (
before: BrowserScenarioCapture,
after: BrowserScenarioCapture,
): string | undefined => {
const left = before.scenario.event_families;
const right = after.scenario.event_families;
if (left === undefined || right === undefined)
return "Event family selection is unknown in a legacy capture; capture both sides with matching event families before comparing event evidence.";
const leftFamilies = new Set(left);
const rightFamilies = new Set(right);
return leftFamilies.size === rightFamilies.size &&
[...leftFamilies].every((family) => rightFamilies.has(family))
? undefined
: `Event family selections differ (${familyList(leftFamilies)} before, ${familyList(rightFamilies)} after); capture both sides with matching event families before comparing event evidence.`;
};
const familyList = (families: ReadonlySet<string>): string =>
families.size === 0 ? "none" : [...families].sort().join(", ");
/** Wrap one value as captured comparison evidence. */
export const captured = <Value>(value: Value): CaptureState<Value> => ({
state: "captured",