Skip to content

[fix] Scope web-test cleanup and render messages once - #6581

Merged
mmabrouk merged 1 commit into
release/v0.115.0from
fix/release-115-safe-web-tests
Sep 5, 2026
Merged

[fix] Scope web-test cleanup and render messages once#6581
mmabrouk merged 1 commit into
release/v0.115.0from
fix/release-115-safe-web-tests

Conversation

@mmabrouk

@mmabrouk mmabrouk commented Sep 5, 2026

Copy link
Copy Markdown
Member

Context

The web acceptance teardown restored the account's persistent default project, deleted its ephemeral test project, then listed secrets without a project scope and deleted every provider whose name contained openai. A release QA run therefore deleted a persistent browser QA credential after the test project was already gone. Setup could also record a fallback default project in the same metadata shape as an ephemeral project, while teardown treated every recorded ID as test-owned.

The Members acceptance cases depended on removed Ant Design classes. Once those selectors were corrected, the focused browser run exposed two identical success toasts and two identical destructive confirmation dialogs. The desktop app mounted the global app-message outlet in both _app and Layout, although the outlet contract requires one mount.

Changes

Setup now records whether a project is ephemeral. Teardown sends DELETE only for an explicitly owned ephemeral project, relies on project deletion to cascade its secrets, and retains metadata after a failed deletion so a later run can retry. It no longer scans or deletes credentials in the restored project.

The Members cases select rows and actions by accessible roles, wait for the exact resend and remove responses, and require one toast and one alert dialog. The app keeps the original _app message outlet and removes the newer duplicate from Layout.

Before, teardown could issue DELETE /secrets/<persistent-id> after restoring the original project, and one message or modal call rendered twice. After this change, its only remote cleanup is an owned DELETE /projects/<ephemeral-id>, and each app-message action has one renderer.

How to review

  1. Read the setup metadata writer and confirm only a successfully created project gets ephemeral: true.
  2. Read teardown and confirm it guards DELETE on that marker and retains metadata when cleanup fails.
  3. Check that _app remains the sole app-message outlet and Layout no longer adds another.
  4. Check the Members locators and response waits against the actions they prove.
  5. Confirm the README describes the remaining teardown behavior.

Tests

  • pnpm exec tsx --test tests/playwright/global-teardown.test.ts (3/3 passed)
  • pnpm lint-fix (25/25 tasks passed)
  • git diff --check
  • Focused staging run before the source fix: invite passed in 2.5 seconds; resend passed in 3.7 seconds; remove exposed two identical dialogs and identified the duplicate outlets.
  • Exact-source local browser run after the fix: invite reached Pending, resend returned HTTP 200, remove showed exactly one alert dialog, DELETE returned HTTP 200, and the row disappeared. The strict staging 3/3 rerun follows the preview deploy.

@vercel

vercel Bot commented Sep 5, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated
agenta-documentation Ready Ready Preview Sep 5, 2026 3:36pm UTC

Request Review

@coderabbitai

coderabbitai Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Summary

Summary by CodeRabbit

  • Bug Fixes

    • Improved member acceptance test reliability across tables, menus, and invitation-resend responses.
    • Updated success-message validation for resent invitations and pending-member status checks.
  • Documentation

    • Updated end-to-end testing guidance to reflect current teardown behavior.
  • Chores

    • Improved test cleanup to safely remove only explicitly temporary projects and retain metadata when deletion fails.
    • Removed model hub secret cleanup from test teardown.
    • Removed the unused application message provider from the layout.

Walkthrough

The changes update member acceptance tests, record ephemeral project ownership, and make teardown delete only owned ephemeral projects. Teardown tests cover success and failure paths. The layout no longer mounts AppMessageContext.

Changes

Member acceptance tests

Layer / File(s) Summary
Accessible member interactions
web/ee/tests/playwright/acceptance/members/index.ts
Member rows and action menus use role-based locators. Resend actions validate the POST response and exact success text. Pending rows require exact "Pending" text. Remove actions target the exact "Remove" menu item.

Ephemeral project lifecycle

Layer / File(s) Summary
Ephemeral project metadata
web/tests/playwright/global-setup.ts
Project metadata records whether the project is ephemeral across creation, fallback, and failure paths.
Ephemeral project teardown
web/tests/playwright/global-teardown.ts, web/tests/playwright/global-teardown.test.ts, web/tests/README.md
Teardown skips non-ephemeral projects, handles restore and deletion responses, retains metadata after failures, and removes model hub secret cleanup. Tests cover these paths. The guide describes ephemeral project deletion.

Layout message provider removal

Layer / File(s) Summary
AppMessageContext removal
web/oss/src/components/Layout/Layout.tsx
The layout no longer imports or mounts AppMessageContext.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: 🔵 Low · up to f03d6

Cleanup now preserves fallback persistent projects and deletes only explicitly owned ephemeral projects. A transient setup failure before successful project creation can still leave an ephemeral test project undeleted on retry, creating bounded test-environment resource leakage.

Sequence Diagram(s)

sequenceDiagram
  participant PlaywrightTeardown
  participant ProjectMetadata
  participant API
  participant Filesystem
  PlaywrightTeardown->>ProjectMetadata: Read ephemeral ownership
  PlaywrightTeardown->>API: Restore the original default project
  PlaywrightTeardown->>API: Delete the ephemeral project
  PlaywrightTeardown->>Filesystem: Remove metadata after successful deletion
  PlaywrightTeardown->>Filesystem: Retain metadata after failed deletion
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 60.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 6 functions across 4 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the two main changes: scoping web-test cleanup and ensuring messages render once.
Description check ✅ Passed The description directly explains the teardown ownership changes, Members test updates, duplicate message outlet removal, and validation performed.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/release-115-safe-web-tests

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.

@mmabrouk
mmabrouk force-pushed the fix/release-115-safe-web-tests branch from 9623c13 to 64902a6 Compare September 5, 2026 15:13
@mmabrouk

mmabrouk commented Sep 5, 2026

Copy link
Copy Markdown
Member Author

🤖 The AI agent says:

@coderabbitai review

Please focus on teardown project ownership and whether each Members locator proves the intended action.

@mmabrouk

mmabrouk commented Sep 5, 2026

Copy link
Copy Markdown
Member Author

🤖 The AI agent says:

Updated the branch after review feedback: the resend step now waits for the exact non-redirected POST /invite/resend response, fails on a non-2xx result, and only then checks the success toast. This prevents the setup toast from producing a false pass.

@coderabbitai review

@mmabrouk
mmabrouk force-pushed the fix/release-115-safe-web-tests branch from 64902a6 to ce33c4e Compare September 5, 2026 15:20
@mmabrouk mmabrouk changed the title [fix] Keep web-test cleanup inside its project [fix] Scope web-test cleanup and render messages once Sep 5, 2026
@mmabrouk

mmabrouk commented Sep 5, 2026

Copy link
Copy Markdown
Member Author

🤖 The AI agent says:

The focused browser rerun exposed an application defect rather than another locator issue: one resend produced two success toasts, and one removal produced two identical Radix alert dialogs. The shared _app already owned the app-message outlet; the August chat refactor added a second outlet inside Layout, despite the package contract requiring one mount.

This revision removes the newer Layout outlet and restores strict assertions for one toast and one alert dialog. The resend test still proves the exact successful POST response before checking the toast. Full frontend lint passes.

@coderabbitai review

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Caution

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

⚠️ Outside diff range comments (2)
web/tests/playwright/global-teardown.ts (2)

41-41: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Guard deletion with an explicit ephemeral marker. writeProjectMetadata records defaultProject.project_id when ephemeral creation is disabled or fails, and deleteEphemeralProject deletes every recorded ID; record only successfully created ephemeral projects.


41-41: 🔒 Security & Privacy | 🟡 Minor | ⚡ Quick win

Sensitive Data Exposure (CWE-459)

Reachability: Internal · Exploitability: Difficult

Retain teardown metadata when project deletion fails.

Project deletion cascades project secrets atomically on success. However, teardown removes the metadata after any failed DELETE request or fetch error, leaving retained secrets without a recovery handle. Remove the metadata only after successful deletion, and retry or explicitly clean up secrets on failure.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Team

Run ID: 545c9a65-82ca-452d-b2a9-6e8acff56471

📥 Commits

Reviewing files that changed from the base of the PR and between 480e020 and 64902a6.

📒 Files selected for processing (3)
  • web/ee/tests/playwright/acceptance/members/index.ts
  • web/tests/README.md
  • web/tests/playwright/global-teardown.ts

Included review availability: Your plan provides up to 8 included reviews per hour; 4 remain after this review.

@coderabbitai

coderabbitai Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

@mmabrouk I will review the updated changes. I will verify teardown project ownership and the Members action locators.

✅ Action performed

Review finished.

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.

@mmabrouk
mmabrouk force-pushed the fix/release-115-safe-web-tests branch from ce33c4e to ce1be09 Compare September 5, 2026 15:32
@mmabrouk

mmabrouk commented Sep 5, 2026

Copy link
Copy Markdown
Member Author

🤖 The AI agent says:

The completed CodeRabbit review covered the previous 64902 head, but its two teardown findings were valid. Setup now writes an explicit ownership marker: disabled or failed ephemeral setup records ephemeral: false, and only a successfully created test project records ephemeral: true. Teardown sends DELETE only for ephemeral: true, removes metadata after success or an already-gone 404, and retains metadata after transport or server failure for a later retry.

Added focused regressions for all three paths: fallback/default sends no DELETE, owned-project success deletes and removes metadata, and failed deletion retains metadata. All 3 pass. Full frontend lint still passes.

@coderabbitai review

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Team

Run ID: 4d5c99b4-11dc-4b9e-90a5-88752a4f6950

📥 Commits

Reviewing files that changed from the base of the PR and between 64902a6 and ce33c4e.

📒 Files selected for processing (2)
  • web/ee/tests/playwright/acceptance/members/index.ts
  • web/oss/src/components/Layout/Layout.tsx
💤 Files with no reviewable changes (1)
  • web/oss/src/components/Layout/Layout.tsx

Included review availability: Your plan provides up to 8 included reviews per hour; 3 remain after this review.

Comment thread web/ee/tests/playwright/acceptance/members/index.ts Outdated
@coderabbitai

coderabbitai Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

@mmabrouk I will review the latest changes. I will verify the ownership marker, teardown deletion conditions, metadata retention behavior, and the focused regressions.

⚠️ Action not completed

Head commit changed.

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.

@mmabrouk
mmabrouk force-pushed the fix/release-115-safe-web-tests branch from ce1be09 to f03d6e8 Compare September 5, 2026 15:35
@mmabrouk

mmabrouk commented Sep 5, 2026

Copy link
Copy Markdown
Member Author

🤖 The AI agent says:

Resolved the current-head Members finding in f03d6e8f: invite setup now requires the exact Pending state before resend or remove can continue. The teardown ownership regressions remain 3/3 passing, and full frontend lint passes.

@coderabbitai review

@mmabrouk
mmabrouk merged commit e3ef284 into release/v0.115.0 Sep 5, 2026
40 of 41 checks passed

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Team

Run ID: 0692f9d9-3b8f-4109-9bd9-5246bb154f3d

📥 Commits

Reviewing files that changed from the base of the PR and between ce33c4e and f03d6e8.

📒 Files selected for processing (4)
  • web/ee/tests/playwright/acceptance/members/index.ts
  • web/tests/playwright/global-setup.ts
  • web/tests/playwright/global-teardown.test.ts
  • web/tests/playwright/global-teardown.ts

Included review availability: Your plan provides up to 8 included reviews per hour; 2 remain after this review.

Comment thread web/tests/playwright/global-setup.ts
@coderabbitai

coderabbitai Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

@mmabrouk I will review the current changes. I will verify the exact Pending state check, Members locators, and teardown ownership behavior.

⚠️ Action not completed

Pull request is closed.

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.

@coderabbitai

coderabbitai Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

@mmabrouk I will review the updated resend response assertion and its toast validation.

⚠️ Action not completed

Pull request is closed.

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.

@mmabrouk

mmabrouk commented Sep 5, 2026

Copy link
Copy Markdown
Member Author

🤖 The AI agent says:

Resolved the final exact-head finding in 64350bf3: setup will not create an ephemeral default project unless it first records the original default project needed for cleanup. This closes the undeletable-project edge case. All focused teardown tests and full frontend lint pass.

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo '=== PR status and diff ==='
git status --short
git diff --stat HEAD^
git diff --unified=80 HEAD^ -- \
  web/tests/playwright/global-setup.ts \
  web/tests/playwright/global-teardown.ts \
  web/tests/playwright/global-teardown.test.ts \
  web/ee/tests/playwright/acceptance/members/index.ts \
  web/oss/src/components/Layout/Layout.tsx \
  web/tests/README.md

echo '=== Candidate file outlines ==='
ast-grep outline web/tests/playwright/global-setup.ts --items all
ast-grep outline web/tests/playwright/global-teardown.ts --items all
ast-grep outline web/tests/playwright/global-teardown.test.ts --items all
ast-grep outline web/ee/tests/playwright/acceptance/members/index.ts --items all

echo '=== Project metadata definitions and usages ==='
rg -n -C 4 --glob '*.ts' --glob '*.tsx' \
  '(writeProjectMetadata\s*\(|ephemeral\s*:|projectPath|statePath|deleteEphemeralProject\s*\()' \
  web/tests web/ee/tests

echo '=== Member UI and acceptance patterns ==='
rg -n -C 5 --glob '*.ts' --glob '*.tsx' \
  '(invite/resend|Resend|Remove member|Pending|alertdialog|successfully|AppMessageContext)' \
  web/ee web/oss/src web/tests/playwright

Length of output: 201660


#!/bin/bash
set -euo pipefail

echo '=== global-setup.ts ==='
cat -n web/tests/playwright/global-setup.ts

echo '=== global-teardown.ts ==='
cat -n web/tests/playwright/global-teardown.ts

echo '=== global-teardown.test.ts ==='
cat -n web/tests/playwright/global-teardown.test.ts

echo '=== Members acceptance test ==='
cat -n web/ee/tests/playwright/acceptance/members/index.ts

echo '=== Narrow Members implementation search ==='
rg -n -C 8 --glob '*.ts' --glob '*.tsx' \
  '(resendInvite|invite/resend|removeMember|Remove member|Resend invitation|Resend invite|Pending)' \
  web/ee web/oss/src/components/pages web/oss/src/pages

echo '=== Metadata file names and all setup/teardown call sites ==='
rg -n -C 6 --glob '*.ts' \
  '(PROJECT.*(?:STATE|METADATA)|project.*(?:state|metadata)|writeProjectMetadata|readFileSync|unlinkSync|rmSync)' \
  web/tests/playwright

You are interacting with an AI system.

@coderabbitai

coderabbitai Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== PR metadata =="
gh pr view 6581 --repo Agenta-AI/agenta --json state,isDraft,headRefOid,baseRefOid,commits,files \
  --jq '{state, isDraft, headRefOid, baseRefOid, commits: [.commits[] | {oid: .oid, messageHeadline: .messageHeadline}], files: [.files[].path]}'

echo "== Target commit =="
git show --no-ext-diff --format=fuller --stat 64350bf3
git show --no-ext-diff --format= --find-renames 64350bf3 -- \
  web/tests/playwright/global-setup.ts \
  web/tests/playwright/global-teardown.ts \
  web/tests/playwright/global-teardown.test.ts

echo "== Relevant file outlines =="
ast-grep outline web/tests/playwright/global-setup.ts --items all
ast-grep outline web/tests/playwright/global-teardown.ts --items all
ast-grep outline web/tests/playwright/global-teardown.test.ts --items all

echo "== Relevant implementation references =="
rg -n -C 5 \
  'maybeCreateEphemeralProject|writeProjectMetadata|ephemeral|originalDefault|defaultProject|deleteEphemeralProject|restore' \
  web/tests/playwright/global-setup.ts \
  web/tests/playwright/global-teardown.ts \
  web/tests/playwright/global-teardown.test.ts

Length of output: 2222


🏁 Script executed:

#!/bin/bash
set -euo pipefail

head="f03d6e8fc77f56ddf9d9f5d2ad1fe8e35b2c2fa5"
base="7496c66dce30494abc5373e267a686f44e73bfb9"

echo "== PR diff at merged head =="
git diff --no-ext-diff --find-renames "${base}...${head}" -- \
  web/tests/playwright/global-setup.ts \
  web/tests/playwright/global-teardown.ts \
  web/tests/playwright/global-teardown.test.ts

echo "== global setup: metadata and ephemeral-project control flow =="
rg -n -C 18 \
  'async function maybeCreateEphemeralProject|function writeProjectMetadata|const writeProjectMetadata|ephemeral|default.*project|project.*default' \
  web/tests/playwright/global-setup.ts

echo "== global teardown: cleanup control flow =="
rg -n -C 18 \
  'interface DeleteEphemeralProjectOptions|async function deleteEphemeralProject|export async function deleteEphemeralProject|ephemeral|default.*project|project.*default|unlink|rm\(' \
  web/tests/playwright/global-teardown.ts

echo "== teardown regression tests =="
rg -n -C 14 \
  'describe\(|test\(|deleteEphemeralProject|ephemeral|default.*project|project.*default|metadata' \
  web/tests/playwright/global-teardown.test.ts

echo "== Calls and metadata types across Playwright tests =="
rg -n -C 4 \
  'maybeCreateEphemeralProject\s*\(|writeProjectMetadata\s*\(|deleteEphemeralProject\s*\(|ephemeral\s*:' \
  web/tests/playwright

Length of output: 41530


@mmabrouk The merged head f03d6e8f still has the undeletable-project path.

In web/tests/playwright/global-setup.ts, maybeCreateEphemeralProject creates a project with make_default: true even when originalDefaultProjectId is null. It then writes ephemeral: true metadata without original_default_project_id.

In web/tests/playwright/global-teardown.ts, teardown restores a default project only when that metadata field exists. It then tries to delete the still-default ephemeral project. The API rejects deletion of a default project. Retrying cannot resolve this state because no original default project was recorded.

Add a guard before the POST /projects/ call. If no original default project was found, write non-ephemeral fallback metadata and do not create the project. Add a regression test for a successful project-list request that contains no default project.

The available PR checkout does not contain 64350bf3, so I could not verify the reported fix.

You are interacting with an AI system.

@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Railway Preview Environment

Preview URL https://gateway-pr-6581.up.railway.app/w
Project agenta-oss-clone-spike
Image tag pr-6581-8684032
Status Deployed
Railway logs Open logs
Workflow logs View workflow run
Updated at 2026-09-05T15:48:29.082Z

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant