@fluidframework/test-utils 1.4.0-121020 → 2.0.0-dev-rc.1.0.0.224419
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/.eslintrc.js +8 -7
- package/.mocharc.js +12 -0
- package/CHANGELOG.md +177 -0
- package/README.md +44 -14
- package/api-extractor-lint.json +4 -0
- package/api-extractor.json +2 -2
- package/api-report/test-utils.api.md +395 -0
- package/dist/DriverWrappers.d.ts +32 -0
- package/dist/DriverWrappers.d.ts.map +1 -0
- package/dist/DriverWrappers.js +57 -0
- package/dist/DriverWrappers.js.map +1 -0
- package/dist/TestConfigs.d.ts +10 -0
- package/dist/TestConfigs.d.ts.map +1 -0
- package/dist/TestConfigs.js +17 -0
- package/dist/TestConfigs.js.map +1 -0
- package/dist/TestSummaryUtils.d.ts +61 -0
- package/dist/TestSummaryUtils.d.ts.map +1 -0
- package/dist/TestSummaryUtils.js +135 -0
- package/dist/TestSummaryUtils.js.map +1 -0
- package/dist/containerUtils.d.ts +46 -0
- package/dist/containerUtils.d.ts.map +1 -0
- package/dist/containerUtils.js +85 -0
- package/dist/containerUtils.js.map +1 -0
- package/dist/index.d.ts +14 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +43 -19
- package/dist/index.js.map +1 -1
- package/dist/interfaces.d.ts +6 -0
- package/dist/interfaces.d.ts.map +1 -1
- package/dist/interfaces.js.map +1 -1
- package/dist/loaderContainerTracker.d.ts +39 -15
- package/dist/loaderContainerTracker.d.ts.map +1 -1
- package/dist/loaderContainerTracker.js +214 -86
- package/dist/loaderContainerTracker.js.map +1 -1
- package/dist/localCodeLoader.d.ts +9 -2
- package/dist/localCodeLoader.d.ts.map +1 -1
- package/dist/localCodeLoader.js +18 -17
- package/dist/localCodeLoader.js.map +1 -1
- package/dist/localLoader.d.ts +3 -2
- package/dist/localLoader.d.ts.map +1 -1
- package/dist/localLoader.js +2 -0
- package/dist/localLoader.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.d.ts.map +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/retry.d.ts +1 -0
- package/dist/retry.d.ts.map +1 -1
- package/dist/retry.js +3 -2
- package/dist/retry.js.map +1 -1
- package/dist/test-utils-alpha.d.ts +305 -0
- package/dist/test-utils-beta.d.ts +202 -0
- package/dist/test-utils-public.d.ts +202 -0
- package/dist/test-utils-untrimmed.d.ts +1001 -0
- package/dist/testContainerRuntimeFactory.d.ts +4 -2
- package/dist/testContainerRuntimeFactory.d.ts.map +1 -1
- package/dist/testContainerRuntimeFactory.js +67 -12
- package/dist/testContainerRuntimeFactory.js.map +1 -1
- package/dist/testContainerRuntimeFactoryWithDefaultDataStore.d.ts +23 -0
- package/dist/testContainerRuntimeFactoryWithDefaultDataStore.d.ts.map +1 -0
- package/dist/testContainerRuntimeFactoryWithDefaultDataStore.js +32 -0
- package/dist/testContainerRuntimeFactoryWithDefaultDataStore.js.map +1 -0
- package/dist/testFluidObject.d.ts +30 -12
- package/dist/testFluidObject.d.ts.map +1 -1
- package/dist/testFluidObject.js +74 -43
- package/dist/testFluidObject.js.map +1 -1
- package/dist/testObjectProvider.d.ts +298 -41
- package/dist/testObjectProvider.d.ts.map +1 -1
- package/dist/testObjectProvider.js +377 -61
- package/dist/testObjectProvider.js.map +1 -1
- package/dist/timeoutUtils.d.ts +42 -0
- package/dist/timeoutUtils.d.ts.map +1 -1
- package/dist/timeoutUtils.js +142 -9
- package/dist/timeoutUtils.js.map +1 -1
- package/dist/tsdoc-metadata.json +11 -0
- package/lib/test-utils-alpha.d.ts +305 -0
- package/lib/test-utils-beta.d.ts +202 -0
- package/lib/test-utils-public.d.ts +202 -0
- package/lib/test-utils-untrimmed.d.ts +1001 -0
- package/package.json +106 -72
- package/prettier.config.cjs +8 -0
- package/src/DriverWrappers.ts +83 -0
- package/src/TestConfigs.ts +17 -0
- package/src/TestSummaryUtils.ts +210 -0
- package/src/containerUtils.ts +90 -0
- package/src/index.ts +47 -9
- package/src/interfaces.ts +16 -7
- package/src/loaderContainerTracker.ts +754 -534
- package/src/localCodeLoader.ts +87 -86
- package/src/localLoader.ts +27 -26
- package/src/packageVersion.ts +1 -1
- package/src/retry.ts +33 -26
- package/src/testContainerRuntimeFactory.ts +152 -59
- package/src/testContainerRuntimeFactoryWithDefaultDataStore.ts +61 -0
- package/src/testFluidObject.ts +190 -147
- package/src/testObjectProvider.ts +931 -372
- package/src/timeoutUtils.ts +226 -37
- package/tsconfig.json +9 -13
package/.eslintrc.js
CHANGED
|
@@ -4,10 +4,11 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
module.exports = {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
7
|
+
extends: [require.resolve("@fluidframework/eslint-config-fluid/minimal"), "prettier"],
|
|
8
|
+
parserOptions: {
|
|
9
|
+
project: ["./tsconfig.json", "./src/test/tsconfig.json"],
|
|
10
|
+
},
|
|
11
|
+
rules: {
|
|
12
|
+
"import/no-nodejs-modules": "off",
|
|
13
|
+
},
|
|
14
|
+
};
|
package/.mocharc.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
"use strict";
|
|
7
|
+
|
|
8
|
+
const getFluidTestMochaConfig = require("@fluidframework/mocha-test-setup/mocharc-common");
|
|
9
|
+
|
|
10
|
+
const packageDir = __dirname;
|
|
11
|
+
const config = getFluidTestMochaConfig(packageDir);
|
|
12
|
+
module.exports = config;
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
# @fluidframework/test-utils
|
|
2
|
+
|
|
3
|
+
## 2.0.0-internal.8.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- data-object-base: Removed IFluidRouter from DataObject interfaces and classes [9a451d4946](https://github.com/microsoft/FluidFramework/commits/9a451d4946b5c51a52e4d1ab5bf51e7b285b0d74)
|
|
8
|
+
|
|
9
|
+
The `IFluidRouter` property has been removed from a number of DataObject related classes:
|
|
10
|
+
|
|
11
|
+
- `PureDataObject`
|
|
12
|
+
- `LazyLoadedDataObject`
|
|
13
|
+
- `TestFluidObject`
|
|
14
|
+
|
|
15
|
+
Please migrate to the new `entryPoint` pattern or use the relevant `request` method as necessary.
|
|
16
|
+
|
|
17
|
+
See
|
|
18
|
+
[Removing-IFluidRouter.md](https://github.com/microsoft/FluidFramework/blob/main/packages/common/core-interfaces/Removing-IFluidRouter.md)
|
|
19
|
+
for more details.
|
|
20
|
+
|
|
21
|
+
## 2.0.0-internal.7.4.0
|
|
22
|
+
|
|
23
|
+
Dependency updates only.
|
|
24
|
+
|
|
25
|
+
## 2.0.0-internal.7.3.0
|
|
26
|
+
|
|
27
|
+
Dependency updates only.
|
|
28
|
+
|
|
29
|
+
## 2.0.0-internal.7.2.0
|
|
30
|
+
|
|
31
|
+
Dependency updates only.
|
|
32
|
+
|
|
33
|
+
## 2.0.0-internal.7.1.0
|
|
34
|
+
|
|
35
|
+
Dependency updates only.
|
|
36
|
+
|
|
37
|
+
## 2.0.0-internal.7.0.0
|
|
38
|
+
|
|
39
|
+
### Major Changes
|
|
40
|
+
|
|
41
|
+
- Dependencies on @fluidframework/protocol-definitions package updated to 3.0.0 [871b3493dd](https://github.com/microsoft/FluidFramework/commits/871b3493dd0d7ea3a89be64998ceb6cb9021a04e)
|
|
42
|
+
|
|
43
|
+
This included the following changes from the protocol-definitions release:
|
|
44
|
+
|
|
45
|
+
- Updating signal interfaces for some planned improvements. The intention is split the interface between signals
|
|
46
|
+
submitted by clients to the server and the resulting signals sent from the server to clients.
|
|
47
|
+
- A new optional type member is available on the ISignalMessage interface and a new ISentSignalMessage interface has
|
|
48
|
+
been added, which will be the typing for signals sent from the client to the server. Both extend a new
|
|
49
|
+
ISignalMessageBase interface that contains common members.
|
|
50
|
+
- The @fluidframework/common-definitions package dependency has been updated to version 1.0.0.
|
|
51
|
+
|
|
52
|
+
- Server upgrade: dependencies on Fluid server packages updated to 2.0.1 [871b3493dd](https://github.com/microsoft/FluidFramework/commits/871b3493dd0d7ea3a89be64998ceb6cb9021a04e)
|
|
53
|
+
|
|
54
|
+
Dependencies on the following Fluid server package have been updated to version 2.0.1:
|
|
55
|
+
|
|
56
|
+
- @fluidframework/gitresources: 2.0.1
|
|
57
|
+
- @fluidframework/server-kafka-orderer: 2.0.1
|
|
58
|
+
- @fluidframework/server-lambdas: 2.0.1
|
|
59
|
+
- @fluidframework/server-lambdas-driver: 2.0.1
|
|
60
|
+
- @fluidframework/server-local-server: 2.0.1
|
|
61
|
+
- @fluidframework/server-memory-orderer: 2.0.1
|
|
62
|
+
- @fluidframework/protocol-base: 2.0.1
|
|
63
|
+
- @fluidframework/server-routerlicious: 2.0.1
|
|
64
|
+
- @fluidframework/server-routerlicious-base: 2.0.1
|
|
65
|
+
- @fluidframework/server-services: 2.0.1
|
|
66
|
+
- @fluidframework/server-services-client: 2.0.1
|
|
67
|
+
- @fluidframework/server-services-core: 2.0.1
|
|
68
|
+
- @fluidframework/server-services-ordering-kafkanode: 2.0.1
|
|
69
|
+
- @fluidframework/server-services-ordering-rdkafka: 2.0.1
|
|
70
|
+
- @fluidframework/server-services-ordering-zookeeper: 2.0.1
|
|
71
|
+
- @fluidframework/server-services-shared: 2.0.1
|
|
72
|
+
- @fluidframework/server-services-telemetry: 2.0.1
|
|
73
|
+
- @fluidframework/server-services-utils: 2.0.1
|
|
74
|
+
- @fluidframework/server-test-utils: 2.0.1
|
|
75
|
+
- tinylicious: 2.0.1
|
|
76
|
+
|
|
77
|
+
- test-utils: provideEntryPoint is required [871b3493dd](https://github.com/microsoft/FluidFramework/commits/871b3493dd0d7ea3a89be64998ceb6cb9021a04e)
|
|
78
|
+
|
|
79
|
+
The optional `provideEntryPoint` method has become required on a number of constructors. A value will need to be provided to the following classes:
|
|
80
|
+
|
|
81
|
+
- `BaseContainerRuntimeFactory`
|
|
82
|
+
- `RuntimeFactory`
|
|
83
|
+
- `ContainerRuntime` (constructor and `loadRuntime`)
|
|
84
|
+
- `FluidDataStoreRuntime`
|
|
85
|
+
|
|
86
|
+
See [testContainerRuntimeFactoryWithDefaultDataStore.ts](https://github.com/microsoft/FluidFramework/tree/main/packages/test/test-utils/src/testContainerRuntimeFactoryWithDefaultDataStore.ts) for an example implemtation of `provideEntryPoint` for ContainerRuntime.
|
|
87
|
+
See [pureDataObjectFactory.ts](https://github.com/microsoft/FluidFramework/tree/main/packages/framework/aqueduct/src/data-object-factories/pureDataObjectFactory.ts#L83) for an example implementation of `provideEntryPoint` for DataStoreRuntime.
|
|
88
|
+
|
|
89
|
+
Subsequently, various `entryPoint` and `getEntryPoint()` endpoints have become required. Please see [containerRuntime.ts](https://github.com/microsoft/FluidFramework/tree/main/packages/runtime/container-runtime/src/containerRuntime.ts) for example implementations of these APIs.
|
|
90
|
+
|
|
91
|
+
For more details, see [Removing-IFluidRouter.md](https://github.com/microsoft/FluidFramework/blob/main/packages/common/core-interfaces/Removing-IFluidRouter.md)
|
|
92
|
+
|
|
93
|
+
- Minimum TypeScript version now 5.1.6 [871b3493dd](https://github.com/microsoft/FluidFramework/commits/871b3493dd0d7ea3a89be64998ceb6cb9021a04e)
|
|
94
|
+
|
|
95
|
+
The minimum supported TypeScript version for Fluid 2.0 clients is now 5.1.6.
|
|
96
|
+
|
|
97
|
+
## 2.0.0-internal.6.4.0
|
|
98
|
+
|
|
99
|
+
Dependency updates only.
|
|
100
|
+
|
|
101
|
+
## 2.0.0-internal.6.3.0
|
|
102
|
+
|
|
103
|
+
Dependency updates only.
|
|
104
|
+
|
|
105
|
+
## 2.0.0-internal.6.2.0
|
|
106
|
+
|
|
107
|
+
Dependency updates only.
|
|
108
|
+
|
|
109
|
+
## 2.0.0-internal.6.1.0
|
|
110
|
+
|
|
111
|
+
Dependency updates only.
|
|
112
|
+
|
|
113
|
+
## 2.0.0-internal.6.0.0
|
|
114
|
+
|
|
115
|
+
### Major Changes
|
|
116
|
+
|
|
117
|
+
- Request APIs deprecated from many places [8abce8cdb4](https://github.com/microsoft/FluidFramework/commits/8abce8cdb4e2832fb6405fb44e393bef03d5648a)
|
|
118
|
+
|
|
119
|
+
The `request` API (associated with the `IFluidRouter` interface) has been deprecated on a number of classes and interfaces. The following are impacted:
|
|
120
|
+
|
|
121
|
+
- `IRuntime` and `ContainerRuntime`
|
|
122
|
+
- `IFluidDataStoreRuntime` and `FluidDataStoreRuntime`
|
|
123
|
+
- `IFluidDataStoreChannel`
|
|
124
|
+
- `MockFluidDataStoreRuntime`
|
|
125
|
+
- `TestFluidObject`
|
|
126
|
+
|
|
127
|
+
Please migrate usage to the corresponding `entryPoint` or `getEntryPoint()` of the object. The value for these "entryPoint" related APIs is determined from factories (for `IRuntime` and `IFluidDataStoreRuntime`) via the `initializeEntryPoint` method. If no method is passed to the factory, the corresponding `entryPoint` and `getEntryPoint()` will be undefined.
|
|
128
|
+
|
|
129
|
+
For an example implementation of `initializeEntryPoint`, see [pureDataObjectFactory.ts](https://github.com/microsoft/FluidFramework/blob/next/packages/framework/aqueduct/src/data-object-factories/pureDataObjectFactory.ts#L84).
|
|
130
|
+
|
|
131
|
+
More information of the migration off the request pattern, and current status of its removal, is documented in [Removing-IFluidRouter.md](https://github.com/microsoft/FluidFramework/blob/main/packages/common/core-interfaces/Removing-IFluidRouter.md).
|
|
132
|
+
|
|
133
|
+
- TestFluidObject.load removed [8abce8cdb4](https://github.com/microsoft/FluidFramework/commits/8abce8cdb4e2832fb6405fb44e393bef03d5648a)
|
|
134
|
+
|
|
135
|
+
TestFluidObject.load performed unsafe initialization, and has instead been replaced by direct usage of the constructor plus a call to testFluidObject.initialize(). This should have no impact to your scenario, as instantiation of TestFluidObjects should only be done through TestFluidObjectFactory.
|
|
136
|
+
|
|
137
|
+
- EventAndErrorTrackingLogger is no longer a TelemetryLogger [8abce8cdb4](https://github.com/microsoft/FluidFramework/commits/8abce8cdb4e2832fb6405fb44e393bef03d5648a)
|
|
138
|
+
|
|
139
|
+
TelemetryLogger was deprecated and has now been removed, so EventAndErrorTrackingLogger can no longer inherit from it. EventAndErrorTrackingLogger is now a ITelemetryBaseLogger, to get an ITelemetryLogger, or ITelemetryLoggerExt call createChildLogger and pass in the EventAndErrorTrackingLogger as the logger property.
|
|
140
|
+
|
|
141
|
+
- Upgraded typescript transpilation target to ES2020 [8abce8cdb4](https://github.com/microsoft/FluidFramework/commits/8abce8cdb4e2832fb6405fb44e393bef03d5648a)
|
|
142
|
+
|
|
143
|
+
Upgraded typescript transpilation target to ES2020. This is done in order to decrease the bundle sizes of Fluid Framework packages. This has provided size improvements across the board for ex. Loader, Driver, Runtime etc. Reduced bundle sizes helps to load lesser code in apps and hence also helps to improve the perf.If any app wants to target any older versions of browsers with which this target version is not compatible, then they can use packages like babel to transpile to a older target.
|
|
144
|
+
|
|
145
|
+
## 2.0.0-internal.5.4.0
|
|
146
|
+
|
|
147
|
+
Dependency updates only.
|
|
148
|
+
|
|
149
|
+
## 2.0.0-internal.5.3.0
|
|
150
|
+
|
|
151
|
+
Dependency updates only.
|
|
152
|
+
|
|
153
|
+
## 2.0.0-internal.5.2.0
|
|
154
|
+
|
|
155
|
+
Dependency updates only.
|
|
156
|
+
|
|
157
|
+
## 2.0.0-internal.5.1.0
|
|
158
|
+
|
|
159
|
+
Dependency updates only.
|
|
160
|
+
|
|
161
|
+
## 2.0.0-internal.5.0.0
|
|
162
|
+
|
|
163
|
+
### Major Changes
|
|
164
|
+
|
|
165
|
+
- ensureSynchronizedWithTimeout removed from LoaderContainerTracker [8b242fdc79](https://github.com/microsoft/FluidFramework/commits/8b242fdc796714cf1da9ad3f90d02efb122af0c2)
|
|
166
|
+
|
|
167
|
+
In @fluidframework/test-utils, `LoaderContainerTracker.ensureSynchronizedWithTimeout` has been removed, as it is
|
|
168
|
+
equivalent to `LoaderContainerTracker.ensureSynchronized`. The `timeoutDuration` parameter from
|
|
169
|
+
`TestObjectProvider.ensureSynchronized` has also been removed. Configure the timeout for the test instead.
|
|
170
|
+
|
|
171
|
+
## 2.0.0-internal.4.4.0
|
|
172
|
+
|
|
173
|
+
Dependency updates only.
|
|
174
|
+
|
|
175
|
+
## 2.0.0-internal.4.1.0
|
|
176
|
+
|
|
177
|
+
Dependency updates only.
|
package/README.md
CHANGED
|
@@ -7,6 +7,7 @@ This package contains utilities for writing end-to-end tests in Fluid Framework.
|
|
|
7
7
|
`LocalCodeLoader` in `localCodeLoader.ts` is a simple code loader that can load a Fluid package with a given entry point. It can be used to load multiple different Fluid packages with different sources (`IFluidCodeDetails`).
|
|
8
8
|
|
|
9
9
|
It should be created by passing in a list of source to entry point mapping. Then entry point can be an `IFluidDataStoreFactory`, `IRuntimeFactory` or a `fluidExport`:
|
|
10
|
+
|
|
10
11
|
```typeScript
|
|
11
12
|
// The fluidEntryPoint type.
|
|
12
13
|
export type fluidEntryPoint = Partial<IProvideRuntimeFactory & IProvideFluidDataStoreFactory & IFluidModule>;
|
|
@@ -14,9 +15,11 @@ export type fluidEntryPoint = Partial<IProvideRuntimeFactory & IProvideFluidData
|
|
|
14
15
|
// Constructor for LocalCodeLoader.
|
|
15
16
|
constructor(packageEntries: Iterable<[IFluidCodeDetails, fluidEntryPoint]>);
|
|
16
17
|
```
|
|
18
|
+
|
|
17
19
|
On load, it retrieves the `fluidEntryPoint` matching the package in the `IFluidCodeDetails` and loads it.
|
|
18
20
|
|
|
19
21
|
## Local Loader
|
|
22
|
+
|
|
20
23
|
`localLoader.ts` contains couple of methods:
|
|
21
24
|
|
|
22
25
|
### `createLocalLoader`
|
|
@@ -24,6 +27,7 @@ On load, it retrieves the `fluidEntryPoint` matching the package in the `IFluidC
|
|
|
24
27
|
This method creates a simple `Loader` that can be used to resolve a Container or request a Fluid object.
|
|
25
28
|
|
|
26
29
|
It should be created with a list of source to entry point mappings (of type `fluidEntryPoint` as explained in [LocalCodeLoader](#Local-Code-Loader) section above), an `ILocalDeltaConnectionServer` and an `IUrlResolver`:
|
|
30
|
+
|
|
27
31
|
```typeScript
|
|
28
32
|
export function createLocalLoader(
|
|
29
33
|
packageEntries: Iterable<[
|
|
@@ -34,8 +38,9 @@ export function createLocalLoader(
|
|
|
34
38
|
urlResolver: IUrlResolver,
|
|
35
39
|
): ILoader;
|
|
36
40
|
```
|
|
37
|
-
|
|
38
|
-
-
|
|
41
|
+
|
|
42
|
+
- It creates a `LocalCodeLoader` using the `fluidEntryPoint` list to load Container code.
|
|
43
|
+
- It creates a `DocumentServiceFactory` which serves as the driver layer between the container and the server.
|
|
39
44
|
|
|
40
45
|
### `createAndAttachContainer`
|
|
41
46
|
|
|
@@ -44,10 +49,10 @@ helper method on the url resolver passed to the loader to generate the `attachRe
|
|
|
44
49
|
|
|
45
50
|
```typescript
|
|
46
51
|
export async function createAndAttachContainer(
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
): Promise<IContainer
|
|
52
|
+
source: IFluidCodeDetails,
|
|
53
|
+
loader: ILoader,
|
|
54
|
+
attachRequest: IRequest,
|
|
55
|
+
): Promise<IContainer>;
|
|
51
56
|
```
|
|
52
57
|
|
|
53
58
|
The usual flow is to create a `LocalLoader` by calling `createLocalLoader` and then using it to call `createAndAttachContainer`. However, this should work with any `ILoader`.
|
|
@@ -58,6 +63,7 @@ The usual flow is to create a `LocalLoader` by calling `createLocalLoader` and t
|
|
|
58
63
|
It can be used to create a Fluid object (TestFluidObject) with a given set of DDSes which can then be retrieved later as required.
|
|
59
64
|
|
|
60
65
|
For example, if you need a Fluid object with couple of SharedStrings, a SharedDirectory and a SparseMatrix, create a `TestFluidObjectFactory` as follows and use this factory to create the Fluid object:
|
|
66
|
+
|
|
61
67
|
```typeScript
|
|
62
68
|
new TestFluidObjectFactory([
|
|
63
69
|
[ "sharedString1" /* id */, SharedString.getFactory() ],
|
|
@@ -68,6 +74,7 @@ new TestFluidObjectFactory([
|
|
|
68
74
|
```
|
|
69
75
|
|
|
70
76
|
The `TestFluidObject` will then create the above DDSes when initializing and they can then be retrieved by calling `getSharedObject` on it and providing the `id` that was used to create it:
|
|
77
|
+
|
|
71
78
|
```typeScript
|
|
72
79
|
const sharedString1 = testFluidObject.getSharedObject<SharedString>("sharedString1");
|
|
73
80
|
const sharedString1 = testFluidObject.getSharedObject<SharedString>("sharedString2");
|
|
@@ -78,6 +85,7 @@ const matrix = testFluidObject.getSharedObject<SparseMatrix>("matrix");
|
|
|
78
85
|
> If you want a DDS to be part of the registry so that it can be created later but don't want `TestFluidObject` to create it during initialization, use `id` as `undefined` in the `TestFluidObjectFactory` creation.
|
|
79
86
|
|
|
80
87
|
## Op Processing Controller
|
|
88
|
+
|
|
81
89
|
`OpProcessingController` provides control over op processing in the tests. It lets you pause and resume the op processing in the containers / fluid objects. It also lets you wait until the ops have been processed by them and the server.
|
|
82
90
|
|
|
83
91
|
`OpProcessingController` should be created by passing in the `ILocalDeltaConnectionServer` that is used in the test. You can then register the Fluid objects / containers whose ops you want to control with it.
|
|
@@ -89,52 +97,73 @@ You can use the `OpProcessingController` to wait for all that to happen by calli
|
|
|
89
97
|
## Usage
|
|
90
98
|
|
|
91
99
|
The typical usage for testing a Fluid object is as follows:
|
|
100
|
+
|
|
92
101
|
1. Create a `LocalDeltaConnectionServer`:
|
|
102
|
+
|
|
93
103
|
```typescript
|
|
94
104
|
const deltaConnectionServer: ILocalDeltaConnectionServer = LocalDeltaConnectionServer.create();
|
|
95
105
|
```
|
|
96
106
|
|
|
97
107
|
2. Create a `LocalResolver`:
|
|
108
|
+
|
|
98
109
|
```typescript
|
|
99
110
|
const urlResolver: IUrlResolver = new LocalResolver();
|
|
100
111
|
```
|
|
101
112
|
|
|
102
113
|
3. Create an `IFluidCodeDetails` and a `TestFluidObjectFactory` which will serve as the Fluid entry point (code details to factory mapping):
|
|
114
|
+
|
|
103
115
|
```typescript
|
|
104
116
|
const codeDetails: IFluidCodeDetails = {
|
|
105
|
-
|
|
106
|
-
|
|
117
|
+
package: "sharedStringTestPackage",
|
|
118
|
+
config: {},
|
|
107
119
|
};
|
|
108
120
|
const entryPoint = new TestFluidObjectFactory([["sharedString", SharedString.getFactory()]]);
|
|
109
121
|
```
|
|
122
|
+
|
|
110
123
|
> This can replaced by any `IFluidDataStoreFactory` or `IRuntimeFactory`. When the loader is asked to resolve a Container with the above code details, it will load the above factory.
|
|
111
124
|
|
|
112
125
|
4. Create a local `Loader`:
|
|
126
|
+
|
|
113
127
|
```typescript
|
|
114
|
-
const loader: ILoader = createLocalLoader(
|
|
128
|
+
const loader: ILoader = createLocalLoader(
|
|
129
|
+
[[codeDetails, entryPoint]],
|
|
130
|
+
deltaConnectionServer,
|
|
131
|
+
urlResolver,
|
|
132
|
+
);
|
|
115
133
|
```
|
|
116
134
|
|
|
117
135
|
5. Create and attach a `Container` by giving it a `documentId` which is used as a URL to resolve the container:
|
|
136
|
+
|
|
118
137
|
```typescript
|
|
119
138
|
const documentId = "testDocument";
|
|
120
139
|
const container = await createAndAttachContainer(
|
|
121
|
-
|
|
140
|
+
codeDetails,
|
|
141
|
+
loader,
|
|
142
|
+
urlResolver.createCreateNewRequest(documentId),
|
|
143
|
+
);
|
|
122
144
|
```
|
|
145
|
+
|
|
123
146
|
> We used the same `IFluidCodeDetails` that was used to create the `Loader` in step 3.
|
|
124
147
|
|
|
125
|
-
6. Get the `Fluid object (TestFluidObject)` by using `
|
|
148
|
+
6. Get the `Fluid object (TestFluidObject)` by using `getEntryPoint()` API on `IContainer`. Then get the `DDS` to test:
|
|
149
|
+
|
|
126
150
|
```typescript
|
|
127
|
-
const fluidObject = await
|
|
151
|
+
const fluidObject = await container.getEntryPoint();
|
|
128
152
|
const sharedString = await fluidObject.getSharedObject<SharedString>("sharedString");
|
|
129
153
|
```
|
|
154
|
+
|
|
130
155
|
> The `ITestFluidObject` would have already created a `SharedString` based off the parameters we provided when creating the `TestFluidObjectFactory` in step 2.
|
|
131
156
|
|
|
132
157
|
7. To truly test collaboration, create a second `Loader`, `Container`, `fluid object` and `DDS` which will serve as a remote client:
|
|
133
158
|
```typescript
|
|
134
159
|
const documentUrl = `fluid-test://localhost/${documentId}`;
|
|
135
|
-
const loader2: ILoader = createLocalLoader(
|
|
160
|
+
const loader2: ILoader = createLocalLoader(
|
|
161
|
+
[[codeDetails, entryPoint]],
|
|
162
|
+
deltaConnectionServer,
|
|
163
|
+
urlResolver,
|
|
164
|
+
);
|
|
136
165
|
const container2 = await loader2.resolver({ url: documentUrl });
|
|
137
|
-
const fluidObject = await
|
|
166
|
+
const fluidObject = await container2.getEntryPoint();
|
|
138
167
|
const sharedString2 = await fluidObject2.getSharedObject<SharedString>("sharedString");
|
|
139
168
|
```
|
|
140
169
|
> It is important to use the same `ILocalDeltaConnectionServer` to create the `Loader` and the same `documentId` to load the `Container`. This will make sure that we load the `Container` that was created earlier and do not create a new one.
|
|
@@ -146,6 +175,7 @@ These steps are demonstrated in the image below:
|
|
|
146
175
|
> Note that the LocalDriver is created by the `createLocalLoader` method and does not need to explicitly created.
|
|
147
176
|
|
|
148
177
|
## Example
|
|
178
|
+
|
|
149
179
|
The above usage is taken from [SharedStringTest](../end-to-end-tests/src/test/sharedStringEndToEndTests.spec.ts) which is a very basic example of how to use these utils.
|
|
150
180
|
|
|
151
181
|
There are a number of other examples (some a little more complex) in the same [directory](../end-to-end-tests/src/test).
|
package/api-extractor.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
|
|
3
|
+
"extends": "../../../common/build/build-common/api-extractor-base.json"
|
|
4
4
|
}
|