Skip to content

test(e2e): port upstream ban-demo-download + punishment-comment-actions coverage - #42

Merged
Rushaway merged 4 commits into
mainfrom
test/punishment-comment-demo-e2e-coverage
Sep 26, 2026
Merged

Rushaway merged 4 commits into
mainfrom
test/punishment-comment-demo-e2e-coverage

Conversation

@Rushaway

Copy link
Copy Markdown
Member

Summary

Closes an E2E coverage gap surfaced while auditing this fork against upstream sbpp/sourcebans-pp's sbpp#1568 ("restore punishment comment and demo actions"): upstream shipped two E2E specs — ban-demo-download.spec.ts and punishment-comment-actions.spec.ts — that this fork never grew, even though the underlying features (sbpp#1544, sbpp#1554) are already implemented and merged here (fix/issue-1544, fix/issue-1554, fix/upstream-1568-demo-comment-gates).

ban-demo-download.spec.ts — near-straight port

The banlist row / drawer markup is byte-for-byte identical between the two trees (row-action-demo-download[-mobile], drawer-demo-download, getdemo.php?type=B&id=<bid>). The one adaptation: seed the demo through a new seed-ban-demo-e2e.php shim (seedBanDemoE2e in fixtures/db.ts) instead of writing straight into ../../demos from Node the way upstream's version does. This suite runs both host-side (docker compose exec) and in-container (E2E_IN_CONTAINER=1); only the PHP side reliably resolves SB_DEMOS the same way getdemo.php does in both modes — a Node-side relative path guess would silently diverge under host-side execution. Cleanup still goes through Actions.BansRemoveDemo, same as upstream, which unlinks the file and drops the :prefix_demos row in one step.

punishment-comment-actions.spec.ts — full rewrite

Upstream drives a dedicated #banlist-comment-form page (row-action-comment-add navigates to a standalone editor built from their extracted punishment-comment-editor.tpl partial). This fork's comment add/edit has always been entirely drawer-driven — per page_bans.tpl's own docblock: "Add / Edit comments open the player drawer (data-comment-compose); there is no ?comment= editor on this page."

The rewritten spec drives the actual flow instead: the row's [data-testid="ban-comment-add"] / [data-testid="comm-comment-add"] button opens the player drawer with the comment composer ([data-testid="drawer-comment-form"]) pre-opened in one step (loadDrawer(key, {mode: 'add'}) → openCommentComposer()), submit posts bans.add_comment and reloads the drawer, which patches the row's inline disclosure in place. Every selector was verified directly against theme.js / page_bans.tpl / page_comms.tpl source (not guessed) — same underlying sbpp#1544 contract as upstream (Add comment reachable from the row; every existing comment exposes author/owner-gated Edit + Delete in both the inline disclosure and the drawer), exercised through this fork's actual UI.

Verification

Both specs run green against the local dev stack before committing:

```
Running 3 tests using 1 worker
✓ ban-demo-download.spec.ts › row and drawer expose the attached demo download (2.3s)
✓ punishment-comment-actions.spec.ts › ban Add comment flow restores per-comment Edit and Delete (2.7s)
✓ punishment-comment-actions.spec.ts › comm-block Add comment uses the shared drawer composer and action set (2.8s)
3 passed (17.7s)
```

  • node --experimental-strip-types --check on all new/changed .ts files: clean.
  • php -l on the new shim: clean.
  • No orphaned demo files left in web/demos/ after the run (verified manually).

Test plan

  • CI's e2e.yml gate green.
  • ./sbpp.sh e2e specs/flows/ban-demo-download.spec.ts specs/flows/punishment-comment-actions.spec.ts locally reproduces the 3/3 pass.

🤖 Generated with Claude Code

…ions coverage

Closes the E2E test-coverage gap found while comparing this fork's
comment/demo work (feat/mods-list-compact-actions and friends) against
upstream sbpp/sourcebans-pp's sbpp#1568 ("restore punishment comment and
demo actions"): upstream shipped two E2E specs this fork never grew,
`ban-demo-download.spec.ts` and `punishment-comment-actions.spec.ts`.

ban-demo-download.spec.ts is close to a straight port — the banlist
row / drawer markup (`row-action-demo-download[-mobile]`,
`drawer-demo-download`, `getdemo.php?type=B&id=<bid>`) is
byte-for-byte identical between the two trees. The one adaptation:
seed the demo through a new `seed-ban-demo-e2e.php` shim
(`seedBanDemoE2e` in fixtures/db.ts) instead of writing straight into
`../../demos` from Node the way upstream's version does — this suite
runs both host-side (via `docker compose exec`) and in-container
(`E2E_IN_CONTAINER=1`), and only the PHP side reliably resolves
`SB_DEMOS` the same way `getdemo.php` does in both modes; a Node-side
relative path guess would silently diverge under host-side execution.
Cleanup still goes through `Actions.BansRemoveDemo` exactly like
upstream, which unlinks the file and drops the `:prefix_demos` row in
one step.

punishment-comment-actions.spec.ts required a full rewrite rather than
a port. Upstream drives a dedicated `#banlist-comment-form` PAGE
(`row-action-comment-add` navigates to a standalone editor built from
their extracted `punishment-comment-editor.tpl` partial). This fork's
comment add/edit has always been entirely drawer-driven — per
page_bans.tpl's own docblock, "there is no `?comment=` editor on this
page" — so the ported spec instead drives the actual flow: the row's
`[data-testid="ban-comment-add"]` / `[data-testid="comm-comment-add"]`
button opens the player drawer with the comment composer
(`[data-testid="drawer-comment-form"]`) pre-opened in one step, submit
posts `bans.add_comment` and reloads the drawer, which patches the
row's inline disclosure in place. Every selector in the rewrite was
verified directly against theme.js / page_bans.tpl / page_comms.tpl
(not guessed) — this is the same underlying sbpp#1544 contract upstream's
spec locks in (Add comment reachable from the row; every existing
comment exposes author/owner-gated Edit + Delete in both the inline
disclosure and the drawer), just exercised through this fork's actual
UI.

Both specs run green against the local dev stack (3/3 passed) before
committing.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
The predicate matched any 200 POST to api.php, so an unrelated lazy call
(e.g. a drawer pane loader) resolving first would be asserted instead of
the comment add.
If the finally-block cleanup never runs (page died before the panel JS
loaded), a non-hex name was never swept by ./sbpp.sh db-reset, which only
deletes MD5-named files from web/demos/. Use the same shape as
UploadHandler's renameToHash output.
The finally block called bans.remove_demo, which always failed with
"Unable to delete demo file from disk.": the shim writes the file as
the CLI user, and www-data can't unlink from a bind-mounted web/demos/
owned by the host user. The error was swallowed, so every run leaked
the file and the :prefix_demos row.

Add a remove mode to seed-ban-demo-e2e.php and a removeBanDemoE2e()
helper, and use it for cleanup.
@Rushaway
Rushaway merged commit bf41de7 into main Sep 26, 2026
6 checks passed
@Rushaway
Rushaway deleted the test/punishment-comment-demo-e2e-coverage branch September 26, 2026 13:25
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.

3 participants