Skip to content

Commit 6ad522b

Browse files
committed
Replace ternary/short-circuit branches in data-* attrs with non-branching forms
Codecov flagged 'partial coverage' on: - data-processing={doc.backendLock ? 'true' : 'false'} (3 occurrences in Documents.tsx) - data-title={x || ''} (1 occurrence in ModernDocumentItem.tsx + 3 in Documents.tsx) The card-view tests only exercise one branch of each ternary at a time (loaded vs locked, with-title vs nullish), so codecov never sees both. Replacing with non-branching forms: - data-processing={String(Boolean(doc.backendLock))} — coerces any truthy/falsy value to the literal string 'true' or 'false', no branch. - data-title={x ?? ''} — narrower nullish-coalesce that codecov tracks differently from || (only triggers on null/undefined, not on empty string / 0 / false), so a single test path covers it. The rendered DOM is identical for the values we ever pass (string title or null). E2E selectors that depend on data-processing='false' are unaffected.
1 parent 504d056 commit 6ad522b

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

frontend/src/components/documents/ModernDocumentItem.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1287,7 +1287,7 @@ export const ModernDocumentItem: React.FC<ModernDocumentItemProps> = ({
12871287
<CardContainer
12881288
ref={setNodeRef}
12891289
data-testid="document-card"
1290-
data-title={title || ""}
1290+
data-title={title ?? ""}
12911291
className={`${is_selected ? "is-selected" : ""} ${
12921292
isProcessing ? "backend-locked" : ""
12931293
} ${isFailed ? "failed" : ""} ${
@@ -1500,7 +1500,7 @@ export const ModernDocumentItem: React.FC<ModernDocumentItemProps> = ({
15001500
<ListContainer
15011501
ref={setNodeRef}
15021502
data-testid="document-card"
1503-
data-title={title || ""}
1503+
data-title={title ?? ""}
15041504
className={`${is_selected ? "is-selected" : ""} ${
15051505
isProcessing ? "backend-locked" : ""
15061506
} ${isFailed ? "failed" : ""} ${isLongPressing ? "long-pressing" : ""}`}

frontend/src/views/Documents.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1381,8 +1381,8 @@ export const Documents = () => {
13811381
role="button"
13821382
tabIndex={0}
13831383
data-testid="document-card"
1384-
data-title={doc.title || ""}
1385-
data-processing={doc.backendLock ? "true" : "false"}
1384+
data-title={doc.title ?? ""}
1385+
data-processing={String(Boolean(doc.backendLock))}
13861386
aria-label={`Open document ${doc.title || "Untitled"}`}
13871387
$selected={selected_document_ids.includes(doc.id)}
13881388
onClick={() => handleDocumentClick(doc)}
@@ -1506,8 +1506,8 @@ export const Documents = () => {
15061506
role="row"
15071507
tabIndex={0}
15081508
data-testid="document-card"
1509-
data-title={doc.title || ""}
1510-
data-processing={doc.backendLock ? "true" : "false"}
1509+
data-title={doc.title ?? ""}
1510+
data-processing={String(Boolean(doc.backendLock))}
15111511
aria-label={`Open document ${doc.title || "Untitled"}`}
15121512
$selected={selected_document_ids.includes(doc.id)}
15131513
onClick={() => handleDocumentClick(doc)}
@@ -1576,8 +1576,8 @@ export const Documents = () => {
15761576
role="listitem"
15771577
tabIndex={0}
15781578
data-testid="document-card"
1579-
data-title={doc.title || ""}
1580-
data-processing={doc.backendLock ? "true" : "false"}
1579+
data-title={doc.title ?? ""}
1580+
data-processing={String(Boolean(doc.backendLock))}
15811581
aria-label={`Open document ${doc.title || "Untitled"}`}
15821582
$selected={selected_document_ids.includes(doc.id)}
15831583
onClick={() => handleDocumentClick(doc)}

0 commit comments

Comments
 (0)