Skip to content

feat: add e2e tests for scheduled sessions and fix edit form workflow state#1221

Open
tiwillia wants to merge 5 commits intoambient-code:mainfrom
tiwillia:e2e-scheduled-sessions
Open

feat: add e2e tests for scheduled sessions and fix edit form workflow state#1221
tiwillia wants to merge 5 commits intoambient-code:mainfrom
tiwillia:e2e-scheduled-sessions

Conversation

@tiwillia
Copy link
Copy Markdown
Contributor

@tiwillia tiwillia commented Apr 6, 2026

Summary

  • Adds Cypress e2e tests for scheduled sessions: creation (preset and custom cron), cron validation (client-side and server-side), schedule update, deletion, and custom workflow create/edit flows
  • Fixes a bug where editing a scheduled session with a custom workflow showed "Select workflow..." instead of pre-populating the workflow fields — caused by a two-phase render race with Radix Select
  • Restores OOTB workflow reverse-matching on edit: if the stored workflow fields match an OOTB workflow, the dropdown shows the OOTB name (e.g., "Fix a bug") instead of "Custom workflow..."
  • Uses a workflowResolved state guard to keep the workflow Skeleton visible until resolution completes, ensuring Radix Select never sees a post-mount value change
  • Adds data-testid attributes to scheduled session form and list components for stable test selectors

Test plan

  • All 10 e2e tests pass against Kind deployment (create preset/custom cron, client/server cron validation, schedule update, custom workflow create/edit, OOTB workflow edit, no-workflow edit, deletion)
  • Verify scheduled session create/edit/delete flows manually
  • Confirm edit form pre-populates custom workflow fields correctly for custom workflows
  • Confirm edit form shows OOTB workflow name when session was created with an OOTB workflow
  • Confirm edit form shows "General chat" when session has no workflow

Summary by CodeRabbit

Release Notes

This release focuses on testing infrastructure and internal improvements with no user-facing changes.

  • Tests
    • Added comprehensive end-to-end test suite covering scheduled sessions workflows, including creation, validation, updates, and deletion
    • Enhanced testability across scheduled sessions components with improved test identifiers

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 6, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: c8756237-b652-4d22-8c63-1f307dee2d7e

📥 Commits

Reviewing files that changed from the base of the PR and between f86351f and fcd9d16.

📒 Files selected for processing (3)
  • components/frontend/src/app/projects/[name]/scheduled-sessions/_components/scheduled-session-form.tsx
  • components/frontend/src/components/workspace-sections/scheduled-sessions-tab.tsx
  • e2e/cypress/e2e/scheduled-sessions.cy.ts
✅ Files skipped from review due to trivial changes (2)
  • components/frontend/src/components/workspace-sections/scheduled-sessions-tab.tsx
  • e2e/cypress/e2e/scheduled-sessions.cy.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • components/frontend/src/app/projects/[name]/scheduled-sessions/_components/scheduled-session-form.tsx

📝 Walkthrough

Walkthrough

Eagerly initialize ScheduledSessionForm workflow-related state from incoming edit-mode data, add data-testid attributes across scheduled sessions UI and form controls, and introduce a comprehensive Cypress E2E spec covering scheduled-session create/validate/update/delete flows.

Changes

Cohort / File(s) Summary
Scheduled Session Form
components/frontend/src/app/projects/[name]/scheduled-sessions/_components/scheduled-session-form.tsx
Changed workflow state initialization to derive selectedWorkflow and custom git fields immediately from initialData.sessionTemplate.activeWorkflow (or defaults). workflowResolved now reflects presence of activeWorkflow; the effect that waited on OOTB workflows only runs while OOTB loading and stops once resolved. Tightened workflow matching logic formatting. Added data-testid attributes to multiple form inputs, selects, cron preview, skeleton-guarded sections, and action buttons.
Scheduled Sessions UI Test IDs
components/frontend/src/components/workspace-sections/scheduled-sessions-tab.tsx
Added data-testid attributes to the "New Scheduled Session" link/button, per-row TableRow elements, per-row actions menu trigger buttons, and delete dropdown items. No behavioral changes.
End-to-End Tests (Cypress)
e2e/cypress/e2e/scheduled-sessions.cy.ts
Added new E2E spec with workspace provisioning/cleanup helpers and tests covering scheduled-session creation (preset & custom cron), cron validation (client/server), schedule updates, custom workflow scenarios (create/edit/match-to-OOTB), and deletion. Includes API helpers, global error suppression for specific React hydration/minified errors, and follow-up API verifications.
🚥 Pre-merge checks | ✅ 5 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed Title follows Conventional Commits format (feat: scope and description) and accurately summarizes both main changes: e2e test suite and workflow state fix.
Performance And Algorithmic Complexity ✅ Passed PR optimizes workflow state initialization with workflowResolved guard preventing unnecessary Radix Select re-renders. All useEffect hooks have complete dependency arrays with early-return guards. resolveWorkflowState uses bounded .find() on small collection. E2E test polling is explicitly limited to 30 attempts with no N+1 patterns.
Security And Secret Handling ✅ Passed PR demonstrates proper security practices: TEST_TOKEN from environment variables, mock secrets use placeholders, backend includes auth checks via checkScheduledSessionAccess(), frontend forms have no hardcoded credentials with Zod validation, no sensitive data logged.
Kubernetes Resource Safety ✅ Passed PR contains exclusively frontend component and E2E test changes with no modifications to Kubernetes manifests, RBAC configurations, or infrastructure-as-code.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
✨ Simplify code
  • Create PR with simplified code

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.

tiwillia added 4 commits April 6, 2026 13:51
Add Cypress e2e tests covering scheduled session CRUD operations:
create with preset schedule, create with custom cron, client-side and
server-side cron validation, schedule update, and deletion.

Add data-testid attributes to the scheduled session form and list
components for reliable test targeting.
Add tests for creating a scheduled session with a custom workflow and
editing an existing custom workflow. The edit test verifies pre-populated
workflow fields, which reproduces a known bug where custom workflows
do not appear on the edit screen.

Add data-testid attributes to workflow form elements (select, git URL,
branch, path inputs).
The scheduled session edit form showed "Select workflow..." (Radix
Select placeholder) instead of "Custom workflow..." with pre-populated
fields when editing a session with a custom workflow.

Root cause: workflow state was initialized to defaults ("none", "", etc.)
in useState, then updated via useEffect after OOTB workflows loaded.
This caused a timing issue where the Radix Select value changed after
mount, leaving the placeholder visible.

Fix: initialize workflow state directly from initialData in the useState
call so the correct values are set from the first render. The useEffect
and resolveWorkflowState function are no longer needed.

Note: this removes OOTB workflow reverse-matching on the edit page.
Sessions originally created via an OOTB workflow selection will now
show as "Custom workflow..." with the raw gitUrl/branch/path fields.
This is acceptable because the backend only stores the raw fields (not
which OOTB was selected), and showing the actual values is more
transparent for editing.
…t guard

Re-introduce resolveWorkflowState to match stored workflow fields against
OOTB workflows when editing a scheduled session. Uses a workflowResolved
state guard to keep the Skeleton visible until resolution completes,
ensuring Radix Select never sees a post-mount value change.

Adds e2e tests for OOTB workflow edit (verifies name shown), no-workflow
edit (verifies "General chat"), and updates the custom workflow edit test
to use non-OOTB fields.
@tiwillia tiwillia force-pushed the e2e-scheduled-sessions branch from 563b9e6 to 64eed9f Compare April 6, 2026 17:51
@tiwillia
Copy link
Copy Markdown
Contributor Author

tiwillia commented Apr 6, 2026

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 6, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@ambient-code ambient-code bot added this to the Review Queue milestone Apr 7, 2026
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