Skip to content

Commit

Permalink
More arbitrary c8 ignores
Browse files Browse the repository at this point in the history
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:
#4234

And the (hopefully correct) upstream issue:
istanbuljs/v8-to-istanbul#236
  • Loading branch information
Vinnl committed Mar 6, 2024
1 parent e3a2d6f commit e57bfd6
Show file tree
Hide file tree
Showing 11 changed files with 47 additions and 13 deletions.
Expand Up @@ -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"
Expand Down
Expand Up @@ -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 }) => (
<div key={id} className={styles.breachItem}>
Expand Down
3 changes: 3 additions & 0 deletions src/app/components/client/Button.tsx
Expand Up @@ -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" ? (
Expand Down
24 changes: 15 additions & 9 deletions src/app/components/client/FixNavigation.tsx
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand All @@ -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 <Image src={src} alt="" width={22} height={22} />;
};

/* 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") {
Expand Down
4 changes: 2 additions & 2 deletions src/app/components/client/ScanResultCard.tsx
Expand Up @@ -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",
Expand All @@ -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",
{
Expand Down
3 changes: 3 additions & 0 deletions src/app/components/client/UpsellBadge.tsx
Expand Up @@ -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 <></>;
}
Expand Down
3 changes: 3 additions & 0 deletions src/app/components/client/toolbar/UserMenu.tsx
Expand Up @@ -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:
Expand Down
3 changes: 3 additions & 0 deletions src/app/functions/server/dashboard.ts
Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions src/app/functions/server/getRelevantGuidedSteps.ts
Expand Up @@ -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");
}
Expand Down
3 changes: 3 additions & 0 deletions src/app/functions/universal/guidedExperienceBreaches.ts
Expand Up @@ -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);
}
Expand Down
9 changes: 8 additions & 1 deletion src/app/hooks/useLocalDismissal.ts
Expand Up @@ -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);
}
Expand Down

0 comments on commit e57bfd6

Please sign in to comment.