---
id: TST-COM-ORD-066
title: Entitlements persisted
kind: integration
product_area: commerce
module: orders
revision: 1
status: draft
source_sha:
  services-commerce: c8b66a98e2490617aec38ba5c8165dd9bd0a8f9b
repository: services-commerce
files:
  - modules/entitlements/tests/integration/services/persistence/entitlements.integration.spec.js
implements:
  - ATS-COM-ORD-013-12
  - ATS-COM-ORD-013-13
  - FAS-COM-ORD-05-05
environment: local
implementation_state: implemented
latest_result: not-run
latest_run_at: null
latest_run_ref: null
conformance: not-verified
estimated_minutes: 2
isolation: The suite creates its own test workspace records and removes them using the fixture cleanup.
evidence:
  - provenance: test
    source: >-
      services-commerce:modules/entitlements/tests/integration/services/persistence/entitlements.integration.spec.js
    test_cases:
      - 'writes the grant active with the quantity, the window open-ended and the remaining quantity generated'
      - 'answers the line’s existing grant of the kind on a second grant, unchanged'
      - 'writes a manual grant with no line each time, unlimited'
      - >-
        draws from the grant that expires soonest first, one use row per unit, and answers the draws with what
        is left
      - 'answers a repeat under the same consumer and reference with the first draw, nothing written'
      - 'refuses a draw the holder cannot cover, with what is available, and writes nothing'
      - never draws another holder’s grants
      - 'is never short of an unlimited grant, and answers null remaining'
      - lets the first draw the two left
      - 'refuses the second once the first committed, and the ledger holds exactly the first’s uses'
      - >-
        gives a use back (the use marked, the count one lower), refuses the same use again 409, and an unknown
        use 404
      - 'lets the next draw take the next index, never the restored one'
      - >-
        revokes the line’s active grants with the reason, keeps the used quantity, and changes nothing on a
        repeat
      - 'reinstates only what the named reason revoked, and expires a reinstated grant whose window has passed'
      - 'expires an active grant whose window has passed, once, and leaves one inside its window'
scenario_coverage:
  - scenario: ATS-COM-ORD-013-12
    test_cases:
      - lets the first draw the two left
      - 'refuses the second once the first committed, and the ledger holds exactly the first’s uses'
    scope: >-
      The cited cases exercise the scenario’s listed fixture outcomes; this register makes no verified
      conformance claim.
  - scenario: ATS-COM-ORD-013-13
    test_cases:
      - 'reinstates only what the named reason revoked, and expires a reinstated grant whose window has passed'
    scope: >-
      The cited cases exercise the scenario’s listed fixture outcomes; this register makes no verified
      conformance claim.
  - scenario: FAS-COM-ORD-05-05
    test_cases:
      - lets the first draw the two left
      - >-
        refuses the second once the first committed, and the ledger holds
        exactly the first’s uses
    scope: >-
      The fixture chain asserts this outcome within the suite’s declared
      dependency boundary.
dependency_evidence:
  provenance: test
  source: >-
    services-commerce:modules/entitlements/tests/integration/services/persistence/entitlements.integration.spec.js
  declared_by_test: >-
    PostgreSQL, the persistence services, the consume function under the capability role, the execution
    contexts under `rhythm_commerce_app`, a second application pool for the race. Doubled: nothing.
---

# Entitlements persisted

## Verification Boundary

The suite exercises persistence or workflow operations against the local integration database.

## What This Suite Proves

The registered cases check entitlements persisted with their fixture records and assertions. Scenario bindings name only the examples those cases exercise.

## What It Does Not Prove

A registered file supplies no run result or verified conformance by itself. Local fixtures do not establish deployed cross-service behavior or complete browser journeys.

## Real Dependencies and Test Doubles

PostgreSQL and the exercised Commerce persistence or workflow code are real. Remote service records, clocks and transports follow the suite’s fixtures.

## Must Not Be Doubled

The database constraints, role restrictions, locks and transactions exercised by this suite must use PostgreSQL.
