@fluidframework/test-utils 2.0.0-internal.6.3.3 → 2.0.0-internal.7.0.0

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.
Files changed (45) hide show
  1. package/CHANGELOG.md +64 -0
  2. package/dist/TestSummaryUtils.d.ts +6 -2
  3. package/dist/TestSummaryUtils.d.ts.map +1 -1
  4. package/dist/TestSummaryUtils.js +17 -9
  5. package/dist/TestSummaryUtils.js.map +1 -1
  6. package/dist/index.d.ts +1 -0
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js +3 -1
  9. package/dist/index.js.map +1 -1
  10. package/dist/localCodeLoader.d.ts +2 -2
  11. package/dist/localCodeLoader.d.ts.map +1 -1
  12. package/dist/localCodeLoader.js +8 -1
  13. package/dist/localCodeLoader.js.map +1 -1
  14. package/dist/packageVersion.d.ts +1 -1
  15. package/dist/packageVersion.js +1 -1
  16. package/dist/packageVersion.js.map +1 -1
  17. package/dist/testContainerRuntimeFactory.d.ts.map +1 -1
  18. package/dist/testContainerRuntimeFactory.js +8 -3
  19. package/dist/testContainerRuntimeFactory.js.map +1 -1
  20. package/dist/testContainerRuntimeFactoryWithDefaultDataStore.d.ts +22 -0
  21. package/dist/testContainerRuntimeFactoryWithDefaultDataStore.d.ts.map +1 -0
  22. package/dist/testContainerRuntimeFactoryWithDefaultDataStore.js +24 -0
  23. package/dist/testContainerRuntimeFactoryWithDefaultDataStore.js.map +1 -0
  24. package/dist/testFluidObject.d.ts +3 -2
  25. package/dist/testFluidObject.d.ts.map +1 -1
  26. package/dist/testFluidObject.js +23 -20
  27. package/dist/testFluidObject.js.map +1 -1
  28. package/dist/testObjectProvider.d.ts +0 -2
  29. package/dist/testObjectProvider.d.ts.map +1 -1
  30. package/dist/testObjectProvider.js +4 -29
  31. package/dist/testObjectProvider.js.map +1 -1
  32. package/dist/timeoutUtils.d.ts +1 -1
  33. package/dist/timeoutUtils.d.ts.map +1 -1
  34. package/dist/timeoutUtils.js +7 -7
  35. package/dist/timeoutUtils.js.map +1 -1
  36. package/dist/tsdoc-metadata.json +1 -1
  37. package/package.json +28 -28
  38. package/src/TestSummaryUtils.ts +29 -15
  39. package/src/index.ts +1 -0
  40. package/src/localCodeLoader.ts +6 -5
  41. package/src/packageVersion.ts +1 -1
  42. package/src/testContainerRuntimeFactory.ts +5 -2
  43. package/src/testContainerRuntimeFactoryWithDefaultDataStore.ts +50 -0
  44. package/src/testFluidObject.ts +6 -4
  45. package/src/testObjectProvider.ts +3 -41
@@ -6,7 +6,11 @@
6
6
  import { ContainerRuntimeFactoryWithDefaultDataStore } from "@fluidframework/aqueduct";
7
7
  import { assert } from "@fluidframework/core-utils";
8
8
  import { IContainer, IHostLoader, LoaderHeader } from "@fluidframework/container-definitions";
9
- import { ISummarizer, ISummaryRuntimeOptions } from "@fluidframework/container-runtime";
9
+ import {
10
+ IOnDemandSummarizeOptions,
11
+ ISummarizer,
12
+ ISummaryRuntimeOptions,
13
+ } from "@fluidframework/container-runtime";
10
14
  import { ITelemetryBaseLogger, FluidObject, IRequest } from "@fluidframework/core-interfaces";
11
15
  import { DriverHeader } from "@fluidframework/driver-definitions";
12
16
  import {
@@ -15,11 +19,11 @@ import {
15
19
  NamedFluidDataStoreRegistryEntries,
16
20
  } from "@fluidframework/runtime-definitions";
17
21
  import { IConfigProviderBase } from "@fluidframework/telemetry-utils";
18
- import { requestFluidObject } from "@fluidframework/runtime-utils";
19
22
  import { ITestContainerConfig, ITestObjectProvider } from "./testObjectProvider";
20
23
  import { mockConfigProvider } from "./TestConfigs";
21
24
  import { waitForContainerConnection } from "./containerUtils";
22
25
  import { timeoutAwait } from "./timeoutUtils";
26
+ import { createContainerRuntimeFactoryWithDefaultDataStore } from "./testContainerRuntimeFactoryWithDefaultDataStore";
23
27
 
24
28
  const summarizerClientType = "summarizer";
25
29
 
@@ -48,11 +52,8 @@ async function createSummarizerCore(
48
52
  const summarizerContainer = await loader.resolve(request);
49
53
  await waitForContainerConnection(summarizerContainer);
50
54
 
51
- const fluidObject: FluidObject<ISummarizer> | undefined = summarizerContainer.getEntryPoint
52
- ? await summarizerContainer.getEntryPoint?.()
53
- : await requestFluidObject<FluidObject<ISummarizer>>(summarizerContainer, {
54
- url: "_summarizer",
55
- });
55
+ const fluidObject: FluidObject<ISummarizer> | undefined =
56
+ await summarizerContainer.getEntryPoint();
56
57
  if (fluidObject?.ISummarizer === undefined) {
57
58
  throw new Error("Fluid object does not implement ISummarizer");
58
59
  }
@@ -89,12 +90,16 @@ export async function createSummarizerFromFactory(
89
90
  ): Promise<{ container: IContainer; summarizer: ISummarizer }> {
90
91
  const innerRequestHandler = async (request: IRequest, runtime: IContainerRuntimeBase) =>
91
92
  runtime.IFluidHandleContext.resolveHandle(request);
92
- const runtimeFactory = new containerRuntimeFactoryType(
93
- dataStoreFactory,
94
- registryEntries ?? [[dataStoreFactory.type, Promise.resolve(dataStoreFactory)]],
95
- undefined,
96
- [innerRequestHandler],
97
- { summaryOptions: defaultSummaryOptions },
93
+ const runtimeFactory = createContainerRuntimeFactoryWithDefaultDataStore(
94
+ containerRuntimeFactoryType,
95
+ {
96
+ defaultFactory: dataStoreFactory,
97
+ registryEntries: registryEntries ?? [
98
+ [dataStoreFactory.type, Promise.resolve(dataStoreFactory)],
99
+ ],
100
+ requestHandlers: [innerRequestHandler],
101
+ runtimeOptions: { summaryOptions: defaultSummaryOptions },
102
+ },
98
103
  );
99
104
 
100
105
  const loader = provider.createLoader([[provider.defaultCodeDetails, runtimeFactory]], {
@@ -136,9 +141,18 @@ export async function createSummarizer(
136
141
  /**
137
142
  * Summarizes on demand and returns the summary tree, the version number and the reference sequence number of the
138
143
  * submitted summary.
144
+ *
145
+ * @param summarizer - The ISummarizer to use to summarize on demand
146
+ * @param inputs - Either the reason string or the full IOnDemandSummarizeOptions.
147
+ * Defaults to the reason "end-to-end test".
139
148
  */
140
- export async function summarizeNow(summarizer: ISummarizer, reason: string = "end-to-end test") {
141
- const result = summarizer.summarizeOnDemand({ reason });
149
+ export async function summarizeNow(
150
+ summarizer: ISummarizer,
151
+ inputs: string | IOnDemandSummarizeOptions = "end-to-end test",
152
+ ) {
153
+ const options: IOnDemandSummarizeOptions =
154
+ typeof inputs === "string" ? { reason: inputs } : inputs;
155
+ const result = summarizer.summarizeOnDemand(options);
142
156
 
143
157
  const submitResult = await timeoutAwait(result.summarySubmitted);
144
158
  if (!submitResult.success) {
package/src/index.ts CHANGED
@@ -38,3 +38,4 @@ export {
38
38
  TimeoutWithValue,
39
39
  } from "./timeoutUtils";
40
40
  export { waitForContainerConnection } from "./containerUtils";
41
+ export { createContainerRuntimeFactoryWithDefaultDataStore } from "./testContainerRuntimeFactoryWithDefaultDataStore";
@@ -71,13 +71,14 @@ export class LocalCodeLoader implements ICodeDetailsLoader {
71
71
  fluidModule = {
72
72
  fluidExport: {
73
73
  ...maybeExport,
74
- IRuntimeFactory: new ContainerRuntimeFactoryWithDefaultDataStore(
74
+ IRuntimeFactory: new ContainerRuntimeFactoryWithDefaultDataStore({
75
75
  defaultFactory,
76
- [[defaultFactory.type, Promise.resolve(defaultFactory)]],
77
- undefined,
78
- [innerRequestHandler],
76
+ registryEntries: [
77
+ [defaultFactory.type, Promise.resolve(defaultFactory)],
78
+ ],
79
+ requestHandlers: [innerRequestHandler],
79
80
  runtimeOptions,
80
- ),
81
+ }),
81
82
  },
82
83
  };
83
84
  }
@@ -6,4 +6,4 @@
6
6
  */
7
7
 
8
8
  export const pkgName = "@fluidframework/test-utils";
9
- export const pkgVersion = "2.0.0-internal.6.3.3";
9
+ export const pkgVersion = "2.0.0-internal.7.0.0";
@@ -3,6 +3,7 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
+ // eslint-disable-next-line import/no-deprecated
6
7
  import { defaultRouteRequestHandler } from "@fluidframework/aqueduct";
7
8
  import { IContainerContext, IRuntime } from "@fluidframework/container-definitions";
8
9
  import {
@@ -11,6 +12,7 @@ import {
11
12
  DefaultSummaryConfiguration,
12
13
  } from "@fluidframework/container-runtime";
13
14
  import { IContainerRuntime } from "@fluidframework/container-runtime-definitions";
15
+ // eslint-disable-next-line import/no-deprecated
14
16
  import { buildRuntimeRequestHandler, RuntimeRequestHandler } from "@fluidframework/request-handler";
15
17
  import { IFluidDataStoreFactory } from "@fluidframework/runtime-definitions";
16
18
  import { RuntimeFactoryHelper } from "@fluidframework/runtime-utils";
@@ -52,8 +54,7 @@ export const createTestContainerRuntimeFactory = (
52
54
  public async instantiateFromExisting(runtime: ContainerRuntime): Promise<void> {
53
55
  // Validate we can load root data stores.
54
56
  // We should be able to load any data store that was created in initializeFirstTime!
55
- await (runtime.getAliasedDataStoreEntryPoint?.("default") ??
56
- runtime.getRootDataStore("default"));
57
+ await runtime.getAliasedDataStoreEntryPoint("default");
57
58
  }
58
59
 
59
60
  async preInitialize(
@@ -66,7 +67,9 @@ export const createTestContainerRuntimeFactory = (
66
67
  ["default", Promise.resolve(this.dataStoreFactory)],
67
68
  [this.type, Promise.resolve(this.dataStoreFactory)],
68
69
  ],
70
+ // eslint-disable-next-line import/no-deprecated
69
71
  buildRuntimeRequestHandler(
72
+ // eslint-disable-next-line import/no-deprecated
70
73
  defaultRouteRequestHandler("default"),
71
74
  ...this.requestHandlers,
72
75
  ),
@@ -0,0 +1,50 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+
6
+ import { ContainerRuntimeFactoryWithDefaultDataStore } from "@fluidframework/aqueduct";
7
+ import { IContainerRuntimeOptions } from "@fluidframework/container-runtime";
8
+ import { IContainerRuntime } from "@fluidframework/container-runtime-definitions";
9
+ import { FluidObject } from "@fluidframework/core-interfaces";
10
+ import { RuntimeRequestHandler } from "@fluidframework/request-handler";
11
+ import {
12
+ IFluidDataStoreFactory,
13
+ NamedFluidDataStoreRegistryEntries,
14
+ } from "@fluidframework/runtime-definitions";
15
+
16
+ /**
17
+ * ! Note: This function is purely needed for back-compat as the constructor argument structure was changed
18
+ */
19
+ export const createContainerRuntimeFactoryWithDefaultDataStore = (
20
+ Base: typeof ContainerRuntimeFactoryWithDefaultDataStore = ContainerRuntimeFactoryWithDefaultDataStore,
21
+ ctorArgs: {
22
+ defaultFactory: IFluidDataStoreFactory;
23
+ registryEntries: NamedFluidDataStoreRegistryEntries;
24
+ dependencyContainer?: any;
25
+ requestHandlers?: RuntimeRequestHandler[];
26
+ runtimeOptions?: IContainerRuntimeOptions;
27
+ provideEntryPoint?: (runtime: IContainerRuntime) => Promise<FluidObject>;
28
+ },
29
+ ): ContainerRuntimeFactoryWithDefaultDataStore => {
30
+ try {
31
+ return new Base(ctorArgs);
32
+ } catch (err) {
33
+ // IMPORTANT: The constructor argument structure changed, so this is needed for dynamically using older ContainerRuntimeFactoryWithDefaultDataStore's
34
+ const {
35
+ defaultFactory,
36
+ registryEntries,
37
+ dependencyContainer,
38
+ requestHandlers,
39
+ runtimeOptions,
40
+ } = ctorArgs;
41
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-return
42
+ return new (Base as any)(
43
+ defaultFactory,
44
+ registryEntries,
45
+ dependencyContainer,
46
+ requestHandlers,
47
+ runtimeOptions,
48
+ );
49
+ }
50
+ };
@@ -3,6 +3,7 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
+ // eslint-disable-next-line import/no-deprecated
6
7
  import { defaultFluidObjectRequestHandler } from "@fluidframework/aqueduct";
7
8
  import {
8
9
  IRequest,
@@ -94,6 +95,7 @@ export class TestFluidObject implements ITestFluidObject {
94
95
  * @deprecated - Will be removed in future major release. Migrate all usage of IFluidRouter to the "entryPoint" pattern. Refer to Removing-IFluidRouter.md
95
96
  */
96
97
  public async request(request: IRequest): Promise<IResponse> {
98
+ // eslint-disable-next-line import/no-deprecated
97
99
  return defaultFluidObjectRequestHandler(this, request);
98
100
  }
99
101
 
@@ -134,6 +136,7 @@ export type ChannelFactoryRegistry = Iterable<[string | undefined, IChannelFacto
134
136
  * Fluid object so that it can create a shared object for each.
135
137
  *
136
138
  * @example
139
+ *
137
140
  * The following will create a Fluid object that creates and loads a SharedString and SharedDirectory.
138
141
  * It will add SparseMatrix to the data store's factory so that it can be created later.
139
142
  *
@@ -152,7 +155,7 @@ export type ChannelFactoryRegistry = Iterable<[string | undefined, IChannelFacto
152
155
  * sharedDir = testFluidObject.getSharedObject<SharedDirectory>("sharedDirectory");
153
156
  * ```
154
157
  *
155
- * @privateRemarks - Beware that using this class generally forfeits some compatibility coverage
158
+ * @privateRemarks Beware that using this class generally forfeits some compatibility coverage
156
159
  * `describeCompat` aims to provide:
157
160
  * `SharedMap`s always reference the current version of SharedMap.
158
161
  * AB#4670 tracks improving this situation.
@@ -199,10 +202,9 @@ export class TestFluidObjectFactory implements IFluidDataStoreFactory {
199
202
 
200
203
  const runtimeClass = mixinRequestHandler(
201
204
  async (request: IRequest, rt: FluidDataStoreRuntime) => {
202
- const maybeRouter: FluidObject<IProvideFluidRouter> | undefined =
203
- await rt.entryPoint?.get();
205
+ const maybeRouter: FluidObject<IProvideFluidRouter> = await rt.entryPoint.get();
204
206
  assert(
205
- maybeRouter?.IFluidRouter !== undefined,
207
+ maybeRouter.IFluidRouter !== undefined,
206
208
  "entryPoint should have been initialized by now",
207
209
  );
208
210
  return maybeRouter.IFluidRouter.request(request);
@@ -7,7 +7,6 @@ import {
7
7
  IContainer,
8
8
  IHostLoader,
9
9
  IFluidCodeDetails,
10
- LoaderHeader,
11
10
  ILoader,
12
11
  } from "@fluidframework/container-definitions";
13
12
  import {
@@ -112,9 +111,6 @@ export interface ITestContainerConfig {
112
111
 
113
112
  /** Loader options for the loader used to create containers */
114
113
  loaderProps?: Partial<ILoaderProps>;
115
-
116
- /** Temporary flag: simulate read connection using delay connection, default is true */
117
- simulateReadConnectionUsingDelay?: boolean;
118
114
  }
119
115
 
120
116
  export const createDocumentId = (): string => uuid();
@@ -386,41 +382,11 @@ export class TestObjectProvider implements ITestObjectProvider {
386
382
  return this.resolveContainer(loader, requestHeader);
387
383
  }
388
384
 
389
- private async resolveContainer(
390
- loader: ILoader,
391
- requestHeader?: IRequestHeader,
392
- delay: boolean = true,
393
- ) {
394
- // Once AB#3889 is done to switch default connection mode to "read" on load, we don't need
395
- // to load "delayed" across the board. Remove the following code.
396
- const delayConnection =
397
- delay &&
398
- (requestHeader === undefined || requestHeader[LoaderHeader.reconnect] !== false);
399
- const headers: IRequestHeader | undefined = delayConnection
400
- ? {
401
- [LoaderHeader.loadMode]: { deltaConnection: "delayed" },
402
- ...requestHeader,
403
- }
404
- : requestHeader;
405
-
406
- const container = await loader.resolve({
385
+ private async resolveContainer(loader: ILoader, headers?: IRequestHeader) {
386
+ return loader.resolve({
407
387
  url: await this.driver.createContainerUrl(this.documentId),
408
388
  headers,
409
389
  });
410
-
411
- // Once AB#3889 is done to switch default connection mode to "read" on load, we don't need
412
- // to load "delayed" across the board. Remove the following code.
413
- if (delayConnection) {
414
- // Older version may not have connect/disconnect. It was add in PR#9439, and available >= 0.59.1000
415
- const maybeContainer = container as Partial<IContainer>;
416
- if (maybeContainer.connect !== undefined) {
417
- container.connect();
418
- } else {
419
- // back compat. Remove when we don't support < 0.59.1000
420
- (container as any).resume();
421
- }
422
- }
423
- return container;
424
390
  }
425
391
 
426
392
  /**
@@ -473,11 +439,7 @@ export class TestObjectProvider implements ITestObjectProvider {
473
439
  ): Promise<IContainer> {
474
440
  const loader = this.makeTestLoader(testContainerConfig);
475
441
 
476
- const container = await this.resolveContainer(
477
- loader,
478
- requestHeader,
479
- testContainerConfig?.simulateReadConnectionUsingDelay,
480
- );
442
+ const container = await this.resolveContainer(loader, requestHeader);
481
443
  await this.waitContainerToCatchUp(container);
482
444
 
483
445
  return container;