Payload AI-assisted publishing: approvals, permissions and rollback
Resetting the fixture: a new SQLite file, three users, one published article.
[⣷] Pulling schema from database...
[✓] Pulling schema from database...
Payload 3.90.2, SQLite, REST API at http://127.0.0.1:62268
MOCKED MODEL OUTPUT. Fixed in advance in this fixture; no language model is called.

   live page  "Return unused items within 30 days of delivery for a ..."  published

1  The assistant proposes a draft
   assistant  save a draft (draft=true)    200  saved as a draft
   live page  "Return unused items within 30 days of delivery for a ..."  unchanged

2  The server refuses what the assistant may not do
   assistant  publish                      403  You are not allowed to perform this action.
   assistant  change the URL slug          403  The assistant role cannot change: slug.
   assistant  approve its own draft        403  The assistant role cannot change: review.status.
   assistant  edit the live page directly  403  Edits must be saved as drafts (draft=true).
   assistant  summary over 200 characters  400  invalid: summary

3  A person reviews the draft
   reviewer   reject, with a note          200  rejected
   publisher  publish the rejected draft   403  Only an approved draft can be published.
   assistant  save a revised draft         200  review reset to pending
   reviewer   amend one sentence           200  still pending
   reviewer   approve                      200  approved by reviewer@outfitters.example
   reviewer   publish                      403  You are not allowed to perform this action.

4  Publishing is a separate permission
   publisher  publish the approved draft   200  published
   live page  "Return unused items within 60 days of delivery for a ..."  60 days: a mistake

5  Roll back the mistake
   assistant  restore version 1            403  Only a publisher can restore a version.
   publisher  restore version 1            200  restored
   live page  "Return unused items within 30 days of delivery for a ..."
   verified   title, slug, summary and body match version 1: yes
   verified   no unpublished draft left behind: yes
   history    8 versions; the mistaken one is still there: yes
   log        created      none
   log        draft-saved  assistant
   log        rejected     reviewer
   log        draft-saved  assistant
   log        draft-saved  reviewer
   log        approved     reviewer
   log        published    publisher
   log        restored     publisher

Every step behaved as expected (34.8 s).
