@itwin/core-backend 5.5.0-dev.1 → 5.5.0-dev.11
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 +34 -1
- package/lib/cjs/ChangesetECAdaptor.d.ts.map +1 -1
- package/lib/cjs/ChangesetECAdaptor.js +0 -2
- package/lib/cjs/ChangesetECAdaptor.js.map +1 -1
- package/lib/cjs/IModelDb.d.ts +15 -1
- package/lib/cjs/IModelDb.d.ts.map +1 -1
- package/lib/cjs/IModelDb.js +17 -15
- package/lib/cjs/IModelDb.js.map +1 -1
- package/lib/cjs/TxnManager.d.ts +2 -1
- package/lib/cjs/TxnManager.d.ts.map +1 -1
- package/lib/cjs/TxnManager.js +7 -2
- package/lib/cjs/TxnManager.js.map +1 -1
- package/lib/esm/ChangesetECAdaptor.d.ts.map +1 -1
- package/lib/esm/ChangesetECAdaptor.js +0 -2
- package/lib/esm/ChangesetECAdaptor.js.map +1 -1
- package/lib/esm/IModelDb.d.ts +15 -1
- package/lib/esm/IModelDb.d.ts.map +1 -1
- package/lib/esm/IModelDb.js +17 -15
- package/lib/esm/IModelDb.js.map +1 -1
- package/lib/esm/TxnManager.d.ts +2 -1
- package/lib/esm/TxnManager.d.ts.map +1 -1
- package/lib/esm/TxnManager.js +7 -2
- package/lib/esm/TxnManager.js.map +1 -1
- package/lib/esm/test/annotations/Fields.test.js +2 -2
- package/lib/esm/test/annotations/Fields.test.js.map +1 -1
- package/lib/esm/test/assets/IncrementalSchemaLocater/configs/simple.config.js +5 -5
- package/lib/esm/test/assets/IncrementalSchemaLocater/configs/simple.config.js.map +1 -1
- package/lib/esm/test/ecdb/ConcurrentQuery.test.js +43 -0
- package/lib/esm/test/ecdb/ConcurrentQuery.test.js.map +1 -1
- package/lib/esm/test/hubaccess/Rebase.test.js +43 -0
- package/lib/esm/test/hubaccess/Rebase.test.js.map +1 -1
- package/lib/esm/test/imodel/IModel.test.js +31 -2
- package/lib/esm/test/imodel/IModel.test.js.map +1 -1
- package/lib/esm/test/incrementalSchemaLocater/ECSqlQueries.test.js +432 -198
- package/lib/esm/test/incrementalSchemaLocater/ECSqlQueries.test.js.map +1 -1
- package/lib/esm/test/incrementalSchemaLocater/IncrementalLoading.test.js +272 -190
- package/lib/esm/test/incrementalSchemaLocater/IncrementalLoading.test.js.map +1 -1
- package/lib/esm/test/incrementalSchemaLocater/TestContext.d.ts +27 -0
- package/lib/esm/test/incrementalSchemaLocater/TestContext.d.ts.map +1 -0
- package/lib/esm/test/incrementalSchemaLocater/TestContext.js +136 -0
- package/lib/esm/test/incrementalSchemaLocater/TestContext.js.map +1 -0
- package/lib/esm/test/standalone/ChangesetReader.test.js +222 -3
- package/lib/esm/test/standalone/ChangesetReader.test.js.map +1 -1
- package/lib/esm/test/standalone/RenderTimeline.test.js +1 -1
- package/lib/esm/test/standalone/RenderTimeline.test.js.map +1 -1
- package/lib/esm/test/standalone/StandaloneDb.test.d.ts +2 -0
- package/lib/esm/test/standalone/StandaloneDb.test.d.ts.map +1 -0
- package/lib/esm/test/standalone/StandaloneDb.test.js +103 -0
- package/lib/esm/test/standalone/StandaloneDb.test.js.map +1 -0
- package/lib/esm/test/standalone/TxnManager.test.js +43 -0
- package/lib/esm/test/standalone/TxnManager.test.js.map +1 -1
- package/package.json +13 -13
- package/lib/esm/test/incrementalSchemaLocater/utils/IModelSchemaLocater.d.ts +0 -11
- package/lib/esm/test/incrementalSchemaLocater/utils/IModelSchemaLocater.d.ts.map +0 -1
- package/lib/esm/test/incrementalSchemaLocater/utils/IModelSchemaLocater.js +0 -36
- package/lib/esm/test/incrementalSchemaLocater/utils/IModelSchemaLocater.js.map +0 -1
- package/lib/esm/test/incrementalSchemaLocater/utils/IncrementalTestHelper.d.ts +0 -20
- package/lib/esm/test/incrementalSchemaLocater/utils/IncrementalTestHelper.d.ts.map +0 -1
- package/lib/esm/test/incrementalSchemaLocater/utils/IncrementalTestHelper.js +0 -126
- package/lib/esm/test/incrementalSchemaLocater/utils/IncrementalTestHelper.js.map +0 -1
- package/lib/esm/test/incrementalSchemaLocater/utils/TestSqlSchemaLocater.d.ts +0 -24
- package/lib/esm/test/incrementalSchemaLocater/utils/TestSqlSchemaLocater.d.ts.map +0 -1
- package/lib/esm/test/incrementalSchemaLocater/utils/TestSqlSchemaLocater.js +0 -67
- package/lib/esm/test/incrementalSchemaLocater/utils/TestSqlSchemaLocater.js.map +0 -1
|
@@ -36,7 +36,7 @@ describe("RenderTimeline", () => {
|
|
|
36
36
|
rootSubject: {
|
|
37
37
|
name,
|
|
38
38
|
},
|
|
39
|
-
|
|
39
|
+
enableTransactions: true,
|
|
40
40
|
};
|
|
41
41
|
const filename = IModelTestUtils.prepareOutputFile("RenderTimeline", `${name}.bim`);
|
|
42
42
|
return StandaloneDb.createEmpty(filename, props);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RenderTimeline.test.js","sourceRoot":"","sources":["../../../../src/test/standalone/RenderTimeline.test.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAC9B,OAAO,EAAE,IAAI,EAAc,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACjE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAuC,MAAM,oBAAoB,CAAC;AACvF,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAC7F,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD,QAAQ,CAAC,gBAAgB,EAAE,GAAG,EAAE;IAC9B,MAAM,CAAC,GAAG,EAAE;QACV,aAAa,CAAC,cAAc,EAAE,CAAC;IACjC,CAAC,CAAC,CAAC;IAEH,SAAS,eAAe;QACtB,OAAO,CAAC;gBACN,OAAO,EAAE,OAAO;gBAChB,gBAAgB,EAAE,CAAC;wBACjB,OAAO,EAAE,CAAC;wBACV,UAAU,EAAE,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Aa,CAAC,CAAC;QACrD,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;QAExD,MAAM,CAAC,KAAK,EAAE,CAAC;IACjB,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\nimport { expect } from \"chai\";\r\nimport { Id64, Id64String, OpenMode } from \"@itwin/core-bentley\";\r\nimport { Code, IModel, RenderSchedule, RenderTimelineProps } from \"@itwin/core-common\";\r\nimport { GenericSchema, IModelJsFs, RenderTimeline, StandaloneDb } from \"../../core-backend\";\r\nimport { IModelTestUtils } from \"../IModelTestUtils\";\r\n\r\ndescribe(\"RenderTimeline\", () => {\r\n before(() => {\r\n GenericSchema.registerSchema();\r\n });\r\n\r\n function makeScriptProps(): RenderSchedule.ScriptProps {\r\n return [{\r\n modelId: \"0x123\",\r\n elementTimelines: [{\r\n batchId: 1,\r\n elementIds: [\"0xabc\", \"0xdef\"],\r\n visibilityTimeline: [{ time: 42, value: 50 }],\r\n }],\r\n }];\r\n }\r\n\r\n function insertTimeline(imodel: StandaloneDb, scriptProps?: RenderSchedule.ScriptProps): Id64String {\r\n const script = JSON.stringify(scriptProps ?? makeScriptProps());\r\n const props: RenderTimelineProps = {\r\n model: IModel.dictionaryId,\r\n classFullName: RenderTimeline.classFullName,\r\n code: Code.createEmpty(),\r\n script,\r\n };\r\n return imodel.elements.insertElement(props);\r\n }\r\n\r\n function createIModel(name: string): StandaloneDb {\r\n const props = {\r\n rootSubject: {\r\n name,\r\n },\r\n enableTransactions: true,\r\n };\r\n const filename = IModelTestUtils.prepareOutputFile(\"RenderTimeline\", `${name}.bim`);\r\n return StandaloneDb.createEmpty(filename, props);\r\n }\r\n\r\n it(\"requires BisCore >= 1.0.13\", () => {\r\n const filename = IModelTestUtils.prepareOutputFile(\"RenderTimeline.SchemaTooOld\", \"testImodel.bim\");\r\n const seedFileName = IModelTestUtils.resolveAssetFile(\"testImodel.bim\");\r\n IModelJsFs.copySync(seedFileName, filename);\r\n\r\n const imodel = StandaloneDb.openFile(filename, OpenMode.ReadWrite);\r\n expect(() => insertTimeline(imodel)).to.throw(\"ecClass not found\");\r\n imodel.close();\r\n });\r\n\r\n it(\"creates, queries, and updates\", () => {\r\n const imodel = createIModel(\"CRUD\");\r\n const timelineId = insertTimeline(imodel);\r\n expect(Id64.isValid(timelineId)).to.be.true;\r\n\r\n let timeline = imodel.elements.getElement<RenderTimeline>(timelineId);\r\n expect(timeline).instanceof(RenderTimeline);\r\n expect(timeline.scriptProps).to.deep.equal(makeScriptProps());\r\n expect(timeline.description).to.equal(\"\");\r\n\r\n timeline.description = \"My timeline\";\r\n const scriptProps = makeScriptProps();\r\n scriptProps.push(makeScriptProps()[0]);\r\n timeline.scriptProps = scriptProps;\r\n\r\n timeline.update();\r\n timeline = imodel.elements.getElement<RenderTimeline>(timelineId);\r\n expect(timeline.description).to.equal(\"My timeline\");\r\n expect(timeline.scriptProps).to.deep.equal(scriptProps);\r\n\r\n imodel.close();\r\n });\r\n});\r\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StandaloneDb.test.d.ts","sourceRoot":"","sources":["../../../../src/test/standalone/StandaloneDb.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
import { assert } from "chai";
|
|
6
|
+
import { _nativeDb, IModelJsFs, StandaloneDb } from "../../core-backend";
|
|
7
|
+
import { IModelTestUtils } from "../IModelTestUtils";
|
|
8
|
+
describe("StandaloneDb", () => {
|
|
9
|
+
describe("transaction flags", () => {
|
|
10
|
+
it("should enable transactions with legacy allowEdit string flag", () => {
|
|
11
|
+
const fileName = IModelTestUtils.prepareOutputFile("StandaloneDb", "AllowEditString.bim");
|
|
12
|
+
// Create with allowEdit set to any truthy string value
|
|
13
|
+
const iModel = StandaloneDb.createEmpty(fileName, {
|
|
14
|
+
rootSubject: { name: "Test" },
|
|
15
|
+
allowEdit: "any string value",
|
|
16
|
+
});
|
|
17
|
+
// Verify the flag is set correctly in the database
|
|
18
|
+
const value = iModel[_nativeDb].queryLocalValue("StandaloneEdit");
|
|
19
|
+
assert.equal(value, `{ "txns": true }`);
|
|
20
|
+
iModel.close();
|
|
21
|
+
IModelJsFs.removeSync(fileName);
|
|
22
|
+
});
|
|
23
|
+
it("should enable transactions with legacy allowEdit JSON string", () => {
|
|
24
|
+
const fileName = IModelTestUtils.prepareOutputFile("StandaloneDb", "AllowEditJSON.bim");
|
|
25
|
+
// Create with allowEdit using the traditional JSON.stringify pattern
|
|
26
|
+
const iModel = StandaloneDb.createEmpty(fileName, {
|
|
27
|
+
rootSubject: { name: "Test" },
|
|
28
|
+
allowEdit: JSON.stringify({ txns: true }),
|
|
29
|
+
});
|
|
30
|
+
// Verify the flag is set correctly
|
|
31
|
+
const value = iModel[_nativeDb].queryLocalValue("StandaloneEdit");
|
|
32
|
+
assert.equal(value, `{ "txns": true }`);
|
|
33
|
+
iModel.close();
|
|
34
|
+
IModelJsFs.removeSync(fileName);
|
|
35
|
+
});
|
|
36
|
+
it("should enable transactions with new enableTransactions boolean flag", () => {
|
|
37
|
+
const fileName = IModelTestUtils.prepareOutputFile("StandaloneDb", "EnableTransactions.bim");
|
|
38
|
+
// Create with the new boolean flag
|
|
39
|
+
const iModel = StandaloneDb.createEmpty(fileName, {
|
|
40
|
+
rootSubject: { name: "Test" },
|
|
41
|
+
enableTransactions: true,
|
|
42
|
+
});
|
|
43
|
+
// Verify the flag is set correctly
|
|
44
|
+
const value = iModel[_nativeDb].queryLocalValue("StandaloneEdit");
|
|
45
|
+
assert.equal(value, `{ "txns": true }`);
|
|
46
|
+
iModel.close();
|
|
47
|
+
IModelJsFs.removeSync(fileName);
|
|
48
|
+
});
|
|
49
|
+
it("should enable transactions when either flag is set", () => {
|
|
50
|
+
const fileName = IModelTestUtils.prepareOutputFile("StandaloneDb", "BothFlags.bim");
|
|
51
|
+
// Create with both flags set
|
|
52
|
+
const iModel = StandaloneDb.createEmpty(fileName, {
|
|
53
|
+
rootSubject: { name: "Test" },
|
|
54
|
+
allowEdit: "legacy",
|
|
55
|
+
enableTransactions: true,
|
|
56
|
+
});
|
|
57
|
+
// Verify the flag is set correctly
|
|
58
|
+
const value = iModel[_nativeDb].queryLocalValue("StandaloneEdit");
|
|
59
|
+
assert.equal(value, `{ "txns": true }`);
|
|
60
|
+
iModel.close();
|
|
61
|
+
IModelJsFs.removeSync(fileName);
|
|
62
|
+
});
|
|
63
|
+
it("should enable transactions with enableTransactions true even if allowEdit is undefined", () => {
|
|
64
|
+
const fileName = IModelTestUtils.prepareOutputFile("StandaloneDb", "OnlyEnableTransactions.bim");
|
|
65
|
+
// Create with only the new flag
|
|
66
|
+
const iModel = StandaloneDb.createEmpty(fileName, {
|
|
67
|
+
rootSubject: { name: "Test" },
|
|
68
|
+
enableTransactions: true,
|
|
69
|
+
});
|
|
70
|
+
// Verify the flag is set correctly
|
|
71
|
+
const value = iModel[_nativeDb].queryLocalValue("StandaloneEdit");
|
|
72
|
+
assert.equal(value, `{ "txns": true }`);
|
|
73
|
+
iModel.close();
|
|
74
|
+
IModelJsFs.removeSync(fileName);
|
|
75
|
+
});
|
|
76
|
+
it("should not enable transactions when both flags are false/undefined", () => {
|
|
77
|
+
const fileName = IModelTestUtils.prepareOutputFile("StandaloneDb", "NoFlags.bim");
|
|
78
|
+
// Create without enabling transactions
|
|
79
|
+
const iModel = StandaloneDb.createEmpty(fileName, {
|
|
80
|
+
rootSubject: { name: "Test" },
|
|
81
|
+
enableTransactions: false,
|
|
82
|
+
});
|
|
83
|
+
// Verify the flag is not set
|
|
84
|
+
const value = iModel[_nativeDb].queryLocalValue("StandaloneEdit");
|
|
85
|
+
assert.isUndefined(value);
|
|
86
|
+
iModel.close();
|
|
87
|
+
IModelJsFs.removeSync(fileName);
|
|
88
|
+
});
|
|
89
|
+
it("should not enable transactions when no flags are provided", () => {
|
|
90
|
+
const fileName = IModelTestUtils.prepareOutputFile("StandaloneDb", "NoFlagsDefault.bim");
|
|
91
|
+
// Create without any edit flags
|
|
92
|
+
const iModel = StandaloneDb.createEmpty(fileName, {
|
|
93
|
+
rootSubject: { name: "Test" },
|
|
94
|
+
});
|
|
95
|
+
// Verify the flag is not set
|
|
96
|
+
const value = iModel[_nativeDb].queryLocalValue("StandaloneEdit");
|
|
97
|
+
assert.isUndefined(value);
|
|
98
|
+
iModel.close();
|
|
99
|
+
IModelJsFs.removeSync(fileName);
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
//# sourceMappingURL=StandaloneDb.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StandaloneDb.test.js","sourceRoot":"","sources":["../../../../src/test/standalone/StandaloneDb.test.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAE/F,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAC9B,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACzE,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE;IAE5B,QAAQ,CAAC,mBAAmB,EAAE,GAAG,EAAE;QAEjC,EAAE,CAAC,8DAA8D,EAAE,GAAG,EAAE;YACtE,MAAM,QAAQ,GAAG,eAAe,CAAC,iBAAiB,CAAC,cAAc,EAAE,qBAAqB,CAAC,CAAC;YAE1F,uDAAuD;YACvD,MAA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AAC,eAAe,CAAC,gBAAgB,CAAC,CAAC;YAClE,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;YAE1B,MAAM,CAAC,KAAK,EAAE,CAAC;YACf,UAAU,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;QAClC,CAAC,CAAC,CAAC;IAEL,CAAC,CAAC,CAAC;AAEL,CAAC,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n\r\nimport { assert } from \"chai\";\r\nimport { _nativeDb, IModelJsFs, StandaloneDb } from \"../../core-backend\";\r\nimport { IModelTestUtils } from \"../IModelTestUtils\";\r\n\r\ndescribe(\"StandaloneDb\", () => {\r\n\r\n describe(\"transaction flags\", () => {\r\n\r\n it(\"should enable transactions with legacy allowEdit string flag\", () => {\r\n const fileName = IModelTestUtils.prepareOutputFile(\"StandaloneDb\", \"AllowEditString.bim\");\r\n\r\n // Create with allowEdit set to any truthy string value\r\n const iModel = StandaloneDb.createEmpty(fileName, {\r\n rootSubject: { name: \"Test\" },\r\n allowEdit: \"any string value\",\r\n });\r\n\r\n // Verify the flag is set correctly in the database\r\n const value = iModel[_nativeDb].queryLocalValue(\"StandaloneEdit\");\r\n assert.equal(value, `{ \"txns\": true }`);\r\n\r\n iModel.close();\r\n IModelJsFs.removeSync(fileName);\r\n });\r\n\r\n it(\"should enable transactions with legacy allowEdit JSON string\", () => {\r\n const fileName = IModelTestUtils.prepareOutputFile(\"StandaloneDb\", \"AllowEditJSON.bim\");\r\n\r\n // Create with allowEdit using the traditional JSON.stringify pattern\r\n const iModel = StandaloneDb.createEmpty(fileName, {\r\n rootSubject: { name: \"Test\" },\r\n allowEdit: JSON.stringify({ txns: true }),\r\n });\r\n\r\n // Verify the flag is set correctly\r\n const value = iModel[_nativeDb].queryLocalValue(\"StandaloneEdit\");\r\n assert.equal(value, `{ \"txns\": true }`);\r\n\r\n iModel.close();\r\n IModelJsFs.removeSync(fileName);\r\n });\r\n\r\n it(\"should enable transactions with new enableTransactions boolean flag\", () => {\r\n const fileName = IModelTestUtils.prepareOutputFile(\"StandaloneDb\", \"EnableTransactions.bim\");\r\n\r\n // Create with the new boolean flag\r\n const iModel = StandaloneDb.createEmpty(fileName, {\r\n rootSubject: { name: \"Test\" },\r\n enableTransactions: true,\r\n });\r\n\r\n // Verify the flag is set correctly\r\n const value = iModel[_nativeDb].queryLocalValue(\"StandaloneEdit\");\r\n assert.equal(value, `{ \"txns\": true }`);\r\n\r\n iModel.close();\r\n IModelJsFs.removeSync(fileName);\r\n });\r\n\r\n it(\"should enable transactions when either flag is set\", () => {\r\n const fileName = IModelTestUtils.prepareOutputFile(\"StandaloneDb\", \"BothFlags.bim\");\r\n\r\n // Create with both flags set\r\n const iModel = StandaloneDb.createEmpty(fileName, {\r\n rootSubject: { name: \"Test\" },\r\n allowEdit: \"legacy\",\r\n enableTransactions: true,\r\n });\r\n\r\n // Verify the flag is set correctly\r\n const value = iModel[_nativeDb].queryLocalValue(\"StandaloneEdit\");\r\n assert.equal(value, `{ \"txns\": true }`);\r\n\r\n iModel.close();\r\n IModelJsFs.removeSync(fileName);\r\n });\r\n\r\n it(\"should enable transactions with enableTransactions true even if allowEdit is undefined\", () => {\r\n const fileName = IModelTestUtils.prepareOutputFile(\"StandaloneDb\", \"OnlyEnableTransactions.bim\");\r\n\r\n // Create with only the new flag\r\n const iModel = StandaloneDb.createEmpty(fileName, {\r\n rootSubject: { name: \"Test\" },\r\n enableTransactions: true,\r\n });\r\n\r\n // Verify the flag is set correctly\r\n const value = iModel[_nativeDb].queryLocalValue(\"StandaloneEdit\");\r\n assert.equal(value, `{ \"txns\": true }`);\r\n\r\n iModel.close();\r\n IModelJsFs.removeSync(fileName);\r\n });\r\n\r\n it(\"should not enable transactions when both flags are false/undefined\", () => {\r\n const fileName = IModelTestUtils.prepareOutputFile(\"StandaloneDb\", \"NoFlags.bim\");\r\n\r\n // Create without enabling transactions\r\n const iModel = StandaloneDb.createEmpty(fileName, {\r\n rootSubject: { name: \"Test\" },\r\n enableTransactions: false,\r\n });\r\n\r\n // Verify the flag is not set\r\n const value = iModel[_nativeDb].queryLocalValue(\"StandaloneEdit\");\r\n assert.isUndefined(value);\r\n\r\n iModel.close();\r\n IModelJsFs.removeSync(fileName);\r\n });\r\n\r\n it(\"should not enable transactions when no flags are provided\", () => {\r\n const fileName = IModelTestUtils.prepareOutputFile(\"StandaloneDb\", \"NoFlagsDefault.bim\");\r\n\r\n // Create without any edit flags\r\n const iModel = StandaloneDb.createEmpty(fileName, {\r\n rootSubject: { name: \"Test\" },\r\n });\r\n\r\n // Verify the flag is not set\r\n const value = iModel[_nativeDb].queryLocalValue(\"StandaloneEdit\");\r\n assert.isUndefined(value);\r\n\r\n iModel.close();\r\n IModelJsFs.removeSync(fileName);\r\n });\r\n\r\n });\r\n\r\n});\r\n"]}
|
|
@@ -253,6 +253,49 @@ describe("TxnManager", () => {
|
|
|
253
253
|
elements.getElement(el1);
|
|
254
254
|
elements.getElement(el2);
|
|
255
255
|
elements.getElement(el3);
|
|
256
|
+
function insert2Elements() {
|
|
257
|
+
const id0 = elements.insertElement(props);
|
|
258
|
+
imodel.saveChanges();
|
|
259
|
+
const id1 = elements.insertElement(props);
|
|
260
|
+
imodel.saveChanges();
|
|
261
|
+
return [id0, id1];
|
|
262
|
+
}
|
|
263
|
+
function expectElementExistences(ids, expectExists) {
|
|
264
|
+
expect(elements.tryGetElementProps(ids[0]) !== undefined).to.equal(expectExists);
|
|
265
|
+
expect(elements.tryGetElementProps(ids[0]) !== undefined).to.equal(expectExists);
|
|
266
|
+
}
|
|
267
|
+
function expectTxnDepth(expected) {
|
|
268
|
+
expect(txns.getMultiTxnOperationDepth()).to.equal(expected);
|
|
269
|
+
}
|
|
270
|
+
// verify nested multi-txn operations
|
|
271
|
+
expectTxnDepth(0);
|
|
272
|
+
txns.beginMultiTxnOperation();
|
|
273
|
+
expectTxnDepth(1);
|
|
274
|
+
txns.beginMultiTxnOperation();
|
|
275
|
+
expectTxnDepth(2);
|
|
276
|
+
const set1 = insert2Elements();
|
|
277
|
+
expectElementExistences(set1, true);
|
|
278
|
+
txns.endMultiTxnOperation();
|
|
279
|
+
expectTxnDepth(1);
|
|
280
|
+
txns.reverseSingleTxn();
|
|
281
|
+
expectElementExistences(set1, false);
|
|
282
|
+
txns.reinstateTxn();
|
|
283
|
+
expectElementExistences(set1, true);
|
|
284
|
+
expectTxnDepth(1);
|
|
285
|
+
txns.beginMultiTxnOperation();
|
|
286
|
+
expectTxnDepth(2);
|
|
287
|
+
const set2 = insert2Elements();
|
|
288
|
+
expectElementExistences(set2, true);
|
|
289
|
+
txns.endMultiTxnOperation();
|
|
290
|
+
expectTxnDepth(1);
|
|
291
|
+
txns.endMultiTxnOperation();
|
|
292
|
+
expectTxnDepth(0);
|
|
293
|
+
txns.reverseSingleTxn();
|
|
294
|
+
expectElementExistences(set2, false);
|
|
295
|
+
expectElementExistences(set1, false);
|
|
296
|
+
txns.reinstateTxn();
|
|
297
|
+
expectElementExistences(set1, true);
|
|
298
|
+
expectElementExistences(set2, true);
|
|
256
299
|
assert.equal(IModelStatus.Success, txns.cancelTo(txns.queryFirstTxnId()));
|
|
257
300
|
assert.isFalse(txns.hasUnsavedChanges);
|
|
258
301
|
assert.isFalse(txns.hasPendingTxns);
|