test: remove TS constant self-equals tautologies (audit T-L1) - #1475
Conversation
…n e2e (audit T-L1)
📝 WalkthroughWalkthroughChangesOIDC login E2E validation
Estimated code review effort: 1 (Trivial) | ~2 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@app/desktop/src/__e2e__/oidc-login.spec.ts`:
- Around line 122-124: Update the assertions in the OIDC login test to verify
the expected AppShell or fallback-specific state rather than merely checking
that any `#root` child is visible. Use a stable selector or accessible marker
corresponding to the intended rendered application state, while retaining the
root attachment check.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 05a360c2-a37b-4b94-9586-8bfcf047176f
📒 Files selected for processing (1)
app/desktop/src/__e2e__/oidc-login.spec.ts
| // this is fine — we just verify the app rendered without crashing. | ||
| await expect(page.locator('#root')).toBeAttached(); | ||
| await expect(page.locator('#root > *').first()).toBeVisible(); |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Assert the expected app state, not any visible root child.
Because AppShell is wrapped by ErrorBoundary in app/desktop/src/main.tsx, an error fallback could satisfy #root > * visibility while the application has crashed. Use a stable selector or accessible state specific to the expected fallback/app-shell rendering.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@app/desktop/src/__e2e__/oidc-login.spec.ts` around lines 122 - 124, Update
the assertions in the OIDC login test to verify the expected AppShell or
fallback-specific state rather than merely checking that any `#root` child is
visible. Use a stable selector or accessible marker corresponding to the
intended rendered application state, while retaining the root attachment check.
Audit T-L1 — TS constant self-equals tautology cleanup
Audit finding T-L1 (comprehensive audit 2026-07-29) flagged "constants self-equals" anti-pattern: assertions like
expect(x).toBe(x)/assert.equal(x, x)where both sides are the same constant/variable, which assert nothing useful (a constant equals itself trivially). The audit estimated ~52 instances across the TS side; this PR does the actual enumeration and cleanup.Scope
app/(*.test.ts,*.test.tsx,*.spec.ts,*.spec.tsx).assemble_test.goare mostly real field-vs-value comparisons).Step 1 — Enumeration result
Exhaustive scan via recursive parser (handles nested parens, multi-line, string literals, chai/vitest/assert styles, all matchers including
.not.,.resolves.,.poll.):expect(X).toBe(X)self-equals (same identifier on both sides): 1expect(X).toEqual(X)self-equals: 0expect(X).toStrictEqual(X): 0assert.equal(X, X)/assert.strictEqual(X, X)/assert.deepEqual(X, X): 0expect(LITERAL).toBe(SAME_LITERAL)(different quote styles, e.g. 'OK' vs "OK"): 0toHaveLength,toMatch,toContain) with self-equals: 0Actual TS-side occurrences: 1 (the audit's ~52 estimate was overstated — most flagged candidates were real
expect(computed).toBe(expected)comparisons with two distinct variables).Step 2 — Judgment & fix
File:
app/desktop/src/__e2e__/oidc-login.spec.ts:123Before:
After:
Replaced the vacuous assertion with two meaningful checks: (1)
#rootis attached to the DOM (page mounted), (2) at least one child element rendered and is visible (React hydrated). Matches the pattern used inapp/desktop/src/__e2e__/smoke.spec.ts('app loads without crash'). Per the task brief's conservative default: replaced with a stronger assertion rather than deleting the test branch.False positives kept (sample of common ones)
expect(agent1.id).toBe(agent2.id)(pipeline-integration.test.ts:749-750) — compares two distinct agent ids to verify idempotency/dedup. KEEP.expect(c1).toBe(c2)(desktop hubAuth.test.ts:96) — compares two PKCE challenge outputs from the same input to verify determinism. KEEP.expect(typesA).toEqual(typesB),expect(zhKeys).toEqual(enKeys)— cross-variable comparisons. KEEP.expect(lower.length).toBe(upper.length)(mobile-rn threads.test.ts:203) — compares two different arrays' lengths. KEEP.expect(res.status).toBe(200),expect(row.status).toBe('ok')etc. — value-vs-literal, real assertions. KEEP.Packages touched
agenthub-desktop(1 file:app/desktop/src/__e2e__/oidc-login.spec.ts)Step 4 — Verification
__e2e__), excluded from desktop vitest config (vitest.config.tstest.include), so it does not run under the vitest suite. Typecheck viatsc --noEmit -p tsconfig.json --ignoreDeprecations 6.0reports 3964 baseline errors both with and without this change (unchanged), and zero new errors in the touched file.pnpm dev); not executed here since the change is a pure assertion replacement using the same locator pattern already present insmoke.spec.ts.Summary
expect(true).toBe(true)with two real DOM-render assertions)Summary by CodeRabbit