@fluidframework/azure-end-to-end-tests 1.1.0-101037
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 +18 -0
- package/LICENSE +21 -0
- package/README.md +8 -0
- package/dist/packageVersion.js +12 -0
- package/dist/packageVersion.js.map +1 -0
- package/dist/test/AzureClientFactory.js +43 -0
- package/dist/test/AzureClientFactory.js.map +1 -0
- package/dist/test/AzureTokenFactory.js +17 -0
- package/dist/test/AzureTokenFactory.js.map +1 -0
- package/dist/test/TestDataObject.js +50 -0
- package/dist/test/TestDataObject.js.map +1 -0
- package/dist/test/audience.spec.js +102 -0
- package/dist/test/audience.spec.js.map +1 -0
- package/dist/test/containerCopy.spec.js +142 -0
- package/dist/test/containerCopy.spec.js.map +1 -0
- package/dist/test/containerCreate.spec.js +112 -0
- package/dist/test/containerCreate.spec.js.map +1 -0
- package/dist/test/ddsTests.spec.js +180 -0
- package/dist/test/ddsTests.spec.js.map +1 -0
- package/dist/test/utils.js +40 -0
- package/dist/test/utils.js.map +1 -0
- package/package.json +97 -0
- package/src/packageVersion.ts +9 -0
- package/src/test/AzureClientFactory.ts +46 -0
- package/src/test/AzureTokenFactory.ts +19 -0
- package/src/test/TestDataObject.ts +68 -0
- package/src/test/audience.spec.ts +138 -0
- package/src/test/containerCopy.spec.ts +184 -0
- package/src/test/containerCreate.spec.ts +152 -0
- package/src/test/ddsTests.spec.ts +246 -0
- package/src/test/tsconfig.json +17 -0
- package/src/test/utils.ts +48 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"containerCreate.spec.js","sourceRoot":"","sources":["../../src/test/containerCreate.spec.ts"],"names":[],"mappings":";;AAAA;;;GAGG;AACH,mCAA0C;AAC1C,iFAAoE;AAEpE,6CAAgD;AAChD,2DAA4D;AAE5D,6DAAyD;AAEzD,QAAQ,CAAC,4BAA4B,EAAE,GAAG,EAAE;IACxC,MAAM,gBAAgB,GAAG,IAA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AAW,EAAE,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC,EAAE;YAC/E,UAAU,EAAE,gBAAgB;YAC5B,QAAQ,EAAE,6BAA6B;SAC1C,CAAC,CAAC;QAEH,MAAM,SAAS,GAAG,MAAM,CAAC,YAAY,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;QAC3D,MAAM,eAAM,CAAC,aAAa,CACtB,SAAS,EACT,GAAG,EAAE,CAAC,IAAI,EACV,sDAAsD,CACzD,CAAC;IACN,CAAC,CAAC,CAAC;IAEH;;;;OAIG;IACH,EAAE,CAAC,iFAAiF,EAAE,KAAK,IAAI,EAAE;QAC7F,MAAM,cAAc,GAAG,OAAO,CAAC,KAAK,CAAC;QACrC,OAAO,CAAC,KAAK,GAAG,GAAS,EAAE,GAAE,CAAC,CAAC;QAC/B,MAAM,qBAAqB,GAAG,MAAM,CAAC,YAAY,CAAC,iBAAiB,EAAE,MAAM,CAAC,CAAC;QAE7E,MAAM,OAAO,GAAG,CAAC,KAAY,EAAW,EAAE;YACtC,eAAM,CAAC,cAAc,CAAC,KAAK,CAAC,OAAO,EAAE,SAAS,EAAE,iCAAiC,CAAC,CAAC;YACnF,OAAO,IAAI,CAAC;QAChB,CAAC,CAAC;QAEF,MAAM,eAAM,CAAC,OAAO,CAChB,qBAAqB,EACrB,OAAO,EACP,gDAAgD,CACnD,CAAC;QACF,OAAO,CAAC,KAAK,GAAG,cAAc,CAAC;IACnC,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport { strict as assert } from \"assert\";\nimport { AttachState } from \"@fluidframework/container-definitions\";\nimport { ContainerSchema } from \"@fluidframework/fluid-static\";\nimport { SharedMap } from \"@fluidframework/map\";\nimport { timeoutPromise } from \"@fluidframework/test-utils\";\nimport { AzureClient } from \"@fluidframework/azure-client\";\nimport { createAzureClient } from \"./AzureClientFactory\";\n\ndescribe(\"Container create scenarios\", () => {\n const connectTimeoutMs = 1000;\n let client: AzureClient;\n let schema: ContainerSchema;\n\n beforeEach(() => {\n client = createAzureClient();\n schema = {\n initialObjects: {\n map1: SharedMap,\n },\n };\n });\n\n /**\n * Scenario: test when Azure Client is instantiated correctly, it can create\n * a container successfully.\n *\n * Expected behavior: an error should not be thrown nor should a rejected promise\n * be returned.\n */\n it(\"can create new Azure Fluid Relay container successfully\", async () => {\n const resourcesP = client.createContainer(schema);\n\n await assert.doesNotReject(\n resourcesP,\n () => true,\n \"container cannot be created in Azure Fluid Relay\",\n );\n });\n\n /**\n * Scenario: test when an Azure Client container is created,\n * it is initially detached.\n *\n * Expected behavior: an error should not be thrown nor should a rejected promise\n * be returned.\n */\n it(\"Created container is detached\", async () => {\n const { container } = await client.createContainer(schema);\n assert.strictEqual(\n container.attachState,\n AttachState.Detached,\n \"Container should be detached\",\n );\n });\n\n /**\n * Scenario: Test attaching a container.\n *\n * Expected behavior: an error should not be thrown nor should a rejected promise\n * be returned.\n */\n it(\"can attach a container\", async () => {\n const { container } = await client.createContainer(schema);\n const containerId = await container.attach();\n\n await timeoutPromise((resolve) => container.once(\"connected\", () => resolve()), {\n durationMs: connectTimeoutMs,\n errorMsg: \"container connect() timeout\",\n });\n\n assert.strictEqual(typeof containerId, \"string\", \"Attach did not return a string ID\");\n assert.strictEqual(\n container.attachState,\n AttachState.Attached,\n \"Container is not attached after attach is called\",\n );\n });\n\n /**\n * Scenario: Test if attaching a container twice fails.\n *\n * Expected behavior: an error should not be thrown nor should a rejected promise\n * be returned.\n */\n it(\"cannot attach a container twice\", async () => {\n const { container } = await client.createContainer(schema);\n const containerId = await container.attach();\n\n await timeoutPromise((resolve) => container.once(\"connected\", () => resolve()), {\n durationMs: connectTimeoutMs,\n errorMsg: \"container connect() timeout\",\n });\n\n assert.strictEqual(typeof containerId, \"string\", \"Attach did not return a string ID\");\n assert.strictEqual(\n container.attachState,\n AttachState.Attached,\n \"Container is attached after attach is called\",\n );\n await assert.rejects(container.attach(), () => true, \"Container should not attach twice\");\n });\n\n /**\n * Scenario: test if Azure Client can get an existing container.\n *\n * Expected behavior: an error should not be thrown nor should a rejected promise\n * be returned.\n */\n it(\"can retrieve existing Azure Fluid Relay container successfully\", async () => {\n const { container: newContainer } = await client.createContainer(schema);\n const containerId = await newContainer.attach();\n\n await timeoutPromise((resolve) => newContainer.once(\"connected\", () => resolve()), {\n durationMs: connectTimeoutMs,\n errorMsg: \"container connect() timeout\",\n });\n\n const resources = client.getContainer(containerId, schema);\n await assert.doesNotReject(\n resources,\n () => true,\n \"container cannot be retrieved from Azure Fluid Relay\",\n );\n });\n\n /**\n * Scenario: test if Azure Client can get a non-exiting container.\n *\n * Expected behavior: an error should be thrown when trying to get a non-existent container.\n */\n it(\"cannot load improperly created container (cannot load a non-existent container)\", async () => {\n const consoleErrorFn = console.error;\n console.error = (): void => {};\n const containerAndServicesP = client.getContainer(\"containerConfig\", schema);\n\n const errorFn = (error: Error): boolean => {\n assert.notStrictEqual(error.message, undefined, \"Azure Client error is undefined\");\n return true;\n };\n\n await assert.rejects(\n containerAndServicesP,\n errorFn,\n \"Azure Client can load a non-existent container\",\n );\n console.error = consoleErrorFn;\n });\n});\n"]}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/*!
|
|
4
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
5
|
+
* Licensed under the MIT License.
|
|
6
|
+
*/
|
|
7
|
+
const assert_1 = require("assert");
|
|
8
|
+
const map_1 = require("@fluidframework/map");
|
|
9
|
+
const test_utils_1 = require("@fluidframework/test-utils");
|
|
10
|
+
const AzureClientFactory_1 = require("./AzureClientFactory");
|
|
11
|
+
const TestDataObject_1 = require("./TestDataObject");
|
|
12
|
+
const utils_1 = require("./utils");
|
|
13
|
+
describe("Fluid data updates", () => {
|
|
14
|
+
const connectTimeoutMs = 1000;
|
|
15
|
+
let client;
|
|
16
|
+
let schema;
|
|
17
|
+
beforeEach(() => {
|
|
18
|
+
client = (0, AzureClientFactory_1.createAzureClient)();
|
|
19
|
+
schema = {
|
|
20
|
+
initialObjects: {
|
|
21
|
+
map1: map_1.SharedMap,
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
});
|
|
25
|
+
/**
|
|
26
|
+
* Scenario: test when an Azure Client container is created,
|
|
27
|
+
* it can set the initial objects.
|
|
28
|
+
*
|
|
29
|
+
* Expected behavior: an error should not be thrown nor should a rejected promise
|
|
30
|
+
* be returned.
|
|
31
|
+
*/
|
|
32
|
+
it("can set DDSes as initial objects for a container", async () => {
|
|
33
|
+
const { container: newContainer } = await client.createContainer(schema);
|
|
34
|
+
const containerId = await newContainer.attach();
|
|
35
|
+
await (0, test_utils_1.timeoutPromise)((resolve) => newContainer.once("connected", () => resolve()), {
|
|
36
|
+
durationMs: connectTimeoutMs,
|
|
37
|
+
errorMsg: "container connect() timeout",
|
|
38
|
+
});
|
|
39
|
+
const resources = client.getContainer(containerId, schema);
|
|
40
|
+
await assert_1.strict.doesNotReject(resources, () => true, "container cannot be retrieved from Azure Fluid Relay");
|
|
41
|
+
const { container } = await resources;
|
|
42
|
+
assert_1.strict.deepStrictEqual(Object.keys(container.initialObjects), Object.keys(schema.initialObjects));
|
|
43
|
+
});
|
|
44
|
+
/**
|
|
45
|
+
* Scenario: test if initialObjects passed into the container functions correctly.
|
|
46
|
+
*
|
|
47
|
+
* Expected behavior: initialObjects value loaded in two different containers should mirror
|
|
48
|
+
* each other after value is changed.
|
|
49
|
+
*/
|
|
50
|
+
it("can change DDSes within initialObjects value", async () => {
|
|
51
|
+
const { container } = await client.createContainer(schema);
|
|
52
|
+
const containerId = await container.attach();
|
|
53
|
+
await (0, test_utils_1.timeoutPromise)((resolve) => container.once("connected", () => resolve()), {
|
|
54
|
+
durationMs: connectTimeoutMs,
|
|
55
|
+
errorMsg: "container connect() timeout",
|
|
56
|
+
});
|
|
57
|
+
const initialObjectsCreate = container.initialObjects;
|
|
58
|
+
const map1Create = initialObjectsCreate.map1;
|
|
59
|
+
map1Create.set("new-key", "new-value");
|
|
60
|
+
const valueCreate = map1Create.get("new-key");
|
|
61
|
+
const { container: containerGet } = await client.getContainer(containerId, schema);
|
|
62
|
+
const map1Get = containerGet.initialObjects.map1;
|
|
63
|
+
const valueGet = await (0, utils_1.mapWait)(map1Get, "new-key");
|
|
64
|
+
assert_1.strict.strictEqual(valueGet, valueCreate, "container can't change initial objects");
|
|
65
|
+
});
|
|
66
|
+
/**
|
|
67
|
+
* Scenario: test if we can create DataObjects through initialObjects schema.
|
|
68
|
+
*
|
|
69
|
+
* Expected behavior: DataObjects can be retrieved from the original and loaded container.
|
|
70
|
+
*/
|
|
71
|
+
it("can set DataObjects as initial objects for a container", async () => {
|
|
72
|
+
const doSchema = {
|
|
73
|
+
initialObjects: {
|
|
74
|
+
mdo1: TestDataObject_1.TestDataObject,
|
|
75
|
+
mdo2: TestDataObject_1.CounterTestDataObject,
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
const { container } = await client.createContainer(doSchema);
|
|
79
|
+
const containerId = await container.attach();
|
|
80
|
+
await (0, test_utils_1.timeoutPromise)((resolve) => container.once("connected", () => resolve()), {
|
|
81
|
+
durationMs: connectTimeoutMs,
|
|
82
|
+
errorMsg: "container connect() timeout",
|
|
83
|
+
});
|
|
84
|
+
const initialObjectsCreate = container.initialObjects;
|
|
85
|
+
(0, assert_1.strict)(initialObjectsCreate.mdo1 instanceof TestDataObject_1.TestDataObject, "container returns the wrong type for mdo1");
|
|
86
|
+
(0, assert_1.strict)(initialObjectsCreate.mdo2 instanceof TestDataObject_1.CounterTestDataObject, "container returns the wrong type for mdo2");
|
|
87
|
+
const { container: containerGet } = await client.getContainer(containerId, doSchema);
|
|
88
|
+
const initialObjectsGet = containerGet.initialObjects;
|
|
89
|
+
(0, assert_1.strict)(initialObjectsGet.mdo1 instanceof TestDataObject_1.TestDataObject, "container returns the wrong type for mdo1");
|
|
90
|
+
(0, assert_1.strict)(initialObjectsCreate.mdo2 instanceof TestDataObject_1.CounterTestDataObject, "container returns the wrong type for mdo2");
|
|
91
|
+
});
|
|
92
|
+
/**
|
|
93
|
+
* Scenario: test if we can create multiple DataObjects of the same type
|
|
94
|
+
*
|
|
95
|
+
* Expected behavior: DataObjects of the same type can be retrieved from the
|
|
96
|
+
* original and loaded container.
|
|
97
|
+
* TODO: Known bug that needs to be re-tested once fixed.
|
|
98
|
+
*/
|
|
99
|
+
it("can use multiple DataObjects of the same type", async () => {
|
|
100
|
+
const doSchema = {
|
|
101
|
+
initialObjects: {
|
|
102
|
+
mdo1: TestDataObject_1.TestDataObject,
|
|
103
|
+
mdo2: TestDataObject_1.CounterTestDataObject,
|
|
104
|
+
mdo3: TestDataObject_1.CounterTestDataObject,
|
|
105
|
+
},
|
|
106
|
+
};
|
|
107
|
+
const { container } = await client.createContainer(doSchema);
|
|
108
|
+
const containerId = await container.attach();
|
|
109
|
+
await (0, test_utils_1.timeoutPromise)((resolve) => container.once("connected", () => resolve()), {
|
|
110
|
+
durationMs: connectTimeoutMs,
|
|
111
|
+
errorMsg: "container connect() timeout",
|
|
112
|
+
});
|
|
113
|
+
const initialObjectsCreate = container.initialObjects;
|
|
114
|
+
(0, assert_1.strict)(initialObjectsCreate.mdo1 instanceof TestDataObject_1.TestDataObject, "container returns the wrong type for mdo1");
|
|
115
|
+
(0, assert_1.strict)(initialObjectsCreate.mdo2 instanceof TestDataObject_1.CounterTestDataObject, "container returns the wrong type for mdo2");
|
|
116
|
+
(0, assert_1.strict)(initialObjectsCreate.mdo3 instanceof TestDataObject_1.CounterTestDataObject, "container returns the wrong type for mdo3");
|
|
117
|
+
const { container: containerGet } = await client.getContainer(containerId, doSchema);
|
|
118
|
+
const initialObjectsGet = containerGet.initialObjects;
|
|
119
|
+
(0, assert_1.strict)(initialObjectsGet.mdo1 instanceof TestDataObject_1.TestDataObject, "container returns the wrong type for mdo1");
|
|
120
|
+
(0, assert_1.strict)(initialObjectsCreate.mdo2 instanceof TestDataObject_1.CounterTestDataObject, "container returns the wrong type for mdo2");
|
|
121
|
+
(0, assert_1.strict)(initialObjectsCreate.mdo3 instanceof TestDataObject_1.CounterTestDataObject, "container returns the wrong type for mdo3");
|
|
122
|
+
});
|
|
123
|
+
/**
|
|
124
|
+
* Scenario: test if we can change DataObject value contained within initialObjects
|
|
125
|
+
*
|
|
126
|
+
* Expected behavior: DataObject changes are correctly reflected on original and loaded containers
|
|
127
|
+
*/
|
|
128
|
+
it("can change DataObjects within initialObjects value", async () => {
|
|
129
|
+
const doSchema = {
|
|
130
|
+
initialObjects: {
|
|
131
|
+
mdo1: TestDataObject_1.TestDataObject,
|
|
132
|
+
mdo2: TestDataObject_1.CounterTestDataObject,
|
|
133
|
+
},
|
|
134
|
+
};
|
|
135
|
+
const { container } = await client.createContainer(doSchema);
|
|
136
|
+
const initialObjectsCreate = container.initialObjects;
|
|
137
|
+
const mdo2 = initialObjectsCreate.mdo2;
|
|
138
|
+
mdo2.increment();
|
|
139
|
+
mdo2.increment();
|
|
140
|
+
mdo2.increment();
|
|
141
|
+
assert_1.strict.strictEqual(mdo2.value, 3);
|
|
142
|
+
const containerId = await container.attach();
|
|
143
|
+
await (0, test_utils_1.timeoutPromise)((resolve) => container.once("connected", () => resolve()), {
|
|
144
|
+
durationMs: connectTimeoutMs,
|
|
145
|
+
errorMsg: "container connect() timeout",
|
|
146
|
+
});
|
|
147
|
+
const { container: containerGet } = await client.getContainer(containerId, doSchema);
|
|
148
|
+
const initialObjectsGet = containerGet.initialObjects;
|
|
149
|
+
const mdo2get = initialObjectsGet.mdo2;
|
|
150
|
+
assert_1.strict.strictEqual(mdo2get.value, 3);
|
|
151
|
+
mdo2get.increment();
|
|
152
|
+
mdo2get.increment();
|
|
153
|
+
assert_1.strict.strictEqual(mdo2get.value, 5);
|
|
154
|
+
});
|
|
155
|
+
/**
|
|
156
|
+
* Scenario: test if the optional schema parameter, dynamicObjectTypes (custom data objects),
|
|
157
|
+
* can be added during runtime and be returned by the container.
|
|
158
|
+
*
|
|
159
|
+
* Expected behavior: added loadable object can be retrieved from the container. Loadable
|
|
160
|
+
* object's id and container config ID should be identical since it's now attached to
|
|
161
|
+
* the container.
|
|
162
|
+
*/
|
|
163
|
+
it("can create/add loadable objects (custom data object) dynamically during runtime", async () => {
|
|
164
|
+
const dynamicSchema = {
|
|
165
|
+
initialObjects: {
|
|
166
|
+
map1: map_1.SharedMap,
|
|
167
|
+
},
|
|
168
|
+
dynamicObjectTypes: [TestDataObject_1.TestDataObject],
|
|
169
|
+
};
|
|
170
|
+
const { container } = await client.createContainer(dynamicSchema);
|
|
171
|
+
const newDo = await container.create(TestDataObject_1.TestDataObject);
|
|
172
|
+
assert_1.strict.ok(newDo === null || newDo === void 0 ? void 0 : newDo.handle);
|
|
173
|
+
const map1 = container.initialObjects.map1;
|
|
174
|
+
map1.set("new-pair-id", newDo.handle);
|
|
175
|
+
const handle = await map1.get("new-pair-id");
|
|
176
|
+
const obj = await (handle === null || handle === void 0 ? void 0 : handle.get());
|
|
177
|
+
assert_1.strict.ok(obj, "container added dynamic objects incorrectly");
|
|
178
|
+
});
|
|
179
|
+
});
|
|
180
|
+
//# sourceMappingURL=ddsTests.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ddsTests.spec.js","sourceRoot":"","sources":["../../src/test/ddsTests.spec.ts"],"names":[],"mappings":";;AAAA;;;GAGG;AACH,mCAA0C;AAG1C,6CAAgD;AAChD,2DAA4D;AAE5D,6DAAyD;AACzD,qDAAyE;AACzE,mCAAkC;AAElC,QAAQ,CAAC,oBAAoB,EAAE,GAAG,EAAE;IAChC,MAAM,gBAAgB,GAAG,IAAI,CAAC;IAC9B,IAAI,MAAmB,CAAC;IACxB,IAAI,MAAuB,CAAC;IAE5B,UAAU,CAAC,GAAG,EAAE;QACZ,MAAM,GAAG,IAAA,sCAAiB,GAAE,CAAC;QAC7B,MA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B,CAAC;QACxD,IAAI,CAAC,GAAG,CAAC,aAAa,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;QACtC,MAAM,MAAM,GAA6B,MAAM,IAAI,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;QACvE,MAAM,GAAG,GAAY,MAAM,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,GAAG,EAAE,CAAA,CAAC;QACzC,eAAM,CAAC,EAAE,CAAC,GAAG,EAAE,6CAA6C,CAAC,CAAC;IAClE,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport { strict as assert } from \"assert\";\nimport { IFluidHandle } from \"@fluidframework/core-interfaces\";\nimport { ContainerSchema } from \"@fluidframework/fluid-static\";\nimport { SharedMap } from \"@fluidframework/map\";\nimport { timeoutPromise } from \"@fluidframework/test-utils\";\nimport { AzureClient } from \"@fluidframework/azure-client\";\nimport { createAzureClient } from \"./AzureClientFactory\";\nimport { TestDataObject, CounterTestDataObject } from \"./TestDataObject\";\nimport { mapWait } from \"./utils\";\n\ndescribe(\"Fluid data updates\", () => {\n const connectTimeoutMs = 1000;\n let client: AzureClient;\n let schema: ContainerSchema;\n\n beforeEach(() => {\n client = createAzureClient();\n schema = {\n initialObjects: {\n map1: SharedMap,\n },\n };\n });\n\n /**\n * Scenario: test when an Azure Client container is created,\n * it can set the initial objects.\n *\n * Expected behavior: an error should not be thrown nor should a rejected promise\n * be returned.\n */\n it(\"can set DDSes as initial objects for a container\", async () => {\n const { container: newContainer } = await client.createContainer(schema);\n const containerId = await newContainer.attach();\n\n await timeoutPromise((resolve) => newContainer.once(\"connected\", () => resolve()), {\n durationMs: connectTimeoutMs,\n errorMsg: \"container connect() timeout\",\n });\n\n const resources = client.getContainer(containerId, schema);\n await assert.doesNotReject(\n resources,\n () => true,\n \"container cannot be retrieved from Azure Fluid Relay\",\n );\n\n const { container } = await resources;\n assert.deepStrictEqual(\n Object.keys(container.initialObjects),\n Object.keys(schema.initialObjects),\n );\n });\n\n /**\n * Scenario: test if initialObjects passed into the container functions correctly.\n *\n * Expected behavior: initialObjects value loaded in two different containers should mirror\n * each other after value is changed.\n */\n it(\"can change DDSes within initialObjects value\", async () => {\n const { container } = await client.createContainer(schema);\n const containerId = await container.attach();\n\n await timeoutPromise((resolve) => container.once(\"connected\", () => resolve()), {\n durationMs: connectTimeoutMs,\n errorMsg: \"container connect() timeout\",\n });\n\n const initialObjectsCreate = container.initialObjects;\n const map1Create = initialObjectsCreate.map1 as SharedMap;\n map1Create.set(\"new-key\", \"new-value\");\n const valueCreate: string | undefined = map1Create.get(\"new-key\");\n\n const { container: containerGet } = await client.getContainer(containerId, schema);\n const map1Get = containerGet.initialObjects.map1 as SharedMap;\n const valueGet: string | undefined = await mapWait(map1Get, \"new-key\");\n assert.strictEqual(valueGet, valueCreate, \"container can't change initial objects\");\n });\n\n /**\n * Scenario: test if we can create DataObjects through initialObjects schema.\n *\n * Expected behavior: DataObjects can be retrieved from the original and loaded container.\n */\n it(\"can set DataObjects as initial objects for a container\", async () => {\n const doSchema: ContainerSchema = {\n initialObjects: {\n mdo1: TestDataObject,\n mdo2: CounterTestDataObject,\n },\n };\n const { container } = await client.createContainer(doSchema);\n const containerId = await container.attach();\n\n await timeoutPromise((resolve) => container.once(\"connected\", () => resolve()), {\n durationMs: connectTimeoutMs,\n errorMsg: \"container connect() timeout\",\n });\n\n const initialObjectsCreate = container.initialObjects;\n assert(\n initialObjectsCreate.mdo1 instanceof TestDataObject,\n \"container returns the wrong type for mdo1\",\n );\n assert(\n initialObjectsCreate.mdo2 instanceof CounterTestDataObject,\n \"container returns the wrong type for mdo2\",\n );\n\n const { container: containerGet } = await client.getContainer(containerId, doSchema);\n const initialObjectsGet = containerGet.initialObjects;\n assert(\n initialObjectsGet.mdo1 instanceof TestDataObject,\n \"container returns the wrong type for mdo1\",\n );\n assert(\n initialObjectsCreate.mdo2 instanceof CounterTestDataObject,\n \"container returns the wrong type for mdo2\",\n );\n });\n\n /**\n * Scenario: test if we can create multiple DataObjects of the same type\n *\n * Expected behavior: DataObjects of the same type can be retrieved from the\n * original and loaded container.\n * TODO: Known bug that needs to be re-tested once fixed.\n */\n it(\"can use multiple DataObjects of the same type\", async () => {\n const doSchema: ContainerSchema = {\n initialObjects: {\n mdo1: TestDataObject,\n mdo2: CounterTestDataObject,\n mdo3: CounterTestDataObject,\n },\n };\n const { container } = await client.createContainer(doSchema);\n const containerId = await container.attach();\n\n await timeoutPromise((resolve) => container.once(\"connected\", () => resolve()), {\n durationMs: connectTimeoutMs,\n errorMsg: \"container connect() timeout\",\n });\n\n const initialObjectsCreate = container.initialObjects;\n assert(\n initialObjectsCreate.mdo1 instanceof TestDataObject,\n \"container returns the wrong type for mdo1\",\n );\n assert(\n initialObjectsCreate.mdo2 instanceof CounterTestDataObject,\n \"container returns the wrong type for mdo2\",\n );\n assert(\n initialObjectsCreate.mdo3 instanceof CounterTestDataObject,\n \"container returns the wrong type for mdo3\",\n );\n\n const { container: containerGet } = await client.getContainer(containerId, doSchema);\n const initialObjectsGet = containerGet.initialObjects;\n assert(\n initialObjectsGet.mdo1 instanceof TestDataObject,\n \"container returns the wrong type for mdo1\",\n );\n assert(\n initialObjectsCreate.mdo2 instanceof CounterTestDataObject,\n \"container returns the wrong type for mdo2\",\n );\n assert(\n initialObjectsCreate.mdo3 instanceof CounterTestDataObject,\n \"container returns the wrong type for mdo3\",\n );\n });\n\n /**\n * Scenario: test if we can change DataObject value contained within initialObjects\n *\n * Expected behavior: DataObject changes are correctly reflected on original and loaded containers\n */\n it(\"can change DataObjects within initialObjects value\", async () => {\n const doSchema: ContainerSchema = {\n initialObjects: {\n mdo1: TestDataObject,\n mdo2: CounterTestDataObject,\n },\n };\n const { container } = await client.createContainer(doSchema);\n const initialObjectsCreate = container.initialObjects;\n const mdo2 = initialObjectsCreate.mdo2 as CounterTestDataObject;\n mdo2.increment();\n mdo2.increment();\n mdo2.increment();\n\n assert.strictEqual(mdo2.value, 3);\n\n const containerId = await container.attach();\n\n await timeoutPromise((resolve) => container.once(\"connected\", () => resolve()), {\n durationMs: connectTimeoutMs,\n errorMsg: \"container connect() timeout\",\n });\n\n const { container: containerGet } = await client.getContainer(containerId, doSchema);\n const initialObjectsGet = containerGet.initialObjects;\n const mdo2get = initialObjectsGet.mdo2 as CounterTestDataObject;\n\n assert.strictEqual(mdo2get.value, 3);\n\n mdo2get.increment();\n mdo2get.increment();\n assert.strictEqual(mdo2get.value, 5);\n });\n\n /**\n * Scenario: test if the optional schema parameter, dynamicObjectTypes (custom data objects),\n * can be added during runtime and be returned by the container.\n *\n * Expected behavior: added loadable object can be retrieved from the container. Loadable\n * object's id and container config ID should be identical since it's now attached to\n * the container.\n */\n it(\"can create/add loadable objects (custom data object) dynamically during runtime\", async () => {\n const dynamicSchema: ContainerSchema = {\n initialObjects: {\n map1: SharedMap,\n },\n dynamicObjectTypes: [TestDataObject],\n };\n\n const { container } = await client.createContainer(dynamicSchema);\n\n const newDo = await container.create(TestDataObject);\n assert.ok(newDo?.handle);\n\n const map1 = container.initialObjects.map1 as SharedMap;\n map1.set(\"new-pair-id\", newDo.handle);\n const handle: IFluidHandle | undefined = await map1.get(\"new-pair-id\");\n const obj: unknown = await handle?.get();\n assert.ok(obj, \"container added dynamic objects incorrectly\");\n });\n});\n"]}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mapWait = exports.waitForMember = void 0;
|
|
4
|
+
const waitForMember = async (audience, userId) => {
|
|
5
|
+
const allMembers = audience.getMembers();
|
|
6
|
+
const member = allMembers.get(userId);
|
|
7
|
+
if (member !== undefined) {
|
|
8
|
+
return member;
|
|
9
|
+
}
|
|
10
|
+
return new Promise((resolve) => {
|
|
11
|
+
const handler = (clientId, newMember) => {
|
|
12
|
+
if (newMember.userId === userId) {
|
|
13
|
+
resolve(newMember);
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
audience.on("memberAdded", handler);
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
exports.waitForMember = waitForMember;
|
|
20
|
+
const mapWait = async (map, key) => {
|
|
21
|
+
const maybeValue = map.get(key);
|
|
22
|
+
if (maybeValue !== undefined) {
|
|
23
|
+
return maybeValue;
|
|
24
|
+
}
|
|
25
|
+
return new Promise((resolve) => {
|
|
26
|
+
const handler = (changed) => {
|
|
27
|
+
if (changed.key === key) {
|
|
28
|
+
map.off("valueChanged", handler);
|
|
29
|
+
const value = map.get(changed.key);
|
|
30
|
+
if (value === undefined) {
|
|
31
|
+
throw new Error("Unexpected valueChanged result");
|
|
32
|
+
}
|
|
33
|
+
resolve(value);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
map.on("valueChanged", handler);
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
exports.mapWait = mapWait;
|
|
40
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/test/utils.ts"],"names":[],"mappings":";;;AASO,MAAM,aAAa,GAAG,KAAK,EAC9B,QAAwB,EACxB,MAAc,EACM,EAAE;IACtB,MAAM,UAAU,GAAG,QAAQ,CAAC,UAAU,EAAE,CAAC;IACzC,MAAM,MAAM,GAAG,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IACtC,IAAI,MAAM,KAAK,SAAS,EAAE;QACtB,OAAO,MAAM,CAAC;KACjB;IACD,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC3B,MAAM,OAAO,GAAG,CAAC,QAAgB,EAAE,SAAkB,EAAQ,EAAE;YAC3D,IAAI,SAAS,CAAC,MAAM,KAAK,MAAM,EAAE;gBAC7B,OAAO,CAAC,SAAwB,CAAC,CAAC;aACrC;QACL,CAAC,CAAC;QACF,QAAQ,CAAC,EAAE,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;IACxC,CAAC,CAAC,CAAC;AACP,CAAC,CAAC;AAjBW,QAAA,aAAa,iBAiBxB;AAEK,MAAM,OAAO,GAAG,KAAK,EAAK,GAAe,EAAE,GAAW,EAAc,EAAE;IACzE,MAAM,UAAU,GAAG,GAAG,CAAC,GAAG,CAAI,GAAG,CAAC,CAAC;IACnC,IAAI,UAAU,KAAK,SAAS,EAAE;QAC1B,OAAO,UAAU,CAAC;KACrB;IAED,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC3B,MAAM,OAAO,GAAG,CAAC,OAAsB,EAAQ,EAAE;YAC7C,IAAI,OAAO,CAAC,GAAG,KAAK,GAAG,EAAE;gBACrB,GAAG,CAAC,GAAG,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;gBACjC,MAAM,KAAK,GAAG,GAAG,CAAC,GAAG,CAAI,OAAO,CAAC,GAAG,CAAC,CAAC;gBACtC,IAAI,KAAK,KAAK,SAAS,EAAE;oBACrB,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;iBACrD;gBACD,OAAO,CAAC,KAAK,CAAC,CAAC;aAClB;QACL,CAAC,CAAC;QACF,GAAG,CAAC,EAAE,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;IACpC,CAAC,CAAC,CAAC;AACP,CAAC,CAAC;AAnBW,QAAA,OAAO,WAmBlB","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport { IMember } from \"fluid-framework\";\n\nimport { AzureMember, IAzureAudience } from \"@fluidframework/azure-client\";\nimport { ISharedMap, IValueChanged } from \"@fluidframework/map\";\n\nexport const waitForMember = async (\n audience: IAzureAudience,\n userId: string,\n): Promise<AzureMember> => {\n const allMembers = audience.getMembers();\n const member = allMembers.get(userId);\n if (member !== undefined) {\n return member;\n }\n return new Promise((resolve) => {\n const handler = (clientId: string, newMember: IMember): void => {\n if (newMember.userId === userId) {\n resolve(newMember as AzureMember);\n }\n };\n audience.on(\"memberAdded\", handler);\n });\n};\n\nexport const mapWait = async <T>(map: ISharedMap, key: string): Promise<T> => {\n const maybeValue = map.get<T>(key);\n if (maybeValue !== undefined) {\n return maybeValue;\n }\n\n return new Promise((resolve) => {\n const handler = (changed: IValueChanged): void => {\n if (changed.key === key) {\n map.off(\"valueChanged\", handler);\n const value = map.get<T>(changed.key);\n if (value === undefined) {\n throw new Error(\"Unexpected valueChanged result\");\n }\n resolve(value);\n }\n };\n map.on(\"valueChanged\", handler);\n });\n};\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@fluidframework/azure-end-to-end-tests",
|
|
3
|
+
"version": "1.1.0-101037",
|
|
4
|
+
"description": "Azure client end to end tests",
|
|
5
|
+
"homepage": "https://fluidframework.com",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/microsoft/FluidFramework.git",
|
|
9
|
+
"directory": "azure/packages/test/end-to-end-tests"
|
|
10
|
+
},
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"author": "Microsoft and contributors",
|
|
13
|
+
"sideEffects": false,
|
|
14
|
+
"scripts": {
|
|
15
|
+
"build": "npm run build:genver && concurrently npm:build:compile npm:lint",
|
|
16
|
+
"build:compile": "npm run build:test",
|
|
17
|
+
"build:full": "npm run build",
|
|
18
|
+
"build:full:compile": "npm run build:compile",
|
|
19
|
+
"build:genver": "gen-version",
|
|
20
|
+
"build:test": "tsc --project ./src/test/tsconfig.json",
|
|
21
|
+
"clean": "rimraf dist lib *.tsbuildinfo *.build.log",
|
|
22
|
+
"eslint": "eslint --format stylish src",
|
|
23
|
+
"eslint:fix": "eslint --format stylish src --fix --fix-type problem,suggestion,layout",
|
|
24
|
+
"lint": "npm run eslint",
|
|
25
|
+
"lint:fix": "npm run eslint:fix",
|
|
26
|
+
"start:tinylicious:test": "PORT=7071 npx @fluidframework/azure-local-service > tinylicious.log 2>&1",
|
|
27
|
+
"test": "npm run test:realsvc",
|
|
28
|
+
"test:realsvc": "npm run test:realsvc:tinylicious",
|
|
29
|
+
"test:realsvc:azure": "cross-env FLUID_CLIENT=azure npm run test:realsvc:azure:run",
|
|
30
|
+
"test:realsvc:azure:run": "mocha --unhandled-rejections=strict --recursive dist/test/**/*.spec.js --exit --timeout 10000",
|
|
31
|
+
"test:realsvc:run": "mocha dist/test --config src/test/.mocharc.js",
|
|
32
|
+
"test:realsvc:tinylicious": "start-server-and-test start:tinylicious:test 7071 test:realsvc:azure:run",
|
|
33
|
+
"test:realsvc:verbose": "cross-env FLUID_TEST_VERBOSE=1 npm run test:realsvc",
|
|
34
|
+
"tsfmt": "tsfmt --verify",
|
|
35
|
+
"tsfmt:fix": "tsfmt --replace"
|
|
36
|
+
},
|
|
37
|
+
"nyc": {
|
|
38
|
+
"all": true,
|
|
39
|
+
"cache-dir": "nyc/.cache",
|
|
40
|
+
"exclude": [
|
|
41
|
+
"src/test/**/*.ts",
|
|
42
|
+
"dist/test/**/*.js"
|
|
43
|
+
],
|
|
44
|
+
"exclude-after-remap": false,
|
|
45
|
+
"include": [
|
|
46
|
+
"src/**/*.ts",
|
|
47
|
+
"dist/**/*.js"
|
|
48
|
+
],
|
|
49
|
+
"report-dir": "nyc/report",
|
|
50
|
+
"reporter": [
|
|
51
|
+
"cobertura",
|
|
52
|
+
"html",
|
|
53
|
+
"text"
|
|
54
|
+
],
|
|
55
|
+
"temp-directory": "nyc/.nyc_output"
|
|
56
|
+
},
|
|
57
|
+
"dependencies": {
|
|
58
|
+
"@fluidframework/aqueduct": "^1.3.0-100520",
|
|
59
|
+
"@fluidframework/azure-client": "1.1.0-101037",
|
|
60
|
+
"@fluidframework/container-definitions": "^1.3.0-100520",
|
|
61
|
+
"@fluidframework/core-interfaces": "^1.3.0-100520",
|
|
62
|
+
"@fluidframework/counter": "^1.3.0-100520",
|
|
63
|
+
"@fluidframework/fluid-static": "^1.3.0-100520",
|
|
64
|
+
"@fluidframework/map": "^1.3.0-100520",
|
|
65
|
+
"@fluidframework/matrix": "^1.3.0-100520",
|
|
66
|
+
"@fluidframework/mocha-test-setup": "^1.3.0-100520",
|
|
67
|
+
"@fluidframework/sequence": "^1.3.0-100520",
|
|
68
|
+
"@fluidframework/server-services-client": "^0.1037.1000-0",
|
|
69
|
+
"@fluidframework/telemetry-utils": "^1.3.0-100520",
|
|
70
|
+
"@fluidframework/test-client-utils": "^1.3.0-100520",
|
|
71
|
+
"@fluidframework/test-runtime-utils": "^1.3.0-100520",
|
|
72
|
+
"@fluidframework/test-utils": "^1.3.0-100520",
|
|
73
|
+
"cross-env": "^7.0.2",
|
|
74
|
+
"fluid-framework": "^1.3.0-100520",
|
|
75
|
+
"mocha": "^10.0.0",
|
|
76
|
+
"sinon": "^7.4.2",
|
|
77
|
+
"start-server-and-test": "^1.11.7",
|
|
78
|
+
"tinylicious": "^0.4.89251",
|
|
79
|
+
"uuid": "^8.3.1"
|
|
80
|
+
},
|
|
81
|
+
"devDependencies": {
|
|
82
|
+
"@fluidframework/build-common": "^1.0.0",
|
|
83
|
+
"@fluidframework/eslint-config-fluid": "^1.0.0",
|
|
84
|
+
"@rushstack/eslint-config": "^2.5.1",
|
|
85
|
+
"@types/mocha": "^9.1.1",
|
|
86
|
+
"@types/nock": "^9.3.0",
|
|
87
|
+
"@types/node": "^14.18.0",
|
|
88
|
+
"@types/uuid": "^8.3.0",
|
|
89
|
+
"concurrently": "^6.2.0",
|
|
90
|
+
"eslint": "~8.6.0",
|
|
91
|
+
"nock": "^10.0.1",
|
|
92
|
+
"nyc": "^15.0.0",
|
|
93
|
+
"rimraf": "^2.6.2",
|
|
94
|
+
"typescript": "~4.5.5",
|
|
95
|
+
"typescript-formatter": "7.1.0"
|
|
96
|
+
}
|
|
97
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*
|
|
5
|
+
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export const pkgName = "@fluidframework/azure-end-to-end-tests";
|
|
9
|
+
export const pkgVersion = "1.1.0-101037";
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { v4 as uuid } from "uuid";
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
AzureClient,
|
|
9
|
+
AzureLocalConnectionConfig,
|
|
10
|
+
AzureRemoteConnectionConfig,
|
|
11
|
+
} from "@fluidframework/azure-client";
|
|
12
|
+
import { InsecureTokenProvider } from "@fluidframework/test-client-utils";
|
|
13
|
+
|
|
14
|
+
import { createAzureTokenProvider } from "./AzureTokenFactory";
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* This function will determine if local or remote mode is required (based on FLUID_CLIENT), and return a new
|
|
18
|
+
* {@link AzureClient} instance based on the mode by setting the Connection config accordingly.
|
|
19
|
+
*/
|
|
20
|
+
export function createAzureClient(userID?: string, userName?: string): AzureClient {
|
|
21
|
+
const useAzure = process.env.FLUID_CLIENT === "azure";
|
|
22
|
+
const tenantId = useAzure
|
|
23
|
+
? (process.env.azure__fluid__relay__service__tenantId as string)
|
|
24
|
+
: "frs-client-tenant";
|
|
25
|
+
const user = {
|
|
26
|
+
id: userID ?? uuid(),
|
|
27
|
+
name: userName ?? uuid(),
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
// use AzureClient remote mode will run against live Azure Fluid Relay.
|
|
31
|
+
// Default to running Tinylicious for PR validation
|
|
32
|
+
// and local testing so it's not hindered by service availability
|
|
33
|
+
const connectionProps: AzureRemoteConnectionConfig | AzureLocalConnectionConfig = useAzure
|
|
34
|
+
? {
|
|
35
|
+
tenantId,
|
|
36
|
+
tokenProvider: createAzureTokenProvider(userID, userName),
|
|
37
|
+
endpoint: "https://alfred.westus2.fluidrelay.azure.com",
|
|
38
|
+
type: "remote",
|
|
39
|
+
}
|
|
40
|
+
: {
|
|
41
|
+
tokenProvider: new InsecureTokenProvider("fooBar", user),
|
|
42
|
+
endpoint: "http://localhost:7071",
|
|
43
|
+
type: "local",
|
|
44
|
+
};
|
|
45
|
+
return new AzureClient({ connection: connectionProps });
|
|
46
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
AzureFunctionTokenProvider
|
|
8
|
+
} from "@fluidframework/azure-client";
|
|
9
|
+
|
|
10
|
+
export function createAzureTokenProvider(
|
|
11
|
+
userID?: string,
|
|
12
|
+
userName?: string,
|
|
13
|
+
): AzureFunctionTokenProvider {
|
|
14
|
+
const fnUrl = process.env.azure__fluid__relay__service__function__url as string;
|
|
15
|
+
return new AzureFunctionTokenProvider(`${fnUrl}/api/GetFrsToken`, {
|
|
16
|
+
userId: userID ?? "foo",
|
|
17
|
+
userName: userName ?? "bar",
|
|
18
|
+
});
|
|
19
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { DataObject, DataObjectFactory, IDataObjectProps } from "@fluidframework/aqueduct";
|
|
7
|
+
import { SharedCounter } from "@fluidframework/counter";
|
|
8
|
+
import { IFluidHandle } from "@fluidframework/core-interfaces";
|
|
9
|
+
|
|
10
|
+
export class TestDataObject extends DataObject {
|
|
11
|
+
public static get Name(): string {
|
|
12
|
+
return "@fluid-example/test-data-object";
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
public static readonly factory = new DataObjectFactory(
|
|
16
|
+
TestDataObject.Name,
|
|
17
|
+
TestDataObject,
|
|
18
|
+
[],
|
|
19
|
+
{},
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
constructor(props: IDataObjectProps) {
|
|
23
|
+
super(props);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export class CounterTestDataObject extends DataObject {
|
|
28
|
+
private _counter: SharedCounter | undefined;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Do setup work here
|
|
32
|
+
*/
|
|
33
|
+
protected async initializingFirstTime(): Promise<void> {
|
|
34
|
+
const counter = SharedCounter.create(this.runtime);
|
|
35
|
+
this.root.set("counter-key", counter.handle);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
protected async hasInitialized(): Promise<void> {
|
|
39
|
+
const counterHandle = this.root.get<IFluidHandle<SharedCounter>>("counter-key");
|
|
40
|
+
this._counter = await counterHandle?.get();
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
public static get Name(): string {
|
|
44
|
+
return "@fluid-example/counter-test-data-object";
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
public static readonly factory = new DataObjectFactory(
|
|
48
|
+
CounterTestDataObject.Name,
|
|
49
|
+
CounterTestDataObject,
|
|
50
|
+
[SharedCounter.getFactory()],
|
|
51
|
+
{},
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
public increment(): void {
|
|
55
|
+
this.counter.increment(1);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
public get value(): number {
|
|
59
|
+
return this.counter.value;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
private get counter(): SharedCounter {
|
|
63
|
+
if (this._counter === undefined) {
|
|
64
|
+
throw new Error("SharedCounter not initialized");
|
|
65
|
+
}
|
|
66
|
+
return this._counter;
|
|
67
|
+
}
|
|
68
|
+
}
|