@itwin/presentation-testing 4.0.2 → 4.1.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 +34 -13
- package/lib/cjs/presentation-testing/Helpers.d.ts +2 -2
- package/lib/cjs/presentation-testing/Helpers.d.ts.map +1 -1
- package/lib/cjs/presentation-testing/Helpers.js +2 -4
- package/lib/cjs/presentation-testing/Helpers.js.map +1 -1
- package/lib/cjs/presentation-testing/IModelUtilities.d.ts +21 -0
- package/lib/cjs/presentation-testing/IModelUtilities.d.ts.map +1 -1
- package/lib/cjs/presentation-testing/IModelUtilities.js +4 -1
- package/lib/cjs/presentation-testing/IModelUtilities.js.map +1 -1
- package/lib/cjs/presentation-testing.d.ts +2 -0
- package/lib/cjs/presentation-testing.d.ts.map +1 -1
- package/lib/cjs/presentation-testing.js +3 -0
- package/lib/cjs/presentation-testing.js.map +1 -1
- package/lib/esm/presentation-testing/Helpers.d.ts +2 -2
- package/lib/esm/presentation-testing/Helpers.d.ts.map +1 -1
- package/lib/esm/presentation-testing/Helpers.js +3 -5
- package/lib/esm/presentation-testing/Helpers.js.map +1 -1
- package/lib/esm/presentation-testing/IModelUtilities.d.ts +21 -0
- package/lib/esm/presentation-testing/IModelUtilities.d.ts.map +1 -1
- package/lib/esm/presentation-testing/IModelUtilities.js +4 -1
- package/lib/esm/presentation-testing/IModelUtilities.js.map +1 -1
- package/lib/esm/presentation-testing.d.ts +2 -0
- package/lib/esm/presentation-testing.d.ts.map +1 -1
- package/lib/esm/presentation-testing.js +2 -0
- package/lib/esm/presentation-testing.js.map +1 -1
- package/package.json +39 -40
package/CHANGELOG.md
CHANGED
|
@@ -1,16 +1,37 @@
|
|
|
1
1
|
# Change Log - @itwin/presentation-testing
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
## 4.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#232](https://github.com/iTwin/presentation/pull/232): Added `TestIModelBuilder.importSchema` API to allow creating iModels with custom schemas.
|
|
8
|
+
- [#232](https://github.com/iTwin/presentation/pull/232): Added `buildTestIModel` overloads that take an async callback to set up the iModel. Deprecated the previous ones.
|
|
9
|
+
|
|
10
|
+
### Patch Changes
|
|
11
|
+
|
|
12
|
+
- Updated dependencies:
|
|
13
|
+
- @itwin/presentation-components@4.2.1
|
|
14
|
+
|
|
15
|
+
This log was last generated on Thu, 31 Aug 2023 11:51:06 GMT and should not be manually modified.
|
|
4
16
|
|
|
5
17
|
<!-- Start content -->
|
|
6
18
|
|
|
19
|
+
## 4.0.3
|
|
20
|
+
|
|
21
|
+
Thu, 31 Aug 2023 11:51:06 GMT
|
|
22
|
+
|
|
23
|
+
### Patches
|
|
24
|
+
|
|
25
|
+
- Update dependencies ([commit](https://github.com/iTwin/presentation/commit/585bfe098c3c388c48ffa4f311c4722f1b6835df))
|
|
26
|
+
- Removed `@itwin/presentation-components` peer dependency. ([commit](https://github.com/iTwin/presentation/commit/9b369dc2cb208ecf4cc6518f319a1648f85c81d9))
|
|
27
|
+
|
|
7
28
|
## 4.0.2
|
|
8
29
|
|
|
9
|
-
Wed, 09 Aug 2023 11:
|
|
30
|
+
Wed, 09 Aug 2023 11:47:16 GMT
|
|
10
31
|
|
|
11
32
|
### Patches
|
|
12
33
|
|
|
13
|
-
- Update package dependencies ([commit](https://github.com/iTwin/presentation/commit/
|
|
34
|
+
- Update package dependencies ([commit](https://github.com/iTwin/presentation/commit/22593a8fddc52b5c547c024d64e7cc5659c81d01))
|
|
14
35
|
|
|
15
36
|
## 4.0.1
|
|
16
37
|
|
|
@@ -18,7 +39,7 @@ Thu, 15 Jun 2023 07:31:33 GMT
|
|
|
18
39
|
|
|
19
40
|
### Patches
|
|
20
41
|
|
|
21
|
-
- Bumped `rimraf` version ([commit](https://github.com/iTwin/presentation/commit/
|
|
42
|
+
- Bumped `rimraf` version ([commit](https://github.com/iTwin/presentation/commit/e5fdd420d31c98ef6d43daa3faad4fbb27625829))
|
|
22
43
|
|
|
23
44
|
## 4.0.0
|
|
24
45
|
|
|
@@ -26,24 +47,24 @@ Tue, 02 May 2023 11:39:31 GMT
|
|
|
26
47
|
|
|
27
48
|
### Major changes
|
|
28
49
|
|
|
29
|
-
- Upgrade to AppUI 4.0 ([commit](https://github.com/iTwin/presentation/commit/
|
|
50
|
+
- Upgrade to AppUI 4.0 ([commit](https://github.com/iTwin/presentation/commit/c869d568d3b462670d20e1ec31807aee15a0857e))
|
|
30
51
|
|
|
31
52
|
### Minor changes
|
|
32
53
|
|
|
33
|
-
- Add a `buildTestIModel` overload that generates imodel name from mocha context ([commit](https://github.com/iTwin/presentation/commit/
|
|
34
|
-
- Change `TestIModelBuilder.insertAspect` to return inserted aspect id. ([commit](https://github.com/iTwin/presentation/commit/
|
|
35
|
-
- Add `TestIModelBuilder.insertRelationship` ([commit](https://github.com/iTwin/presentation/commit/
|
|
36
|
-
- Bump minimum required `itwinjs-core` version to `3.6.3` ([commit](https://github.com/iTwin/presentation/commit/
|
|
54
|
+
- Add a `buildTestIModel` overload that generates imodel name from mocha context ([commit](https://github.com/iTwin/presentation/commit/6b844055de128dbf3b1de1611144391dc7ee6d31))
|
|
55
|
+
- Change `TestIModelBuilder.insertAspect` to return inserted aspect id. ([commit](https://github.com/iTwin/presentation/commit/4b7ff68423cd641c73d9f3fb5b4bfbb5266fa1e0))
|
|
56
|
+
- Add `TestIModelBuilder.insertRelationship` ([commit](https://github.com/iTwin/presentation/commit/56c533083105473e4c9c05d061609a7cd5928d5d))
|
|
57
|
+
- Bump minimum required `itwinjs-core` version to `3.6.3` ([commit](https://github.com/iTwin/presentation/commit/7bf12337f09b7fda0362474d3d63b18bb4b07aab))
|
|
37
58
|
|
|
38
59
|
### Patches
|
|
39
60
|
|
|
40
|
-
- Reduce deprecated API usage ([commit](https://github.com/iTwin/presentation/commit/
|
|
41
|
-
- Replace all spaces in test name when creating test iModel. ([commit](https://github.com/iTwin/presentation/commit/
|
|
61
|
+
- Reduce deprecated API usage ([commit](https://github.com/iTwin/presentation/commit/6bf1a99ec570751e16f30af658e0fa7e27e7631f))
|
|
62
|
+
- Replace all spaces in test name when creating test iModel. ([commit](https://github.com/iTwin/presentation/commit/070f9587299e156ebd58eb7fa0941b50f56ec188))
|
|
42
63
|
|
|
43
64
|
### Changes
|
|
44
65
|
|
|
45
|
-
- Update dependencies ([commit](https://github.com/iTwin/presentation/commit/
|
|
46
|
-
- Updated to TypeScript 5.0 ([commit](https://github.com/iTwin/presentation/commit/
|
|
66
|
+
- Update dependencies ([commit](https://github.com/iTwin/presentation/commit/ddf8cf327436fa38dc304666992e9fb66e942933))
|
|
67
|
+
- Updated to TypeScript 5.0 ([commit](https://github.com/iTwin/presentation/commit/4b7924ee69265aaadeaba81f02162bf5c404d33a))
|
|
47
68
|
|
|
48
69
|
## 3.7.4
|
|
49
70
|
|
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
import { IModelHostOptions } from "@itwin/core-backend";
|
|
5
5
|
import { RpcInterfaceDefinition } from "@itwin/core-common";
|
|
6
6
|
import { IModelApp, IModelAppOptions } from "@itwin/core-frontend";
|
|
7
|
-
import { HierarchyCacheMode, PresentationManagerProps as PresentationBackendProps
|
|
7
|
+
import { HierarchyCacheMode, PresentationManagerProps as PresentationBackendProps } from "@itwin/presentation-backend";
|
|
8
8
|
import { PresentationProps as PresentationFrontendProps } from "@itwin/presentation-frontend";
|
|
9
9
|
/** @internal */
|
|
10
10
|
export declare const getTestOutputDir: () => string;
|
|
11
|
-
export { HierarchyCacheMode,
|
|
11
|
+
export { HierarchyCacheMode, PresentationBackendProps };
|
|
12
12
|
/** @public */
|
|
13
13
|
export interface PresentationTestingInitProps {
|
|
14
14
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Helpers.d.ts","sourceRoot":"","sources":["../../../src/presentation-testing/Helpers.ts"],"names":[],"mappings":"AAIA;;GAEG;
|
|
1
|
+
{"version":3,"file":"Helpers.d.ts","sourceRoot":"","sources":["../../../src/presentation-testing/Helpers.ts"],"names":[],"mappings":"AAIA;;GAEG;AAKH,OAAO,EAAc,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAEpE,OAAO,EAAqE,sBAAsB,EAA8B,MAAM,oBAAoB,CAAC;AAC3J,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAe,MAAM,sBAAsB,CAAC;AAChF,OAAO,EAAE,kBAAkB,EAAuC,wBAAwB,IAAI,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AAE5J,OAAO,EAAwC,iBAAiB,IAAI,yBAAyB,EAAE,MAAM,8BAA8B,CAAC;AA0BpI,gBAAgB;AAChB,eAAO,MAAM,gBAAgB,QAAO,MAEnC,CAAC;AAEF,OAAO,EAAE,kBAAkB,EAAE,wBAAwB,EAAE,CAAC;AAExD,cAAc;AACd,MAAM,WAAW,4BAA4B;IAC3C;;;;OAIG;IACH,IAAI,CAAC,EAAE,sBAAsB,EAAE,CAAC;IAChC,4CAA4C;IAC5C,YAAY,CAAC,EAAE,wBAAwB,CAAC;IACxC,kCAAkC;IAClC,gBAAgB,CAAC,EAAE,iBAAiB,CAAC;IACrC,6CAA6C;IAC7C,aAAa,CAAC,EAAE,yBAAyB,CAAC;IAC1C,+BAA+B;IAC/B,WAAW,CAAC,EAAE;QAAE,OAAO,EAAE,CAAC,IAAI,CAAC,EAAE,gBAAgB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;KAAE,CAAC;IACtE,0BAA0B;IAC1B,kBAAkB,CAAC,EAAE,gBAAgB,CAAC;IACtC,wFAAwF;IACxF,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,UAAU,WAAkB,4BAA4B,kBAoCpE,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,SAAS,mDA0BrB,CAAC"}
|
|
@@ -30,8 +30,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
30
30
|
return result;
|
|
31
31
|
};
|
|
32
32
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
|
-
exports.terminate = exports.initialize = exports.
|
|
34
|
-
/* istanbul ignore file */ // TODO: Remove istanbul ignore file when https://github.com/iTwin/itwinjs-backlog/issues/463 is fixed.
|
|
33
|
+
exports.terminate = exports.initialize = exports.HierarchyCacheMode = exports.getTestOutputDir = void 0;
|
|
35
34
|
const os_1 = require("os");
|
|
36
35
|
const path_1 = require("path");
|
|
37
36
|
const rimraf = __importStar(require("rimraf"));
|
|
@@ -41,7 +40,6 @@ const core_common_1 = require("@itwin/core-common");
|
|
|
41
40
|
const core_frontend_1 = require("@itwin/core-frontend");
|
|
42
41
|
const presentation_backend_1 = require("@itwin/presentation-backend");
|
|
43
42
|
Object.defineProperty(exports, "HierarchyCacheMode", { enumerable: true, get: function () { return presentation_backend_1.HierarchyCacheMode; } });
|
|
44
|
-
Object.defineProperty(exports, "PresentationManagerMode", { enumerable: true, get: function () { return presentation_backend_1.PresentationManagerMode; } });
|
|
45
43
|
const presentation_common_1 = require("@itwin/presentation-common");
|
|
46
44
|
const presentation_frontend_1 = require("@itwin/presentation-frontend");
|
|
47
45
|
function initializeRpcInterfaces(interfaces) {
|
|
@@ -57,7 +55,7 @@ function initializeRpcInterfaces(interfaces) {
|
|
|
57
55
|
}
|
|
58
56
|
};
|
|
59
57
|
for (const definition of interfaces) {
|
|
60
|
-
core_common_1.RpcConfiguration.assign(definition, () => config); // eslint-disable-line @itwin/no-internal
|
|
58
|
+
core_common_1.RpcConfiguration.assign(definition, /* istanbul ignore next */ () => config); // eslint-disable-line @itwin/no-internal
|
|
61
59
|
}
|
|
62
60
|
const instance = core_common_1.RpcConfiguration.obtain(config); // eslint-disable-line @itwin/no-internal
|
|
63
61
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Helpers.js","sourceRoot":"","sources":["../../../src/presentation-testing/Helpers.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;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vB,CAAC,CAAC;AApCW,QAAA,UAAU,cAoCrB;AAEF;;;;;;;GAOG;AACI,MAAM,SAAS,GAAG,KAAK,EAAE,WAAW,GAAG,yBAAS,EAAE,EAAE;IACzD,IAAI,CAAC,aAAa,EAAE;QAClB,OAAO;KACR;IAED,8CAA8C;IAC9C,IAAI,yBAA6C,CAAC;IAClD,MAAM,sBAAsB,GAAG,mCAAmB,CAAC,SAAS,EAAE,OAAO,EAAE,WAAW,CAAC;IACnF,IAAI,sBAAsB,EAAE,IAAI,KAAK,yCAAkB,CAAC,IAAI,EAAE;QAC5D,yBAAyB,GAAG,sBAAsB,EAAE,SAAS,CAAC;KAC/D;SAAM,IAAI,sBAAsB,EAAE,IAAI,KAAK,yCAAkB,CAAC,MAAM,EAAE;QACrE,yBAAyB,GAAG,sBAAsB,EAAE,IAAI,EAAE,SAAS,CAAC;KACrE;IAED,oBAAoB;IACpB,mCAAmB,CAAC,SAAS,EAAE,CAAC;IAChC,MAAM,yBAAU,CAAC,QAAQ,EAAE,CAAC;IAC5B,IAAI,yBAAyB,EAAE;QAC7B,MAAM,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC;KACxC;IAED,qBAAqB;IACrB,oCAAoB,CAAC,SAAS,EAAE,CAAC;IACjC,MAAM,WAAW,CAAC,QAAQ,EAAE,CAAC;IAE7B,aAAa,GAAG,KAAK,CAAC;AACxB,CAAC,CAAC;AA1BW,QAAA,SAAS,aA0BpB","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Helpers\n */\n\nimport { tmpdir } from \"os\";\nimport { join } from \"path\";\nimport * as rimraf from \"rimraf\";\nimport { IModelHost, IModelHostOptions } from \"@itwin/core-backend\";\nimport { Guid } from \"@itwin/core-bentley\";\nimport { IModelReadRpcInterface, RpcConfiguration, RpcDefaultConfiguration, RpcInterfaceDefinition, SnapshotIModelRpcInterface } from \"@itwin/core-common\";\nimport { IModelApp, IModelAppOptions, NoRenderApp } from \"@itwin/core-frontend\";\nimport { HierarchyCacheMode, Presentation as PresentationBackend, PresentationManagerProps as PresentationBackendProps } from \"@itwin/presentation-backend\";\nimport { PresentationRpcInterface } from \"@itwin/presentation-common\";\nimport { Presentation as PresentationFrontend, PresentationProps as PresentationFrontendProps } from \"@itwin/presentation-frontend\";\n\nfunction initializeRpcInterfaces(interfaces: RpcInterfaceDefinition[]) {\n const config = class extends RpcDefaultConfiguration {\n public override interfaces: any = () => interfaces;\n };\n\n for (const definition of interfaces) {\n RpcConfiguration.assign(definition, /* istanbul ignore next */ () => config); // eslint-disable-line @itwin/no-internal\n }\n\n const instance = RpcConfiguration.obtain(config); // eslint-disable-line @itwin/no-internal\n\n try {\n RpcConfiguration.initializeInterfaces(instance); // eslint-disable-line @itwin/no-internal\n } catch {\n // this may fail with \"Error: RPC interface \"xxx\" is already initialized.\" because\n // multiple different tests want to set up rpc interfaces\n }\n}\n\nlet isInitialized = false;\n\nconst defaultTestOutputDir = tmpdir();\nlet testOutputDir: string | undefined;\n\n/** @internal */\nexport const getTestOutputDir = (): string => {\n return testOutputDir ?? defaultTestOutputDir;\n};\n\nexport { HierarchyCacheMode, PresentationBackendProps };\n\n/** @public */\nexport interface PresentationTestingInitProps {\n /**\n * RPC interfaces to enable. Defaults to `[SnapshotIModelRpcInterface, IModelReadRpcInterface, PresentationRpcInterface]`.\n *\n * Note: Implementations for these interfaces are **not** automatically registered on the backend - that has to be done manually.\n */\n rpcs?: RpcInterfaceDefinition[];\n /** Properties for backend initialization */\n backendProps?: PresentationBackendProps;\n /** Properties for `IModelHost` */\n backendHostProps?: IModelHostOptions;\n /** Properties for frontend initialization */\n frontendProps?: PresentationFrontendProps;\n /** IModelApp implementation */\n frontendApp?: { startup: (opts?: IModelAppOptions) => Promise<void> };\n /** `IModelApp` options */\n frontendAppOptions?: IModelAppOptions;\n /** Custom test output directory. Defaults to temporary directory provided by the OS. */\n testOutputDir?: string;\n}\n\n/**\n * Initialize the framework for presentation testing. The function sets up backend,\n * frontend and RPC communication between them.\n *\n * @see `terminate`\n *\n * @public\n */\nexport const initialize = async (props?: PresentationTestingInitProps) => {\n if (isInitialized) {\n return;\n }\n\n if (!props) {\n props = {};\n }\n\n // set up rpc interfaces\n initializeRpcInterfaces(props.rpcs ?? [SnapshotIModelRpcInterface, IModelReadRpcInterface, PresentationRpcInterface]);\n\n // init backend\n // make sure backend gets assigned an id which puts its resources into a unique directory\n props.backendProps = props.backendProps ?? {};\n // eslint-disable-next-line @itwin/no-internal\n if (!props.backendProps.id) {\n props.backendProps.id = `test-${Guid.createValue()}`; // eslint-disable-line @itwin/no-internal\n }\n await IModelHost.startup({ cacheDir: join(__dirname, \".cache\"), ...props.backendHostProps });\n PresentationBackend.initialize(props.backendProps);\n\n // init frontend\n if (!props.frontendApp) {\n props.frontendApp = NoRenderApp;\n }\n await props.frontendApp.startup(props.frontendAppOptions);\n const defaultFrontendProps: PresentationFrontendProps = {\n presentation: {\n activeLocale: IModelApp.localization.getLanguageList()[0],\n },\n };\n await PresentationFrontend.initialize({ ...defaultFrontendProps, ...props.frontendProps });\n testOutputDir = props.testOutputDir;\n\n isInitialized = true;\n};\n\n/**\n * Undoes the setup made by `initialize`.\n * @param frontendApp IModelApp implementation\n *\n * @see `initialize`\n *\n * @public\n */\nexport const terminate = async (frontendApp = IModelApp) => {\n if (!isInitialized) {\n return;\n }\n\n // store directory that needs to be cleaned-up\n let hierarchiesCacheDirectory: string | undefined;\n const hierarchiesCacheConfig = PresentationBackend.initProps?.caching?.hierarchies;\n if (hierarchiesCacheConfig?.mode === HierarchyCacheMode.Disk) {\n hierarchiesCacheDirectory = hierarchiesCacheConfig?.directory;\n } else if (hierarchiesCacheConfig?.mode === HierarchyCacheMode.Hybrid) {\n hierarchiesCacheDirectory = hierarchiesCacheConfig?.disk?.directory;\n }\n\n // terminate backend\n PresentationBackend.terminate();\n await IModelHost.shutdown();\n if (hierarchiesCacheDirectory) {\n rimraf.sync(hierarchiesCacheDirectory);\n }\n\n // terminate frontend\n PresentationFrontend.terminate();\n await frontendApp.shutdown();\n\n isInitialized = false;\n};\n"]}
|
|
@@ -27,21 +27,41 @@ export interface TestIModelBuilder {
|
|
|
27
27
|
* Code value has to be unique within its scope (see [Codes documentation page]($docs/bis/guide/fundamentals/codes.md)).
|
|
28
28
|
*/
|
|
29
29
|
createCode(scopeModelId: CodeScopeProps, codeSpecName: BisCodeSpec, codeValue: string): Code;
|
|
30
|
+
/**
|
|
31
|
+
* Import an ECSchema in a form of XML string into the builder's iModel.
|
|
32
|
+
*/
|
|
33
|
+
importSchema(schemaXml: string): Promise<void>;
|
|
30
34
|
}
|
|
31
35
|
/**
|
|
32
36
|
* Function that creates an iModel and returns a connection to it.
|
|
33
37
|
* @param name Name of test IModel
|
|
34
38
|
* @param cb Callback function that receives an [[TestIModelBuilder]] to fill the iModel with data
|
|
35
39
|
* @beta
|
|
40
|
+
* @deprecated in 4.x. Use an overload with `cb` returning a promise.
|
|
36
41
|
*/
|
|
37
42
|
export declare function buildTestIModel(name: string, cb: (builder: TestIModelBuilder) => void): Promise<IModelConnection>;
|
|
43
|
+
/**
|
|
44
|
+
* Function that creates an iModel and returns a connection to it.
|
|
45
|
+
* @param name Name of test IModel
|
|
46
|
+
* @param cb Callback function that receives an [[TestIModelBuilder]] to fill the iModel with data
|
|
47
|
+
* @beta
|
|
48
|
+
*/
|
|
49
|
+
export declare function buildTestIModel(name: string, cb: (builder: TestIModelBuilder) => Promise<void>): Promise<IModelConnection>;
|
|
38
50
|
/**
|
|
39
51
|
* Function that creates an iModel and returns a connection to it.
|
|
40
52
|
* @param mochaContext Mocha context to generate iModel name from
|
|
41
53
|
* @param cb Callback function that receives an [[TestIModelBuilder]] to fill the iModel with data
|
|
42
54
|
* @beta
|
|
55
|
+
* @deprecated in 4.x. Use an overload with `cb` returning a promise.
|
|
43
56
|
*/
|
|
44
57
|
export declare function buildTestIModel(mochaContext: Mocha.Context, cb: (builder: TestIModelBuilder) => void): Promise<IModelConnection>;
|
|
58
|
+
/**
|
|
59
|
+
* Function that creates an iModel and returns a connection to it.
|
|
60
|
+
* @param mochaContext Mocha context to generate iModel name from
|
|
61
|
+
* @param cb Callback function that receives an [[TestIModelBuilder]] to fill the iModel with data
|
|
62
|
+
* @beta
|
|
63
|
+
*/
|
|
64
|
+
export declare function buildTestIModel(mochaContext: Mocha.Context, cb: (builder: TestIModelBuilder) => Promise<void>): Promise<IModelConnection>;
|
|
45
65
|
/**
|
|
46
66
|
* Default implementation of IModel builder pattern. Used for building IModels to test rulesets.
|
|
47
67
|
*
|
|
@@ -55,6 +75,7 @@ export declare class IModelBuilder implements TestIModelBuilder {
|
|
|
55
75
|
insertAspect<TProps extends ElementAspectProps>(props: TProps): Id64String;
|
|
56
76
|
insertRelationship<TProps extends RelationshipProps>(props: TProps): Id64String;
|
|
57
77
|
createCode(scopeModelId: CodeScopeProps, codeSpecName: BisCodeSpec, codeValue: string): Code;
|
|
78
|
+
importSchema(schemaXml: string): Promise<void>;
|
|
58
79
|
}
|
|
59
80
|
/** @internal */
|
|
60
81
|
export declare function createFileNameFromString(str: string): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IModelUtilities.d.ts","sourceRoot":"","sources":["../../../src/presentation-testing/IModelUtilities.ts"],"names":[],"mappings":"AAIA;;GAEG;;AAIH,OAAO,EAAE,QAAQ,EAA0B,MAAM,qBAAqB,CAAC;AACvE,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EACL,WAAW,EACX,IAAI,EACJ,cAAc,EAEd,kBAAkB,EAClB,YAAY,EAEZ,UAAU,EACV,iBAAiB,EAClB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,gBAAgB,EAAsB,MAAM,sBAAsB,CAAC;AAG5E;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC,+CAA+C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,MAAM,SAAS,kBAAkB,EAAE,KAAK,EAAE,MAAM,GAAG,UAAU;IAI1E,kBAAkB,CAAC,MAAM,SAAS,iBAAiB,EAAE,KAAK,EAAE,MAAM,GAAG,UAAU;IAI/E,UAAU,CAAC,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI;IAKtF,YAAY,CAAC,SAAS,EAAE,MAAM;CAG5C;AAkBD,gBAAgB;AAChB,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,MAAM,UAEnD"}
|
|
@@ -23,7 +23,7 @@ async function buildTestIModel(nameParam, cb) {
|
|
|
23
23
|
const db = core_backend_1.SnapshotDb.createEmpty(outputFile, { rootSubject: { name } });
|
|
24
24
|
const builder = new IModelBuilder(db);
|
|
25
25
|
try {
|
|
26
|
-
cb(builder);
|
|
26
|
+
await cb(builder);
|
|
27
27
|
}
|
|
28
28
|
finally {
|
|
29
29
|
db.saveChanges("Created test IModel");
|
|
@@ -63,6 +63,9 @@ class IModelBuilder {
|
|
|
63
63
|
const codeSpec = this._iModel.codeSpecs.getByName(codeSpecName);
|
|
64
64
|
return new core_common_1.Code({ spec: codeSpec.id, scope: scopeModelId, value: codeValue });
|
|
65
65
|
}
|
|
66
|
+
async importSchema(schemaXml) {
|
|
67
|
+
await this._iModel.importSchemaStrings([schemaXml]);
|
|
68
|
+
}
|
|
66
69
|
}
|
|
67
70
|
exports.IModelBuilder = IModelBuilder;
|
|
68
71
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IModelUtilities.js","sourceRoot":"","sources":["../../../src/presentation-testing/IModelUtilities.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;AAEH,gDAAwB;AACxB,0EAAyC;AACzC,sDAAuE;AAEvE,oDAU4B;AAC5B,wDAA4E;AAC5E,uCAA6C;
|
|
1
|
+
{"version":3,"file":"IModelUtilities.js","sourceRoot":"","sources":["../../../src/present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E,CAAC;AAFD,4DAEC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module IModel\n */\n\nimport path from \"path\";\nimport sanitize from \"sanitize-filename\";\nimport { IModelDb, IModelJsFs, SnapshotDb } from \"@itwin/core-backend\";\nimport { Id64String } from \"@itwin/core-bentley\";\nimport {\n BisCodeSpec,\n Code,\n CodeScopeProps,\n CodeSpec,\n ElementAspectProps,\n ElementProps,\n LocalFileName,\n ModelProps,\n RelationshipProps,\n} from \"@itwin/core-common\";\nimport { IModelConnection, SnapshotConnection } from \"@itwin/core-frontend\";\nimport { getTestOutputDir } from \"./Helpers\";\n\n/**\n * Interface for IModel builder pattern. Used for building IModels to test rulesets.\n * @beta\n */\nexport interface TestIModelBuilder {\n /** Insert a model into the builder's iModel */\n insertModel<TProps extends ModelProps>(props: TProps): Id64String;\n /** Insert an element into the builder's iModel */\n insertElement<TProps extends ElementProps>(props: TProps): Id64String;\n /** Insert an element aspect into the specified element */\n insertAspect<TProps extends ElementAspectProps>(props: TProps): Id64String;\n /**\n * Insert a relationship between two instances. The relationship is expected to be a subclass\n * of `BisCore:ElementRefersToElements` or `BisCore:ElementDrivesElement`.\n */\n insertRelationship<TProps extends RelationshipProps>(props: TProps): Id64String;\n /**\n * Create code for specified element.\n * Code value has to be unique within its scope (see [Codes documentation page]($docs/bis/guide/fundamentals/codes.md)).\n */\n createCode(scopeModelId: CodeScopeProps, codeSpecName: BisCodeSpec, codeValue: string): Code;\n /**\n * Import an ECSchema in a form of XML string into the builder's iModel.\n */\n importSchema(schemaXml: string): Promise<void>;\n}\n\n/**\n * Function that creates an iModel and returns a connection to it.\n * @param name Name of test IModel\n * @param cb Callback function that receives an [[TestIModelBuilder]] to fill the iModel with data\n * @beta\n * @deprecated in 4.x. Use an overload with `cb` returning a promise.\n */\nexport async function buildTestIModel(name: string, cb: (builder: TestIModelBuilder) => void): Promise<IModelConnection>;\n/**\n * Function that creates an iModel and returns a connection to it.\n * @param name Name of test IModel\n * @param cb Callback function that receives an [[TestIModelBuilder]] to fill the iModel with data\n * @beta\n */\n// eslint-disable-next-line @typescript-eslint/unified-signatures\nexport async function buildTestIModel(name: string, cb: (builder: TestIModelBuilder) => Promise<void>): Promise<IModelConnection>;\n/**\n * Function that creates an iModel and returns a connection to it.\n * @param mochaContext Mocha context to generate iModel name from\n * @param cb Callback function that receives an [[TestIModelBuilder]] to fill the iModel with data\n * @beta\n * @deprecated in 4.x. Use an overload with `cb` returning a promise.\n */\n// eslint-disable-next-line @typescript-eslint/unified-signatures\nexport async function buildTestIModel(mochaContext: Mocha.Context, cb: (builder: TestIModelBuilder) => void): Promise<IModelConnection>;\n/**\n * Function that creates an iModel and returns a connection to it.\n * @param mochaContext Mocha context to generate iModel name from\n * @param cb Callback function that receives an [[TestIModelBuilder]] to fill the iModel with data\n * @beta\n */\n// eslint-disable-next-line @typescript-eslint/unified-signatures\nexport async function buildTestIModel(mochaContext: Mocha.Context, cb: (builder: TestIModelBuilder) => Promise<void>): Promise<IModelConnection>;\nexport async function buildTestIModel(nameParam: string | Mocha.Context, cb: (builder: TestIModelBuilder) => void | Promise<void>): Promise<IModelConnection> {\n const name = typeof nameParam === \"string\" ? nameParam : createFileNameFromString(nameParam.test!.fullTitle());\n const outputFile = setupOutputFileLocation(name);\n const db = SnapshotDb.createEmpty(outputFile, { rootSubject: { name } });\n const builder = new IModelBuilder(db);\n try {\n await cb(builder);\n } finally {\n db.saveChanges(\"Created test IModel\");\n db.close();\n }\n return SnapshotConnection.openFile(outputFile);\n}\n\n/**\n * Default implementation of IModel builder pattern. Used for building IModels to test rulesets.\n *\n * @internal\n */\nexport class IModelBuilder implements TestIModelBuilder {\n private _iModel: IModelDb;\n\n constructor(iModel: IModelDb) {\n this._iModel = iModel;\n }\n\n public insertModel<TProps extends ModelProps>(props: TProps): Id64String {\n return this._iModel.models.insertModel(props);\n }\n\n public insertElement<TProps extends ElementProps>(props: TProps): Id64String {\n return this._iModel.elements.insertElement(props);\n }\n\n public insertAspect<TProps extends ElementAspectProps>(props: TProps): Id64String {\n return this._iModel.elements.insertAspect(props);\n }\n\n public insertRelationship<TProps extends RelationshipProps>(props: TProps): Id64String {\n return this._iModel.relationships.insertInstance(props);\n }\n\n public createCode(scopeModelId: CodeScopeProps, codeSpecName: BisCodeSpec, codeValue: string): Code {\n const codeSpec: CodeSpec = this._iModel.codeSpecs.getByName(codeSpecName);\n return new Code({ spec: codeSpec.id, scope: scopeModelId, value: codeValue });\n }\n\n public async importSchema(schemaXml: string) {\n await this._iModel.importSchemaStrings([schemaXml]);\n }\n}\n\n/**\n * Prepare for an output file by:\n * - Resolving the output file name under the known test output directory\n * - Making directories as necessary\n * - Removing a previous copy of the output file\n * @param fileName Name of output file\n */\nfunction setupOutputFileLocation(fileName: string): LocalFileName {\n const testOutputDir = getTestOutputDir();\n !IModelJsFs.existsSync(testOutputDir) && IModelJsFs.mkdirSync(testOutputDir);\n\n const outputFile = path.join(testOutputDir, `${fileName}.bim`);\n IModelJsFs.existsSync(outputFile) && IModelJsFs.unlinkSync(outputFile);\n return outputFile;\n}\n\n/** @internal */\nexport function createFileNameFromString(str: string) {\n return sanitize(str.replace(/[ ]+/g, \"-\")).toLocaleLowerCase();\n}\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { PresentationManagerMode } from "@itwin/presentation-backend";
|
|
1
2
|
/**
|
|
2
3
|
* @module Hierarchies
|
|
3
4
|
*
|
|
@@ -26,4 +27,5 @@ export * from "./presentation-testing/Helpers";
|
|
|
26
27
|
* Utilities for creating test iModels that can be used to exercise presentation rules.
|
|
27
28
|
*/
|
|
28
29
|
export * from "./presentation-testing/IModelUtilities";
|
|
30
|
+
export { PresentationManagerMode };
|
|
29
31
|
//# sourceMappingURL=presentation-testing.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presentation-testing.d.ts","sourceRoot":"","sources":["../../src/presentation-testing.ts"],"names":[],"mappings":"AAKA;;;;;GAKG;AACH,cAAc,yCAAyC,CAAC;AAExD;;;;;GAKG;AACH,cAAc,uCAAuC,CAAC;AAEtD;;;;;GAKG;AACH,cAAc,gCAAgC,CAAC;AAE/C;;;;;GAKG;AACH,cAAc,wCAAwC,CAAC"}
|
|
1
|
+
{"version":3,"file":"presentation-testing.d.ts","sourceRoot":"","sources":["../../src/presentation-testing.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAEtE;;;;;GAKG;AACH,cAAc,yCAAyC,CAAC;AAExD;;;;;GAKG;AACH,cAAc,uCAAuC,CAAC;AAEtD;;;;;GAKG;AACH,cAAc,gCAAgC,CAAC;AAE/C;;;;;GAKG;AACH,cAAc,wCAAwC,CAAC;AAEvD,OAAO,EAAE,uBAAuB,EAAE,CAAC"}
|
|
@@ -18,6 +18,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
18
18
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
19
19
|
};
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.PresentationManagerMode = void 0;
|
|
22
|
+
const presentation_backend_1 = require("@itwin/presentation-backend");
|
|
23
|
+
Object.defineProperty(exports, "PresentationManagerMode", { enumerable: true, get: function () { return presentation_backend_1.PresentationManagerMode; } });
|
|
21
24
|
/**
|
|
22
25
|
* @module Hierarchies
|
|
23
26
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presentation-testing.js","sourceRoot":"","sources":["../../src/presentation-testing.ts"],"names":[],"mappings":";AAAA;;;gGAGgG
|
|
1
|
+
{"version":3,"file":"presentation-testing.js","sourceRoot":"","sources":["../../src/presentation-testing.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;;;;;;;;;;;;;;;AAEhG,sEAAsE;AAkC7D,wGAlCA,8CAAuB,OAkCA;AAhChC;;;;;GAKG;AACH,0EAAwD;AAExD;;;;;GAKG;AACH,wEAAsD;AAEtD;;;;;GAKG;AACH,iEAA+C;AAE/C;;;;;GAKG;AACH,yEAAuD","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { PresentationManagerMode } from \"@itwin/presentation-backend\";\n\n/**\n * @module Hierarchies\n *\n * @docs-group-description Hierarchies\n * Types for testing hierarchies.\n */\nexport * from \"./presentation-testing/HierarchyBuilder\";\n\n/**\n * @module Content\n *\n * @docs-group-description Content\n * Types for testing content.\n */\nexport * from \"./presentation-testing/ContentBuilder\";\n\n/**\n * @module Helpers\n *\n * @docs-group-description Helpers\n * Various test helpers.\n */\nexport * from \"./presentation-testing/Helpers\";\n\n/**\n * @module IModel\n *\n * @docs-group-description IModel\n * Utilities for creating test iModels that can be used to exercise presentation rules.\n */\nexport * from \"./presentation-testing/IModelUtilities\";\n\nexport { PresentationManagerMode }; // eslint-disable-line deprecation/deprecation\n"]}
|
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
import { IModelHostOptions } from "@itwin/core-backend";
|
|
5
5
|
import { RpcInterfaceDefinition } from "@itwin/core-common";
|
|
6
6
|
import { IModelApp, IModelAppOptions } from "@itwin/core-frontend";
|
|
7
|
-
import { HierarchyCacheMode, PresentationManagerProps as PresentationBackendProps
|
|
7
|
+
import { HierarchyCacheMode, PresentationManagerProps as PresentationBackendProps } from "@itwin/presentation-backend";
|
|
8
8
|
import { PresentationProps as PresentationFrontendProps } from "@itwin/presentation-frontend";
|
|
9
9
|
/** @internal */
|
|
10
10
|
export declare const getTestOutputDir: () => string;
|
|
11
|
-
export { HierarchyCacheMode,
|
|
11
|
+
export { HierarchyCacheMode, PresentationBackendProps };
|
|
12
12
|
/** @public */
|
|
13
13
|
export interface PresentationTestingInitProps {
|
|
14
14
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Helpers.d.ts","sourceRoot":"","sources":["../../../src/presentation-testing/Helpers.ts"],"names":[],"mappings":"AAIA;;GAEG;
|
|
1
|
+
{"version":3,"file":"Helpers.d.ts","sourceRoot":"","sources":["../../../src/presentation-testing/Helpers.ts"],"names":[],"mappings":"AAIA;;GAEG;AAKH,OAAO,EAAc,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAEpE,OAAO,EAAqE,sBAAsB,EAA8B,MAAM,oBAAoB,CAAC;AAC3J,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAe,MAAM,sBAAsB,CAAC;AAChF,OAAO,EAAE,kBAAkB,EAAuC,wBAAwB,IAAI,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AAE5J,OAAO,EAAwC,iBAAiB,IAAI,yBAAyB,EAAE,MAAM,8BAA8B,CAAC;AA0BpI,gBAAgB;AAChB,eAAO,MAAM,gBAAgB,QAAO,MAEnC,CAAC;AAEF,OAAO,EAAE,kBAAkB,EAAE,wBAAwB,EAAE,CAAC;AAExD,cAAc;AACd,MAAM,WAAW,4BAA4B;IAC3C;;;;OAIG;IACH,IAAI,CAAC,EAAE,sBAAsB,EAAE,CAAC;IAChC,4CAA4C;IAC5C,YAAY,CAAC,EAAE,wBAAwB,CAAC;IACxC,kCAAkC;IAClC,gBAAgB,CAAC,EAAE,iBAAiB,CAAC;IACrC,6CAA6C;IAC7C,aAAa,CAAC,EAAE,yBAAyB,CAAC;IAC1C,+BAA+B;IAC/B,WAAW,CAAC,EAAE;QAAE,OAAO,EAAE,CAAC,IAAI,CAAC,EAAE,gBAAgB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAA;KAAE,CAAC;IACtE,0BAA0B;IAC1B,kBAAkB,CAAC,EAAE,gBAAgB,CAAC;IACtC,wFAAwF;IACxF,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,UAAU,WAAkB,4BAA4B,kBAoCpE,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,SAAS,mDA0BrB,CAAC"}
|
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
/** @packageDocumentation
|
|
6
6
|
* @module Helpers
|
|
7
7
|
*/
|
|
8
|
-
/* istanbul ignore file */ // TODO: Remove istanbul ignore file when https://github.com/iTwin/itwinjs-backlog/issues/463 is fixed.
|
|
9
8
|
import { tmpdir } from "os";
|
|
10
9
|
import { join } from "path";
|
|
11
10
|
import * as rimraf from "rimraf";
|
|
@@ -13,7 +12,7 @@ import { IModelHost } from "@itwin/core-backend";
|
|
|
13
12
|
import { Guid } from "@itwin/core-bentley";
|
|
14
13
|
import { IModelReadRpcInterface, RpcConfiguration, RpcDefaultConfiguration, SnapshotIModelRpcInterface } from "@itwin/core-common";
|
|
15
14
|
import { IModelApp, NoRenderApp } from "@itwin/core-frontend";
|
|
16
|
-
import { HierarchyCacheMode, Presentation as PresentationBackend
|
|
15
|
+
import { HierarchyCacheMode, Presentation as PresentationBackend } from "@itwin/presentation-backend";
|
|
17
16
|
import { PresentationRpcInterface } from "@itwin/presentation-common";
|
|
18
17
|
import { Presentation as PresentationFrontend } from "@itwin/presentation-frontend";
|
|
19
18
|
function initializeRpcInterfaces(interfaces) {
|
|
@@ -29,7 +28,7 @@ function initializeRpcInterfaces(interfaces) {
|
|
|
29
28
|
}
|
|
30
29
|
};
|
|
31
30
|
for (const definition of interfaces) {
|
|
32
|
-
RpcConfiguration.assign(definition, () => config); // eslint-disable-line @itwin/no-internal
|
|
31
|
+
RpcConfiguration.assign(definition, /* istanbul ignore next */ () => config); // eslint-disable-line @itwin/no-internal
|
|
33
32
|
}
|
|
34
33
|
const instance = RpcConfiguration.obtain(config); // eslint-disable-line @itwin/no-internal
|
|
35
34
|
try {
|
|
@@ -47,8 +46,7 @@ let testOutputDir;
|
|
|
47
46
|
export const getTestOutputDir = () => {
|
|
48
47
|
return testOutputDir ?? defaultTestOutputDir;
|
|
49
48
|
};
|
|
50
|
-
|
|
51
|
-
export { HierarchyCacheMode, PresentationManagerMode };
|
|
49
|
+
export { HierarchyCacheMode };
|
|
52
50
|
/**
|
|
53
51
|
* Initialize the framework for presentation testing. The function sets up backend,
|
|
54
52
|
* frontend and RPC communication between them.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Helpers.js","sourceRoot":"","sources":["../../../src/presentation-testing/Helpers.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,
|
|
1
|
+
{"version":3,"file":"Helpers.js","sourceRoot":"","sources":["../../../src/presentation-testing/Helpers.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,IAAI,CAAC;AAC5B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,EAAE,UAAU,EAAqB,MAAM,qBAAqB,CAAC;AACpE,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAC3C,OAAO,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,uBAAuB,EAA0B,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AAC3J,OAAO,EAAE,SAAS,EAAoB,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAChF,OAAO,EAAE,kBAAkB,EAAE,YAAY,IAAI,mBAAmB,EAAwD,MAAM,6BAA6B,CAAC;AAC5J,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,YAAY,IAAI,oBAAoB,EAAkD,MAAM,8BAA8B,CAAC;AAEpI,SAAS,uBAAuB,CAAC,UAAoC;IACnE,MAAM,MAAM,GAAG,KAAM,SAAQ,uBAAuB;QAArC;;YACG;;;;uBAAkB,GAAG,EAAE,CAAC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GAAG,sBAAsB,EAAE,IAAI,EAAE,SAAS,CAAC;KACrE;IAED,oBAAoB;IACpB,mBAAmB,CAAC,SAAS,EAAE,CAAC;IAChC,MAAM,UAAU,CAAC,QAAQ,EAAE,CAAC;IAC5B,IAAI,yBAAyB,EAAE;QAC7B,MAAM,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC;KACxC;IAED,qBAAqB;IACrB,oBAAoB,CAAC,SAAS,EAAE,CAAC;IACjC,MAAM,WAAW,CAAC,QAAQ,EAAE,CAAC;IAE7B,aAAa,GAAG,KAAK,CAAC;AACxB,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Helpers\n */\n\nimport { tmpdir } from \"os\";\nimport { join } from \"path\";\nimport * as rimraf from \"rimraf\";\nimport { IModelHost, IModelHostOptions } from \"@itwin/core-backend\";\nimport { Guid } from \"@itwin/core-bentley\";\nimport { IModelReadRpcInterface, RpcConfiguration, RpcDefaultConfiguration, RpcInterfaceDefinition, SnapshotIModelRpcInterface } from \"@itwin/core-common\";\nimport { IModelApp, IModelAppOptions, NoRenderApp } from \"@itwin/core-frontend\";\nimport { HierarchyCacheMode, Presentation as PresentationBackend, PresentationManagerProps as PresentationBackendProps } from \"@itwin/presentation-backend\";\nimport { PresentationRpcInterface } from \"@itwin/presentation-common\";\nimport { Presentation as PresentationFrontend, PresentationProps as PresentationFrontendProps } from \"@itwin/presentation-frontend\";\n\nfunction initializeRpcInterfaces(interfaces: RpcInterfaceDefinition[]) {\n const config = class extends RpcDefaultConfiguration {\n public override interfaces: any = () => interfaces;\n };\n\n for (const definition of interfaces) {\n RpcConfiguration.assign(definition, /* istanbul ignore next */ () => config); // eslint-disable-line @itwin/no-internal\n }\n\n const instance = RpcConfiguration.obtain(config); // eslint-disable-line @itwin/no-internal\n\n try {\n RpcConfiguration.initializeInterfaces(instance); // eslint-disable-line @itwin/no-internal\n } catch {\n // this may fail with \"Error: RPC interface \"xxx\" is already initialized.\" because\n // multiple different tests want to set up rpc interfaces\n }\n}\n\nlet isInitialized = false;\n\nconst defaultTestOutputDir = tmpdir();\nlet testOutputDir: string | undefined;\n\n/** @internal */\nexport const getTestOutputDir = (): string => {\n return testOutputDir ?? defaultTestOutputDir;\n};\n\nexport { HierarchyCacheMode, PresentationBackendProps };\n\n/** @public */\nexport interface PresentationTestingInitProps {\n /**\n * RPC interfaces to enable. Defaults to `[SnapshotIModelRpcInterface, IModelReadRpcInterface, PresentationRpcInterface]`.\n *\n * Note: Implementations for these interfaces are **not** automatically registered on the backend - that has to be done manually.\n */\n rpcs?: RpcInterfaceDefinition[];\n /** Properties for backend initialization */\n backendProps?: PresentationBackendProps;\n /** Properties for `IModelHost` */\n backendHostProps?: IModelHostOptions;\n /** Properties for frontend initialization */\n frontendProps?: PresentationFrontendProps;\n /** IModelApp implementation */\n frontendApp?: { startup: (opts?: IModelAppOptions) => Promise<void> };\n /** `IModelApp` options */\n frontendAppOptions?: IModelAppOptions;\n /** Custom test output directory. Defaults to temporary directory provided by the OS. */\n testOutputDir?: string;\n}\n\n/**\n * Initialize the framework for presentation testing. The function sets up backend,\n * frontend and RPC communication between them.\n *\n * @see `terminate`\n *\n * @public\n */\nexport const initialize = async (props?: PresentationTestingInitProps) => {\n if (isInitialized) {\n return;\n }\n\n if (!props) {\n props = {};\n }\n\n // set up rpc interfaces\n initializeRpcInterfaces(props.rpcs ?? [SnapshotIModelRpcInterface, IModelReadRpcInterface, PresentationRpcInterface]);\n\n // init backend\n // make sure backend gets assigned an id which puts its resources into a unique directory\n props.backendProps = props.backendProps ?? {};\n // eslint-disable-next-line @itwin/no-internal\n if (!props.backendProps.id) {\n props.backendProps.id = `test-${Guid.createValue()}`; // eslint-disable-line @itwin/no-internal\n }\n await IModelHost.startup({ cacheDir: join(__dirname, \".cache\"), ...props.backendHostProps });\n PresentationBackend.initialize(props.backendProps);\n\n // init frontend\n if (!props.frontendApp) {\n props.frontendApp = NoRenderApp;\n }\n await props.frontendApp.startup(props.frontendAppOptions);\n const defaultFrontendProps: PresentationFrontendProps = {\n presentation: {\n activeLocale: IModelApp.localization.getLanguageList()[0],\n },\n };\n await PresentationFrontend.initialize({ ...defaultFrontendProps, ...props.frontendProps });\n testOutputDir = props.testOutputDir;\n\n isInitialized = true;\n};\n\n/**\n * Undoes the setup made by `initialize`.\n * @param frontendApp IModelApp implementation\n *\n * @see `initialize`\n *\n * @public\n */\nexport const terminate = async (frontendApp = IModelApp) => {\n if (!isInitialized) {\n return;\n }\n\n // store directory that needs to be cleaned-up\n let hierarchiesCacheDirectory: string | undefined;\n const hierarchiesCacheConfig = PresentationBackend.initProps?.caching?.hierarchies;\n if (hierarchiesCacheConfig?.mode === HierarchyCacheMode.Disk) {\n hierarchiesCacheDirectory = hierarchiesCacheConfig?.directory;\n } else if (hierarchiesCacheConfig?.mode === HierarchyCacheMode.Hybrid) {\n hierarchiesCacheDirectory = hierarchiesCacheConfig?.disk?.directory;\n }\n\n // terminate backend\n PresentationBackend.terminate();\n await IModelHost.shutdown();\n if (hierarchiesCacheDirectory) {\n rimraf.sync(hierarchiesCacheDirectory);\n }\n\n // terminate frontend\n PresentationFrontend.terminate();\n await frontendApp.shutdown();\n\n isInitialized = false;\n};\n"]}
|
|
@@ -27,21 +27,41 @@ export interface TestIModelBuilder {
|
|
|
27
27
|
* Code value has to be unique within its scope (see [Codes documentation page]($docs/bis/guide/fundamentals/codes.md)).
|
|
28
28
|
*/
|
|
29
29
|
createCode(scopeModelId: CodeScopeProps, codeSpecName: BisCodeSpec, codeValue: string): Code;
|
|
30
|
+
/**
|
|
31
|
+
* Import an ECSchema in a form of XML string into the builder's iModel.
|
|
32
|
+
*/
|
|
33
|
+
importSchema(schemaXml: string): Promise<void>;
|
|
30
34
|
}
|
|
31
35
|
/**
|
|
32
36
|
* Function that creates an iModel and returns a connection to it.
|
|
33
37
|
* @param name Name of test IModel
|
|
34
38
|
* @param cb Callback function that receives an [[TestIModelBuilder]] to fill the iModel with data
|
|
35
39
|
* @beta
|
|
40
|
+
* @deprecated in 4.x. Use an overload with `cb` returning a promise.
|
|
36
41
|
*/
|
|
37
42
|
export declare function buildTestIModel(name: string, cb: (builder: TestIModelBuilder) => void): Promise<IModelConnection>;
|
|
43
|
+
/**
|
|
44
|
+
* Function that creates an iModel and returns a connection to it.
|
|
45
|
+
* @param name Name of test IModel
|
|
46
|
+
* @param cb Callback function that receives an [[TestIModelBuilder]] to fill the iModel with data
|
|
47
|
+
* @beta
|
|
48
|
+
*/
|
|
49
|
+
export declare function buildTestIModel(name: string, cb: (builder: TestIModelBuilder) => Promise<void>): Promise<IModelConnection>;
|
|
38
50
|
/**
|
|
39
51
|
* Function that creates an iModel and returns a connection to it.
|
|
40
52
|
* @param mochaContext Mocha context to generate iModel name from
|
|
41
53
|
* @param cb Callback function that receives an [[TestIModelBuilder]] to fill the iModel with data
|
|
42
54
|
* @beta
|
|
55
|
+
* @deprecated in 4.x. Use an overload with `cb` returning a promise.
|
|
43
56
|
*/
|
|
44
57
|
export declare function buildTestIModel(mochaContext: Mocha.Context, cb: (builder: TestIModelBuilder) => void): Promise<IModelConnection>;
|
|
58
|
+
/**
|
|
59
|
+
* Function that creates an iModel and returns a connection to it.
|
|
60
|
+
* @param mochaContext Mocha context to generate iModel name from
|
|
61
|
+
* @param cb Callback function that receives an [[TestIModelBuilder]] to fill the iModel with data
|
|
62
|
+
* @beta
|
|
63
|
+
*/
|
|
64
|
+
export declare function buildTestIModel(mochaContext: Mocha.Context, cb: (builder: TestIModelBuilder) => Promise<void>): Promise<IModelConnection>;
|
|
45
65
|
/**
|
|
46
66
|
* Default implementation of IModel builder pattern. Used for building IModels to test rulesets.
|
|
47
67
|
*
|
|
@@ -55,6 +75,7 @@ export declare class IModelBuilder implements TestIModelBuilder {
|
|
|
55
75
|
insertAspect<TProps extends ElementAspectProps>(props: TProps): Id64String;
|
|
56
76
|
insertRelationship<TProps extends RelationshipProps>(props: TProps): Id64String;
|
|
57
77
|
createCode(scopeModelId: CodeScopeProps, codeSpecName: BisCodeSpec, codeValue: string): Code;
|
|
78
|
+
importSchema(schemaXml: string): Promise<void>;
|
|
58
79
|
}
|
|
59
80
|
/** @internal */
|
|
60
81
|
export declare function createFileNameFromString(str: string): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IModelUtilities.d.ts","sourceRoot":"","sources":["../../../src/presentation-testing/IModelUtilities.ts"],"names":[],"mappings":"AAIA;;GAEG;;AAIH,OAAO,EAAE,QAAQ,EAA0B,MAAM,qBAAqB,CAAC;AACvE,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EACL,WAAW,EACX,IAAI,EACJ,cAAc,EAEd,kBAAkB,EAClB,YAAY,EAEZ,UAAU,EACV,iBAAiB,EAClB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,gBAAgB,EAAsB,MAAM,sBAAsB,CAAC;AAG5E;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC,+CAA+C;IAC/C,WAAW,CAAC,MAAM,SAAS,UAAU,EAAE,KAAK,EAAE,MAAM,GAAG,UAAU,CAAC;IAClE,kDAAkD;IAClD,aAAa,CAAC,MAAM,SAAS,YAAY,EAAE,KAAK,EAAE,MAAM,GAAG,UAAU,CAAC;IACtE,0DAA0D;IAC1D,YAAY,CAAC,MAAM,SAAS,kBAAkB,EAAE,KAAK,EAAE,MAAM,GAAG,UAAU,CAAC;IAC3E;;;OAGG;IACH,kBAAkB,CAAC,MAAM,SAAS,iBAAiB,EAAE,KAAK,EAAE,MAAM,GAAG,UAAU,CAAC;IAChF;;;OAGG;IACH,UAAU,CAAC,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"IModelUtilities.d.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,EAAE,iBAAiB,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;AAClI;;;;;;GAMG;AAEH,wBAAsB,eAAe,CAAC,YAAY,EAAE,KAAK,CAAC,OAAO,EAAE,EAAE,EAAE,CAAC,OAAO,EAAE,iBAAiB,KAAK,IAAI,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;AACxI;;;;;GAKG;AAEH,wBAAsB,eAAe,CAAC,YAAY,EAAE,KAAK,CAAC,OAAO,EAAE,EAAE,EAAE,CAAC,OAAO,EAAE,iBAAiB,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;AAejJ;;;;GAIG;AACH,qBAAa,aAAc,YAAW,iBAAiB;IACrD,OAAO,CAAC,OAAO,CAAW;gBAEd,MAAM,EAAE,QAAQ;IAIrB,WAAW,CAAC,MAAM,SAAS,UAAU,EAAE,KAAK,EAAE,MAAM,GAAG,UAAU;IAIjE,aAAa,CAAC,MAAM,SAAS,YAAY,EAAE,KAAK,EAAE,MAAM,GAAG,UAAU;IAIrE,YAAY,CAAC,MAAM,SAAS,kBAAkB,EAAE,KAAK,EAAE,MAAM,GAAG,UAAU;IAI1E,kBAAkB,CAAC,MAAM,SAAS,iBAAiB,EAAE,KAAK,EAAE,MAAM,GAAG,UAAU;IAI/E,UAAU,CAAC,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI;IAKtF,YAAY,CAAC,SAAS,EAAE,MAAM;CAG5C;AAkBD,gBAAgB;AAChB,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,MAAM,UAEnD"}
|
|
@@ -17,7 +17,7 @@ export async function buildTestIModel(nameParam, cb) {
|
|
|
17
17
|
const db = SnapshotDb.createEmpty(outputFile, { rootSubject: { name } });
|
|
18
18
|
const builder = new IModelBuilder(db);
|
|
19
19
|
try {
|
|
20
|
-
cb(builder);
|
|
20
|
+
await cb(builder);
|
|
21
21
|
}
|
|
22
22
|
finally {
|
|
23
23
|
db.saveChanges("Created test IModel");
|
|
@@ -56,6 +56,9 @@ export class IModelBuilder {
|
|
|
56
56
|
const codeSpec = this._iModel.codeSpecs.getByName(codeSpecName);
|
|
57
57
|
return new Code({ spec: codeSpec.id, scope: scopeModelId, value: codeValue });
|
|
58
58
|
}
|
|
59
|
+
async importSchema(schemaXml) {
|
|
60
|
+
await this._iModel.importSchemaStrings([schemaXml]);
|
|
61
|
+
}
|
|
59
62
|
}
|
|
60
63
|
/**
|
|
61
64
|
* Prepare for an output file by:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IModelUtilities.js","sourceRoot":"","sources":["../../../src/presentation-testing/IModelUtilities.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,QAAQ,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAY,UAAU,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEvE,OAAO,EAEL,IAAI,GAQL,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAoB,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC5E,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"IModelUtilities.js","sourceRoot":"","sources":["../../../src/presentation-testing/IModelUtilities.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,QAAQ,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAY,UAAU,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEvE,OAAO,EAEL,IAAI,GAQL,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAoB,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC5E,OAAO,EAAE,gBAAgB,EAAE,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AO,CAAC,aAAa,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;IAC1D,CAAC;IAEM,UAAU,CAAC,YAA4B,EAAE,YAAyB,EAAE,SAAiB;QAC1F,MAAM,QAAQ,GAAa,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;QAC1E,OAAO,IAAI,IAAI,CAAC,EAAE,IAAI,EAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;IAChF,CAAC;IAEM,KAAK,CAAC,YAAY,CAAC,SAAiB;QACzC,MAAM,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;IACtD,CAAC;CACF;AAED;;;;;;GAMG;AACH,SAAS,uBAAuB,CAAC,QAAgB;IAC/C,MAAM,aAAa,GAAG,gBAAgB,EAAE,CAAC;IACzC,CAAC,UAAU,CAAC,UAAU,CAAC,aAAa,CAAC,IAAI,UAAU,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC;IAE7E,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,GAAG,QAAQ,MAAM,CAAC,CAAC;IAC/D,UAAU,CAAC,UAAU,CAAC,UAAU,CAAC,IAAI,UAAU,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;IACvE,OAAO,UAAU,CAAC;AACpB,CAAC;AAED,gBAAgB;AAChB,MAAM,UAAU,wBAAwB,CAAC,GAAW;IAClD,OAAO,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC,iBAAiB,EAAE,CAAC;AACjE,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module IModel\n */\n\nimport path from \"path\";\nimport sanitize from \"sanitize-filename\";\nimport { IModelDb, IModelJsFs, SnapshotDb } from \"@itwin/core-backend\";\nimport { Id64String } from \"@itwin/core-bentley\";\nimport {\n BisCodeSpec,\n Code,\n CodeScopeProps,\n CodeSpec,\n ElementAspectProps,\n ElementProps,\n LocalFileName,\n ModelProps,\n RelationshipProps,\n} from \"@itwin/core-common\";\nimport { IModelConnection, SnapshotConnection } from \"@itwin/core-frontend\";\nimport { getTestOutputDir } from \"./Helpers\";\n\n/**\n * Interface for IModel builder pattern. Used for building IModels to test rulesets.\n * @beta\n */\nexport interface TestIModelBuilder {\n /** Insert a model into the builder's iModel */\n insertModel<TProps extends ModelProps>(props: TProps): Id64String;\n /** Insert an element into the builder's iModel */\n insertElement<TProps extends ElementProps>(props: TProps): Id64String;\n /** Insert an element aspect into the specified element */\n insertAspect<TProps extends ElementAspectProps>(props: TProps): Id64String;\n /**\n * Insert a relationship between two instances. The relationship is expected to be a subclass\n * of `BisCore:ElementRefersToElements` or `BisCore:ElementDrivesElement`.\n */\n insertRelationship<TProps extends RelationshipProps>(props: TProps): Id64String;\n /**\n * Create code for specified element.\n * Code value has to be unique within its scope (see [Codes documentation page]($docs/bis/guide/fundamentals/codes.md)).\n */\n createCode(scopeModelId: CodeScopeProps, codeSpecName: BisCodeSpec, codeValue: string): Code;\n /**\n * Import an ECSchema in a form of XML string into the builder's iModel.\n */\n importSchema(schemaXml: string): Promise<void>;\n}\n\n/**\n * Function that creates an iModel and returns a connection to it.\n * @param name Name of test IModel\n * @param cb Callback function that receives an [[TestIModelBuilder]] to fill the iModel with data\n * @beta\n * @deprecated in 4.x. Use an overload with `cb` returning a promise.\n */\nexport async function buildTestIModel(name: string, cb: (builder: TestIModelBuilder) => void): Promise<IModelConnection>;\n/**\n * Function that creates an iModel and returns a connection to it.\n * @param name Name of test IModel\n * @param cb Callback function that receives an [[TestIModelBuilder]] to fill the iModel with data\n * @beta\n */\n// eslint-disable-next-line @typescript-eslint/unified-signatures\nexport async function buildTestIModel(name: string, cb: (builder: TestIModelBuilder) => Promise<void>): Promise<IModelConnection>;\n/**\n * Function that creates an iModel and returns a connection to it.\n * @param mochaContext Mocha context to generate iModel name from\n * @param cb Callback function that receives an [[TestIModelBuilder]] to fill the iModel with data\n * @beta\n * @deprecated in 4.x. Use an overload with `cb` returning a promise.\n */\n// eslint-disable-next-line @typescript-eslint/unified-signatures\nexport async function buildTestIModel(mochaContext: Mocha.Context, cb: (builder: TestIModelBuilder) => void): Promise<IModelConnection>;\n/**\n * Function that creates an iModel and returns a connection to it.\n * @param mochaContext Mocha context to generate iModel name from\n * @param cb Callback function that receives an [[TestIModelBuilder]] to fill the iModel with data\n * @beta\n */\n// eslint-disable-next-line @typescript-eslint/unified-signatures\nexport async function buildTestIModel(mochaContext: Mocha.Context, cb: (builder: TestIModelBuilder) => Promise<void>): Promise<IModelConnection>;\nexport async function buildTestIModel(nameParam: string | Mocha.Context, cb: (builder: TestIModelBuilder) => void | Promise<void>): Promise<IModelConnection> {\n const name = typeof nameParam === \"string\" ? nameParam : createFileNameFromString(nameParam.test!.fullTitle());\n const outputFile = setupOutputFileLocation(name);\n const db = SnapshotDb.createEmpty(outputFile, { rootSubject: { name } });\n const builder = new IModelBuilder(db);\n try {\n await cb(builder);\n } finally {\n db.saveChanges(\"Created test IModel\");\n db.close();\n }\n return SnapshotConnection.openFile(outputFile);\n}\n\n/**\n * Default implementation of IModel builder pattern. Used for building IModels to test rulesets.\n *\n * @internal\n */\nexport class IModelBuilder implements TestIModelBuilder {\n private _iModel: IModelDb;\n\n constructor(iModel: IModelDb) {\n this._iModel = iModel;\n }\n\n public insertModel<TProps extends ModelProps>(props: TProps): Id64String {\n return this._iModel.models.insertModel(props);\n }\n\n public insertElement<TProps extends ElementProps>(props: TProps): Id64String {\n return this._iModel.elements.insertElement(props);\n }\n\n public insertAspect<TProps extends ElementAspectProps>(props: TProps): Id64String {\n return this._iModel.elements.insertAspect(props);\n }\n\n public insertRelationship<TProps extends RelationshipProps>(props: TProps): Id64String {\n return this._iModel.relationships.insertInstance(props);\n }\n\n public createCode(scopeModelId: CodeScopeProps, codeSpecName: BisCodeSpec, codeValue: string): Code {\n const codeSpec: CodeSpec = this._iModel.codeSpecs.getByName(codeSpecName);\n return new Code({ spec: codeSpec.id, scope: scopeModelId, value: codeValue });\n }\n\n public async importSchema(schemaXml: string) {\n await this._iModel.importSchemaStrings([schemaXml]);\n }\n}\n\n/**\n * Prepare for an output file by:\n * - Resolving the output file name under the known test output directory\n * - Making directories as necessary\n * - Removing a previous copy of the output file\n * @param fileName Name of output file\n */\nfunction setupOutputFileLocation(fileName: string): LocalFileName {\n const testOutputDir = getTestOutputDir();\n !IModelJsFs.existsSync(testOutputDir) && IModelJsFs.mkdirSync(testOutputDir);\n\n const outputFile = path.join(testOutputDir, `${fileName}.bim`);\n IModelJsFs.existsSync(outputFile) && IModelJsFs.unlinkSync(outputFile);\n return outputFile;\n}\n\n/** @internal */\nexport function createFileNameFromString(str: string) {\n return sanitize(str.replace(/[ ]+/g, \"-\")).toLocaleLowerCase();\n}\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { PresentationManagerMode } from "@itwin/presentation-backend";
|
|
1
2
|
/**
|
|
2
3
|
* @module Hierarchies
|
|
3
4
|
*
|
|
@@ -26,4 +27,5 @@ export * from "./presentation-testing/Helpers";
|
|
|
26
27
|
* Utilities for creating test iModels that can be used to exercise presentation rules.
|
|
27
28
|
*/
|
|
28
29
|
export * from "./presentation-testing/IModelUtilities";
|
|
30
|
+
export { PresentationManagerMode };
|
|
29
31
|
//# sourceMappingURL=presentation-testing.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presentation-testing.d.ts","sourceRoot":"","sources":["../../src/presentation-testing.ts"],"names":[],"mappings":"AAKA;;;;;GAKG;AACH,cAAc,yCAAyC,CAAC;AAExD;;;;;GAKG;AACH,cAAc,uCAAuC,CAAC;AAEtD;;;;;GAKG;AACH,cAAc,gCAAgC,CAAC;AAE/C;;;;;GAKG;AACH,cAAc,wCAAwC,CAAC"}
|
|
1
|
+
{"version":3,"file":"presentation-testing.d.ts","sourceRoot":"","sources":["../../src/presentation-testing.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAEtE;;;;;GAKG;AACH,cAAc,yCAAyC,CAAC;AAExD;;;;;GAKG;AACH,cAAc,uCAAuC,CAAC;AAEtD;;;;;GAKG;AACH,cAAc,gCAAgC,CAAC;AAE/C;;;;;GAKG;AACH,cAAc,wCAAwC,CAAC;AAEvD,OAAO,EAAE,uBAAuB,EAAE,CAAC"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
3
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
import { PresentationManagerMode } from "@itwin/presentation-backend";
|
|
5
6
|
/**
|
|
6
7
|
* @module Hierarchies
|
|
7
8
|
*
|
|
@@ -30,4 +31,5 @@ export * from "./presentation-testing/Helpers";
|
|
|
30
31
|
* Utilities for creating test iModels that can be used to exercise presentation rules.
|
|
31
32
|
*/
|
|
32
33
|
export * from "./presentation-testing/IModelUtilities";
|
|
34
|
+
export { PresentationManagerMode }; // eslint-disable-line deprecation/deprecation
|
|
33
35
|
//# sourceMappingURL=presentation-testing.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presentation-testing.js","sourceRoot":"","sources":["../../src/presentation-testing.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG;;;;;GAKG;AACH,cAAc,yCAAyC,CAAC;AAExD;;;;;GAKG;AACH,cAAc,uCAAuC,CAAC;AAEtD;;;;;GAKG;AACH,cAAc,gCAAgC,CAAC;AAE/C;;;;;GAKG;AACH,cAAc,wCAAwC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\n/**\n * @module Hierarchies\n *\n * @docs-group-description Hierarchies\n * Types for testing hierarchies.\n */\nexport * from \"./presentation-testing/HierarchyBuilder\";\n\n/**\n * @module Content\n *\n * @docs-group-description Content\n * Types for testing content.\n */\nexport * from \"./presentation-testing/ContentBuilder\";\n\n/**\n * @module Helpers\n *\n * @docs-group-description Helpers\n * Various test helpers.\n */\nexport * from \"./presentation-testing/Helpers\";\n\n/**\n * @module IModel\n *\n * @docs-group-description IModel\n * Utilities for creating test iModels that can be used to exercise presentation rules.\n */\nexport * from \"./presentation-testing/IModelUtilities\";\n"]}
|
|
1
|
+
{"version":3,"file":"presentation-testing.js","sourceRoot":"","sources":["../../src/presentation-testing.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAEtE;;;;;GAKG;AACH,cAAc,yCAAyC,CAAC;AAExD;;;;;GAKG;AACH,cAAc,uCAAuC,CAAC;AAEtD;;;;;GAKG;AACH,cAAc,gCAAgC,CAAC;AAE/C;;;;;GAKG;AACH,cAAc,wCAAwC,CAAC;AAEvD,OAAO,EAAE,uBAAuB,EAAE,CAAC,CAAC,8CAA8C","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n\nimport { PresentationManagerMode } from \"@itwin/presentation-backend\";\n\n/**\n * @module Hierarchies\n *\n * @docs-group-description Hierarchies\n * Types for testing hierarchies.\n */\nexport * from \"./presentation-testing/HierarchyBuilder\";\n\n/**\n * @module Content\n *\n * @docs-group-description Content\n * Types for testing content.\n */\nexport * from \"./presentation-testing/ContentBuilder\";\n\n/**\n * @module Helpers\n *\n * @docs-group-description Helpers\n * Various test helpers.\n */\nexport * from \"./presentation-testing/Helpers\";\n\n/**\n * @module IModel\n *\n * @docs-group-description IModel\n * Utilities for creating test iModels that can be used to exercise presentation rules.\n */\nexport * from \"./presentation-testing/IModelUtilities\";\n\nexport { PresentationManagerMode }; // eslint-disable-line deprecation/deprecation\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itwin/presentation-testing",
|
|
3
|
-
"version": "4.0
|
|
3
|
+
"version": "4.1.0",
|
|
4
4
|
"description": "Testing utilities for iTwin.js Presentation library",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -21,23 +21,10 @@
|
|
|
21
21
|
"main": "lib/cjs/presentation-testing.js",
|
|
22
22
|
"module": "lib/esm/presentation-testing.js",
|
|
23
23
|
"types": "lib/cjs/presentation-testing.d.ts",
|
|
24
|
-
"scripts": {
|
|
25
|
-
"build": "npm run -s build:cjs && npm run -s build:esm",
|
|
26
|
-
"build:cjs": "tsc -p tsconfig.cjs.json",
|
|
27
|
-
"build:esm": "tsc -p tsconfig.esm.json",
|
|
28
|
-
"build:watch": "npm run -s build:cjs -- -w",
|
|
29
|
-
"clean": "rimraf lib",
|
|
30
|
-
"cover": "nyc npm -s test",
|
|
31
|
-
"docs": "npm run -s docs:reference && npm run -s docs:changelog",
|
|
32
|
-
"docs:changelog": "cpx ./CHANGELOG.md ../../build/docs/reference/presentation-testing",
|
|
33
|
-
"docs:reference": "betools docs --includes=../../build/docs/extract --json=../../build/docs/reference/presentation-testing/file.json --tsIndexFile=presentation-testing.ts --onlyJson --testExcludeGlob=./src/test/**",
|
|
34
|
-
"lint": "eslint ./src/**/*.ts",
|
|
35
|
-
"test": "mocha --config ./.mocharc.json \"./lib/cjs/test/**/*.test.js\"",
|
|
36
|
-
"extract-api": "betools extract-api --entry=presentation-testing --apiReportFolder=./api --apiReportTempFolder=./api/temp --apiSummaryFolder=./api"
|
|
37
|
-
},
|
|
38
24
|
"dependencies": {
|
|
39
25
|
"rimraf": "^5.0.1",
|
|
40
|
-
"sanitize-filename": "^1.6.3"
|
|
26
|
+
"sanitize-filename": "^1.6.3",
|
|
27
|
+
"@itwin/presentation-components": "4.2.1"
|
|
41
28
|
},
|
|
42
29
|
"peerDependencies": {
|
|
43
30
|
"@itwin/appui-abstract": "^3.6.3 || ^4.0.0",
|
|
@@ -48,50 +35,62 @@
|
|
|
48
35
|
"@itwin/core-frontend": "^3.6.3 || ^4.0.0",
|
|
49
36
|
"@itwin/presentation-backend": "^3.6.3 || ^4.0.0",
|
|
50
37
|
"@itwin/presentation-common": "^3.6.3 || ^4.0.0",
|
|
51
|
-
"@itwin/presentation-components": "^4.1.0",
|
|
52
38
|
"@itwin/presentation-frontend": "^3.6.3 || ^4.0.0"
|
|
53
39
|
},
|
|
54
40
|
"devDependencies": {
|
|
55
|
-
"@itwin/appui-abstract": "4.1.
|
|
56
|
-
"@itwin/build-tools": "4.1.
|
|
57
|
-
"@itwin/components-react": "^4.
|
|
58
|
-
"@itwin/core-backend": "4.1.
|
|
59
|
-
"@itwin/core-bentley": "4.1.
|
|
60
|
-
"@itwin/core-common": "4.1.
|
|
61
|
-
"@itwin/core-frontend": "4.1.
|
|
62
|
-
"@itwin/core-geometry": "4.1.
|
|
63
|
-
"@itwin/core-orbitgt": "4.1.
|
|
64
|
-
"@itwin/core-quantity": "4.1.
|
|
65
|
-
"@itwin/core-react": "^4.
|
|
66
|
-
"@itwin/ecschema-metadata": "4.1.
|
|
67
|
-
"@itwin/eslint-plugin": "
|
|
68
|
-
"@itwin/presentation-backend": "4.1.
|
|
69
|
-
"@itwin/presentation-common": "4.1.
|
|
70
|
-
"@itwin/presentation-
|
|
71
|
-
"@itwin/
|
|
72
|
-
"@itwin/webgl-compatibility": "4.1.0-dev.71",
|
|
41
|
+
"@itwin/appui-abstract": "^4.1.1",
|
|
42
|
+
"@itwin/build-tools": "^4.1.1",
|
|
43
|
+
"@itwin/components-react": "^4.4.0",
|
|
44
|
+
"@itwin/core-backend": "^4.1.1",
|
|
45
|
+
"@itwin/core-bentley": "^4.1.1",
|
|
46
|
+
"@itwin/core-common": "^4.1.1",
|
|
47
|
+
"@itwin/core-frontend": "^4.1.1",
|
|
48
|
+
"@itwin/core-geometry": "^4.1.1",
|
|
49
|
+
"@itwin/core-orbitgt": "^4.1.1",
|
|
50
|
+
"@itwin/core-quantity": "^4.1.1",
|
|
51
|
+
"@itwin/core-react": "^4.4.0",
|
|
52
|
+
"@itwin/ecschema-metadata": "^4.1.1",
|
|
53
|
+
"@itwin/eslint-plugin": "4.0.0-dev.48",
|
|
54
|
+
"@itwin/presentation-backend": "^4.1.1",
|
|
55
|
+
"@itwin/presentation-common": "^4.1.1",
|
|
56
|
+
"@itwin/presentation-frontend": "^4.1.1",
|
|
57
|
+
"@itwin/webgl-compatibility": "^4.1.1",
|
|
73
58
|
"@opentelemetry/api": "^1.4.1",
|
|
74
59
|
"@types/chai": "4.3.1",
|
|
75
60
|
"@types/chai-as-promised": "^7.1.5",
|
|
76
61
|
"@types/chai-jest-snapshot": "^1.3.6",
|
|
77
62
|
"@types/mocha": "^8.2.3",
|
|
78
|
-
"@types/sinon": "^10.0.
|
|
63
|
+
"@types/sinon": "^10.0.16",
|
|
79
64
|
"@types/sinon-chai": "^3.2.9",
|
|
80
65
|
"chai": "^4.3.7",
|
|
81
66
|
"chai-as-promised": "^7.1.1",
|
|
82
67
|
"chai-jest-snapshot": "^2.0.0",
|
|
83
68
|
"cpx2": "^3.0.2",
|
|
84
|
-
"eslint": "^8.
|
|
69
|
+
"eslint": "^8.47.0",
|
|
85
70
|
"ignore-styles": "^5.0.1",
|
|
86
71
|
"jsdom": "^22.1.0",
|
|
87
72
|
"jsdom-global": "3.0.2",
|
|
88
73
|
"mocha": "^10.2.0",
|
|
89
74
|
"nyc": "^15.1.0",
|
|
90
|
-
"react": "^17.0.
|
|
91
|
-
"react-dom": "^17.0.
|
|
75
|
+
"react": "^17.0.2",
|
|
76
|
+
"react-dom": "^17.0.2",
|
|
92
77
|
"sinon": "^15.2.0",
|
|
93
78
|
"sinon-chai": "^3.7.0",
|
|
94
79
|
"typemoq": "^2.1.0",
|
|
95
80
|
"typescript": "~5.0.4"
|
|
81
|
+
},
|
|
82
|
+
"scripts": {
|
|
83
|
+
"build": "npm run -s build:cjs && npm run -s build:esm",
|
|
84
|
+
"build:cjs": "tsc -p tsconfig.cjs.json",
|
|
85
|
+
"build:esm": "tsc -p tsconfig.esm.json",
|
|
86
|
+
"build:watch": "npm run -s build:cjs -- -w",
|
|
87
|
+
"clean": "rimraf lib build",
|
|
88
|
+
"cover": "nyc npm -s test",
|
|
89
|
+
"docs": "npm run -s docs:reference && npm run -s docs:changelog",
|
|
90
|
+
"docs:changelog": "cpx ./CHANGELOG.md ./build/docs/reference/presentation-testing",
|
|
91
|
+
"docs:reference": "betools docs --includes=./build/docs/extract --json=./build/docs/reference/presentation-testing/file.json --tsIndexFile=presentation-testing.ts --onlyJson --testExcludeGlob=./src/test/**",
|
|
92
|
+
"lint": "eslint ./src/**/*.ts",
|
|
93
|
+
"test": "mocha --config ./.mocharc.json \"./lib/cjs/test/**/*.test.js\"",
|
|
94
|
+
"extract-api": "betools extract-api --entry=presentation-testing --apiReportFolder=./api --apiReportTempFolder=./api/temp --apiSummaryFolder=./api"
|
|
96
95
|
}
|
|
97
|
-
}
|
|
96
|
+
}
|