Skip to content

fix(e2e): restore projectinfo rows after CASCADE DELETE in resetRepoCards()#121

Merged
ryota-murakami merged 3 commits intomainfrom
fix/e2e-cascade-delete-projectinfo
Feb 15, 2026
Merged

fix(e2e): restore projectinfo rows after CASCADE DELETE in resetRepoCards()#121
ryota-murakami merged 3 commits intomainfrom
fix/e2e-cascade-delete-projectinfo

Conversation

@ryota-murakami
Copy link
Contributor

@ryota-murakami ryota-murakami commented Feb 15, 2026

Summary

  • Fix resetRepoCards() to restore projectinfo rows that are silently deleted by PostgreSQL's ON DELETE CASCADE when repocards are deleted
  • Prevents 47+ flaky E2E failures across 7 spec files caused by test execution order dependency
  • Matches seed.sql values exactly; card5 intentionally has no projectinfo per seed design

Root Cause

resetRepoCards() → DELETE repocard WHERE board_id = testBoard
  → CASCADE: projectinfo rows deleted (IDs 401-404)
  → resetRepoCards() UPSERTs repocards (restored)
  → BUT projectinfo rows NOT restored
  → resetProjectInfoComments() UPDATE → 0 rows matched → FAIL

Test plan

  • pnpm typecheck — clean
  • pnpm lint — 0 warnings
  • pnpm build — success
  • pnpm test — 1282 passed
  • Targeted sequential E2E (resetRepoCards callers → resetProjectInfoComments callers) — 45/45 passed
  • pnpm e2e full suite — 318 passed, 3 failed (pre-existing add-repository-pagination flakiness, unrelated)

Summary by CodeRabbit

  • Changes

    • Theme selection moved to the sidebar; Settings page now shows only display preferences (Compact Mode, Show Card Metadata).
    • Removed "Change Theme" option from the Command Palette.
  • Documentation

    • E2E workflow updated to recommend parallel test execution with a sequential fallback.
  • Tests

    • E2E tests updated to select themes via the sidebar and refocused Settings tests on display toggles.

Theme selection was duplicated between the Settings page grid and the
sidebar ThemeToggle dropdown. Remove the Settings page theme UI to
align with SPEC.md which defines Settings as Display-only. Theme is
now exclusively accessed via the sidebar ThemeToggle.

- Remove ThemeButton component and theme card grid from SettingsClient
- Remove "Change Theme" command from CommandPalette
- Rewrite theme E2E tests to use sidebar dropdown instead of Settings
- Update loading skeleton to match Display-only layout
- Update CLAUDE.md to prefer pnpm e2e:parallel
…ards()

resetRepoCards() deletes all repocards then re-inserts them, but the
DELETE triggers ON DELETE CASCADE on projectinfo.repo_card_id, silently
removing projectinfo rows (IDs 401-404). Downstream helpers like
resetProjectInfoComments() and resetProjectInfoLinks() then fail with
"UPDATE matched 0 rows" when run after resetRepoCards() in the same shard.

Add projectinfo upsert after repocard restoration, matching seed.sql
values exactly. Card5 intentionally has no projectinfo per seed design.
@vercel
Copy link
Contributor

vercel bot commented Feb 15, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
gitbox Ready Ready Preview, Comment Feb 15, 2026 2:34pm

Request Review

@coderabbitai
Copy link

coderabbitai bot commented Feb 15, 2026

📝 Walkthrough

Walkthrough

Replaces theme selection UI on Settings with a sidebar ThemeToggle; Settings now only exposes display preferences. E2E tests updated to select themes via the sidebar and restore projectinfo seed rows after repo card resets. Command Palette theme command removed. CLAUDE.md recommends running E2E in parallel first.

Changes

Cohort / File(s) Summary
Docs / Workflow
CLAUDE.md
Recommend pnpm e2e:parallel as primary E2E workflow with pnpm e2e as fallback.
DB helper
e2e/helpers/db-query.ts
After repocard reset, upserts four seed projectinfo rows (with onConflict:id) and throws detailed errors on failure to restore seed state.
Settings UI
src/app/settings/SettingsClient.tsx, src/app/settings/SettingsClient.stories.tsx, src/app/settings/loading.tsx
Removed theme UI/logic and ThemeButton; retained display toggles (Compact Mode, Show Card Metadata) and adjusted loading skeleton to show display settings.
E2E tests (settings)
e2e/logged-in/settings.spec.ts
Refocused tests from theme controls to display-related toggles; removed theme-change assertions.
E2E tests (theme via sidebar)
e2e/logged-in/theme-persistence.spec.ts, e2e/logged-in/theme-visual-application.spec.ts
Added selectThemeFromSidebar helper; tests now open sidebar ThemeToggle and select themes there; updated navigation targets and assertions to match new flow.
Command Palette
src/components/CommandPalette/CommandPalette.tsx, src/tests/unit/components/CommandPalette/CommandPalette.test.tsx
Removed the "Change Theme" command and its test assertion; dropped related icon import.

Sequence Diagram

sequenceDiagram
    participant User
    participant Sidebar
    participant ThemeToggle
    participant Settings

    rect rgba(200, 150, 255, 0.5)
    Note over User,Settings: Previous Flow (removed)
    User->>Settings: Navigate to /settings
    Settings->>User: Render theme options
    User->>Settings: Select theme
    Settings->>Settings: Apply & persist theme
    end

    rect rgba(100, 200, 255, 0.5)
    Note over User,Sidebar: New Flow (current)
    User->>Sidebar: Open sidebar
    Sidebar->>ThemeToggle: Reveal theme control
    User->>ThemeToggle: Select theme from dropdown
    ThemeToggle->>ThemeToggle: Apply & persist theme (localStorage)
    ThemeToggle->>User: UI reflects applied theme
    end

    rect rgba(150, 200, 100, 0.5)
    Note over User,Settings: Settings Page (simplified)
    User->>Settings: Navigate to /settings
    Settings->>User: Display only display settings (compact, metadata)
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🎨 From settings pane the theme took flight,
Sidebar now holds the palette bright.
Settings trimmed to what matters most—
Compact cards and metadata post.
DB seeds restored, tests run in parallel light.

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main fix in the changeset: restoring projectinfo rows after CASCADE DELETE in resetRepoCards(), which is the primary technical change across e2e/helpers/db-query.ts and related E2E tests.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Merge Conflict Detection ✅ Passed ✅ No merge conflicts detected when merging into main

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/e2e-cascade-delete-projectinfo

No actionable comments were generated in the recent review. 🎉


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@morph-subagents
Copy link

🤖 Morph Preview Test

Looks like you hit your rate limits!

Please upgrade your limits here, or wait a few minutes and try again.

If you need help, reach out to support@morphllm.com.


Automated testing by Morph

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
src/app/settings/SettingsClient.stories.tsx (1)

26-28: ⚠️ Potential issue | 🟡 Minor

Stale doc comment still references theme selection.

Line 27 says "theme selection and display preferences" but lines 5–6 explicitly state theme is handled via sidebar. Update to match.

Proposed fix
-/** Default settings page showing theme selection and display preferences */
+/** Default settings page showing display preferences */
e2e/logged-in/settings.spec.ts (1)

14-16: ⚠️ Potential issue | 🟡 Minor

Missing networkidle wait after page.goto.

All page.goto('/settings') calls in this file lack waitForLoadState('networkidle'). The other theme E2E files consistently call it. As per coding guidelines: "Use networkidle wait strategy for page loads."

Example fix for the first test
     await page.goto('/settings')
+    await page.waitForLoadState('networkidle')
🤖 Fix all issues with AI agents
In `@e2e/logged-in/theme-visual-application.spec.ts`:
- Around line 51-56: The test currently waits for a possibly stale dropdown
(existingMenu locator) to auto-close which can flake; instead, actively dismiss
it before proceeding by sending a keyboard Escape (e.g.,
page.keyboard.press('Escape')) or clicking outside until
existingMenu.isVisible() returns false; update the block that checks
existingMenu to catch errors, press Escape (or click outside) and loop a couple
times with short waits to ensure existingMenu is not visible before continuing,
using the existingMenu locator name to find and verify closure.
🧹 Nitpick comments (3)
src/app/settings/SettingsClient.tsx (2)

123-132: Hydration placeholder doesn't match the loading.tsx skeleton.

The inline fallback uses a generic pulse div, while loading.tsx renders a structured skeleton with header + card + toggle rows. Consider reusing or aligning with the loading skeleton for visual consistency during mount.


48-79: Replace custom Toggle with shadcn Switch.

The custom Toggle component duplicates the functionality of Switch from @/components/ui. Both accept checked and onCheckedChange with identical interfaces. The shadcn Switch provides better accessibility through the Radix UI primitive, including proper focus-visible ring styling and disabled state handling.

- import Toggle from custom
+ import { Switch } from '@/components/ui/switch'
- <Toggle checked={...} onCheckedChange={...} />
+ <Switch checked={...} onCheckedChange={...} />
e2e/logged-in/theme-persistence.spec.ts (1)

16-29: Extract selectThemeFromSidebar to shared helper.

This function is duplicated in theme-persistence.spec.ts and theme-visual-application.spec.ts with divergent implementations. The version in theme-visual-application.spec.ts includes defensive dropdown-close logic (lines 51–55) and post-selection wait (lines 65–66) that prevents flakiness; theme-persistence.spec.ts lacks these guards. Extract to e2e/helpers/theme.ts so both files use the same robust implementation and stay in sync.

@codecov-commenter
Copy link

codecov-commenter commented Feb 15, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 72.21%. Comparing base (83f1682) to head (00272d7).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #121      +/-   ##
==========================================
- Coverage   72.28%   72.21%   -0.08%     
==========================================
  Files         143      143              
  Lines        4236     4214      -22     
  Branches     1135     1097      -38     
==========================================
- Hits         3062     3043      -19     
+ Misses       1153     1150       -3     
  Partials       21       21              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions
Copy link

github-actions bot commented Feb 15, 2026

🧪 E2E Coverage Report (Sharded: 12 parallel jobs)

Metric Coverage
Lines 94.39%
Functions 17.77%
Branches 16.97%
Statements 30.55%

📊 Full report available in workflow artifacts

Press Escape to deterministically close any open dropdown menu
rather than passively waiting for it to auto-close, preventing
flaky test failures in theme visual application E2E tests.
@morph-subagents
Copy link

🤖 Morph Preview Test

Looks like you hit your rate limits!

Please upgrade your limits here, or wait a few minutes and try again.

If you need help, reach out to support@morphllm.com.


Automated testing by Morph

@ryota-murakami ryota-murakami merged commit c0c64c3 into main Feb 15, 2026
20 checks passed
@ryota-murakami ryota-murakami deleted the fix/e2e-cascade-delete-projectinfo branch February 15, 2026 14:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants