Skip to content

test: failing reproducer for entity:persisting / entity:persisted (#28)#29

Draft
jonasnobile wants to merge 1 commit into
mainfrom
fix/entity-persist-events-not-emitted
Draft

test: failing reproducer for entity:persisting / entity:persisted (#28)#29
jonasnobile wants to merge 1 commit into
mainfrom
fix/entity-persist-events-not-emitted

Conversation

@jonasnobile
Copy link
Copy Markdown
Member

Reproduces #28.

Two failing tests in tests/cases/entityPersistEvents.test.tsx that assert the canonical advertised usage of entity:persisting interceptors and entity:persisted listeners:

(fail) entity:persisting interceptor fires before BatchPersister sends mutations
        Expected length: 1
        Received length: 0
(fail) entity:persisted listener fires after a successful persist
        Expected length: 1
        Received length: 0

The mutation itself succeeds (the in-memory store reflects the new value — assert passes mid-test) which scopes the failure cleanly to the event factory, not the persist pipeline.

Tests are intentionally left failing so the fix-PR can flip them to green without rewriting the assertions.

See #28 for root-cause analysis and two proposed fix paths. Happy to follow up with the implementation against whichever path maintainers prefer.

🤖 Generated with Claude Code

Both the EntityHandle.intercept('entity:persisting', ...) interceptor
and the useOnEntityEvent('entity:persisted', ...) hook are publicly
advertised (the hook's own JSDoc literally documents the persisted
example), but never fire at runtime. The events/eventFactory.ts
createBeforeEvent / createAfterEvent switch statements have no case
for SET_PERSISTING (the action BatchPersister dispatches around the
mutation), so the EventEmitter never receives a before/after event
to fan out.

The two new tests assert the canonical advertised usage and currently
fail with `Received length: 0`. The mutation itself succeeds — the
mock store reflects the new value — proving the gap is purely in the
event factory, not in the persist pipeline.

Same root cause exists for entity:persistFailed (failure path) and
entity:deleting / entity:deleted (DELETE_ENTITY action). Adding
failure injection to MockAdapter is out of scope here; mirroring the
fix once the persisting/persisted path lands is a one-line addition
in the BatchPersister catch branch and the eventFactory switch.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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