[PR #7229] [MERGED] test(e2e): isolate the trash feature toggle and settle edge-docked phone tools #7636

Closed
opened 2026-10-24 04:06:04 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/7229
Author: @SpicyMarinara
Created: 10/7/2026
Status: ✅ Merged
Merged: 10/7/2026
Merged by: @SpicyMarinara

Base: staging ← Head: test/flaky-trash-and-docked-tools-7220


📝 Commits (1)

  • 572d460 test(e2e): isolate the trash feature toggle and settle edge-docked phone tools

📊 Changes

2 files changed (+54 additions, -13 deletions)

View changed files

📝 e2e/message-marks-trash.e2e.ts (+51 -13)
📝 e2e/phone-bubbles.e2e.ts (+3 -0)

📄 Description

Important

Contributions target staging. Only SpicyMarinara may promote this repository's staging branch or a same-repository hotfix/* branch to main.
Outside and first-time contributors also require an approving review from SpicyMarinara.

Linked issue

Closes #7220

Why this change

Two e2e tests failed now and then even though the app behaved correctly. Each failure blocks or slows unrelated PRs, and each was caused by the test, not by the app.

  • e2e/message-marks-trash.e2e.ts under parallel workers. The test turns on the global Message Trash switch, then sets it back to the value it saved at the start. The mobile projects and --repeat-each copies share one server, so this sequence breaks it: run A saves "off" and turns trash on, run B starts and saves "on", then A finishes and turns trash off while B is still running. B's fixture delete then removes the message for good, returning { trashed: false, trashedCount: 0 } at the trashed: true check. Reproduced on staging deterministically: one roleplay copy waits 3 s before starting and 15 s before its delete, and that copy fails at exactly that line.
  • e2e/phone-bubbles.e2e.ts › "edge-docked phone Chat tools stay centered above and below their launcher". When the loop switches to the large (96 px) buttons, toHaveCSS("width", "96px") can pass as soon as styles recalculate. The launcher is only moved back inside the chat when its ResizeObserver fires in the next frame. Measured in WebKit: when the width first reads 96px, the launcher is still at y 531.5 and overhangs the message box. The first rAF after that still reads 531.5. By the second rAF it has been re-clamped to y 471.5. If the next dragBubble reads the box in that window, it grabs 12 px below the real launcher. The drag misses, the launcher stays docked bottom-left, its menu opens above, and the "below" check at phone-bubbles.e2e.ts:~1006 fails. This is the same class of problem as #7200/#7216: measuring before things settle.

What changed

Test-only. No app code, docs or CHANGELOG entry.

  • message-marks-trash: the copies that need Message Trash now share it instead of each saving and restoring it on its own. A small holdMessageTrash helper keeps a holder count in .tmp/playwright-data/message-trash-<port>/ (reset whenever the e2e servers start). The first holder saves the original feature settings, every holder makes sure trash is on, and only the last holder restores the saved settings. If that restore fails, the saved original is kept for the next run. A short mkdir lock guards only those two settings calls, so the tests still run in parallel. I tried the suite's existing whole-test mkdir lock (expression-active-sprites.e2e.ts) first. It removed the race, but under --repeat-each=3/4 --workers=4 it queued up to eight copies, and some timed out waiting for the lock. That is why I used a shared hold instead. The test's assertions are unchanged.
  • phone-bubbles edge-docked test: after each size change, call the existing expectComposerClearAndNoSideScroll(page) (#7216's helper) before dragging. It waits until every button holds still for 3 frames, then checks that none sits on the message box. So the drag reads the re-clamped launcher, and the clamp the test relies on is now asserted too. The test's other assertions are unchanged.

Validation

  • pnpm check passes locally
  • Container (Docker / Podman) built and ran without issue
  • Ran the app, clicked through the changes manually
  • Checked edge cases (light + dark mode, mobile viewport, empty states, error paths)
  • Above manual verification completed (describe below)
  • Read and followed CONTRIBUTING.md

Agent-run evidence (local macOS, Playwright 1.63; boxes above left for the human reviewer):

Trash toggle (message-marks-trash)

  • Natural reproduction: --repeat-each=3 --workers=4 and --project=mobile-webkit --project=mobile-chromium --repeat-each=4 --workers=4 passed 3 times on untouched staging (6/16 tests each). The race window is narrow.
  • Deterministic reproduction on staging (temporary change, reverted): the roleplay copy with repeatEachIndex === 1 waits 3 s before saving the settings and 15 s before its delete. Result: 1 failed, with Expected trashed: true, trashedCount: 1 / Received trashed: false, trashedCount: 0 at the fixture-delete check (message-marks-trash.e2e.ts:155 on staging).
  • The same delays on the fix: 4 passed. The two roleplay copies overlapped (12.7 s and 30.5 s), so they still run in parallel.
  • Repeat proof on the final code, 0 failures:
    • --project=mobile-webkit --repeat-each=3 --workers=4: 6 passed, twice.
    • --project=mobile-webkit --project=mobile-chromium --repeat-each=4 --workers=4: 16 passed.
    • Against servers I started myself, --project=mobile-webkit --project=mobile-chromium --repeat-each=3 --workers=4: 12 passed in each of 5 runs. After every run, GET /api/app-settings/features returned {"settings":{}}, the original, and the hold file read holders: 0.
  • Review fix check: I simulated an earlier failed restore (trash left on, real original {"stableLorebookGroupPicks":true} kept in the hold file). The next run passed and restored {"stableLorebookGroupPicks":true}.
  • Negative check (temporary server change, reverted): chatUsesMessageTrash always returns false. Both copies fail at expect(await deleted.json()).toEqual({ trashed: true, trashedCount: 1 }), and the second copy still got the hold after the first failed.
  • Rejected alternative: the suite's whole-test mkdir lock removed the race, but under --repeat-each=3 --workers=4 (1 of 6) and both mobile projects --repeat-each=4 --workers=4 (2 of 16) some copies failed with EEXIST after waiting 60 s for the lock.

Edge-docked phone Chat tools (phone-bubbles)

  • Natural reproduction: the issue's --repeat-each=5 full-spec WebKit run passed on untouched staging here (65 passed, 15 project skips). The test on its own passed 10/10 unloaded and 12/12 under CPU load (8 yes processes on 10 cores). So I measured the mechanism instead.
  • In-page measurement (WebKit, 4 runs): after the switch to 96 px, the launcher's box when its computed width first reads 96px is y 531.5 (overhanging the message box). The 1st rAF still reads 531.5. The 2nd reads 471.5, the re-clamped spot.
  • A per-frame recorder from the click through the measurements showed the open menu stays still (the only change is the test's own scroll), so the measurements themselves were not the problem.
  • Deterministic reproduction on staging (temporary init script delaying ResizeObserver callbacks by 30 ms, about two frames, reverted): 3 of 4 failed at the "below" check with Expected: >= 567.5, Received: 58.83. The 96 px launcher stayed bottom-left because the drag grabbed the stale box, and the menu opened above it.
  • The same mutation on the fix: 8 passed.
  • Repeat proof on the final code, 0 failures:
    • -g "edge-docked" --repeat-each=10 --workers=1: 10 passed.
    • Under CPU load, --repeat-each=12: 12 passed.
    • Whole spec, --project=mobile-webkit --project=mobile-chromium --workers=1: 27 passed, 5 skipped (existing project skips).
  • Negative check 1 (temporary app change, reverted): WindowBubble clamps with the 36 px default instead of the rendered size, so a grown launcher is never moved back. The new wait at line 964 fails with settled: true, overlap: ["chat-tools-menu"]. The wait does not hide a real clamp bug.
  • Negative check 2 (temporary app change, reverted): the Chat tools menu column shifts 10 px off centre. The test fails at the centring check, Expected: <= 1, Received: 10.

Checks

  • pnpm check passed on the final commit.
  • Local CodeRabbit (coderabbit review --agent --committed, one run) returned 2 findings:
    • Fixed: keep the saved original until a restore succeeds, so a failed restore can't make later runs "restore" the leaked trash-on state. Verified as above.
    • Declined: worker-ownership tracking and stale lock/holder reclaim. This is the ceiling documented in the ponytail: comment, and it matches the suite's existing lock pattern (expression-active-sprites.e2e.ts). The lock covers only two settings calls and is released in finally, including after a timeout tears down the request fixture. A stale holder only leaves trash on until the e2e servers restart and reset .tmp/playwright-data.
  • GitHub CI and GitHub CodeRabbit had not run when this PR was opened.

Manual verification notes

  • Manually run pnpm regression:ui e2e/message-marks-trash.e2e.ts --project=mobile-webkit --repeat-each=3 --workers=4 and confirm 6 passed.
  • Manually run pnpm regression:ui e2e/message-marks-trash.e2e.ts --project=mobile-webkit --project=mobile-chromium --repeat-each=4 --workers=4 and confirm 16 passed.
  • Manually run pnpm regression:ui e2e/phone-bubbles.e2e.ts --project=mobile-webkit --repeat-each=5 --workers=1 and confirm no failures (skips are the spec's existing project skips).
  • After a trash run against servers you started yourself (PLAYWRIGHT_SKIP_WEBSERVER=true), manually check that GET /api/app-settings/features returns the settings it had before the run.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed
  • Translated docs on the docs-i18n branch updated to match, or a [docs-i18n] follow-up issue opened (see CONTRIBUTING.md § Translated documentation)
  • Version/release files updated (only if this PR includes a version bump)

Test-only change: no user-facing docs or CHANGELOG entry.

UI evidence (if applicable)

Not applicable (test-only).

Summary by CodeRabbit

  • Tests
    • Improved end-to-end test reliability for message trash settings by coordinating setup and cleanup across tests.
    • Updated chat tool positioning tests to wait for controls to settle and confirm the page has no horizontal overflow before continuing.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/7229 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 10/7/2026 **Status:** ✅ Merged **Merged:** 10/7/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `test/flaky-trash-and-docked-tools-7220` --- ### 📝 Commits (1) - [`572d460`](https://github.com/Pasta-Devs/Marinara-Engine/commit/572d460abf6db13ed1abbb0dff8a9620e29cc2e3) test(e2e): isolate the trash feature toggle and settle edge-docked phone tools ### 📊 Changes **2 files changed** (+54 additions, -13 deletions) <details> <summary>View changed files</summary> 📝 `e2e/message-marks-trash.e2e.ts` (+51 -13) 📝 `e2e/phone-bubbles.e2e.ts` (+3 -0) </details> ### 📄 Description > [!IMPORTANT] > Contributions target `staging`. Only `SpicyMarinara` may promote this repository's `staging` branch or a same-repository `hotfix/*` branch to `main`. > Outside and first-time contributors also require an approving review from `SpicyMarinara`. <!-- See CONTRIBUTING.md § Branches. --> ## Linked issue Closes #7220 ## Why this change Two e2e tests failed now and then even though the app behaved correctly. Each failure blocks or slows unrelated PRs, and each was caused by the test, not by the app. - **`e2e/message-marks-trash.e2e.ts` under parallel workers.** The test turns on the global Message Trash switch, then sets it back to the value it saved at the start. The mobile projects and `--repeat-each` copies share one server, so this sequence breaks it: run A saves "off" and turns trash on, run B starts and saves "on", then A finishes and turns trash off while B is still running. B's fixture delete then removes the message for good, returning `{ trashed: false, trashedCount: 0 }` at the `trashed: true` check. Reproduced on `staging` deterministically: one roleplay copy waits 3 s before starting and 15 s before its delete, and that copy fails at exactly that line. - **`e2e/phone-bubbles.e2e.ts` › "edge-docked phone Chat tools stay centered above and below their launcher".** When the loop switches to the large (96 px) buttons, `toHaveCSS("width", "96px")` can pass as soon as styles recalculate. The launcher is only moved back inside the chat when its `ResizeObserver` fires in the next frame. Measured in WebKit: when the width first reads 96px, the launcher is still at `y 531.5` and overhangs the message box. The first rAF after that still reads `531.5`. By the second rAF it has been re-clamped to `y 471.5`. If the next `dragBubble` reads the box in that window, it grabs 12 px below the real launcher. The drag misses, the launcher stays docked bottom-left, its menu opens above, and the "below" check at `phone-bubbles.e2e.ts:~1006` fails. This is the same class of problem as #7200/#7216: measuring before things settle. ## What changed Test-only. No app code, docs or CHANGELOG entry. - `message-marks-trash`: the copies that need Message Trash now share it instead of each saving and restoring it on its own. A small `holdMessageTrash` helper keeps a holder count in `.tmp/playwright-data/message-trash-<port>/` (reset whenever the e2e servers start). The first holder saves the original feature settings, every holder makes sure trash is on, and only the last holder restores the saved settings. If that restore fails, the saved original is kept for the next run. A short `mkdir` lock guards only those two settings calls, so the tests still run in parallel. I tried the suite's existing whole-test `mkdir` lock (`expression-active-sprites.e2e.ts`) first. It removed the race, but under `--repeat-each=3/4 --workers=4` it queued up to eight copies, and some timed out waiting for the lock. That is why I used a shared hold instead. The test's assertions are unchanged. - `phone-bubbles` edge-docked test: after each size change, call the existing `expectComposerClearAndNoSideScroll(page)` (#7216's helper) before dragging. It waits until every button holds still for 3 frames, then checks that none sits on the message box. So the drag reads the re-clamped launcher, and the clamp the test relies on is now asserted too. The test's other assertions are unchanged. ## Validation - [ ] `pnpm check` passes locally - [ ] Container (Docker / Podman) built and ran without issue - [ ] Ran the app, clicked through the changes manually - [ ] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [ ] Above manual verification completed (describe below) - [ ] Read and followed `CONTRIBUTING.md` Agent-run evidence (local macOS, Playwright 1.63; boxes above left for the human reviewer): **Trash toggle (`message-marks-trash`)** - Natural reproduction: `--repeat-each=3 --workers=4` and `--project=mobile-webkit --project=mobile-chromium --repeat-each=4 --workers=4` passed 3 times on untouched `staging` (6/16 tests each). The race window is narrow. - Deterministic reproduction on `staging` (temporary change, reverted): the roleplay copy with `repeatEachIndex === 1` waits 3 s before saving the settings and 15 s before its delete. Result: `1 failed`, with `Expected trashed: true, trashedCount: 1` / `Received trashed: false, trashedCount: 0` at the fixture-delete check (`message-marks-trash.e2e.ts:155` on staging). - The same delays on the fix: 4 passed. The two roleplay copies overlapped (12.7 s and 30.5 s), so they still run in parallel. - Repeat proof on the final code, 0 failures: - `--project=mobile-webkit --repeat-each=3 --workers=4`: 6 passed, twice. - `--project=mobile-webkit --project=mobile-chromium --repeat-each=4 --workers=4`: 16 passed. - Against servers I started myself, `--project=mobile-webkit --project=mobile-chromium --repeat-each=3 --workers=4`: 12 passed in each of 5 runs. After every run, `GET /api/app-settings/features` returned `{"settings":{}}`, the original, and the hold file read `holders: 0`. - Review fix check: I simulated an earlier failed restore (trash left on, real original `{"stableLorebookGroupPicks":true}` kept in the hold file). The next run passed and restored `{"stableLorebookGroupPicks":true}`. - Negative check (temporary server change, reverted): `chatUsesMessageTrash` always returns false. Both copies fail at `expect(await deleted.json()).toEqual({ trashed: true, trashedCount: 1 })`, and the second copy still got the hold after the first failed. - Rejected alternative: the suite's whole-test `mkdir` lock removed the race, but under `--repeat-each=3 --workers=4` (1 of 6) and both mobile projects `--repeat-each=4 --workers=4` (2 of 16) some copies failed with `EEXIST` after waiting 60 s for the lock. **Edge-docked phone Chat tools (`phone-bubbles`)** - Natural reproduction: the issue's `--repeat-each=5` full-spec WebKit run passed on untouched `staging` here (65 passed, 15 project skips). The test on its own passed 10/10 unloaded and 12/12 under CPU load (8 `yes` processes on 10 cores). So I measured the mechanism instead. - In-page measurement (WebKit, 4 runs): after the switch to 96 px, the launcher's box when its computed width first reads `96px` is `y 531.5` (overhanging the message box). The 1st rAF still reads `531.5`. The 2nd reads `471.5`, the re-clamped spot. - A per-frame recorder from the click through the measurements showed the open menu stays still (the only change is the test's own scroll), so the measurements themselves were not the problem. - Deterministic reproduction on `staging` (temporary init script delaying `ResizeObserver` callbacks by 30 ms, about two frames, reverted): 3 of 4 failed at the "below" check with `Expected: >= 567.5, Received: 58.83`. The 96 px launcher stayed bottom-left because the drag grabbed the stale box, and the menu opened above it. - The same mutation on the fix: 8 passed. - Repeat proof on the final code, 0 failures: - `-g "edge-docked" --repeat-each=10 --workers=1`: 10 passed. - Under CPU load, `--repeat-each=12`: 12 passed. - Whole spec, `--project=mobile-webkit --project=mobile-chromium --workers=1`: 27 passed, 5 skipped (existing project skips). - Negative check 1 (temporary app change, reverted): `WindowBubble` clamps with the 36 px default instead of the rendered size, so a grown launcher is never moved back. The new wait at line 964 fails with `settled: true, overlap: ["chat-tools-menu"]`. The wait does not hide a real clamp bug. - Negative check 2 (temporary app change, reverted): the Chat tools menu column shifts 10 px off centre. The test fails at the centring check, `Expected: <= 1, Received: 10`. **Checks** - `pnpm check` passed on the final commit. - Local CodeRabbit (`coderabbit review --agent --committed`, one run) returned 2 findings: - Fixed: keep the saved original until a restore succeeds, so a failed restore can't make later runs "restore" the leaked trash-on state. Verified as above. - Declined: worker-ownership tracking and stale lock/holder reclaim. This is the ceiling documented in the `ponytail:` comment, and it matches the suite's existing lock pattern (`expression-active-sprites.e2e.ts`). The lock covers only two settings calls and is released in `finally`, including after a timeout tears down the request fixture. A stale holder only leaves trash on until the e2e servers restart and reset `.tmp/playwright-data`. - GitHub CI and GitHub CodeRabbit had not run when this PR was opened. ### Manual verification notes - Manually run `pnpm regression:ui e2e/message-marks-trash.e2e.ts --project=mobile-webkit --repeat-each=3 --workers=4` and confirm 6 passed. - Manually run `pnpm regression:ui e2e/message-marks-trash.e2e.ts --project=mobile-webkit --project=mobile-chromium --repeat-each=4 --workers=4` and confirm 16 passed. - Manually run `pnpm regression:ui e2e/phone-bubbles.e2e.ts --project=mobile-webkit --repeat-each=5 --workers=1` and confirm no failures (skips are the spec's existing project skips). - After a trash run against servers you started yourself (`PLAYWRIGHT_SKIP_WEBSERVER=true`), manually check that `GET /api/app-settings/features` returns the settings it had before the run. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed - [ ] Translated docs on the `docs-i18n` branch updated to match, or a `[docs-i18n]` follow-up issue opened (see CONTRIBUTING.md § Translated documentation) - [ ] Version/release files updated (only if this PR includes a version bump) Test-only change: no user-facing docs or CHANGELOG entry. ## UI evidence (if applicable) Not applicable (test-only). <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Tests** * Improved end-to-end test reliability for message trash settings by coordinating setup and cleanup across tests. * Updated chat tool positioning tests to wait for controls to settle and confirm the page has no horizontal overflow before continuing. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-24 04:06:04 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#7636
No description provided.