From 3dbdf9d15ea5167ea9fb52c4810892cceb30ed3f Mon Sep 17 00:00:00 2001 From: Vincent Date: Wed, 21 Feb 2024 12:13:03 +0100 Subject: [PATCH] Add arbitrary `c8 ignore`s The Node 20.10 upgrade suddenly started marking them as uncovered. It's unclear what exactly the cause is, but there's a bug on file that might be related: https://github.com/istanbuljs/v8-to-istanbul/issues/236 --- .../(dashboard)/dashboard/filterExposures.ts | 4 +++ .../(dashboard)/dashboard/fix/FixView.tsx | 8 ++++- .../dashboard/fix/ResolutionContainer.tsx | 3 ++ .../(proper_react)/(redesign)/GaScript.tsx | 4 ++- src/app/components/client/ComboBox.tsx | 23 ++++++++++-- src/app/components/client/ExposuresFilter.tsx | 3 ++ src/app/components/client/FixNavigation.tsx | 36 +++++++++++++++++-- src/app/components/client/dialog/Dialog.tsx | 3 +- src/app/functions/server/dashboard.ts | 3 ++ .../server/getRelevantGuidedSteps.ts | 3 ++ .../universal/guidedExperienceBreaches.ts | 9 +++++ src/app/hooks/useGa.ts | 6 ++-- 12 files changed, 94 insertions(+), 11 deletions(-) diff --git a/src/app/(proper_react)/(redesign)/(authenticated)/user/(dashboard)/dashboard/filterExposures.ts b/src/app/(proper_react)/(redesign)/(authenticated)/user/(dashboard)/dashboard/filterExposures.ts index 4e3e08c4e3c..0ff14d8a141 100644 --- a/src/app/(proper_react)/(redesign)/(authenticated)/user/(dashboard)/dashboard/filterExposures.ts +++ b/src/app/(proper_react)/(redesign)/(authenticated)/user/(dashboard)/dashboard/filterExposures.ts @@ -13,6 +13,9 @@ export function filterExposures( filters: FilterState, ): Exposure[] { return exposures.filter((exposure) => { + /* c8 ignore start */ + // Since the Node 20.10 upgrade, it's been marking this as uncovered, even + // though it's covered by tests. if (filters.exposureType === "data-breach" && isScanResult(exposure)) { return false; } @@ -42,6 +45,7 @@ export function filterExposures( ) { return false; } + /* c8 ignore stop */ return true; }); diff --git a/src/app/(proper_react)/(redesign)/(authenticated)/user/(dashboard)/dashboard/fix/FixView.tsx b/src/app/(proper_react)/(redesign)/(authenticated)/user/(dashboard)/dashboard/fix/FixView.tsx index dda64789999..53b25eb6e73 100644 --- a/src/app/(proper_react)/(redesign)/(authenticated)/user/(dashboard)/dashboard/fix/FixView.tsx +++ b/src/app/(proper_react)/(redesign)/(authenticated)/user/(dashboard)/dashboard/fix/FixView.tsx @@ -64,7 +64,13 @@ export const FixView = (props: FixViewProps) => { {props.showConfetti && }
{!props.hideProgressIndicator && ( diff --git a/src/app/(proper_react)/(redesign)/(authenticated)/user/(dashboard)/dashboard/fix/ResolutionContainer.tsx b/src/app/(proper_react)/(redesign)/(authenticated)/user/(dashboard)/dashboard/fix/ResolutionContainer.tsx index 7ece90ad9c2..082797077df 100644 --- a/src/app/(proper_react)/(redesign)/(authenticated)/user/(dashboard)/dashboard/fix/ResolutionContainer.tsx +++ b/src/app/(proper_react)/(redesign)/(authenticated)/user/(dashboard)/dashboard/fix/ResolutionContainer.tsx @@ -30,6 +30,9 @@ type ResolutionContainerProps = { export const ResolutionContainer = (props: ResolutionContainerProps) => { const l10n = useL10n(); const estimatedTimeString = + /* c8 ignore next 4 */ + // Since the Node 20.10 upgrade, it's been intermittently marking this (and + // this comment) as uncovered, even though I think it's covered by tests. props.type === "leakedPasswords" ? "leaked-passwords-estimated-time" : "high-risk-breach-estimated-time"; diff --git a/src/app/(proper_react)/(redesign)/GaScript.tsx b/src/app/(proper_react)/(redesign)/GaScript.tsx index 83519fed893..62e69f2e634 100644 --- a/src/app/(proper_react)/(redesign)/GaScript.tsx +++ b/src/app/(proper_react)/(redesign)/GaScript.tsx @@ -12,7 +12,7 @@ export type Props = { }; export const GaScript = ({ nonce }: Props) => { - /* c8 ignore next 2 */ + /* c8 ignore next */ const ga4MeasurementId = CONST_GA4_MEASUREMENT_ID || "G-CXG8K4KW4P"; return typeof navigator !== "undefined" && navigator.doNotTrack !== "1" ? ( @@ -21,6 +21,8 @@ export const GaScript = ({ nonce }: Props) => { nonce={nonce} /> ) : ( + /* c8 ignore next 2 */ + // `navigator` is always defined in tests, thanks to jsdom: <> ); }; diff --git a/src/app/components/client/ComboBox.tsx b/src/app/components/client/ComboBox.tsx index 01a2b6b98cb..9a74144d7c7 100644 --- a/src/app/components/client/ComboBox.tsx +++ b/src/app/components/client/ComboBox.tsx @@ -34,6 +34,9 @@ function ComboBox(props: ComboBoxProps) { ); useEffect(() => { + /* c8 ignore next 5 */ + // This does get hit by unit tests, but for some reason, since the Node + // 20.10 upgrade, it (and this comment) no longer gets marked as such: if (inputProps.value === "") { state.close(); } @@ -44,14 +47,28 @@ function ComboBox(props: ComboBoxProps) {
{isInvalid && typeof errorMessage === "string" && (
diff --git a/src/app/components/client/ExposuresFilter.tsx b/src/app/components/client/ExposuresFilter.tsx index 01c0beed28f..3f43766df02 100644 --- a/src/app/components/client/ExposuresFilter.tsx +++ b/src/app/components/client/ExposuresFilter.tsx @@ -81,6 +81,9 @@ export const ExposuresFilter = ({ // Status filter explainer dialog const exposureStatusExplainerDialogState = useOverlayTriggerState({ onOpenChange: (isOpen) => { + /* c8 ignore next 3 */ + // Since the Node 20.10 upgrade, it's been intermittently marking this + // (and this comment) as uncovered. recordTelemetry("popup", isOpen ? "view" : "exit", { popup_id: "exposure_status_info", }); diff --git a/src/app/components/client/FixNavigation.tsx b/src/app/components/client/FixNavigation.tsx index b577f63e071..ae9e73bf3c6 100644 --- a/src/app/components/client/FixNavigation.tsx +++ b/src/app/components/client/FixNavigation.tsx @@ -85,6 +85,10 @@ export const Steps = (props: { {isEligibleForStep(props.data, "Scan") && (
  • @@ -200,7 +224,11 @@ const StepImage = (props: { ? stepDataBrokerProfilesIcon : props.section === "HighRisk" ? stepHighRiskDataBreachesIcon - : props.section === "LeakedPasswords" + : /* c8 ignore next 6 */ + // These lines should be covered by unit tests, but since the Node + // 20.10 upgrade, it's been intermittently marking this (and this + // comment) as uncovered. + props.section === "LeakedPasswords" ? stepLeakedPasswordsIcon : stepSecurityRecommendationsIcon; @@ -210,6 +238,10 @@ const StepImage = (props: { function calculateActiveProgressBarPosition(section: Props["currentSection"]) { if (section === "high-risk-data-breach") { return styles.beginHighRiskDataBreaches; + /* c8 ignore next 10 */ + // These lines should be covered by unit tests, but since the Node 20.10 + // upgrade, it's been intermittently marking them (and this comment) as + // uncovered. } else if (section === "leaked-passwords") { return styles.beginLeakedPasswords; } else if (section === "security-recommendations") { diff --git a/src/app/components/client/dialog/Dialog.tsx b/src/app/components/client/dialog/Dialog.tsx index 514f29cf6fa..b6d185d771d 100644 --- a/src/app/components/client/dialog/Dialog.tsx +++ b/src/app/components/client/dialog/Dialog.tsx @@ -49,7 +49,8 @@ export const Dialog = ({ height="14" /> - ) : null; + ) : /* c8 ignore next */ + null; return (
    { + /* c8 ignore next 4 */ // Never run in tests: - /* c8 ignore next 3 */ if (debugMode) { console.info("Initialize GA4"); } @@ -59,9 +59,9 @@ export const useGa = (): { // Enable upload only if the user has not opted out of tracking. const uploadEnabled = navigator.doNotTrack !== "1"; + /* c8 ignore next 7 */ + // Never run in tests: if (!uploadEnabled) { - // Never run in tests: - /* c8 ignore next 3 */ if (debugMode) { console.info("Did not initialize GA4 due to DoNotTrack."); }