[PR #7209] [MERGED] test(e2e): make the 5,001-row trash batching proof reliable on slow WebKit #7624

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

📋 Pull Request Information

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

Base: staging ← Head: test/trash-batching-timing


📝 Commits (2)

  • cd4c8b8 test(e2e): make the 5,001-row trash batching proof reliable on slow WebKit
  • 2d7b8c4 test(e2e): keep the trash toast visibility check in the mount record

📊 Changes

1 file changed (+41 additions, -12 deletions)

View changed files

📝 e2e/message-trash-batching.e2e.ts (+41 -12)

📄 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

No linked issue: CI flake found while validating #7194; see #7200 for the related phone flake.

Why this change

e2e/message-trash-batching.e2e.ts failed both of its tests twice in a row on CI mobile-webkit (run 37542395904, shard 8: original run and rerun) while #7194 was being validated. #7194 doesn't touch trash code. Adding a spec file reshuffled the shards and moved this file into a heavier one. The CI traces show two timing problems in the test, not a product regression:

  1. "restore all batches large selections…" timed out waiting for "Restore all". After the 5,001-row trash response arrived, WebKit's main thread stayed blocked for 15–17 s. The screencast shows "Loading messages…" until the list painted 15 s later. The test only allowed 10 s.
  2. "restore all keeps conflicts-only batches…" lost the warning toast. The toast's 6 s auto-dismiss timer starts when it mounts. The next re-render of all 5,001 rows then blocked the page for about as long. In the trace the toast first paints at +6.5 s after the failed batch, and it's gone 0.5 s later. waitFor caught it in that window. The follow-up toHaveAttribute("data-type", "warning") then found no element (element(s) not found). On a slow runner, each separate locator check on the toast races the same timer.

The same trace shows a near miss too: toBeDisabled() after clicking Restore all took 7.8 s of its 10 s budget, because disabling every row's buttons re-renders all 5,001 rows.

The fix keeps everything the test proves: batching into 5,000 + 1, partial-failure retry, conflicts-only batches, the warning toast's type, title and description (or lack of one), and that the toast was visible. Only the timing budgets change, and the toast race is fixed by recording the toast when it mounts.

What changed

  • e2e/message-trash-batching.e2e.ts only (test-only, so no CHANGELOG entry):
    • Wait up to 30 s for the first 5,001-row render ("Restore all"), for the busy state after clicking it, and in the conflicts-only branch for the re-enabled state. Each wait re-renders every row. The test timeout goes from 90 s to 120 s so the per-step budgets fit.
    • Before releasing the failing second batch, install a MutationObserver that records each sonner toast as it mounts. It records the toast's data-type, title and description, and whether it is visible by Playwright's definition (non-empty box and not visibility: hidden). One expect.poll(...).toContainEqual(...) then asserts { visible: true, type: "warning", title: "Synthetic later-batch failure", description: "4999 messages restored" | null }. This replaces the waitFor + toHaveAttribute pair and the later description checks ([data-description] count 0 / getByText("4999 messages restored")), which raced the same 6 s timer. The conflicts-only [data-description] count of 0 could also pass vacuously once the toast was gone.
    • Corrected the existing comment: only expect retries that find no element take the whole-page accessibility snapshot (Playwright 1.63 _expectInternal). That's why the failed toHaveAttribute above ran 11 s.

For the maintainer, product note (not changed here): with 5,001 trash rows on a slow device, a user sees the same thing CI did. The page freezes for several seconds, and the restore-failure warning can flash for under a second before its 6 s timer runs out. Rendering the trash list in pages or virtualizing it would fix both.

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 checks (for the reviewer to confirm, not ticked):

  • pnpm check and pnpm exec prettier --check e2e/message-trash-batching.e2e.ts exit 0 on this branch and on hotfix/termux-2.5.0-fixes.
  • playwright test e2e/message-trash-batching.e2e.ts --project=mobile-webkit --project=desktop-chromium passes on both branches, including --repeat-each=2.
  • Under load: --repeat-each=5 --workers=6 on mobile-webkit, alongside the CI shard-8 neighbours (multiplayer-controls, lorebook-images, markdown-blocks, message-marks-colors), gave 10/10 trash runs passing in 40 s–1.4 min. The only failure in that run was an unrelated cold-start markdown-blocks blockquote count.
  • Reproduction with temporary copies of the spec (deleted afterwards) that inject the CI-sized main-thread blocks (13 s on the first list render, 11 s when the buttons go disabled, 6.5 s right after the toast mounts):
    • Old spec, list block: locator.waitFor: Timeout 10000ms exceeded (CI failure 1).
    • Old spec, toast block, --repeat-each=4: 3/4 conflicts-only runs failed with toHaveAttribute … Expected: "warning" … element(s) not found (CI failure 2).
    • New spec, toast block, --repeat-each=4: 8/8 pass. New spec with all three blocks stacked: 6/6 pass on WebKit (78–84 s each, hence the 120 s test timeout) and 4/4 on Chromium.
    • Negative check: expecting type: "error" fails with the recorded toast { visible: true, type: "warning", title: "Synthetic later-batch failure", description: "4999 messages restored" } (and description: null in conflicts-only).

Manual verification notes

  • Confirm the mobile-webkit shard containing message-trash-batching.e2e.ts passes in this PR's CI.
  • Optionally rerun that shard once more to check it's stable. This PR doesn't change product behaviour, so there is nothing to click through in the app.

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)

The same two commits are on the #7194 hotfix branch (888e0111b, 1fb1c7b1c).

UI evidence (if applicable)

Not applicable (test-only).


🔄 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/7209 **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/trash-batching-timing` --- ### 📝 Commits (2) - [`cd4c8b8`](https://github.com/Pasta-Devs/Marinara-Engine/commit/cd4c8b8b9fca1b8a18fa639881f33fe67e5a52fa) test(e2e): make the 5,001-row trash batching proof reliable on slow WebKit - [`2d7b8c4`](https://github.com/Pasta-Devs/Marinara-Engine/commit/2d7b8c4a5a2eca82d7525bce7d76f52dbb3d51a6) test(e2e): keep the trash toast visibility check in the mount record ### 📊 Changes **1 file changed** (+41 additions, -12 deletions) <details> <summary>View changed files</summary> 📝 `e2e/message-trash-batching.e2e.ts` (+41 -12) </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 No linked issue: CI flake found while validating #7194; see #7200 for the related phone flake. ## Why this change `e2e/message-trash-batching.e2e.ts` failed both of its tests twice in a row on CI mobile-webkit (run 37542395904, shard 8: original run and rerun) while #7194 was being validated. #7194 doesn't touch trash code. Adding a spec file reshuffled the shards and moved this file into a heavier one. The CI traces show two timing problems in the test, not a product regression: 1. **"restore all batches large selections…" timed out waiting for "Restore all".** After the 5,001-row trash response arrived, WebKit's main thread stayed blocked for 15–17 s. The screencast shows "Loading messages…" until the list painted 15 s later. The test only allowed 10 s. 2. **"restore all keeps conflicts-only batches…" lost the warning toast.** The toast's 6 s auto-dismiss timer starts when it mounts. The next re-render of all 5,001 rows then blocked the page for about as long. In the trace the toast first paints at +6.5 s after the failed batch, and it's gone 0.5 s later. `waitFor` caught it in that window. The follow-up `toHaveAttribute("data-type", "warning")` then found no element (`element(s) not found`). On a slow runner, each separate locator check on the toast races the same timer. The same trace shows a near miss too: `toBeDisabled()` after clicking Restore all took 7.8 s of its 10 s budget, because disabling every row's buttons re-renders all 5,001 rows. The fix keeps everything the test proves: batching into 5,000 + 1, partial-failure retry, conflicts-only batches, the warning toast's type, title and description (or lack of one), and that the toast was visible. Only the timing budgets change, and the toast race is fixed by recording the toast when it mounts. ## What changed - `e2e/message-trash-batching.e2e.ts` only (test-only, so no CHANGELOG entry): - Wait up to 30 s for the first 5,001-row render ("Restore all"), for the busy state after clicking it, and in the conflicts-only branch for the re-enabled state. Each wait re-renders every row. The test timeout goes from 90 s to 120 s so the per-step budgets fit. - Before releasing the failing second batch, install a `MutationObserver` that records each sonner toast as it mounts. It records the toast's `data-type`, title and description, and whether it is visible by Playwright's definition (non-empty box and not `visibility: hidden`). One `expect.poll(...).toContainEqual(...)` then asserts `{ visible: true, type: "warning", title: "Synthetic later-batch failure", description: "4999 messages restored" | null }`. This replaces the `waitFor` + `toHaveAttribute` pair and the later description checks (`[data-description]` count 0 / `getByText("4999 messages restored")`), which raced the same 6 s timer. The conflicts-only `[data-description]` count of 0 could also pass vacuously once the toast was gone. - Corrected the existing comment: only expect retries that find **no element** take the whole-page accessibility snapshot (Playwright 1.63 `_expectInternal`). That's why the failed `toHaveAttribute` above ran 11 s. **For the maintainer, product note (not changed here):** with 5,001 trash rows on a slow device, a user sees the same thing CI did. The page freezes for several seconds, and the restore-failure warning can flash for under a second before its 6 s timer runs out. Rendering the trash list in pages or virtualizing it would fix both. ## 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 checks (for the reviewer to confirm, not ticked): - `pnpm check` and `pnpm exec prettier --check e2e/message-trash-batching.e2e.ts` exit 0 on this branch and on `hotfix/termux-2.5.0-fixes`. - `playwright test e2e/message-trash-batching.e2e.ts --project=mobile-webkit --project=desktop-chromium` passes on both branches, including `--repeat-each=2`. - Under load: `--repeat-each=5 --workers=6` on mobile-webkit, alongside the CI shard-8 neighbours (multiplayer-controls, lorebook-images, markdown-blocks, message-marks-colors), gave 10/10 trash runs passing in 40 s–1.4 min. The only failure in that run was an unrelated cold-start `markdown-blocks` blockquote count. - Reproduction with temporary copies of the spec (deleted afterwards) that inject the CI-sized main-thread blocks (13 s on the first list render, 11 s when the buttons go disabled, 6.5 s right after the toast mounts): - Old spec, list block: `locator.waitFor: Timeout 10000ms exceeded` (CI failure 1). - Old spec, toast block, `--repeat-each=4`: 3/4 conflicts-only runs failed with `toHaveAttribute … Expected: "warning" … element(s) not found` (CI failure 2). - New spec, toast block, `--repeat-each=4`: 8/8 pass. New spec with all three blocks stacked: 6/6 pass on WebKit (78–84 s each, hence the 120 s test timeout) and 4/4 on Chromium. - Negative check: expecting `type: "error"` fails with the recorded toast `{ visible: true, type: "warning", title: "Synthetic later-batch failure", description: "4999 messages restored" }` (and `description: null` in conflicts-only). ### Manual verification notes - Confirm the `mobile-webkit` shard containing `message-trash-batching.e2e.ts` passes in this PR's CI. - Optionally rerun that shard once more to check it's stable. This PR doesn't change product behaviour, so there is nothing to click through in the app. ## 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) The same two commits are on the #7194 hotfix branch (`888e0111b`, `1fb1c7b1c`). ## UI evidence (if applicable) Not applicable (test-only). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-24 04:05:58 +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#7624
No description provided.