Skip to content

Check the lifecycle cases the trash and team folders promise - #317

Merged
Jaggob merged 9 commits into
mainfrom
test/lifecycle-scenarios
Oct 7, 2026
Merged

Jaggob merged 9 commits into
mainfrom
test/lifecycle-scenarios

Conversation

@Jaggob

@Jaggob Jaggob commented Oct 6, 2026 •

Copy link
Copy Markdown
Collaborator

New e2e cases for what the lifecycle of a .pad file promises now that a pad lives until its file is deleted for good: the promises no spec checked yet (docs/deleting-pads.md). Every case passes against the app as it is; no app code changed.

Two terms from that page: the job is the background job that deletes the pads of files gone for good, and a settle is one run of it from the admin's pending check (settle-pending), which the specs use instead of waiting for cron.

Trash and restore

  • An editor still open while its file goes to the trash (pad-trash-restore.spec.ts): a protected pad loses its sessions, and what the editor types next does not reach the pad. The test waits several times what the first change needed to arrive, three seconds at least. Observed, not asserted: Etherpad 2 refuses the change without telling the writer, and the page keeps showing what was typed. That Etherpad tells the writer nothing is Etherpad's; what this app could show instead is left for later.
  • A public pad in the trash (pad-gone-for-good.spec.ts) is typed into by its link, from a browser without a Nextcloud session, and takes what is written. The restore brings that back with the pad, and the next sync writes it into the file. A visit to a public pad's address makes the pad anew if it is gone, so the trash is checked to have kept it before the visit, and what it held before the trash has to come back too.
  • A file trashed under 1.1.0-beta.1 (pad-lost.spec.ts), whose pad and row went with that trash, gets a new pad from its content when it is restored, and opens on it at once.

A pad made anew from its file

What is written into a pad made anew, by the recovery, by a restore, or by the restore of a file from 1.1.0-beta.1, reaches the file with an ordinary sync, answered updated (pad-lost.spec.ts). The new pad counts its revisions anew, below the old pad's count: the file has to take the new pad's count with it, and the test checks that against Etherpad. The old pad is given more revisions than the new one reaches, so a file that kept the old count would take what is written into the new pad for nothing new.

Team folders and delete_pad_with_file

In pad-gone-for-good.spec.ts:

  • A file moved from a home into a team folder and back crosses storages twice. It keeps its id and its pad, the job takes nothing, and the count of pending deletes stays as it was. A row wrongly marked as gone would not show otherwise: the job finds the file present and leaves such a row waiting, so it keeps its pad and opens as before, and only that count tells. The count is the instance's, so it is held exact only on a throwaway stack.
  • A single file in a team folder's trash keeps its pad, gets it back when restored, and takes it when deleted from there.
  • With delete_pad_with_file off, a file deleted for good leaves its pad, counted as a pending delete. Switched back on, the job deletes it. The admin's value is put back afterwards, or removed if there was none. The case runs only where deleting is on already: switched on and settled at once, it would delete every pad an admin who has it off is keeping.

Many pads at once

A folder of 250 pads, more than one of the job's batches of 200, goes to the trash and is deleted from there: one settle takes them all, and on a throwaway stack a later run finds nothing more. A create that fails is tried again under a new name, and a run that stops early takes its folder past the trash. Like the other folder cases it is skipped on Nextcloud 34 up to 34.0.4, which reports a removed folder's files under the wrong ids (nextcloud/server#63998), so it runs on 32.0.9 and 33.

Helpers

  • typeInEtherpad() types into the editor of the pad the viewer shows, four frames down; typeInEtherpadPage() into a pad opened by its own address. The Etherpad frames are built in one place for these and the display-name check.
  • restoreAppConfig() puts back a value as it was read, removing it over the provisioning API (deleteAppConfig()) if it was not set. pad-legacy-group-boundary.spec.ts uses it too, and no longer leaves an empty key behind.
  • padOfFile() is the pad a file opens on, for the specs that asked the open the same way in three places.

Verification

  • Against the local stack with Nextcloud 34.0.4 and Etherpad 2: 62 passed, 5 skipped (the four folder cases, the new one among them, and the external pad from the template picker, which needs an allowlisted pad server).
  • With Nextcloud 32.0.9: 66 passed, 1 skipped (the external pad from the template picker). The many-pads test takes under four seconds in all.
  • The open-editor case fails when the file is not moved to the trash: then the second text reaches the pad.
  • The sync check fails against a restore that leaves the old revision count in the file, in every case that makes a pad anew.

Jaggob added 7 commits October 6, 2026 17:18
The new pad starts its revisions anew, under a file whose snapshot
counted the old pad's: a sync that compared the two would take what is
written into the new pad for nothing new. After each way a lost pad is
made anew, the recovery and the restore, what is then written into it
reaches the file with an ordinary sync, answered `updated`.
Under 1.1.0-beta.1 the trash deleted the pad, and the file came back
naming a pad nobody has, with no row. Beta 2 is the first update for
those installations: such a file restored is opened at once, on a new
pad made from its content.
- A public pad in the trash still opens by its link and takes what is
  written into it; the restore brings that back with the pad, and the
  next sync writes it into the file.
- With `delete_pad_with_file` off, a file deleted for good leaves its
  pad, counted as pending; switched back on, the job deletes it.
- A file moved from a home into a team folder and back crosses storages
  twice: it keeps its id and its pad, and the job takes nothing.
- A single file in a team folder's trash keeps its pad, gets it back
  when restored, and takes it when deleted from there.
A protected pad loses its sessions when its file goes to the trash, and
the docs promise that whoever still has it open writes no more from the
next change on. A viewer types into the pad, the file goes to the trash,
and what it types next does not reach the pad. A helper types into the
editor four frames down.
250 pads in one folder, more than one of the job's batches of 200, go to
the trash with it and are deleted from there. One settle takes them all
and a later run finds nothing more. Like the other folder cases it is
skipped on Nextcloud 34 up to 34.0.4, which reports a removed folder's
files under the wrong ids; it runs on 32 and 33.
- The public pad in the trash is typed into by its link, from a browser
  without a Nextcloud session: Etherpad answers any /p/ address with 200,
  and the API takes any pad, so neither showed the link still works.
- The move between a home and a team folder compares the pending
  deletes before and after: a row wrongly marked as gone keeps its pad
  and opens as before, and only that count shows it.
- The open editor waits several times what its first change needed,
  three seconds at least, before it says the second never came.
- The switch is put back as the admin had it, unset if it was, through
  the provisioning API's delete.
- The open editor's file is deleted afterwards if the test stopped
  before the trash.
- The Etherpad frames are built in one place for every helper.
`as typeof payload` took the `null` the variable was declared with, and
every field read after it was `never`: three strict errors, without
effect only because Playwright does not check types.
@qodo-code-review

Copy link
Copy Markdown

ⓘ Qodo reviews are paused because the subscription is no longer active. Ask your workspace admin to reactivate the subscription to resume reviews. Manage billing

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

PR Summary by Qodo

Cover pad lifecycle across trash, restore, and permanent deletion

🧪 Tests 🕐 20-40 Minutes

Grey Divider

AI Description

• Add end-to-end coverage for pad access, edits, and recovery across trash and restore.
• Verify team-folder moves, deletion settings, and cleanup across multiple job batches.
• Check that ordinary sync writes newly recovered pad content back to its file.
Diagram

graph TD
  S["Lifecycle specs"] --> D["WebDAV fixtures"] --> F["Nextcloud files"] --> P["Pad API"] --> E["Etherpad pads"]
  S --> B["Browser editor"] --> E
  S --> A["Admin settle"] --> E
Loading
High-Level Assessment

Keep the end-to-end approach: the promises depend on Nextcloud file events, real editor behavior, and Etherpad state together. API-only checks would miss browser behavior, while waiting for cron would make cleanup assertions slower and less deterministic.

Files changed (6) +311 / -12

Tests (6) +311 / -12
dav.tsAdd app-config deletion for test cleanup +5/-0

Add app-config deletion for test cleanup

• Adds a provisioning-API helper to remove an app setting. Tests can restore an initially unset setting rather than leaving an explicit value behind.

tests/e2e/fixtures/dav.ts

etherpad.tsCorrect the Etherpad API response type +5/-2

Correct the Etherpad API response type

• Uses an explicit response type when parsing Etherpad JSON, avoiding the incorrect narrowing caused by casting to the initially null payload variable.

tests/e2e/fixtures/etherpad.ts

nextcloud.tsShare Etherpad frame traversal and typing helpers +30/-6

Share Etherpad frame traversal and typing helpers

• Centralizes viewer and editor iframe locators and adds helpers for typing through the Nextcloud viewer or a direct pad page. The existing display-name assertion reuses the viewer locator.

tests/e2e/fixtures/nextcloud.ts

pad-gone-for-good.spec.tsTest public trash access, deletion settings, team moves, and batch cleanup +180/-3

Test public trash access, deletion settings, team moves, and batch cleanup

• Adds cases for editing a public pad while its file is trashed, preserving pads across team-folder moves and trash restores, and honoring 'delete_pad_with_file'. A 250-pad folder case checks cleanup beyond one batch, with the existing Nextcloud 34 folder-deletion skip applied.

tests/e2e/specs/pad-gone-for-good.spec.ts

pad-lost.spec.tsVerify restored and recovered pads sync new edits +48/-0

Verify restored and recovered pads sync new edits

• Checks that ordinary sync returns 'updated' and writes edits from a newly created pad into its file. Adds a restore case modeling a beta.1-trashed file whose original pad and binding row are gone.

tests/e2e/specs/pad-lost.spec.ts

pad-trash-restore.spec.tsCheck that trashing stops an open protected editor from writing +43/-1

Check that trashing stops an open protected editor from writing

• Types into an open protected pad before and after its file enters the trash, then verifies the later text never reaches Etherpad. The test allows at least three seconds for a rejected change to arrive and cleans up the trashed file.

tests/e2e/specs/pad-trash-restore.spec.ts

@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (1) 📘 Rule violations (0) 📎 Requirement gaps (0) 🎨 UX issues (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)

Grey Divider


Action required

1. Public pad tests fail on Docker HTTPS 🐞 Bug ☼ Reliability
Description
browser.newContext() creates the visitor context without the ignoreHTTPSErrors option configured
for the normal Playwright context. When the test opens the Docker stack’s HTTPS pad URL, its locally
minted certificate can stop navigation before the public-pad behavior is tested.
Code

tests/e2e/specs/pad-gone-for-good.spec.ts[237]

+			const visitor = await browser.newContext({ storageState: { cookies: [], origins: [] } })
Evidence
The added context supplies only an empty storage state before navigating to pad.padUrl. The
Playwright configuration sets ignoreHTTPSErrors for its configured contexts, and the Docker stack
explicitly requires that setting for its locally minted certificate.

tests/e2e/specs/pad-gone-for-good.spec.ts[237-242]
tests/e2e/playwright.config.ts[98-104]
tests/e2e/docker/README.md[70-81]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The new unauthenticated visitor context omits the certificate option needed to open the Docker stack’s HTTPS Etherpad URL.
## Fix Focus Areas
- tests/e2e/specs/pad-gone-for-good.spec.ts[237-242]
- tests/e2e/playwright.config.ts[98-104]
## Recommended Fix
Pass `ignoreHTTPSErrors` to the visitor’s `browser.newContext()` using the same `E2E_IGNORE_HTTPS_ERRORS` setting as the Playwright configuration, while keeping certificate errors fatal for other targets.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Tip of the day
💡 Did you know, you can route each severity your way: inline, summary, both, or drop

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

const written = `written while in the trash ${Date.now()}`
try {
await deleteViaDav(name)
const visitor = await browser.newContext({ storageState: { cookies: [], origins: [] } })

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Action required

1. Public pad tests fail on docker https 🐞 Bug ☼ Reliability

browser.newContext() creates the visitor context without the ignoreHTTPSErrors option configured
for the normal Playwright context. When the test opens the Docker stack’s HTTPS pad URL, its locally
minted certificate can stop navigation before the public-pad behavior is tested.
Agent Prompt
## Issue description
The new unauthenticated visitor context omits the certificate option needed to open the Docker stack’s HTTPS Etherpad URL.

## Fix Focus Areas
- tests/e2e/specs/pad-gone-for-good.spec.ts[237-242]
- tests/e2e/playwright.config.ts[98-104]

## Recommended Fix
Pass `ignoreHTTPSErrors` to the visitor’s `browser.newContext()` using the same `E2E_IGNORE_HTTPS_ERRORS` setting as the Playwright configuration, while keeping certificate errors fatal for other targets.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Not applied. In Playwright Test, a context a test opens with browser.newContext() takes the config's use options, ignoreHTTPSErrors among them; the options passed here replace only storageState. The visitor context opens the Docker stack's pad over HTTPS: this test passed against the stack locally, on Nextcloud 34 and 32.0.9, and in all three e2e jobs of this PR's run on 67974de, Etherpad 3 included, on a runner whose browser does not trust the stack's CA. public-share-view.spec.ts has opened the same stack from plain browser.newContext() contexts all along.

Jaggob added 2 commits October 7, 2026 00:58
…o run

- The switch is only flipped where deleting is on already: switched on
  and settled at once, it would delete every pad an admin who has it
  off is keeping. A non-admin account skips it like the rest.
- The sync after a pad made anew checks the file counts the new pad's
  revisions, and the old pad has more than the new one reaches: kept at
  the old count, the file would have passed before. The beta.1 restore
  runs that check too.
- The public pad in the trash is checked to be kept before its link is
  visited, which would make it anew, and what it held before the trash
  has to come back with what was written in it.
- The move into the team folder is tried again while its mount is not
  there yet; the counts that are the instance's, pending deletes and a
  later settle, are held exact only on a throwaway stack.
- The open editor's round trip is timed from the keys, not the editor's
  load, and its wait is capped.
- The many-pads case retries a create under a new name, checks the pads
  ten at a time, and leaves no folder behind when it stops early; the
  team trash case leaves no file or trash entry.
- padOfFile() and restoreAppConfig() are shared helpers; the legacy
  spec puts back an unset key as unset.
@Jaggob
Jaggob merged commit a31255c into main Oct 7, 2026
@Jaggob
Jaggob deleted the test/lifecycle-scenarios branch October 7, 2026 12:07
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