@cratis/arc 20.28.0 → 20.33.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cratis/arc",
3
- "version": "20.28.0",
3
+ "version": "20.33.2",
4
4
  "description": "",
5
5
  "author": "Cratis",
6
6
  "license": "MIT",
@@ -118,10 +118,6 @@ export class ObservableQueryDiagnostics implements IObservableQueryDiagnostics {
118
118
  }
119
119
 
120
120
  private _publishSnapshot(snapshot: ObservableQueryDiagnosticsSnapshot): void {
121
- if (typeof window !== 'undefined') {
122
- window.dispatchEvent(new CustomEvent('cratis:observable-query-diagnostics', { detail: snapshot }));
123
- }
124
-
125
121
  this._snapshots.next(snapshot);
126
122
  }
127
123
  }
@@ -1,3 +1,6 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+
1
4
  import { describe, it } from 'vitest';
2
5
  import { ObservableQueryDiagnostics, QueryInstanceCache } from '../../queries';
3
6
 
@@ -21,4 +24,26 @@ describe('when tracking query owners', () => {
21
24
  snapshots.should.have.lengthOf(2);
22
25
  snapshots[1].should.equal('{"ownersByQueryKey":{},"queriesByOwner":{}}');
23
26
  });
27
+
28
+ it('should not dispatch browser events when publishing snapshots', () => {
29
+ const diagnostics = new ObservableQueryDiagnostics(
30
+ new QueryInstanceCache(0),
31
+ () => undefined,
32
+ () => ({ queryTransportMethod: 'ServerSentEvents', queryDirectMode: false })
33
+ );
34
+
35
+ const globalWithWindow = globalThis as Record<string, unknown>;
36
+ const originalWindow = globalWithWindow.window;
37
+ const dispatchEvent = function(): never {
38
+ throw new Error('dispatchEvent should not be called');
39
+ };
40
+
41
+ try {
42
+ globalWithWindow.window = { dispatchEvent };
43
+ diagnostics.beginTracking('cache-key', 'OrdersPage');
44
+ diagnostics.endTracking('cache-key');
45
+ } finally {
46
+ globalWithWindow.window = originalWindow;
47
+ }
48
+ });
24
49
  });