@fluidframework/test-utils 2.0.0-internal.6.4.0 → 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.
- package/CHANGELOG.md +60 -0
- package/dist/TestSummaryUtils.d.ts.map +1 -1
- package/dist/TestSummaryUtils.js +10 -7
- package/dist/TestSummaryUtils.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/localCodeLoader.d.ts +2 -2
- package/dist/localCodeLoader.d.ts.map +1 -1
- package/dist/localCodeLoader.js +8 -1
- package/dist/localCodeLoader.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/testContainerRuntimeFactory.d.ts.map +1 -1
- package/dist/testContainerRuntimeFactory.js +8 -3
- package/dist/testContainerRuntimeFactory.js.map +1 -1
- package/dist/testContainerRuntimeFactoryWithDefaultDataStore.d.ts +22 -0
- package/dist/testContainerRuntimeFactoryWithDefaultDataStore.d.ts.map +1 -0
- package/dist/testContainerRuntimeFactoryWithDefaultDataStore.js +24 -0
- package/dist/testContainerRuntimeFactoryWithDefaultDataStore.js.map +1 -0
- package/dist/testFluidObject.d.ts +1 -1
- package/dist/testFluidObject.d.ts.map +1 -1
- package/dist/testFluidObject.js +21 -19
- package/dist/testFluidObject.js.map +1 -1
- package/dist/testObjectProvider.d.ts +0 -2
- package/dist/testObjectProvider.d.ts.map +1 -1
- package/dist/testObjectProvider.js +4 -29
- package/dist/testObjectProvider.js.map +1 -1
- package/dist/timeoutUtils.d.ts +1 -1
- package/dist/timeoutUtils.d.ts.map +1 -1
- package/dist/timeoutUtils.js +7 -7
- package/dist/timeoutUtils.js.map +1 -1
- package/dist/tsdoc-metadata.json +1 -1
- package/package.json +27 -27
- package/src/TestSummaryUtils.ts +13 -12
- package/src/index.ts +1 -0
- package/src/localCodeLoader.ts +6 -5
- package/src/packageVersion.ts +1 -1
- package/src/testContainerRuntimeFactory.ts +5 -2
- package/src/testContainerRuntimeFactoryWithDefaultDataStore.ts +50 -0
- package/src/testFluidObject.ts +4 -3
- package/src/testObjectProvider.ts +3 -41
|
@@ -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
|
|
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
|
+
};
|
package/src/testFluidObject.ts
CHANGED
|
@@ -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
|
|
|
@@ -200,10 +202,9 @@ export class TestFluidObjectFactory implements IFluidDataStoreFactory {
|
|
|
200
202
|
|
|
201
203
|
const runtimeClass = mixinRequestHandler(
|
|
202
204
|
async (request: IRequest, rt: FluidDataStoreRuntime) => {
|
|
203
|
-
const maybeRouter: FluidObject<IProvideFluidRouter>
|
|
204
|
-
await rt.entryPoint?.get();
|
|
205
|
+
const maybeRouter: FluidObject<IProvideFluidRouter> = await rt.entryPoint.get();
|
|
205
206
|
assert(
|
|
206
|
-
maybeRouter
|
|
207
|
+
maybeRouter.IFluidRouter !== undefined,
|
|
207
208
|
"entryPoint should have been initialized by now",
|
|
208
209
|
);
|
|
209
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
|
|
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;
|