Skip to content

Add automatic entity cleanup tracking for scenarios #677

Description

@AlexSkrypnyk

Summary

Track entities created during a scenario and delete them at teardown, with an opt-out tag.

Details

Add an opt-in mechanism that tracks every entity created during a scenario and deletes them (in reverse order) at scenario end, with a tag to bypass cleanup for specific types. This keeps a test database clean across long suites and prevents cross-scenario contamination from leftover content, users, or files.

Proposed behaviour

  • Record entities created through the library's creation steps during a scenario.
  • Delete tracked entities in reverse creation order in an @AfterScenario hook.
  • Provide a tag to bypass cleanup for named entity types.

Acceptance criteria

  • New trait, or shared behaviour, under src/Drupal/.
  • Cleanup runs in reverse creation order and tolerates already-deleted entities.
  • The bypass tag is documented and honoured.
  • Interoperates with the base extension's own cleanup without double-deleting.
  • BDD coverage proving created entities are gone after the scenario.
  • STEPS.md regenerated via ahoy update-docs if steps are added.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions