Add tests for PatchSet and ServeSession functionality

- Introduced comprehensive tests for the `PatchSet` module, covering methods such as `hasRemoves`, `hasAdditions`, `hasUpdates`, and various ID and instance checks.
- Added a new test suite for `ServeSession`, focusing on WebSocket message handling and confirmation behavior, ensuring correct merging and application of patches.
- Implemented edge case tests in `ChangeBatcher` to verify data integrity during rapid changes and instance removals.
- Enhanced `applyPatch` tests to handle scenarios involving missing instances and ignored class names, ensuring robust patch application logic.
This commit is contained in:
Joe 2026-02-06 22:23:14 -06:00
parent a2c8a583a6
commit 4f3e66bec9
11 changed files with 3026 additions and 20 deletions

View file

@ -230,7 +230,7 @@ function ServeSession:__onWebSocketMessage(messagesPacket)
-- If we're already waiting for confirmation, merge into the patch being confirmed
-- Changes flow into the dialogue even in one-shot mode so user can see them
if self.__confirmingPatch ~= nil then
Log.trace("Already confirming, merging into current patch")
Log.info("Already confirming, merging into current patch")
-- Collect IDs of items that are being changed (for unselecting in UI)
local changedIds = {}
@ -291,7 +291,10 @@ function ServeSession:__onWebSocketMessage(messagesPacket)
-- that arrived while we were waiting for confirmation
self:__applyPatch(combinedPatch)
end
-- Note: "Reject" is not handled for ongoing patches, only for initial sync
-- Note: Table-type responses ({ type = "Confirm", selections = ... }) from
-- the selection-based UI are not yet handled here. Ongoing WebSocket patches
-- with per-item selections would need the same logic as
-- __confirmAndApplyInitialPatch to properly respect push/pull/ignore choices.
end)
self.__apiContext:setMessageCursor(messagesPacket.messageCursor)