Skip to content

Commit f39c867

Browse files
feat(directory): Add oracle for event testing (#25477)
This change introduces a new oracle SharedDirectoryOracle for validating ISharedDirectory event correctness and API contracts. The oracle maintains two separate models tracking directory state through different event streams to ensure both event types report changes consistently. Key features: - Maintains two nested tree models: one tracking valueChanged events (global), one tracking containedValueChanged events (per-directory) - Validates previousValue correctness in events, accounting for optimistic operations and post-clear events - Post-clear events: previousValue has pre-clear value, oracle already cleared → expected mismatch - Remote ops with pending local ops: previousValue is sequenced, oracle is optimistic → expected mismatch - Validates actual directory state matches oracle models using validate() method - Subscribed events: - valueChanged, containedValueChanged: Track key changes - clearInternal: Track directory clears - subDirectoryCreated, subDirectoryDeleted: Track subdirectory lifecycle - disposed, undisposed: Handle rollback scenarios Bugs: [ADO#54515](https://dev.azure.com/fluidframework/internal/_workitems/edit/54515)
1 parent 54584b3 commit f39c867

File tree

5 files changed

+454
-4
lines changed

5 files changed

+454
-4
lines changed

packages/dds/map/src/directory.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1913,11 +1913,13 @@ class SubDirectory extends TypedEventEmitter<IDirectoryEvents> implements IDirec
19131913
}
19141914

19151915
// For pending set operations, emit valueChanged events
1916+
// Include 'path' so listeners can identify which subdirectory the change occurred in
19161917
for (const { key, previousValue } of pendingSets) {
19171918
this.directory.emit(
19181919
"valueChanged",
19191920
{
19201921
key,
1922+
path: this.absolutePath,
19211923
previousValue,
19221924
},
19231925
local,

0 commit comments

Comments
 (0)