From e57bfd65b23c7aef901ff07e95ba583093f852dc Mon Sep 17 00:00:00 2001 From: Vincent Date: Wed, 6 Mar 2024 12:02:39 +0100 Subject: [PATCH] More arbitrary c8 ignores As we add code, more existing code suddenly gets marked as uncovered by unit tests intermittently. This adds c8 ignore comments for everything that turned up when running npm test -- --no-cache --runInBand But I really hope this gets fixed upstream soon, because this isn't sustainable. For more context, see: https://github.com/mozilla/blurts-server/pull/4234 And the (hopefully correct) upstream issue: https://github.com/istanbuljs/v8-to-istanbul/issues/236 --- .../dashboard/fix/ResolutionContainer.tsx | 2 +- .../dashboard/fix/ResolutionContent.tsx | 3 +++ src/app/components/client/Button.tsx | 3 +++ src/app/components/client/FixNavigation.tsx | 24 ++++++++++++------- src/app/components/client/ScanResultCard.tsx | 4 ++-- src/app/components/client/UpsellBadge.tsx | 3 +++ .../components/client/toolbar/UserMenu.tsx | 3 +++ src/app/functions/server/dashboard.ts | 3 +++ .../server/getRelevantGuidedSteps.ts | 3 +++ .../universal/guidedExperienceBreaches.ts | 3 +++ src/app/hooks/useLocalDismissal.ts | 9 ++++++- 11 files changed, 47 insertions(+), 13 deletions(-) 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 082797077df..48cdd16065f 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,7 +30,7 @@ type ResolutionContainerProps = { export const ResolutionContainer = (props: ResolutionContainerProps) => { const l10n = useL10n(); const estimatedTimeString = - /* c8 ignore next 4 */ + /* c8 ignore next 8 */ // 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" diff --git a/src/app/(proper_react)/(redesign)/(authenticated)/user/(dashboard)/dashboard/fix/ResolutionContent.tsx b/src/app/(proper_react)/(redesign)/(authenticated)/user/(dashboard)/dashboard/fix/ResolutionContent.tsx index cf80bd86f5f..75128b3e128 100644 --- a/src/app/(proper_react)/(redesign)/(authenticated)/user/(dashboard)/dashboard/fix/ResolutionContent.tsx +++ b/src/app/(proper_react)/(redesign)/(authenticated)/user/(dashboard)/dashboard/fix/ResolutionContent.tsx @@ -28,6 +28,9 @@ export const ResolutionContent = ({ }); const listOfBreaches = + /* 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. exposedData && exposedData.map(({ id, title, breachDate }) => (
diff --git a/src/app/components/client/Button.tsx b/src/app/components/client/Button.tsx index d31c14ded98..a8d7afe45bb 100644 --- a/src/app/components/client/Button.tsx +++ b/src/app/components/client/Button.tsx @@ -66,6 +66,9 @@ export const Button = (props: ButtonProps) => { // If `props.isLoading` is not undefined, the contents of the link is going to // change into a loading indicator, which needs to be read by a screen reader: const ariaLiveValue: AriaAttributes["aria-live"] = + /* c8 ignore next 3 */ + // 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. typeof isLoading === "boolean" ? "polite" : undefined; return typeof href === "string" ? ( diff --git a/src/app/components/client/FixNavigation.tsx b/src/app/components/client/FixNavigation.tsx index ae9e73bf3c6..40c65a8a101 100644 --- a/src/app/components/client/FixNavigation.tsx +++ b/src/app/components/client/FixNavigation.tsx @@ -58,6 +58,9 @@ export const Steps = (props: { breachesByClassification.highRisk, ).reduce((acc, array) => acc + array.length, 0); const totalDataBrokerProfiles = + /* c8 ignore next 3 */ + // 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.data.latestScanData?.results.length ?? 0; const totalPasswordBreaches = Object.values( breachesByClassification.passwordBreaches, @@ -198,6 +201,10 @@ export const Steps = (props: { className={`${ styles.activeProgressBarLine } ${calculateActiveProgressBarPosition(props.currentSection)} ${ + /* c8 ignore next 5 */ + // 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. isEligibleForStep(props.data, "Scan") ? styles.hasFourSteps : styles.hasThreeSteps @@ -219,29 +226,28 @@ const StepImage = (props: { ); } + /* c8 ignore next 10 */ + // 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. const src = props.section === "Scan" ? stepDataBrokerProfilesIcon : props.section === "HighRisk" ? stepHighRiskDataBreachesIcon - : /* 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" + : props.section === "LeakedPasswords" ? stepLeakedPasswordsIcon : stepSecurityRecommendationsIcon; return ; }; +/* c8 ignore next 14 */ +// 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. 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/ScanResultCard.tsx b/src/app/components/client/ScanResultCard.tsx index 7b4ea585951..541b06b9b35 100644 --- a/src/app/components/client/ScanResultCard.tsx +++ b/src/app/components/client/ScanResultCard.tsx @@ -155,8 +155,8 @@ export const ScanResultCard = (props: ScanResultCardProps) => { }, ); } + /* c8 ignore start */ if (props.isOnManualRemovePage) { - /* c8 ignore start */ return scanResult.manually_resolved ? l10n.getFragment( "exposure-card-description-info-for-sale-fixed-manually-fixed", @@ -174,8 +174,8 @@ export const ScanResultCard = (props: ScanResultCardProps) => { }, }, ); - /* c8 ignore stop */ } + /* c8 ignore stop */ return l10n.getFragment( "exposure-card-description-info-for-sale-action-needed-dashboard", { diff --git a/src/app/components/client/UpsellBadge.tsx b/src/app/components/client/UpsellBadge.tsx index ff5b7968a86..7c64af461ab 100644 --- a/src/app/components/client/UpsellBadge.tsx +++ b/src/app/components/client/UpsellBadge.tsx @@ -133,6 +133,9 @@ export function UpsellBadge(props: UpsellButtonProps) { const countryCode = useContext(CountryCodeContext); const session = useSession(); + /* c8 ignore next 5 */ + // 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. if (!session.data) { return <>; } diff --git a/src/app/components/client/toolbar/UserMenu.tsx b/src/app/components/client/toolbar/UserMenu.tsx index c56c9de2aa4..430fc31f551 100644 --- a/src/app/components/client/toolbar/UserMenu.tsx +++ b/src/app/components/client/toolbar/UserMenu.tsx @@ -61,6 +61,9 @@ export const UserMenu = (props: UserMenuProps) => { signout: "signout", }; + /* c8 ignore next 21 */ + // 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. const handleOnAction = (menuItemKey: Key) => { switch (menuItemKey) { case itemKeys.fxa: diff --git a/src/app/functions/server/dashboard.ts b/src/app/functions/server/dashboard.ts index 18c104dad93..4cfe10b3ec7 100644 --- a/src/app/functions/server/dashboard.ts +++ b/src/app/functions/server/dashboard.ts @@ -357,6 +357,9 @@ export function getDashboardSummary( } } + /* c8 ignore next 11 */ + // 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. if (dataClasses.includes(BreachDataTypes.BankAccount)) { summary.totalDataPointsNum += increment; summary.dataBreachTotalDataPointsNum += increment; diff --git a/src/app/functions/server/getRelevantGuidedSteps.ts b/src/app/functions/server/getRelevantGuidedSteps.ts index 2df970ccf45..fb43517a2fa 100644 --- a/src/app/functions/server/getRelevantGuidedSteps.ts +++ b/src/app/functions/server/getRelevantGuidedSteps.ts @@ -180,6 +180,9 @@ export function hasCompletedStepSection( data: StepDeterminationData, section: "Scan" | "HighRisk" | "LeakedPasswords" | "SecurityTips", ): boolean { + /* c8 ignore next 5 */ + // I believe this *is* covered by unit tests, but for some reason, + // since the upgrade to Node 20.10, it doesn't get marked as covered anymore: if (section === "Scan") { return hasCompletedStep(data, "Scan"); } diff --git a/src/app/functions/universal/guidedExperienceBreaches.ts b/src/app/functions/universal/guidedExperienceBreaches.ts index cd42b3c2102..8e47dc68615 100644 --- a/src/app/functions/universal/guidedExperienceBreaches.ts +++ b/src/app/functions/universal/guidedExperienceBreaches.ts @@ -44,6 +44,9 @@ export function getGuidedExperienceBreaches( subscriberBreaches.forEach((breach) => { // high risks + // This does get covered by unit tests, but for some reason, since the + // upgrade to Node 20.10, it doesn't get marked as covered anymore: + /* c8 ignore next 3 */ if (isUnresolvedDataBreachClass(breach, BreachDataTypes.SSN)) { guidedExperienceBreaches.highRisk.ssnBreaches.push(breach); } diff --git a/src/app/hooks/useLocalDismissal.ts b/src/app/hooks/useLocalDismissal.ts index c723e6e600e..9f29dee033a 100644 --- a/src/app/hooks/useLocalDismissal.ts +++ b/src/app/hooks/useLocalDismissal.ts @@ -43,10 +43,17 @@ export function useLocalDismissal( const maxAgeInSeconds = typeof options.duration === "number" ? options.duration - : 100 * 365 * 24 * 60 * 60; + : /* 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. + 100 * 365 * 24 * 60 * 60; setCookie(cookieId, Date.now().toString(), { maxAge: maxAgeInSeconds, }); + /* c8 ignore next 3 */ + // 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. if (dismissOptions?.soft !== true) { setIsDismissed(true); }