Skip to content

fix: delete order documents before deleting created orders in cleanup - #735

Merged
Yusuf Tür (yusufttur) merged 1 commit into
trunkfrom
fix/cleanup-delete-order-documents
Oct 19, 2026
Merged

Yusuf Tür (yusufttur) merged 1 commit into
trunkfrom
fix/cleanup-delete-order-documents

Conversation

@yusufttur

Copy link
Copy Markdown
Contributor

fix: delete order documents before deleting created orders in cleanup

What?

TestDataService.cleanUp() now deletes the documents of all created orders before it deletes the orders themselves.

  • New public method TestDataService.deleteOrderDocuments(orderIds). It deletes dependent documents (credit notes, cancellation invoices) first, then the documents they reference.
  • cleanUp() calls it for every record registered as order before the priority delete runs.
  • New spec tests/TestDataService/OrderDocumentCleanup.spec.ts creates an order with an invoice and a cancellation invoice, runs the cleanup, and checks that both the documents and the order are gone.

Why?

document.order_id references order with ON DELETE RESTRICT, and the order definition has no cascade for documents. Today, when a test registers an order that has a document (generated through the API, through the admin, or by a flow on the shop), the priority _action/sync delete fails:

  • the order and its documents stay in the shop
  • every other record in the same priority sync (products, customers, categories, …) stays too, because the sync request fails as a whole
  • the test's teardown fails on expect(priorityDeleteOperationsResponse.ok())

This shows up as leftover data after the nightly runs (shopware/shopware#21547). The review on shopware/shopware#21548 asked to fix it centrally here instead of in each test.

How to test

npx playwright test tests/TestDataService/OrderDocumentCleanup.spec.ts

oxlint --type-aware, oxfmt --check and tsgo --noEmit pass.

Follow-up

After the release, bump @shopware-ag/acceptance-test-suite in shopware/shopware#21548. That PR then only registers the storefront order for cleanup; the per-test document cleanup is removed.

🤖 Generated with Claude Code

https://claude.ai/code/session_012HXAuz5s1mTqTrV5HFrfgP

Documents restrict the deletion of their order (ON DELETE RESTRICT), so a
created order with a generated document made the whole cleanup sync fail and
left the order and all other priority records in the shop.

The cleanup now deletes the documents of all created orders first, dependent
documents (credit notes, cancellation invoices) before the documents they
reference. The new TestDataService.deleteOrderDocuments() can also be used
directly.

Related: shopware/shopware#21547

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012HXAuz5s1mTqTrV5HFrfgP
@yusufttur
Yusuf Tür (yusufttur) requested a review from a team as a code owner October 19, 2026 09:10
@pkg-pr-new

pkg-pr-new Bot commented Oct 19, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/shopware/acceptance-test-suite/@shopware-ag/acceptance-test-suite@735

commit: 8ab78bd

@frobel
Florian Robel (frobel) requested a review from a team October 19, 2026 09:47
@yusufttur
Yusuf Tür (yusufttur) merged commit 4334504 into trunk Oct 19, 2026
9 checks passed
@yusufttur
Yusuf Tür (yusufttur) deleted the fix/cleanup-delete-order-documents branch October 19, 2026 11:04
@octo-sts octo-sts Bot mentioned this pull request Oct 19, 2026
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