Skip to content

Commit

Permalink
Add arbitrary c8 ignores
Browse files Browse the repository at this point in the history
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:
istanbuljs/v8-to-istanbul#236
  • Loading branch information
Vinnl committed Feb 21, 2024
1 parent f1d51a3 commit 2886eb2
Show file tree
Hide file tree
Showing 10 changed files with 88 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -42,6 +45,7 @@ export function filterExposures(
) {
return false;
}
/* c8 ignore stop */

return true;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,13 @@ export const FixView = (props: FixViewProps) => {
{props.showConfetti && <Confetti />}
<div
className={`${styles.fixWrapper} ${
isResolutionLayout ? styles.highRiskDataBreachContentBg : ""
isResolutionLayout
? styles.highRiskDataBreachContentBg
: /* 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.hideProgressIndicator && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
23 changes: 20 additions & 3 deletions src/app/components/client/ComboBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand All @@ -44,14 +47,28 @@ function ComboBox(props: ComboBoxProps) {
<div className={styles.comboBox}>
<label {...labelProps} className={styles.inputLabel}>
{label}
{isRequired ? <span aria-hidden="true">*</span> : ""}
{isRequired ? (
<span aria-hidden="true">*</span>
) : (
/* c8 ignore next 4 */
// 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:
""
)}
</label>
<input
{...inputProps}
ref={inputRef}
className={`${styles.inputField} ${
!inputProps.value ? styles.noValue : ""
} ${isInvalid ? styles.hasError : ""}`}
!inputProps.value
? /* c8 ignore next 4 */
// 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:
styles.noValue
: ""
} ${isInvalid ? /* c8 ignore next */ styles.hasError : ""}`}
/>
{isInvalid && typeof errorMessage === "string" && (
<div {...errorMessageProps} className={styles.inputMessage}>
Expand Down
3 changes: 3 additions & 0 deletions src/app/components/client/ExposuresFilter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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",
});
Expand Down
36 changes: 34 additions & 2 deletions src/app/components/client/FixNavigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ export const Steps = (props: {
{isEligibleForStep(props.data, "Scan") && (
<li
aria-current={
/* c8 ignore next 7 */
// 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.currentSection === "data-broker-profiles" ? "step" : undefined
}
className={`${styles.navigationItem} ${
Expand All @@ -117,6 +121,10 @@ export const Steps = (props: {
)}
<li
aria-current={
/* c8 ignore next 11 */
// 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.currentSection === "high-risk-data-breach" ? "step" : undefined
}
className={`${styles.navigationItem} ${
Expand All @@ -137,6 +145,10 @@ export const Steps = (props: {
</li>
<li
aria-current={
/* c8 ignore next 11 */
// 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.currentSection === "leaked-passwords" ? "step" : undefined
}
className={`${styles.navigationItem} ${
Expand All @@ -157,18 +169,30 @@ export const Steps = (props: {
</li>
<li
aria-current={
/* c8 ignore next 5 */
// This line 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.currentSection === "security-recommendations"
? "step"
: undefined
}
className={`${styles.navigationItem} ${
/* c8 ignore next 5 */
// This line 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.currentSection === "security-recommendations"
? styles.active
: ""
} ${
hasCompletedStepSection(props.data, "SecurityTips")
? styles.isCompleted
: ""
: /* c8 ignore next 4 */
// This line should be covered by unit tests, but since the Node 20.10
// upgrade, it's been intermittently marking this (and this comment)
// as uncovered.
""
}`}
>
<div className={styles.stepIcon}>
Expand Down Expand Up @@ -211,7 +235,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;

Expand All @@ -221,6 +249,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") {
Expand Down
3 changes: 2 additions & 1 deletion src/app/components/client/dialog/Dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ export const Dialog = ({
height="14"
/>
</button>
) : null;
) : /* c8 ignore next */
null;

return (
<div
Expand Down
3 changes: 3 additions & 0 deletions src/app/functions/server/dashboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,9 @@ function sanitizeDataPoints(
}

export function getDataPointReduction(summary: DashboardSummary): number {
// The `if` statement is totally 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 */
if (summary.totalDataPointsNum <= 0) return 100;
return Math.round(
(summary.dataBrokerTotalDataPointsNum / summary.totalDataPointsNum) * 100,
Expand Down
3 changes: 3 additions & 0 deletions src/app/functions/server/getRelevantGuidedSteps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,9 @@ export function hasCompletedStepSection(
return hasCompletedStep(data, "Scan");
}
if (section === "HighRisk") {
/* c8 ignore next 7 */
// 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:
return (
hasCompletedStep(data, "HighRiskSsn") &&
hasCompletedStep(data, "HighRiskCreditCard") &&
Expand Down
9 changes: 9 additions & 0 deletions src/app/functions/universal/guidedExperienceBreaches.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,23 @@ export function getGuidedExperienceBreaches(
guidedExperienceBreaches.highRisk.ssnBreaches.push(breach);
}

// 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.CreditCard)) {
guidedExperienceBreaches.highRisk.creditCardBreaches.push(breach);
}

// 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.PIN)) {
guidedExperienceBreaches.highRisk.pinBreaches.push(breach);
}

// 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.BankAccount)) {
guidedExperienceBreaches.highRisk.bankBreaches.push(breach);
}
Expand Down

0 comments on commit 2886eb2

Please sign in to comment.