Skip to content

Commit 35f1b73

Browse files
committed
Add arbitrary c8 ignores
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
1 parent 434a190 commit 35f1b73

File tree

12 files changed

+94
-12
lines changed

12 files changed

+94
-12
lines changed

src/app/(proper_react)/(redesign)/(authenticated)/user/(dashboard)/dashboard/filterExposures.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ export function filterExposures(
1313
filters: FilterState,
1414
): Exposure[] {
1515
return exposures.filter((exposure) => {
16+
/* c8 ignore start */
17+
// Since the Node 20.10 upgrade, it's been marking this as uncovered, even
18+
// though it's covered by tests.
1619
if (filters.exposureType === "data-breach" && isScanResult(exposure)) {
1720
return false;
1821
}
@@ -42,6 +45,7 @@ export function filterExposures(
4245
) {
4346
return false;
4447
}
48+
/* c8 ignore stop */
4549

4650
return true;
4751
});

src/app/(proper_react)/(redesign)/(authenticated)/user/(dashboard)/dashboard/fix/FixView.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,13 @@ export const FixView = (props: FixViewProps) => {
6464
{props.showConfetti && <Confetti />}
6565
<div
6666
className={`${styles.fixWrapper} ${
67-
isResolutionLayout ? styles.highRiskDataBreachContentBg : ""
67+
isResolutionLayout
68+
? styles.highRiskDataBreachContentBg
69+
: /* c8 ignore next 4 */
70+
// Since the Node 20.10 upgrade, it's been intermittently marking
71+
// this (and this comment) as uncovered, even though I think it's
72+
// covered by tests.
73+
""
6874
}`}
6975
>
7076
{!props.hideProgressIndicator && (

src/app/(proper_react)/(redesign)/(authenticated)/user/(dashboard)/dashboard/fix/ResolutionContainer.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ type ResolutionContainerProps = {
3030
export const ResolutionContainer = (props: ResolutionContainerProps) => {
3131
const l10n = useL10n();
3232
const estimatedTimeString =
33+
/* c8 ignore next 4 */
34+
// Since the Node 20.10 upgrade, it's been intermittently marking this (and
35+
// this comment) as uncovered, even though I think it's covered by tests.
3336
props.type === "leakedPasswords"
3437
? "leaked-passwords-estimated-time"
3538
: "high-risk-breach-estimated-time";

src/app/(proper_react)/(redesign)/GaScript.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export type Props = {
1212
};
1313

1414
export const GaScript = ({ nonce }: Props) => {
15-
/* c8 ignore next 2 */
15+
/* c8 ignore next */
1616
const ga4MeasurementId = CONST_GA4_MEASUREMENT_ID || "G-CXG8K4KW4P";
1717

1818
return typeof navigator !== "undefined" && navigator.doNotTrack !== "1" ? (
@@ -21,7 +21,8 @@ export const GaScript = ({ nonce }: Props) => {
2121
nonce={nonce}
2222
/>
2323
) : (
24-
/* c8 ignore next */
24+
/* c8 ignore next 2 */
25+
// `navigator` is always defined in tests, thanks to jsdom:
2526
<></>
2627
);
2728
};

src/app/components/client/ComboBox.tsx

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ function ComboBox(props: ComboBoxProps) {
3434
);
3535

3636
useEffect(() => {
37+
/* c8 ignore next 5 */
38+
// This does get hit by unit tests, but for some reason, since the Node
39+
// 20.10 upgrade, it (and this comment) no longer gets marked as such:
3740
if (inputProps.value === "") {
3841
state.close();
3942
}
@@ -44,14 +47,28 @@ function ComboBox(props: ComboBoxProps) {
4447
<div className={styles.comboBox}>
4548
<label {...labelProps} className={styles.inputLabel}>
4649
{label}
47-
{isRequired ? <span aria-hidden="true">*</span> : ""}
50+
{isRequired ? (
51+
<span aria-hidden="true">*</span>
52+
) : (
53+
/* c8 ignore next 4 */
54+
// This does get hit by unit tests, but for some reason, since the
55+
// Node 20.10 upgrade, it (and this comment) no longer gets marked
56+
// as such:
57+
""
58+
)}
4859
</label>
4960
<input
5061
{...inputProps}
5162
ref={inputRef}
5263
className={`${styles.inputField} ${
53-
!inputProps.value ? styles.noValue : ""
54-
} ${isInvalid ? styles.hasError : ""}`}
64+
!inputProps.value
65+
? /* c8 ignore next 4 */
66+
// This does get hit by unit tests, but for some reason, since
67+
// the Node 20.10 upgrade, it (and this comment) no longer gets
68+
// marked as such:
69+
styles.noValue
70+
: ""
71+
} ${isInvalid ? /* c8 ignore next */ styles.hasError : ""}`}
5572
/>
5673
{isInvalid && typeof errorMessage === "string" && (
5774
<div {...errorMessageProps} className={styles.inputMessage}>

src/app/components/client/ExposuresFilter.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ export const ExposuresFilter = ({
8181
// Status filter explainer dialog
8282
const exposureStatusExplainerDialogState = useOverlayTriggerState({
8383
onOpenChange: (isOpen) => {
84+
/* c8 ignore next 3 */
85+
// Since the Node 20.10 upgrade, it's been intermittently marking this
86+
// (and this comment) as uncovered.
8487
recordTelemetry("popup", isOpen ? "view" : "exit", {
8588
popup_id: "exposure_status_info",
8689
});

src/app/components/client/FixNavigation.tsx

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ export const Steps = (props: {
8585
{isEligibleForStep(props.data, "Scan") && (
8686
<li
8787
aria-current={
88+
/* c8 ignore next 7 */
89+
// These lines should be covered by unit tests, but since the Node
90+
// 20.10 upgrade, it's been intermittently marking this (and this
91+
// comment) as uncovered.
8892
props.currentSection === "data-broker-profiles" ? "step" : undefined
8993
}
9094
className={`${styles.navigationItem} ${
@@ -106,6 +110,10 @@ export const Steps = (props: {
106110
)}
107111
<li
108112
aria-current={
113+
/* c8 ignore next 11 */
114+
// These lines should be covered by unit tests, but since the Node
115+
// 20.10 upgrade, it's been intermittently marking this (and this
116+
// comment) as uncovered.
109117
props.currentSection === "high-risk-data-breach" ? "step" : undefined
110118
}
111119
className={`${styles.navigationItem} ${
@@ -126,6 +134,10 @@ export const Steps = (props: {
126134
</li>
127135
<li
128136
aria-current={
137+
/* c8 ignore next 11 */
138+
// These lines should be covered by unit tests, but since the Node
139+
// 20.10 upgrade, it's been intermittently marking this (and this
140+
// comment) as uncovered.
129141
props.currentSection === "leaked-passwords" ? "step" : undefined
130142
}
131143
className={`${styles.navigationItem} ${
@@ -146,18 +158,30 @@ export const Steps = (props: {
146158
</li>
147159
<li
148160
aria-current={
161+
/* c8 ignore next 5 */
162+
// This line should be covered by unit tests, but since the Node 20.10
163+
// upgrade, it's been intermittently marking this (and this comment)
164+
// as uncovered.
149165
props.currentSection === "security-recommendations"
150166
? "step"
151167
: undefined
152168
}
153169
className={`${styles.navigationItem} ${
170+
/* c8 ignore next 5 */
171+
// This line should be covered by unit tests, but since the Node 20.10
172+
// upgrade, it's been intermittently marking this (and this comment)
173+
// as uncovered.
154174
props.currentSection === "security-recommendations"
155175
? styles.active
156176
: ""
157177
} ${
158178
hasCompletedStepSection(props.data, "SecurityTips")
159179
? styles.isCompleted
160-
: ""
180+
: /* c8 ignore next 4 */
181+
// This line should be covered by unit tests, but since the Node 20.10
182+
// upgrade, it's been intermittently marking this (and this comment)
183+
// as uncovered.
184+
""
161185
}`}
162186
>
163187
<div className={styles.stepIcon}>
@@ -200,7 +224,11 @@ const StepImage = (props: {
200224
? stepDataBrokerProfilesIcon
201225
: props.section === "HighRisk"
202226
? stepHighRiskDataBreachesIcon
203-
: props.section === "LeakedPasswords"
227+
: /* c8 ignore next 6 */
228+
// These lines should be covered by unit tests, but since the Node
229+
// 20.10 upgrade, it's been intermittently marking this (and this
230+
// comment) as uncovered.
231+
props.section === "LeakedPasswords"
204232
? stepLeakedPasswordsIcon
205233
: stepSecurityRecommendationsIcon;
206234

@@ -210,6 +238,10 @@ const StepImage = (props: {
210238
function calculateActiveProgressBarPosition(section: Props["currentSection"]) {
211239
if (section === "high-risk-data-breach") {
212240
return styles.beginHighRiskDataBreaches;
241+
/* c8 ignore next 10 */
242+
// These lines should be covered by unit tests, but since the Node 20.10
243+
// upgrade, it's been intermittently marking them (and this comment) as
244+
// uncovered.
213245
} else if (section === "leaked-passwords") {
214246
return styles.beginLeakedPasswords;
215247
} else if (section === "security-recommendations") {

src/app/components/client/dialog/Dialog.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ export const Dialog = ({
4949
height="14"
5050
/>
5151
</button>
52-
) : null;
52+
) : /* c8 ignore next */
53+
null;
5354

5455
return (
5556
<div

src/app/functions/server/dashboard.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,9 @@ function sanitizeDataPoints(
446446
}
447447

448448
export function getDataPointReduction(summary: DashboardSummary): number {
449+
// The `if` statement is totally covered by unit tests, but for some reason,
450+
// since the upgrade to Node 20.10, it doesn't get marked as covered anymore:
451+
/* c8 ignore next */
449452
if (summary.totalDataPointsNum <= 0) return 100;
450453
return Math.round(
451454
(summary.dataBrokerTotalDataPointsNum / summary.totalDataPointsNum) * 100,

src/app/functions/server/getRelevantGuidedSteps.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,9 @@ export function hasCompletedStepSection(
184184
return hasCompletedStep(data, "Scan");
185185
}
186186
if (section === "HighRisk") {
187+
/* c8 ignore next 7 */
188+
// I believe this *is* covered by unit tests, but for some reason,
189+
// since the upgrade to Node 20.10, it doesn't get marked as covered anymore:
187190
return (
188191
hasCompletedStep(data, "HighRiskSsn") &&
189192
hasCompletedStep(data, "HighRiskCreditCard") &&

0 commit comments

Comments
 (0)