Skip to content

feat(e2e): Enable conditional tests and fix discovery startup#191

Merged
frankbria merged 1 commit intomainfrom
feat/e2e-conditional-tests
Jan 5, 2026
Merged

feat(e2e): Enable conditional tests and fix discovery startup#191
frankbria merged 1 commit intomainfrom
feat/e2e-conditional-tests

Conversation

@frankbria
Copy link
Owner

@frankbria frankbria commented Jan 5, 2026

Summary

  • Fix createTestProject to call /api/projects/{id}/start endpoint after project creation
  • Fix lead_agent.py CHECK constraint bug (discovery_contextdiscovery_state)
  • Add discovery state seeding in seed-test-data.py for UI-only tests
  • Enable previously-skipped tests with conditional API key execution
  • Create new test file test_task_execution_flow.spec.ts for task management UI

Problem

Conditional tests requiring Claude API (discovery → PRD flow) were failing because:

  1. createTestProject created projects but didn't start discovery
  2. Backend had a CHECK constraint bug preventing discovery state storage
  3. Tests had inconsistent UI flows with redundant navigation

Solution

  • Updated createTestProject helper to call the /api/projects/{id}/start endpoint
  • Fixed lead_agent.py to use valid discovery_state category instead of discovery_context
  • Added startDiscovery parameter to createTestProject for flexibility
  • Tests now use HAS_API_KEY pattern for conditional execution

Test Results

Environment Result
With API key 12 passed
Without API key (CI) 10 passed, 2 skipped

Test plan

  • Run tests without API key: npx playwright test test_complete_user_journey.spec.ts test_task_execution_flow.spec.ts test_start_agent_flow.spec.ts --project=chromium
  • Run tests with API key: Same command with ANTHROPIC_API_KEY set
  • Verify conditional tests skip gracefully in CI mode
  • Verify full discovery → PRD flow works with API key

Summary by CodeRabbit

  • Tests

    • Expanded E2E suite with seeded-data discovery flows, a new Task Execution test suite, and seeded UI verification paths.
    • Split full-path tests into seeded vs. API-key-gated paths; added conditional execution, improved error monitoring, and seeded-data assertions.
    • Test utilities updated to optionally start discovery to support seeded and UI-only workflows.
  • Chores

    • Adjusted where project description is persisted to ensure consistent discovery readiness for tests.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 5, 2026

Walkthrough

LeadAgent now persists project description under discovery_state.context_project_description. E2E tooling seeds discovery_state, updates project phase to discovery, and test utilities optionally POST to /api/projects/{id}/start (with JWT) to trigger discovery; several E2E tests were adjusted to use seeded-data flows and API-key gating.

Changes

Cohort / File(s) Summary
Core Logic
codeframe/agents/lead_agent.py
Persist project description to discovery_state.context_project_description instead of discovery_context.project_description.
Test Data Seeding
tests/e2e/seed-test-data.py
Adds seeding that clears/inserts discovery_state rows (state=discovering, current_question_id, current_question_text) and updates projects.phase = 'discovery'.
Test Utilities
tests/e2e/test-utils.ts
createTestProject() signature extended with startDiscovery?: boolean (default true). When enabled, obtains a JWT and POSTs to /api/projects/{projectId}/start with Bearer token, then waits briefly for initialization.
E2E Test Suite Adjustments
tests/e2e/test_complete_user_journey.spec.ts, tests/e2e/test_start_agent_flow.spec.ts, tests/e2e/test_checkpoint_ui.spec.ts
Tests refactored to seeded-data flows, add HAS_API_KEY gating and env config (FRONTEND_URL, PROJECT_ID), wire error-monitoring hooks, and update createTestProject call sites (pass startDiscovery as needed).
New E2E Test
tests/e2e/test_task_execution_flow.spec.ts
New end-to-end test validating Tasks UI, task statistics, agent status panels, review findings, and dashboard navigation using seeded data.
E2E Seed/Flow Integration
tests/e2e/*
Multiple test files now rely on seeded discovery_state and optional backend-start flow; some tests split into seeded vs API-key-dependent paths.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant E2E as E2E Test / Test Utils
  participant Auth as Auth Service (getAuthToken)
  participant API as Backend API (/api/projects/{id}/start)
  participant Lead as LeadAgent.start_discovery
  participant DB as DB (memory / discovery_state)

  Note over E2E,API: Optional backend-driven discovery start (conditional in createTestProject)
  E2E->>Auth: request JWT for test user
  Auth-->>E2E: return Bearer token
  E2E->>API: POST /api/projects/{id}/start (Authorization: Bearer ...)
  API->>Lead: invoke start_discovery(projectId, project_description?)
  Lead->>DB: upsert discovery_state (context_project_description, current_question_*)
  DB-->>Lead: ack
  Lead-->>API: return success
  API-->>E2E: 200 OK
  Note over DB,E2E: Tests may also seed discovery_state directly for seeded-data assertions
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

🐰 I hopped a log and moved a tiny key,

tucked project notes where discovery can see,
seeds awaken questions for UI play,
a token, a POST — the backend lights the way,
carrots, code, and tests all bright and free!

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main changes: enabling conditional tests and fixing discovery startup, which are the primary objectives of this PR.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ 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 feat/e2e-conditional-tests

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

Copy link
Contributor

@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

Fix all issues with AI Agents 🤖
In @tests/e2e/test_task_execution_flow.spec.ts:
- Around line 111-114: The assertion mixes a Locator object (agentPanel) with a
boolean (agentStatePanelVisible) so it always passes; compute a boolean for
agentPanel visibility (e.g., const agentPanelVisible = await
agentPanel.isVisible().catch(() => false) or check count and visibility) and
then assert expect(agentPanelVisible || agentStatePanelVisible).toBeTruthy(),
replacing the current expect(agentPanel || agentStatePanelVisible) call and
using the new agentPanelVisible variable.
🧹 Nitpick comments (4)
tests/e2e/seed-test-data.py (1)

1135-1135: Consider defining TABLE_MEMORY with other table constants.

For consistency with TABLE_AGENTS, TABLE_TASKS, etc. defined at the top of the file (lines 33-38), move this constant to the same location.

🔎 Suggested refactor

Add at line 39 (after other table constants):

TABLE_MEMORY = "memory"

Then remove line 1135.

tests/e2e/test-utils.ts (1)

640-641: Consider replacing fixed timeout with event-based waiting.

waitForTimeout(2000) can cause flakiness in CI environments. Consider waiting for a specific condition instead.

🔎 Suggested improvement
-    // Wait for discovery to initialize (first question should appear)
-    await page.waitForTimeout(2000);
+    // Wait for discovery to initialize by checking for question or loading state
+    await page.waitForSelector(
+      '[data-testid="discovery-question"], [data-testid="discovery-loading"]',
+      { timeout: 10000 }
+    ).catch(() => {
+      // Discovery may already be complete or in different state - continue
+    });
tests/e2e/test_task_execution_flow.spec.ts (2)

139-145: Redundant assertion after visibility checks.

The final expect(reviewPanel).toBeAttached() on line 145 is redundant since the same assertion already passed on line 133. The visibility check results (hasSummary, hasFindingsList) are captured but not used in any assertion.

🔎 Suggested improvement

Either remove the redundant assertion or use the visibility results:

     // Either summary or findings list should be visible (depending on data state)
     const hasSummary = await reviewSummary.isVisible().catch(() => false);
     const hasFindingsList = await reviewFindingsList.isVisible().catch(() => false);
 
-    // The review panel is attached, which is sufficient for this test
-    // Actual findings display depends on the backend data state
-    expect(reviewPanel).toBeAttached();
+    // At least one of the review elements should be present
+    expect(hasSummary || hasFindingsList).toBeTruthy();

170-171: Fixed timeouts in tab navigation test.

Using waitForTimeout(1000) for tab content loading can cause flakiness. Consider waiting for specific content or using waitForLoadState.

🔎 Suggested improvement
     if (hasQualityGatesTab) {
       await qualityGatesTab.click();
-      // Verify quality gates panel loads
-      await page.waitForTimeout(1000);
+      // Verify quality gates panel loads
+      await page.waitForLoadState('networkidle', { timeout: 5000 }).catch(() => {});
     }

Also applies to: 180-181

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 84572b0 and 9bfe3d7.

📒 Files selected for processing (6)
  • codeframe/agents/lead_agent.py
  • tests/e2e/seed-test-data.py
  • tests/e2e/test-utils.ts
  • tests/e2e/test_complete_user_journey.spec.ts
  • tests/e2e/test_start_agent_flow.spec.ts
  • tests/e2e/test_task_execution_flow.spec.ts
🧰 Additional context used
📓 Path-based instructions (2)
tests/e2e/**/*.ts

📄 CodeRabbit inference engine (CLAUDE.md)

Implement E2E tests using Playwright + TestSprite with loginUser() helper from tests/e2e/test-utils.ts for authentication

Files:

  • tests/e2e/test-utils.ts
  • tests/e2e/test_start_agent_flow.spec.ts
  • tests/e2e/test_complete_user_journey.spec.ts
  • tests/e2e/test_task_execution_flow.spec.ts
codeframe/**/*.py

📄 CodeRabbit inference engine (CLAUDE.md)

codeframe/**/*.py: Use Python 3.11+ for backend development with FastAPI, AsyncAnthropic, SQLite with async support (aiosqlite), and tiktoken for token counting
Use token counting via tiktoken library for token budget management with ~50,000 token limit per conversation
Use asyncio patterns with AsyncAnthropic for async/await in Python backend for concurrent operations
Implement quality gates with multi-stage pre-completion checks (tests → type → coverage → review) and Git + SQLite + context snapshots for project state rollback
Use tiered memory system (HOT/WARM/COLD) with importance scoring using hybrid exponential decay algorithm for context management with 30-50% token reduction
Implement session lifecycle management with auto-save/restore using file-based storage at .codeframe/session_state.json

Files:

  • codeframe/agents/lead_agent.py
🧠 Learnings (6)
📓 Common learnings
Learnt from: CR
Repo: frankbria/codeframe PR: 0
File: docs/CLAUDE.md:0-0
Timestamp: 2025-11-25T19:08:37.203Z
Learning: Implement Lead Agent for orchestration and Worker Agents for specialization (Backend, Frontend, Test, Review) with maturity levels D1-D4
📚 Learning: 2026-01-04T06:26:12.870Z
Learnt from: CR
Repo: frankbria/codeframe PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-04T06:26:12.870Z
Learning: Applies to web-ui/src/app/page.tsx : Implement automatic project discovery start after project creation with loading state transitions and 'Start Discovery' button for idle projects

Applied to files:

  • tests/e2e/test-utils.ts
  • tests/e2e/test_start_agent_flow.spec.ts
📚 Learning: 2026-01-04T06:26:12.870Z
Learnt from: CR
Repo: frankbria/codeframe PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-04T06:26:12.870Z
Learning: Applies to tests/e2e/**/*.ts : Implement E2E tests using Playwright + TestSprite with loginUser() helper from tests/e2e/test-utils.ts for authentication

Applied to files:

  • tests/e2e/test-utils.ts
  • tests/e2e/test_start_agent_flow.spec.ts
  • tests/e2e/test_complete_user_journey.spec.ts
  • tests/e2e/test_task_execution_flow.spec.ts
📚 Learning: 2026-01-04T06:26:12.870Z
Learnt from: CR
Repo: frankbria/codeframe PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-04T06:26:12.870Z
Learning: Applies to web-ui/src/lib/**/*.ts : Frontend API files must use const API_BASE_URL = process.env.NEXT_PUBLIC_API_URL || 'http://localhost:8080' pattern without hardcoded production URLs or different fallback ports

Applied to files:

  • tests/e2e/test-utils.ts
  • tests/e2e/test_start_agent_flow.spec.ts
📚 Learning: 2025-11-25T19:08:37.203Z
Learnt from: CR
Repo: frankbria/codeframe PR: 0
File: docs/CLAUDE.md:0-0
Timestamp: 2025-11-25T19:08:37.203Z
Learning: Applies to docs/web-ui/**/__tests__/**/*.test.{ts,tsx} : Create JavaScript test files colocated or in __tests__/ as *.test.ts

Applied to files:

  • tests/e2e/test_task_execution_flow.spec.ts
📚 Learning: 2025-11-25T19:08:54.154Z
Learnt from: CR
Repo: frankbria/codeframe PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-25T19:08:54.154Z
Learning: Applies to specs/*/tasks.md : Feature task files (tasks.md) must include phase-by-phase task breakdown with unique task identifiers (T001, T002, etc.), acceptance criteria per task, beads issue references, and estimated effort

Applied to files:

  • tests/e2e/test_task_execution_flow.spec.ts
🧬 Code graph analysis (4)
tests/e2e/test-utils.ts (1)
tests/e2e/e2e-config.ts (1)
  • BACKEND_URL (11-11)
codeframe/agents/lead_agent.py (1)
codeframe/persistence/database.py (1)
  • create_memory (502-504)
tests/e2e/seed-test-data.py (1)
tests/test_review_api.py (1)
  • project_id (95-103)
tests/e2e/test_task_execution_flow.spec.ts (2)
tests/e2e/e2e-config.ts (1)
  • FRONTEND_URL (14-14)
tests/e2e/test-utils.ts (4)
  • setupErrorMonitoring (64-104)
  • ExtendedPage (25-27)
  • loginUser (483-500)
  • checkTestErrors (192-216)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: Frontend Unit Tests
  • GitHub Check: Backend Unit Tests
  • GitHub Check: claude-review
  • GitHub Check: E2E Smoke Tests (Chromium)
🔇 Additional comments (16)
tests/e2e/seed-test-data.py (2)

1146-1179: Discovery state seeding implementation is well-structured.

The seeding correctly:

  • Clears existing entries for idempotency
  • Seeds the three required fields that LeadAgent._load_discovery_state() expects
  • Uses problem_1 which is the first required question in DiscoveryQuestionFramework
  • Includes proper error handling and count verification

1181-1193: Project phase update aligns with discovery UI requirements.

Setting the project phase to 'discovery' ensures the frontend renders the discovery UI correctly when tests navigate to the seeded project.

tests/e2e/test-utils.ts (3)

13-13: Import addition is appropriate.

The BACKEND_URL import is needed for the new API call to start discovery.


565-584: Function signature update maintains backward compatibility.

The startDiscovery parameter defaults to true, ensuring existing callers continue to work without modification. The JSDoc updates clearly document the two-step process.


618-638: API call implementation for starting discovery is well-structured.

The implementation correctly:

  • Retrieves the auth token from the page context
  • Includes proper Authorization header
  • Handles error cases with descriptive messages
tests/e2e/test_task_execution_flow.spec.ts (1)

1-27: Well-documented test file with clear data dependencies.

The header clearly documents the seeded data expectations and test coverage scope, making it easy for maintainers to understand the test requirements.

tests/e2e/test_start_agent_flow.spec.ts (4)

27-29: Conditional test pattern is well-implemented.

Using HAS_API_KEY with a descriptive test name and test.skip() provides clear visibility in test reports about why tests were skipped.


58-78: Seeded data verification test is appropriate.

The test correctly:

  • Uses the seeded project ID from environment
  • Verifies the exact question text matches seed data
  • Avoids any Claude API calls, ensuring it runs in CI

80-116: Conditional PRD generation test handles API dependency correctly.

The test properly:

  • Skips when API key is unavailable with clear messaging
  • Creates a fresh project for the full discovery flow
  • Handles variable discovery question counts gracefully
  • Uses appropriate timeouts for Claude API latency

118-129: Redundant navigation after createTestProject.

Since createTestProject already navigates to the dashboard and waits for the page to load, the explicit navigation on lines 121 (per comment) is handled. However, this test doesn't have explicit navigation after createTestProject, which is correct.

tests/e2e/test_complete_user_journey.spec.ts (5)

29-32: Environment configuration is consistent with other test files.

The pattern of using environment variables with sensible defaults is consistent across the E2E test suite.


58-102: Seeded data verification test provides good UI coverage.

The test verifies:

  • Authentication state is maintained
  • Discovery UI renders with seeded data
  • Dashboard and agent panels are accessible
  • Tab navigation works correctly

This ensures basic functionality works without requiring API calls.


143-152: Discovery answer content is well-crafted for PRD generation.

The detailed, multi-line answers provide meaningful context for Claude to generate a comprehensive PRD, making the test more realistic and the PRD output more useful for verification.


104-198: Full workflow test provides comprehensive E2E coverage.

The conditional test properly exercises the complete user journey when the API key is available, covering project creation, discovery, PRD generation, and dashboard navigation. The skip behavior ensures CI runs remain stable.


112-112: Test ID user-menu is confirmed to exist in the UI.

The test ID is properly defined in web-ui/src/components/Navigation.tsx (line 44) and is rendered when user authentication is successful. The assertion at line 112 is correct.

codeframe/agents/lead_agent.py (1)

390-398: Fix for CHECK constraint is correct.

The change from discovery_context to discovery_state category resolves the schema constraint violation. The database schema defines the allowed memory categories as: 'pattern', 'decision', 'gotcha', 'preference', 'conversation', 'discovery_state', 'discovery_answers', 'prd'. The key rename to context_project_description is appropriate for namespacing within the discovery_state category and has no impact on other code (the key is written but never read from the database elsewhere).

@claude
Copy link

claude bot commented Jan 5, 2026

Code Review - PR #191

Summary

This PR successfully addresses E2E test failures by fixing a critical database constraint bug and implementing a robust conditional testing strategy.

Strengths

1. Critical Bug Fix (lead_agent.py:390-398)

  • Correctly changes discovery_context to discovery_state to match schema CHECK constraint
  • Schema allows: pattern, decision, gotcha, preference, conversation, discovery_state, discovery_answers, prd
  • Clear comment explaining the fix
  • Key renamed to context_project_description for clarity

2. Test Data Seeding (seed-test-data.py:1127-1193)

  • Excellent approach to UI testing without API dependency
  • Seeds discovery state directly into memory table
  • Idempotent design (clears before inserting)
  • Sets project phase to discovery for UI consistency

3. Conditional Testing Pattern

  • Clean HAS_API_KEY implementation
  • Test names clearly indicate skip reason
  • Runs locally with API key, skips gracefully in CI
  • 10 tests always run, 2 tests conditional

4. Improved Test Helper (test-utils.ts:565-644)

  • Properly handles two-phase project creation
  • startDiscovery parameter provides flexibility

Areas for Improvement

1. Hard-coded Timeout (test-utils.ts:641)

  • Fixed 2000ms timeout is brittle
  • Recommend: Use conditional wait on UI state instead

2. Error Context (test-utils.ts:637)

  • Add project ID to error message for easier debugging

3. Test Data Hardcoding (seed-test-data.py:1156)

  • Hardcoded question text may drift from source
  • Recommend: Import from DiscoveryQuestionFramework

4. Test Assertions (test_task_execution_flow.spec.ts)

  • Many tests use .toBeAttached() instead of .toBeVisible()
  • toBeAttached only verifies DOM presence, not visibility
  • Recommend: Use toBeVisible for meaningful UI tests

Security & Performance

Security: ✅ No concerns - auth properly handled
Performance: ⚠️ Minor - test helper duplication could be reduced

Final Verdict

LGTM with minor recommendations

Blockers: None

Successfully:

  • Fixes critical CHECK constraint bug
  • Implements robust conditional testing
  • Adds comprehensive test coverage
  • Maintains backward compatibility

Test Results: ✅ 12 passed with API key, 10 passed + 2 skipped without

Great work addressing the E2E testing gaps!

@frankbria frankbria force-pushed the feat/e2e-conditional-tests branch from 9bfe3d7 to acab61a Compare January 5, 2026 23:02
@claude
Copy link

claude bot commented Jan 5, 2026

Follow-up Code Review - PR #191

I've reviewed the changes in this PR along with my previous review comments and the CodeRabbit feedback. Here's my updated analysis:

✅ Excellent Improvements

1. Critical Bug Fix Confirmed (lead_agent.py:390-398)

  • The fix from discovery_contextdiscovery_state is correct and necessary
  • The schema CHECK constraint only allows: pattern, decision, gotcha, preference, conversation, discovery_state, discovery_answers, prd
  • The comment clearly explains the rationale
  • Key renamed to context_project_description for clarity

2. Robust Test Data Seeding (seed-test-data.py:1127-1193)

  • Excellent strategy for UI testing without API dependency
  • Idempotent design (clears before inserting) prevents test pollution
  • Properly sets project phase to 'discovery' for UI consistency
  • Well-documented with clear comments explaining the purpose

3. Smart Conditional Testing Pattern

  • HAS_API_KEY pattern is clean and maintainable
  • Test names clearly indicate when tests are skipped
  • 10 tests always run (UI verification), 2 tests conditional (API-dependent)
  • Graceful degradation in CI environments

🔍 Outstanding Issues to Address

1. CRITICAL: Logic Error in Assertion (test_task_execution_flow.spec.ts:111-114)

As CodeRabbit correctly identified, this is a type mismatch bug:

// ❌ Current (always passes - mixing Locator with boolean)
expect(agentPanel || agentStatePanelVisible).toBeTruthy();

Fix required:

// ✅ Correct - compute boolean for agentPanel
const agentPanelVisible = await agentPanel.isVisible().catch(() => false);
expect(agentPanelVisible || agentStatePanelVisible).toBeTruthy();

This is a blocker - the assertion will always pass regardless of UI state.

2. Hard-coded Timeouts (test-utils.ts:641, test_task_execution_flow.spec.ts:170-171, 180-181)

Multiple instances of waitForTimeout() should be replaced with event-based waits:

// ❌ Brittle
await page.waitForTimeout(2000);

// ✅ Robust
await page.waitForSelector('[data-testid="discovery-question"]', { timeout: 10000 })
  .catch(() => {});

3. Missing Error Context (test-utils.ts:637)
Add project ID to error message for debugging:

throw new Error(`Failed to start discovery for project ${projectId}: ${startResponse.status()} - ${errorText}`);

4. Redundant Assertion (test_task_execution_flow.spec.ts:139-145)
The final expect(reviewPanel).toBeAttached() on line 145 is redundant since the same check passed on line 133. Either remove it or assert that one of the child elements is visible.

📊 Test Coverage Assessment

Strengths:

  • Comprehensive task statistics validation (numeric checks)
  • Agent status panel verification
  • Dashboard navigation testing
  • Review findings panel checks

Weakness:

  • Many tests use .toBeAttached() instead of .toBeVisible()
  • .toBeAttached() only verifies DOM presence, not actual visibility to users
  • Recommend: Use .toBeVisible() for meaningful UI assertions

🎯 Final Verdict

Status: APPROVED with required fixes ⚠️

Blockers:

  1. Fix the logic error in test_task_execution_flow.spec.ts:111-114 (critical assertion bug)

Recommended (non-blocking):

  1. Replace hard-coded timeouts with event-based waits
  2. Add project ID to error messages
  3. Remove redundant assertions
  4. Convert .toBeAttached() to .toBeVisible() where appropriate

Test Results: ✅ 12 passed with API key, 10 passed + 2 skipped without

This PR successfully:

  • Fixes the critical CHECK constraint bug
  • Implements robust conditional testing
  • Adds comprehensive E2E coverage
  • Maintains backward compatibility

Please address the critical assertion bug before merging. Great work on the conditional testing strategy!

Copy link
Contributor

@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: 0

🧹 Nitpick comments (4)
tests/e2e/seed-test-data.py (1)

1181-1194: Consider verifying the UPDATE affected exactly one row.

While the error handling is present, you could strengthen the validation by checking that exactly one row was updated.

🔎 Optional enhancement to verify UPDATE success
         cursor.execute(
             "UPDATE projects SET phase = 'discovery' WHERE id = ?",
             (project_id,),
         )
+        if cursor.rowcount != 1:
+            print(f"⚠️  Warning: Expected to update 1 project, but updated {cursor.rowcount}")
         print(f"✅ Set project {project_id} phase to 'discovery'")
tests/e2e/test-utils.ts (1)

617-642: Replace fixed timeout with state-based waiting for better test reliability.

Line 641 uses page.waitForTimeout(2000) which is a fixed delay that could cause flakiness in CI environments. Consider waiting for a specific UI state or API response instead.

🔎 Suggested improvement using state-based waiting
     if (!startResponse.ok()) {
       const errorText = await startResponse.text();
       throw new Error(`Failed to start discovery: ${startResponse.status()} - ${errorText}`);
     }

-    // Wait for discovery to initialize (first question should appear)
-    await page.waitForTimeout(2000);
+    // Wait for discovery to initialize by checking for the discovery question or loading state
+    try {
+      await page.getByTestId('discovery-question')
+        .or(page.getByTestId('discovery-loading'))
+        .waitFor({ state: 'visible', timeout: 5000 });
+    } catch {
+      // Discovery might not have started yet or test doesn't need it - non-blocking
+    }
   }
tests/e2e/test_start_agent_flow.spec.ts (1)

80-116: Consider replacing the fixed timeout in the answer loop with state-based waiting.

Line 109 uses page.waitForTimeout(3000) between discovery questions. While this accounts for API processing time, a state-based wait would be more reliable.

🔎 Suggested improvement
         // Answer the question
         await answerDiscoveryQuestion(
           page,
           `Test answer ${i + 1} - This is a comprehensive response to help generate the PRD.`
         );

-        // Wait for next question or completion
-        await page.waitForTimeout(3000);
+        // Wait for next question to load or PRD to generate
+        try {
+          await page.getByTestId('discovery-question')
+            .or(page.getByTestId('prd-generated'))
+            .waitFor({ state: 'visible', timeout: 10000 });
+        } catch {
+          // Discovery might be complete
+        }
       }
tests/e2e/test_complete_user_journey.spec.ts (1)

129-152: Consider replacing the fixed timeout in the discovery answer loop.

Line 151 uses page.waitForTimeout(3000) between answering discovery questions. This is the same pattern seen in other test files and could benefit from state-based waiting for improved reliability.

🔎 Suggested improvement
         await answerDiscoveryQuestion(page, answer);

-        // Wait for processing and next question
-        await page.waitForTimeout(3000);
+        // Wait for next question to load or discovery to complete
+        try {
+          await page.getByTestId('discovery-question')
+            .or(page.getByTestId('prd-generated'))
+            .waitFor({ state: 'visible', timeout: 10000 });
+        } catch {
+          // Discovery might be complete
+        }
       }
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9bfe3d7 and acab61a.

📒 Files selected for processing (6)
  • codeframe/agents/lead_agent.py
  • tests/e2e/seed-test-data.py
  • tests/e2e/test-utils.ts
  • tests/e2e/test_complete_user_journey.spec.ts
  • tests/e2e/test_start_agent_flow.spec.ts
  • tests/e2e/test_task_execution_flow.spec.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • tests/e2e/test_task_execution_flow.spec.ts
  • codeframe/agents/lead_agent.py
🧰 Additional context used
📓 Path-based instructions (1)
tests/e2e/**/*.ts

📄 CodeRabbit inference engine (CLAUDE.md)

Implement E2E tests using Playwright + TestSprite with loginUser() helper from tests/e2e/test-utils.ts for authentication

Files:

  • tests/e2e/test_start_agent_flow.spec.ts
  • tests/e2e/test-utils.ts
  • tests/e2e/test_complete_user_journey.spec.ts
🧠 Learnings (5)
📓 Common learnings
Learnt from: CR
Repo: frankbria/codeframe PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-04T06:26:12.870Z
Learning: Applies to web-ui/src/app/page.tsx : Implement automatic project discovery start after project creation with loading state transitions and 'Start Discovery' button for idle projects
📚 Learning: 2026-01-04T06:26:12.870Z
Learnt from: CR
Repo: frankbria/codeframe PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-04T06:26:12.870Z
Learning: Applies to tests/e2e/**/*.ts : Implement E2E tests using Playwright + TestSprite with loginUser() helper from tests/e2e/test-utils.ts for authentication

Applied to files:

  • tests/e2e/test_start_agent_flow.spec.ts
  • tests/e2e/test-utils.ts
  • tests/e2e/test_complete_user_journey.spec.ts
📚 Learning: 2026-01-04T06:26:12.870Z
Learnt from: CR
Repo: frankbria/codeframe PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-04T06:26:12.870Z
Learning: Applies to web-ui/src/lib/**/*.ts : Frontend API files must use const API_BASE_URL = process.env.NEXT_PUBLIC_API_URL || 'http://localhost:8080' pattern without hardcoded production URLs or different fallback ports

Applied to files:

  • tests/e2e/test_start_agent_flow.spec.ts
  • tests/e2e/test-utils.ts
📚 Learning: 2026-01-04T06:26:12.870Z
Learnt from: CR
Repo: frankbria/codeframe PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-04T06:26:12.870Z
Learning: Applies to web-ui/src/app/page.tsx : Implement automatic project discovery start after project creation with loading state transitions and 'Start Discovery' button for idle projects

Applied to files:

  • tests/e2e/test_start_agent_flow.spec.ts
  • tests/e2e/test-utils.ts
📚 Learning: 2025-11-25T19:08:37.203Z
Learnt from: CR
Repo: frankbria/codeframe PR: 0
File: docs/CLAUDE.md:0-0
Timestamp: 2025-11-25T19:08:37.203Z
Learning: Applies to docs/web-ui/**/__tests__/**/*.test.{ts,tsx} : Create JavaScript test files colocated or in __tests__/ as *.test.ts

Applied to files:

  • tests/e2e/test_complete_user_journey.spec.ts
🧬 Code graph analysis (3)
tests/e2e/test_start_agent_flow.spec.ts (2)
tests/e2e/e2e-config.ts (1)
  • FRONTEND_URL (14-14)
tests/e2e/test-utils.ts (2)
  • createTestProject (580-645)
  • answerDiscoveryQuestion (687-719)
tests/e2e/test-utils.ts (1)
tests/e2e/e2e-config.ts (1)
  • BACKEND_URL (11-11)
tests/e2e/seed-test-data.py (1)
tests/test_review_api.py (1)
  • project_id (95-103)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: Backend Unit Tests
  • GitHub Check: Frontend Unit Tests
  • GitHub Check: claude-review
  • GitHub Check: E2E Smoke Tests (Chromium)
🔇 Additional comments (8)
tests/e2e/test-utils.ts (1)

13-13: LGTM!

The import of BACKEND_URL from the config module follows the established pattern and enables environment-driven API endpoint configuration.

tests/e2e/test_start_agent_flow.spec.ts (3)

27-29: LGTM!

The environment-driven configuration pattern enables conditional test execution based on API key availability, allowing tests to run in CI without requiring Anthropic API access while still supporting full validation locally.


118-209: LGTM!

The tests appropriately handle multiple discovery states and provide good coverage of edge cases. The conditional execution pattern ensures tests run reliably in both CI and local environments.


58-78: Seeded question text matches expected value.

The hardcoded question text on line 77 correctly matches the value in tests/e2e/seed-test-data.py line 1156: both contain 'What problem does this application solve?'. The test also properly uses the loginUser() helper from test-utils.ts for authentication.

tests/e2e/test_complete_user_journey.spec.ts (3)

20-34: LGTM!

The imports and configuration constants follow the established pattern from other test files in this PR. Enabling the test suite (removing .skip on line 34) achieves the PR objective of making these tests executable.


36-56: LGTM!

The error monitoring setup provides better visibility into test failures while filtering expected transient errors. The pattern is consistent across the test suite.


104-198: Well-structured conditional test execution.

The test properly gates Claude API-dependent steps behind the HAS_API_KEY check and provides comprehensive coverage of the complete user journey. The test name dynamically reflects whether it will run or be skipped.

tests/e2e/seed-test-data.py (1)

1127-1179: Category and question ID alignment confirmed with backend implementation.

The seeding correctly uses category = 'discovery_state' (defined in schema CHECK constraint), current_question_id = 'problem_1' (first required question in DiscoveryQuestionFramework), and the exact question text. These values align with what LeadAgent._load_discovery_state() expects and will be properly restored from the memory table.

@frankbria frankbria force-pushed the feat/e2e-conditional-tests branch from acab61a to ef192ee Compare January 5, 2026 23:08
@claude
Copy link

claude bot commented Jan 5, 2026

Final Code Review - PR #191

I've reviewed the changes and my previous comments. The PR is in excellent shape! Here's my final assessment:

✅ Critical Issues - RESOLVED

1. Logic Error Fixed (test_task_execution_flow.spec.ts:111-115)
The critical assertion bug that CodeRabbit flagged has been fixed:

  • Line 111 correctly computes agentPanelVisible as a boolean
  • Line 115 assertion now properly evaluates agentPanelVisible || agentStatePanelVisible
  • ✅ This blocker has been resolved

✅ Excellent Improvements Confirmed

1. Critical Bug Fix (lead_agent.py:390-398)

  • ✅ Correctly changed discovery_contextdiscovery_state to match schema CHECK constraint
  • ✅ Clear comment explaining the rationale
  • ✅ Key renamed to context_project_description for clarity

2. Robust Test Data Seeding (seed-test-data.py:1127-1193)

  • ✅ Excellent strategy for UI testing without API dependency
  • ✅ Idempotent design prevents test pollution
  • ✅ Properly sets project phase to 'discovery'
  • ✅ Well-documented with clear comments

3. Smart Conditional Testing Pattern

  • HAS_API_KEY pattern is clean and maintainable
  • ✅ Test names clearly indicate when tests are skipped
  • ✅ 10 tests always run (UI verification), 2 tests conditional (API-dependent)
  • ✅ Graceful degradation in CI environments

4. Improved Test Helper (test-utils.ts:565-644)

  • ✅ Properly handles two-phase project creation (create + start)
  • startDiscovery parameter provides flexibility

💡 Minor Recommendations (Non-blocking)

1. Hard-coded Timeouts
Consider replacing fixed timeouts with event-based waits in future iterations:

  • test-utils.ts:641
  • test_task_execution_flow.spec.ts:170-171, 180-181

2. Error Context (test-utils.ts:637)
Could add project ID to error message for easier debugging

3. Assertion Preference
Many tests use .toBeAttached() instead of .toBeVisible(). For UI testing, .toBeVisible() is generally more meaningful as it verifies the element is actually visible to users, not just in the DOM.

🎯 Final Verdict

APPROVED ✅

Blockers: None - all critical issues resolved

Test Results: ✅ 12 passed with API key, 10 passed + 2 skipped without

This PR successfully:

  • ✅ Fixes the critical CHECK constraint bug that was blocking tests
  • ✅ Implements a robust conditional testing strategy
  • ✅ Adds comprehensive E2E coverage for task management
  • ✅ Maintains backward compatibility
  • ✅ Provides clear test documentation

Excellent work on the conditional testing strategy and comprehensive E2E coverage! The seeded data approach is particularly well-designed. 🎉

Copy link
Contributor

@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: 0

🧹 Nitpick comments (4)
tests/e2e/test_start_agent_flow.spec.ts (3)

176-178: Unused variable discoveryActive.

The discoveryActive locator is defined but never used. This appears to be leftover code from an earlier iteration.

🔎 Remove unused variable
-      // At this point, discovery should be started (either auto or via button)
-      // Verify that we see either:
-      // - Discovery question input
-      // - Discovery in progress indicator
-      // - Discovery complete message
-      const discoveryActive = page.locator('[data-testid="discovery-answer-input"]')
-        .or(page.locator('text=/discovery complete/i'))
-        .or(page.locator('text=/not started/i'));
-
       // Give some time for the state to update
       await page.waitForTimeout(1000);

141-141: Inconsistent URL construction.

Lines 141 and 196 use relative paths (/projects/${projectId}) while other navigations in this file use ${FRONTEND_URL}/projects/${projectId}. This inconsistency could cause issues if Playwright's base URL configuration differs.

🔎 Use consistent URL construction
-      await page.goto(`/projects/${projectId}`);
+      await page.goto(`${FRONTEND_URL}/projects/${projectId}`);

Also applies to: 196-196


109-109: Consider replacing fixed waits with explicit conditions.

Multiple waitForTimeout calls introduce potential flakiness. Consider replacing with explicit waits for state changes where possible.

For example, instead of await page.waitForTimeout(3000) after answering a question, wait for the next question or completion state:

await Promise.race([
  page.getByTestId('discovery-question').waitFor({ state: 'visible', timeout: 10000 }),
  page.getByTestId('prd-generated').waitFor({ state: 'visible', timeout: 10000 })
]);

Also applies to: 151-152, 168-169, 181-182

tests/e2e/test_complete_user_journey.spec.ts (1)

29-32: Consider importing FRONTEND_URL from shared config.

FRONTEND_URL is already exported from tests/e2e/e2e-config.ts (as shown in relevant snippets). Importing it would reduce duplication across test files.

🔎 Import from shared config
 import { test, expect } from '@playwright/test';
 import {
   answerDiscoveryQuestion,
   loginUser,
   createTestProject,
   setupErrorMonitoring,
   checkTestErrors,
   ExtendedPage
 } from './test-utils';
+import { FRONTEND_URL } from './e2e-config';

 // Check if API key is available for tests that require Claude API calls
 const HAS_API_KEY = !!process.env.ANTHROPIC_API_KEY;
-const FRONTEND_URL = process.env.FRONTEND_URL || 'http://localhost:3001';
 const PROJECT_ID = process.env.E2E_TEST_PROJECT_ID || '1';
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between acab61a and ef192ee.

📒 Files selected for processing (7)
  • codeframe/agents/lead_agent.py
  • tests/e2e/seed-test-data.py
  • tests/e2e/test-utils.ts
  • tests/e2e/test_checkpoint_ui.spec.ts
  • tests/e2e/test_complete_user_journey.spec.ts
  • tests/e2e/test_start_agent_flow.spec.ts
  • tests/e2e/test_task_execution_flow.spec.ts
🚧 Files skipped from review as they are similar to previous changes (4)
  • tests/e2e/test-utils.ts
  • tests/e2e/test_task_execution_flow.spec.ts
  • codeframe/agents/lead_agent.py
  • tests/e2e/seed-test-data.py
🧰 Additional context used
📓 Path-based instructions (1)
tests/e2e/**/*.ts

📄 CodeRabbit inference engine (CLAUDE.md)

Implement E2E tests using Playwright + TestSprite with loginUser() helper from tests/e2e/test-utils.ts for authentication

Files:

  • tests/e2e/test_start_agent_flow.spec.ts
  • tests/e2e/test_complete_user_journey.spec.ts
  • tests/e2e/test_checkpoint_ui.spec.ts
🧠 Learnings (4)
📓 Common learnings
Learnt from: CR
Repo: frankbria/codeframe PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-04T06:26:12.870Z
Learning: Applies to web-ui/src/app/page.tsx : Implement automatic project discovery start after project creation with loading state transitions and 'Start Discovery' button for idle projects
📚 Learning: 2026-01-04T06:26:12.870Z
Learnt from: CR
Repo: frankbria/codeframe PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-04T06:26:12.870Z
Learning: Applies to tests/e2e/**/*.ts : Implement E2E tests using Playwright + TestSprite with loginUser() helper from tests/e2e/test-utils.ts for authentication

Applied to files:

  • tests/e2e/test_start_agent_flow.spec.ts
  • tests/e2e/test_complete_user_journey.spec.ts
📚 Learning: 2026-01-04T06:26:12.870Z
Learnt from: CR
Repo: frankbria/codeframe PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-04T06:26:12.870Z
Learning: Applies to web-ui/src/lib/**/*.ts : Frontend API files must use const API_BASE_URL = process.env.NEXT_PUBLIC_API_URL || 'http://localhost:8080' pattern without hardcoded production URLs or different fallback ports

Applied to files:

  • tests/e2e/test_start_agent_flow.spec.ts
📚 Learning: 2026-01-04T06:26:12.870Z
Learnt from: CR
Repo: frankbria/codeframe PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-04T06:26:12.870Z
Learning: Applies to web-ui/src/app/page.tsx : Implement automatic project discovery start after project creation with loading state transitions and 'Start Discovery' button for idle projects

Applied to files:

  • tests/e2e/test_start_agent_flow.spec.ts
  • tests/e2e/test_checkpoint_ui.spec.ts
🧬 Code graph analysis (1)
tests/e2e/test_complete_user_journey.spec.ts (3)
tests/e2e/e2e-config.ts (1)
  • FRONTEND_URL (14-14)
tests/e2e/test-utils.ts (6)
  • setupErrorMonitoring (64-104)
  • ExtendedPage (25-27)
  • loginUser (483-500)
  • checkTestErrors (192-216)
  • createTestProject (580-645)
  • answerDiscoveryQuestion (687-719)
codeframe/cli/discovery_commands.py (1)
  • answer (159-216)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Frontend Unit Tests
  • GitHub Check: Backend Unit Tests
  • GitHub Check: claude-review
🔇 Additional comments (6)
tests/e2e/test_checkpoint_ui.spec.ts (1)

255-262: LGTM!

The changes correctly pass startDiscovery = false to createTestProject, aligning with the PR's goal of separating UI-only checkpoint verification from discovery startup. The inline comment clearly documents the intent.

tests/e2e/test_start_agent_flow.spec.ts (2)

27-30: LGTM - Clear conditional test gating.

The HAS_API_KEY pattern provides a clean way to conditionally run tests requiring Claude API calls while allowing UI-only tests to pass in CI.


58-78: LGTM - Good use of seeded data for CI-safe testing.

The test correctly uses seeded project data from seed-test-data.py and verifies the expected discovery question content, enabling reliable testing without API key dependency.

tests/e2e/test_complete_user_journey.spec.ts (3)

34-56: LGTM - Robust test lifecycle setup.

The error monitoring setup and transient error filtering provide good resilience against flaky failures from expected network behaviors (WebSocket reconnects, request cancellations during navigation).


58-102: LGTM - Comprehensive seeded-data UI verification.

This test provides solid CI coverage by validating authentication, discovery UI, dashboard panels, and tab navigation using pre-seeded data—no API key required.


104-198: LGTM - Well-structured conditional full-workflow test.

The test properly gates itself with test.skip(!HAS_API_KEY, ...) and covers the complete journey from project creation through PRD generation and dashboard verification. The multi-line answer template (lines 143-146) provides meaningful content for the discovery process.

One minor note: line 151 uses waitForTimeout(3000) which could be replaced with an explicit state wait (similar to the suggestion in test_start_agent_flow.spec.ts), but this is acceptable given the inherent variability of Claude API response times.

@frankbria frankbria force-pushed the feat/e2e-conditional-tests branch from ef192ee to 40e8572 Compare January 5, 2026 23:12
@claude
Copy link

claude bot commented Jan 5, 2026

Final Code Review - PR #191

I've reviewed the latest changes and confirmed that all critical issues have been resolved. This PR is ready to merge.

✅ Critical Bug Fixed - VERIFIED

Assertion Logic Error (test_task_execution_flow.spec.ts:111-115)

  • The blocker I flagged in my previous review has been fixed
  • Lines 111-112 now correctly compute both agentPanelVisible and agentStatePanelVisible as booleans
  • Line 115 properly evaluates the OR condition with two boolean values
  • This was previously mixing a Locator with a boolean, causing the test to always pass

✅ Core Improvements - All Excellent

1. Critical Backend Bug Fix (lead_agent.py:390-398)

  • ✅ Correctly changed discovery_contextdiscovery_state to match schema CHECK constraint
  • ✅ Clear explanatory comment added
  • ✅ Key renamed to context_project_description for clarity
  • This fix was essential - the old code violated the database schema constraint

2. Robust Test Data Seeding (seed-test-data.py:1127-1193)

  • ✅ Excellent strategy for UI testing without API dependency
  • ✅ Idempotent design (DELETE before INSERT)
  • ✅ Sets project phase to 'discovery' for UI consistency
  • ✅ Well-documented with clear comments explaining the purpose

3. Smart Conditional Testing Pattern

  • HAS_API_KEY pattern is clean and maintainable
  • ✅ Test names clearly indicate skip conditions
  • ✅ 10 tests always run (seeded data), 2 tests conditional (API-dependent)
  • ✅ Graceful degradation in CI environments

4. Improved Test Helper (test-utils.ts:565-644)

  • ✅ Properly handles two-phase project creation (create + start)
  • startDiscovery parameter provides flexibility
  • ✅ Clear documentation explaining the flow

💡 Minor Observations (Non-blocking)

These are minor points for potential future improvements, not blockers:

  1. Hard-coded timeouts: test-utils.ts:641 uses a fixed 2000ms timeout. Event-based waits would be more robust.
  2. Error context: test-utils.ts:637 could include the project ID in the error message for easier debugging.
  3. Assertion preference: Some tests use .toBeAttached() instead of .toBeVisible(). The latter is generally better for UI testing as it verifies actual visibility, not just DOM presence.

🎯 Final Verdict

APPROVED ✅ - Ready to Merge

Test Results: ✅ 12 passed with API key, 10 passed + 2 skipped without

This PR successfully:

  • ✅ Fixes the critical CHECK constraint bug blocking discovery tests
  • ✅ Implements a robust conditional testing strategy
  • ✅ Adds comprehensive E2E coverage for task management UI
  • ✅ Maintains backward compatibility
  • ✅ Provides excellent test documentation

The seeded data approach is particularly well-designed and will serve as a good pattern for future E2E tests. Excellent work! 🎉

Copy link
Contributor

@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

Fix all issues with AI Agents 🤖
In @tests/e2e/test_complete_user_journey.spec.ts:
- Around line 29-32: Replace the local FRONTEND_URL constant in
test_complete_user_journey.spec.ts with the exported one from ./e2e-config:
remove the local declaration "const FRONTEND_URL = process.env.FRONTEND_URL ||
'http://localhost:3001';" and import FRONTEND_URL from "./e2e-config" at the top
of the file so the test uses the single shared constant used by
playwright.config.ts.
🧹 Nitpick comments (3)
tests/e2e/test-utils.ts (1)

617-644: Consider timeout and error handling improvements.

The discovery start logic correctly implements auth-gated API calls with proper error handling. Consider two optional improvements:

  1. Request timeout: The POST request lacks an explicit timeout. In CI/slow network conditions, this could hang indefinitely.
  2. Response parsing safety: The error text extraction (line 636) assumes text response, which could fail for binary error responses.
🔎 Suggested improvements
    // Call the start endpoint to initialize LeadAgent and begin discovery
    const startResponse = await page.request.post(
      `${BACKEND_URL}/api/projects/${projectId}/start`,
      {
        headers: {
          'Authorization': `Bearer ${authToken}`,
          'Content-Type': 'application/json'
-        }
+        },
+        timeout: 30000  // 30s timeout for API call
      }
    );

    if (!startResponse.ok()) {
-      const errorText = await startResponse.text();
+      const errorText = await startResponse.text().catch(() => 'Unable to read error response');
      throw new Error(`Failed to start discovery: ${startResponse.status()} - ${errorText}`);
    }
tests/e2e/test_complete_user_journey.spec.ts (2)

47-55: Consider narrowing the 'discovery' error filter pattern.

The pattern 'discovery' at line 54 is very broad and could suppress legitimate discovery-related errors (e.g., "Discovery API failed" or "Discovery state error"). If the intent is to filter specific transient errors, use more precise patterns like 'discovery WebSocket' or 'discovery connection'.

🔎 Example: More specific patterns
   checkTestErrors(page, 'Complete user journey test', [
     'WebSocket', 'ws://', 'wss://',
     'net::ERR_ABORTED',
     'net::ERR_FAILED',
     'Failed to fetch',
     'Load request cancelled',
     'cancelled',
-    'discovery'
+    'discovery WebSocket', // Only filter WebSocket-related discovery errors
+    'discovery connection'  // Only filter connection-related discovery errors
   ]);

130-152: Replace hardcoded timeout with condition-based waiting.

The waitForTimeout(3000) at line 151 is a Playwright anti-pattern. Instead of waiting an arbitrary 3 seconds, wait for the specific UI condition that indicates the system is ready for the next question (e.g., the next question appearing or a loading indicator disappearing).

🔎 Suggested approach
       await answerDiscoveryQuestion(page, answer);

-      // Wait for processing and next question
-      await page.waitForTimeout(3000);
+      // Wait for either next question or discovery completion
+      await Promise.race([
+        page.getByTestId('discovery-question').waitFor({ state: 'visible', timeout: 10000 }),
+        page.getByTestId('prd-generated').waitFor({ state: 'visible', timeout: 10000 })
+      ]).catch(() => {
+        // Either condition met or timeout - continue
+      });
     }
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ef192ee and 40e8572.

📒 Files selected for processing (7)
  • codeframe/agents/lead_agent.py
  • tests/e2e/seed-test-data.py
  • tests/e2e/test-utils.ts
  • tests/e2e/test_checkpoint_ui.spec.ts
  • tests/e2e/test_complete_user_journey.spec.ts
  • tests/e2e/test_start_agent_flow.spec.ts
  • tests/e2e/test_task_execution_flow.spec.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • codeframe/agents/lead_agent.py
🧰 Additional context used
📓 Path-based instructions (1)
tests/e2e/**/*.ts

📄 CodeRabbit inference engine (CLAUDE.md)

Implement E2E tests using Playwright + TestSprite with loginUser() helper from tests/e2e/test-utils.ts for authentication

Files:

  • tests/e2e/test_start_agent_flow.spec.ts
  • tests/e2e/test-utils.ts
  • tests/e2e/test_checkpoint_ui.spec.ts
  • tests/e2e/test_complete_user_journey.spec.ts
  • tests/e2e/test_task_execution_flow.spec.ts
🧠 Learnings (7)
📓 Common learnings
Learnt from: CR
Repo: frankbria/codeframe PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-04T06:26:12.870Z
Learning: Applies to web-ui/src/app/page.tsx : Implement automatic project discovery start after project creation with loading state transitions and 'Start Discovery' button for idle projects
📚 Learning: 2026-01-04T06:26:12.870Z
Learnt from: CR
Repo: frankbria/codeframe PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-04T06:26:12.870Z
Learning: Applies to tests/e2e/**/*.ts : Implement E2E tests using Playwright + TestSprite with loginUser() helper from tests/e2e/test-utils.ts for authentication

Applied to files:

  • tests/e2e/test_start_agent_flow.spec.ts
  • tests/e2e/test-utils.ts
  • tests/e2e/test_complete_user_journey.spec.ts
  • tests/e2e/test_task_execution_flow.spec.ts
📚 Learning: 2026-01-04T06:26:12.870Z
Learnt from: CR
Repo: frankbria/codeframe PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-04T06:26:12.870Z
Learning: Applies to web-ui/src/lib/**/*.ts : Frontend API files must use const API_BASE_URL = process.env.NEXT_PUBLIC_API_URL || 'http://localhost:8080' pattern without hardcoded production URLs or different fallback ports

Applied to files:

  • tests/e2e/test_start_agent_flow.spec.ts
  • tests/e2e/test-utils.ts
📚 Learning: 2026-01-04T06:26:12.870Z
Learnt from: CR
Repo: frankbria/codeframe PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-04T06:26:12.870Z
Learning: Applies to web-ui/src/app/page.tsx : Implement automatic project discovery start after project creation with loading state transitions and 'Start Discovery' button for idle projects

Applied to files:

  • tests/e2e/test_start_agent_flow.spec.ts
  • tests/e2e/test-utils.ts
  • tests/e2e/test_checkpoint_ui.spec.ts
📚 Learning: 2025-11-25T19:08:37.203Z
Learnt from: CR
Repo: frankbria/codeframe PR: 0
File: docs/CLAUDE.md:0-0
Timestamp: 2025-11-25T19:08:37.203Z
Learning: Applies to docs/web-ui/**/__tests__/**/*.test.{ts,tsx} : Create JavaScript test files colocated or in __tests__/ as *.test.ts

Applied to files:

  • tests/e2e/test-utils.ts
  • tests/e2e/test_checkpoint_ui.spec.ts
  • tests/e2e/test_task_execution_flow.spec.ts
📚 Learning: 2025-11-25T19:08:54.154Z
Learnt from: CR
Repo: frankbria/codeframe PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-25T19:08:54.154Z
Learning: Applies to specs/*/tasks.md : Feature task files (tasks.md) must include phase-by-phase task breakdown with unique task identifiers (T001, T002, etc.), acceptance criteria per task, beads issue references, and estimated effort

Applied to files:

  • tests/e2e/test_task_execution_flow.spec.ts
📚 Learning: 2026-01-04T06:26:12.870Z
Learnt from: CR
Repo: frankbria/codeframe PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-04T06:26:12.870Z
Learning: Applies to web-ui/src/components/AgentStateProvider.tsx : Wrap AgentStateProvider with ErrorBoundary component for graceful error handling in Dashboard

Applied to files:

  • tests/e2e/test_task_execution_flow.spec.ts
🧬 Code graph analysis (3)
tests/e2e/test_start_agent_flow.spec.ts (2)
tests/e2e/e2e-config.ts (1)
  • FRONTEND_URL (14-14)
tests/e2e/test-utils.ts (2)
  • createTestProject (580-645)
  • answerDiscoveryQuestion (687-719)
tests/e2e/test-utils.ts (1)
tests/e2e/e2e-config.ts (1)
  • BACKEND_URL (11-11)
tests/e2e/test_complete_user_journey.spec.ts (3)
tests/e2e/e2e-config.ts (1)
  • FRONTEND_URL (14-14)
tests/e2e/test-utils.ts (6)
  • setupErrorMonitoring (64-104)
  • ExtendedPage (25-27)
  • loginUser (483-500)
  • checkTestErrors (192-216)
  • createTestProject (580-645)
  • answerDiscoveryQuestion (687-719)
codeframe/cli/discovery_commands.py (1)
  • answer (159-216)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Backend Unit Tests
  • GitHub Check: Frontend Unit Tests
  • GitHub Check: E2E Smoke Tests (Chromium)
🔇 Additional comments (19)
tests/e2e/seed-test-data.py (2)

1181-1194: LGTM!

The project phase update is correctly implemented with parameterized queries and appropriate error handling.


1127-1180: LGTM. Question text matches framework definition.

The discovery state seeding logic is well-structured with idempotent cleanup, parameterized queries, and per-entry error handling. The hard-coded question text for problem_1 ("What problem does this application solve?") matches the actual discovery framework definition in codeframe/discovery/questions.py.

tests/e2e/test_checkpoint_ui.spec.ts (1)

255-262: LGTM!

The explicit startDiscovery=false parameter correctly implements the UI-only test strategy, preventing unnecessary backend discovery initialization during checkpoint UI verification.

tests/e2e/test_task_execution_flow.spec.ts (6)

31-51: LGTM!

Test setup and teardown hooks properly initialize error monitoring, clear auth state, and filter transient network errors.


53-71: LGTM!

The test correctly verifies task panel visibility and the presence of task statistics elements.


73-97: LGTM!

The test appropriately validates that task statistics display numeric values, with a clear comment acknowledging potential API vs. seeded data differences.


99-116: LGTM!

The agent panel assertion correctly computes boolean visibility values for both panels before the logical OR check. The previous issue flagged in past reviews has been properly resolved.


118-147: LGTM!

The test appropriately verifies review findings panel presence with a conservative assertion strategy that accommodates variable backend data states.


149-197: LGTM!

The tab navigation test correctly implements conditional checks for optional tabs and verifies bidirectional navigation functionality.

tests/e2e/test_start_agent_flow.spec.ts (6)

27-30: LGTM!

The API key detection and frontend URL configuration correctly enable conditional test execution for Claude-dependent flows.


58-78: LGTM!

The test correctly leverages seeded discovery state to verify UI rendering without requiring live API calls, aligning with the PR's seeded-data strategy.


80-116: Verify timeout duration for PRD generation.

The conditional test correctly gates Claude API-dependent flows. However, the 15-second timeout for PRD generation (line 114) may be insufficient when Claude API calls are slow or rate-limited. Consider increasing the timeout or verifying that 3 answered questions are sufficient to trigger PRD generation.

💡 Suggested adjustment
-      await expect(page.getByTestId('prd-generated')).toBeVisible({ timeout: 15000 });
+      await expect(page.getByTestId('prd-generated')).toBeVisible({ timeout: 30000 });

118-129: LGTM!

The test correctly opts out of discovery initialization for a UI-focused agent panel verification, consistent with the seeded-data approach.


131-186: LGTM!

The test appropriately handles both automatic and manual discovery initialization flows with flexible locator patterns and conditional logic. The multiple fallback strategies accommodate variable UI states.


188-215: LGTM!

The test correctly verifies that the UI handles already-in-progress discovery without displaying start errors, using appropriate conditional assertions.

tests/e2e/test-utils.ts (2)

13-13: LGTM!

The BACKEND_URL import enables the discovery start API call functionality.


565-584: LGTM!

The function signature update maintains backward compatibility with startDiscovery = true default, and the JSDoc clearly documents the two-step flow.

tests/e2e/test_complete_user_journey.spec.ts (2)

104-108: Excellent conditional test pattern.

The approach of using a conditional test name and explicit test.skip() provides clear visibility in test reports. When the API key is unavailable, the test name itself explains why it's skipped, which improves the developer experience.


58-102: Well-structured seeded data test.

The test effectively verifies the UI using pre-seeded data and includes defensive checks for optional elements like tabs. The approach of separating UI verification (this test) from full API-dependent workflows (the conditional test) aligns well with the test strategy described in the PR objectives.

- Fix createTestProject to call /api/projects/{id}/start endpoint
- Fix lead_agent.py CHECK constraint bug (discovery_context → discovery_state)
- Add discovery state seeding in seed-test-data.py
- Enable previously-skipped tests with conditional API key execution
- Create test_task_execution_flow.spec.ts for task management UI
- Update tests to remove redundant navigation after project creation

Tests now run conditionally based on ANTHROPIC_API_KEY availability:
- With API key: 12 passed (full discovery + PRD flow)
- Without API key: 10 passed, 2 skipped (graceful CI behavior)
@frankbria frankbria force-pushed the feat/e2e-conditional-tests branch from 40e8572 to 0360e55 Compare January 5, 2026 23:17
@claude
Copy link

claude bot commented Jan 5, 2026

Final Code Review - PR #191

I've reviewed this PR and all previous review comments. The code is in excellent shape and ready to merge.

Summary

This PR successfully fixes critical E2E test failures through:

  1. Database constraint bug fix - Correcting discovery_contextdiscovery_state
  2. Conditional testing strategy - Enabling tests to run with/without API keys
  3. Test data seeding - Supporting UI tests without live API calls
  4. Improved test infrastructure - Better error handling and test utilities

✅ Critical Issues - All Resolved

1. Schema Constraint Bug (lead_agent.py:390-398)

  • Correctly changed discovery_context to discovery_state to match schema CHECK constraint
  • Schema only allows: pattern, decision, gotcha, preference, conversation, discovery_state, discovery_answers, prd
  • Clear explanatory comment added
  • Key renamed to context_project_description for clarity
  • Status: Fixed

2. Logic Error (test_task_execution_flow.spec.ts:111-115)

  • The critical assertion bug flagged by CodeRabbit has been fixed
  • Lines 111-112 now correctly compute both agentPanelVisible and agentStatePanelVisible as booleans
  • Line 115 properly evaluates the OR condition with two boolean values
  • Status: Fixed

🎯 Excellent Implementation

1. Robust Test Data Seeding (seed-test-data.py:1127-1193)

  • Excellent strategy for UI testing without API dependency
  • Idempotent design (clears before inserting) prevents test pollution
  • Properly sets project phase to 'discovery' for UI consistency
  • Well-documented with clear comments
  • Seeds 3 discovery state entries correctly

2. Smart Conditional Testing Pattern

  • Clean HAS_API_KEY implementation for conditional execution
  • Test names clearly indicate when tests are skipped
  • 10 tests always run (UI verification), 2 tests conditional (API-dependent)
  • Graceful degradation in CI environments without API keys
  • Test results: ✅ 12 passed with API key, 10 passed + 2 skipped without

3. Improved Test Helper (test-utils.ts:565-644)

  • Properly handles two-phase project creation (create + start)
  • startDiscovery parameter provides flexibility for UI-only tests
  • Correctly authenticates before calling start endpoint
  • Good error messages with response status codes

4. Comprehensive E2E Coverage (test_task_execution_flow.spec.ts)

  • Task list visibility and navigation
  • Task statistics validation (numeric checks)
  • Agent panel verification
  • Review findings display
  • Dashboard tab navigation
  • All tests use seeded data appropriately

📊 Code Quality Assessment

Category Rating Notes
Correctness ✅ Excellent Critical bug fixed, tests passing
Test Coverage ✅ Excellent 12 E2E tests covering key workflows
Documentation ✅ Good Clear comments explaining fixes
Error Handling ✅ Good Proper error messages and monitoring
Maintainability ✅ Excellent Clean separation of seeded vs API tests

💡 Minor Recommendations (Non-blocking)

These are suggestions for future improvements, not blockers:

  1. Hard-coded Timeouts - Consider replacing fixed timeouts with event-based waits:

    • test-utils.ts:641 (waitForTimeout(2000))
    • test_task_execution_flow.spec.ts:170-171, 180-181
  2. Error Context - Could add project ID to error message at test-utils.ts:637

  3. Assertion Preference - Many tests use .toBeAttached() instead of .toBeVisible(). For UI testing, .toBeVisible() is generally more meaningful as it verifies elements are actually visible to users.

  4. Test Data Hardcoding - Question text at seed-test-data.py:1156 is hardcoded and could drift from source. Consider importing from DiscoveryQuestionFramework.

🔒 Security & Performance

Security: ✅ No concerns

  • Auth properly handled with JWT tokens
  • Proper error handling prevents information leakage

Performance: ✅ Good

  • Test execution time is reasonable
  • Seeded data strategy reduces API calls

Final Verdict

APPROVED FOR MERGE

Blockers: None - all critical issues resolved

Test Results:

  • ✅ With API key: 12 tests passed
  • ✅ Without API key (CI): 10 tests passed, 2 skipped (as expected)

This PR successfully:

  • ✅ Fixes the critical CHECK constraint bug blocking tests
  • ✅ Implements a robust conditional testing strategy
  • ✅ Adds comprehensive E2E coverage for task management
  • ✅ Maintains backward compatibility
  • ✅ Provides clear test documentation and error handling

Excellent work on the conditional testing strategy! The seeded data approach is particularly well-designed and will make the E2E test suite much more reliable in CI environments. 🎉


Review conducted by Claude Code - consistent with previous review findings

Copy link
Contributor

@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

Fix all issues with AI Agents 🤖
In @tests/e2e/test_task_execution_flow.spec.ts:
- Around line 144-146: Remove the duplicate assertion
expect(reviewPanel).toBeAttached() that repeats an identical check already
performed earlier in the test; locate the redundant call that follows the
comment "// The review panel is attached, which is sufficient for this test" and
delete that extra expect(reviewPanel).toBeAttached() so the test only asserts
attachment once using the existing reviewPanel variable.
🧹 Nitpick comments (4)
tests/e2e/test_task_execution_flow.spec.ts (1)

168-182: Consider replacing arbitrary timeouts with element-based waits.

The use of page.waitForTimeout(1000) on lines 171 and 181 is an anti-pattern in Playwright tests. Instead of arbitrary delays, wait for specific panel elements to be visible or for network activity to settle (e.g., waitForLoadState('networkidle')).

🔎 Proposed refactor
     if (hasQualityGatesTab) {
       await qualityGatesTab.click();
-      // Verify quality gates panel loads
-      await page.waitForTimeout(1000);
+      // Wait for quality gates panel content to load
+      await page.waitForLoadState('networkidle');
     }
 
     // Navigate to Metrics tab (if exists)
     const metricsTab = page.locator('[data-testid="metrics-tab"]');
     const hasMetricsTab = await metricsTab.isVisible().catch(() => false);
 
     if (hasMetricsTab) {
       await metricsTab.click();
-      // Verify metrics content loads
-      await page.waitForTimeout(1000);
+      // Wait for metrics content to load
+      await page.waitForLoadState('networkidle');
     }
tests/e2e/test_start_agent_flow.spec.ts (3)

27-29: Consider importing FRONTEND_URL from ./e2e-config.

e2e-config.ts exports FRONTEND_URL with the same fallback value. Importing it would maintain a single source of truth, consistent with how playwright.config.ts uses this constant.

🔎 Proposed fix
 import {
   createTestProject,
   answerDiscoveryQuestion,
   loginUser,
   setupErrorMonitoring,
   checkTestErrors,
   ExtendedPage
 } from './test-utils';
+import { FRONTEND_URL } from './e2e-config';

 // Check if API key is available for tests that require Claude API calls
 const HAS_API_KEY = !!process.env.ANTHROPIC_API_KEY;
-const FRONTEND_URL = process.env.FRONTEND_URL || 'http://localhost:3001';

58-78: Missing PROJECT_ID constant declaration.

Line 61 uses process.env.E2E_TEST_PROJECT_ID || '1' inline, but a PROJECT_ID constant (like in test_complete_user_journey.spec.ts) would improve consistency and readability.

🔎 Proposed fix
 // Check if API key is available for tests that require Claude API calls
 const HAS_API_KEY = !!process.env.ANTHROPIC_API_KEY;
 const FRONTEND_URL = process.env.FRONTEND_URL || 'http://localhost:3001';
+const PROJECT_ID = process.env.E2E_TEST_PROJECT_ID || '1';

Then update line 61:

-    const projectId = process.env.E2E_TEST_PROJECT_ID || '1';
+    const projectId = PROJECT_ID;

140-141: Consider using FRONTEND_URL for consistency with other navigation calls.

Line 141 uses a relative URL /projects/${projectId} while line 64 uses ${FRONTEND_URL}/projects/${projectId}. Using the same pattern throughout the file improves consistency.

🔎 Proposed fix
-      await page.goto(`/projects/${projectId}`);
+      await page.goto(`${FRONTEND_URL}/projects/${projectId}`);
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 40e8572 and 0360e55.

📒 Files selected for processing (7)
  • codeframe/agents/lead_agent.py
  • tests/e2e/seed-test-data.py
  • tests/e2e/test-utils.ts
  • tests/e2e/test_checkpoint_ui.spec.ts
  • tests/e2e/test_complete_user_journey.spec.ts
  • tests/e2e/test_start_agent_flow.spec.ts
  • tests/e2e/test_task_execution_flow.spec.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • tests/e2e/test-utils.ts
  • tests/e2e/seed-test-data.py
🧰 Additional context used
📓 Path-based instructions (2)
tests/e2e/**/*.ts

📄 CodeRabbit inference engine (CLAUDE.md)

Implement E2E tests using Playwright + TestSprite with loginUser() helper from tests/e2e/test-utils.ts for authentication

Files:

  • tests/e2e/test_task_execution_flow.spec.ts
  • tests/e2e/test_complete_user_journey.spec.ts
  • tests/e2e/test_checkpoint_ui.spec.ts
  • tests/e2e/test_start_agent_flow.spec.ts
codeframe/**/*.py

📄 CodeRabbit inference engine (CLAUDE.md)

codeframe/**/*.py: Use Python 3.11+ for backend development with FastAPI, AsyncAnthropic, SQLite with async support (aiosqlite), and tiktoken for token counting
Use token counting via tiktoken library for token budget management with ~50,000 token limit per conversation
Use asyncio patterns with AsyncAnthropic for async/await in Python backend for concurrent operations
Implement quality gates with multi-stage pre-completion checks (tests → type → coverage → review) and Git + SQLite + context snapshots for project state rollback
Use tiered memory system (HOT/WARM/COLD) with importance scoring using hybrid exponential decay algorithm for context management with 30-50% token reduction
Implement session lifecycle management with auto-save/restore using file-based storage at .codeframe/session_state.json

Files:

  • codeframe/agents/lead_agent.py
🧠 Learnings (7)
📓 Common learnings
Learnt from: CR
Repo: frankbria/codeframe PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-04T06:26:12.870Z
Learning: Applies to web-ui/src/app/page.tsx : Implement automatic project discovery start after project creation with loading state transitions and 'Start Discovery' button for idle projects
📚 Learning: 2026-01-04T06:26:12.870Z
Learnt from: CR
Repo: frankbria/codeframe PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-04T06:26:12.870Z
Learning: Applies to tests/e2e/**/*.ts : Implement E2E tests using Playwright + TestSprite with loginUser() helper from tests/e2e/test-utils.ts for authentication

Applied to files:

  • tests/e2e/test_task_execution_flow.spec.ts
  • tests/e2e/test_complete_user_journey.spec.ts
  • tests/e2e/test_start_agent_flow.spec.ts
📚 Learning: 2025-11-25T19:08:37.203Z
Learnt from: CR
Repo: frankbria/codeframe PR: 0
File: docs/CLAUDE.md:0-0
Timestamp: 2025-11-25T19:08:37.203Z
Learning: Applies to docs/web-ui/**/__tests__/**/*.test.{ts,tsx} : Create JavaScript test files colocated or in __tests__/ as *.test.ts

Applied to files:

  • tests/e2e/test_task_execution_flow.spec.ts
  • tests/e2e/test_checkpoint_ui.spec.ts
📚 Learning: 2025-11-25T19:08:54.154Z
Learnt from: CR
Repo: frankbria/codeframe PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-25T19:08:54.154Z
Learning: Applies to specs/*/tasks.md : Feature task files (tasks.md) must include phase-by-phase task breakdown with unique task identifiers (T001, T002, etc.), acceptance criteria per task, beads issue references, and estimated effort

Applied to files:

  • tests/e2e/test_task_execution_flow.spec.ts
📚 Learning: 2026-01-04T06:26:12.870Z
Learnt from: CR
Repo: frankbria/codeframe PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-04T06:26:12.870Z
Learning: Applies to web-ui/src/components/AgentStateProvider.tsx : Wrap AgentStateProvider with ErrorBoundary component for graceful error handling in Dashboard

Applied to files:

  • tests/e2e/test_task_execution_flow.spec.ts
📚 Learning: 2026-01-04T06:26:12.870Z
Learnt from: CR
Repo: frankbria/codeframe PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-04T06:26:12.870Z
Learning: Applies to web-ui/src/lib/**/*.ts : Frontend API files must use const API_BASE_URL = process.env.NEXT_PUBLIC_API_URL || 'http://localhost:8080' pattern without hardcoded production URLs or different fallback ports

Applied to files:

  • tests/e2e/test_complete_user_journey.spec.ts
  • tests/e2e/test_start_agent_flow.spec.ts
📚 Learning: 2026-01-04T06:26:12.870Z
Learnt from: CR
Repo: frankbria/codeframe PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-04T06:26:12.870Z
Learning: Applies to web-ui/src/app/page.tsx : Implement automatic project discovery start after project creation with loading state transitions and 'Start Discovery' button for idle projects

Applied to files:

  • tests/e2e/test_checkpoint_ui.spec.ts
  • tests/e2e/test_start_agent_flow.spec.ts
🧬 Code graph analysis (3)
codeframe/agents/lead_agent.py (1)
codeframe/persistence/database.py (1)
  • create_memory (502-504)
tests/e2e/test_complete_user_journey.spec.ts (2)
tests/e2e/test-utils.ts (5)
  • setupErrorMonitoring (64-104)
  • ExtendedPage (25-27)
  • loginUser (483-500)
  • checkTestErrors (192-216)
  • createTestProject (580-645)
tests/e2e/e2e-config.ts (1)
  • FRONTEND_URL (14-14)
tests/e2e/test_start_agent_flow.spec.ts (2)
tests/e2e/e2e-config.ts (1)
  • FRONTEND_URL (14-14)
tests/e2e/test-utils.ts (2)
  • createTestProject (580-645)
  • answerDiscoveryQuestion (687-719)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: Backend Unit Tests
  • GitHub Check: Frontend Unit Tests
  • GitHub Check: E2E Smoke Tests (Chromium)
  • GitHub Check: claude-review
🔇 Additional comments (13)
tests/e2e/test_task_execution_flow.spec.ts (4)

1-29: LGTM! Well-documented test structure.

The imports and configuration follow the E2E testing guidelines correctly. The header documentation clearly describes the test coverage, seeded data expectations, and authentication approach.


31-51: LGTM! Proper test setup with error handling.

The beforeEach and afterEach hooks correctly implement test isolation, error monitoring, and transient error filtering for network-related issues common in E2E tests.


53-97: LGTM! Thorough task statistics validation.

These tests appropriately separate concerns: the first verifies element presence, the second validates numeric content using regex patterns. The comment acknowledging potential API data variance is a good practice.


99-116: LGTM! Previous logic error has been fixed.

The agent panel visibility check now correctly computes boolean values for both panels before the assertion. This resolves the issue flagged in the previous review where a Locator object was mixed with a boolean.

codeframe/agents/lead_agent.py (1)

390-398: LGTM! Correct fix for the CHECK constraint violation.

The change from discovery_context to discovery_state category aligns with the database schema's allowed values. The key rename to context_project_description clearly indicates this is context data within the discovery state.

tests/e2e/test_checkpoint_ui.spec.ts (1)

255-262: LGTM! Correct use of the new startDiscovery parameter.

Passing startDiscovery=false is appropriate for this UI-focused checkpoint test, avoiding unnecessary API calls and making the test faster and more reliable.

tests/e2e/test_start_agent_flow.spec.ts (3)

80-116: Good implementation of conditional test execution.

The pattern using HAS_API_KEY ? 'test name' : 'skip: reason' combined with test.skip(!HAS_API_KEY, ...) provides clear visibility in test reports while properly gating API-dependent tests.


118-129: LGTM! Correct use of startDiscovery=false for UI-only test.

The test verifies the agent status panel exists without requiring discovery, making it faster and suitable for CI without an API key.


188-215: Good defensive test for discovery error handling.

The test correctly verifies that no error alerts appear during discovery initialization. The conditional gating with HAS_API_KEY ensures this test only runs when API calls can succeed.

tests/e2e/test_complete_user_journey.spec.ts (4)

28-32: Good fix: FRONTEND_URL is now imported from ./e2e-config.

This addresses the previous review comment and maintains a single source of truth for the frontend URL configuration.


36-56: LGTM! Well-structured test lifecycle with error monitoring.

The beforeEach/afterEach pattern correctly sets up error monitoring and filters transient errors that are expected during E2E tests (WebSocket reconnects, navigation-cancelled requests, etc.).


58-102: LGTM! Comprehensive UI verification test using seeded data.

This test provides excellent coverage of the dashboard UI without requiring API calls, making it reliable for CI environments. The defensive .catch(() => false) pattern handles optional UI elements gracefully.


104-198: LGTM! Well-designed conditional full workflow test.

The test provides comprehensive end-to-end coverage when an API key is available:

  • Creates projects with unique names for isolation
  • Uses meaningful discovery answers to generate quality PRDs
  • Verifies multiple dashboard panels and navigation
  • Handles optional UI elements defensively

The generous timeouts (15-20s) are appropriate for Claude API response times.

Comment on lines +144 to +146
// The review panel is attached, which is sufficient for this test
// Actual findings display depends on the backend data state
expect(reviewPanel).toBeAttached();
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Remove redundant assertion.

Line 146 duplicates the assertion already made on Line 134. Since the comment states that panel attachment is sufficient for this test, the duplicate assertion on Line 146 should be removed.

🔎 Proposed fix
-    // The review panel is attached, which is sufficient for this test
-    // Actual findings display depends on the backend data state
-    expect(reviewPanel).toBeAttached();
+    // The review panel is attached, which is sufficient for this test
+    // Actual findings display depends on the backend data state
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// The review panel is attached, which is sufficient for this test
// Actual findings display depends on the backend data state
expect(reviewPanel).toBeAttached();
// The review panel is attached, which is sufficient for this test
// Actual findings display depends on the backend data state
🤖 Prompt for AI Agents
In @tests/e2e/test_task_execution_flow.spec.ts around lines 144-146, Remove the
duplicate assertion expect(reviewPanel).toBeAttached() that repeats an identical
check already performed earlier in the test; locate the redundant call that
follows the comment "// The review panel is attached, which is sufficient for
this test" and delete that extra expect(reviewPanel).toBeAttached() so the test
only asserts attachment once using the existing reviewPanel variable.

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.

1 participant