@itwin/presentation-testing 3.4.0-dev.9 → 3.5.0-dev.4
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 +25 -1
- package/lib/cjs/presentation-testing/Helpers.d.ts +4 -1
- package/lib/cjs/presentation-testing/Helpers.d.ts.map +1 -1
- package/lib/cjs/presentation-testing/Helpers.js +3 -3
- package/lib/cjs/presentation-testing/Helpers.js.map +1 -1
- package/lib/cjs/presentation-testing/IModelBuilder.d.ts +46 -0
- package/lib/cjs/presentation-testing/IModelBuilder.d.ts.map +1 -0
- package/lib/cjs/presentation-testing/IModelBuilder.js +171 -0
- package/lib/cjs/presentation-testing/IModelBuilder.js.map +1 -0
- package/lib/cjs/presentation-testing/IModelTestUtility.d.ts +25 -0
- package/lib/cjs/presentation-testing/IModelTestUtility.d.ts.map +1 -0
- package/lib/cjs/presentation-testing/IModelTestUtility.js +63 -0
- package/lib/cjs/presentation-testing/IModelTestUtility.js.map +1 -0
- package/lib/cjs/presentation-testing.d.ts +7 -0
- package/lib/cjs/presentation-testing.d.ts.map +1 -1
- package/lib/cjs/presentation-testing.js +7 -0
- package/lib/cjs/presentation-testing.js.map +1 -1
- package/lib/esm/presentation-testing/Helpers.d.ts +4 -1
- package/lib/esm/presentation-testing/Helpers.d.ts.map +1 -1
- package/lib/esm/presentation-testing/Helpers.js +4 -4
- package/lib/esm/presentation-testing/Helpers.js.map +1 -1
- package/lib/esm/presentation-testing/IModelBuilder.d.ts +46 -0
- package/lib/esm/presentation-testing/IModelBuilder.d.ts.map +1 -0
- package/lib/esm/presentation-testing/IModelBuilder.js +147 -0
- package/lib/esm/presentation-testing/IModelBuilder.js.map +1 -0
- package/lib/esm/presentation-testing/IModelTestUtility.d.ts +25 -0
- package/lib/esm/presentation-testing/IModelTestUtility.d.ts.map +1 -0
- package/lib/esm/presentation-testing/IModelTestUtility.js +59 -0
- package/lib/esm/presentation-testing/IModelTestUtility.js.map +1 -0
- package/lib/esm/presentation-testing.d.ts +7 -0
- package/lib/esm/presentation-testing.d.ts.map +1 -1
- package/lib/esm/presentation-testing.js +7 -0
- package/lib/esm/presentation-testing.js.map +1 -1
- package/package.json +13 -13
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,30 @@
|
|
|
1
1
|
# Change Log - @itwin/presentation-testing
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Thu, 01 Sep 2022 14:37:23 GMT and should not be manually modified.
|
|
4
|
+
|
|
5
|
+
## 3.3.2
|
|
6
|
+
Thu, 01 Sep 2022 14:37:23 GMT
|
|
7
|
+
|
|
8
|
+
_Version update only_
|
|
9
|
+
|
|
10
|
+
## 3.3.1
|
|
11
|
+
Fri, 26 Aug 2022 15:40:02 GMT
|
|
12
|
+
|
|
13
|
+
_Version update only_
|
|
14
|
+
|
|
15
|
+
## 3.3.0
|
|
16
|
+
Thu, 18 Aug 2022 19:08:02 GMT
|
|
17
|
+
|
|
18
|
+
### Updates
|
|
19
|
+
|
|
20
|
+
- upgrade mocha to version 10.0.0
|
|
21
|
+
- make sure tests use a unique cacheDir
|
|
22
|
+
- IModelHost.startup now accepts IModelHostOptions interface rather than IModelHostConfiguration instance
|
|
23
|
+
|
|
24
|
+
## 3.2.9
|
|
25
|
+
Fri, 26 Aug 2022 14:21:40 GMT
|
|
26
|
+
|
|
27
|
+
_Version update only_
|
|
4
28
|
|
|
5
29
|
## 3.2.8
|
|
6
30
|
Tue, 09 Aug 2022 15:52:41 GMT
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { IModelHostOptions } from "@itwin/core-backend";
|
|
1
2
|
import { IModelApp, IModelAppOptions } from "@itwin/core-frontend";
|
|
2
3
|
import { HierarchyCacheMode, PresentationManagerProps as PresentationBackendProps, PresentationManagerMode } from "@itwin/presentation-backend";
|
|
3
4
|
import { PresentationProps as PresentationFrontendProps } from "@itwin/presentation-frontend";
|
|
@@ -6,13 +7,15 @@ export { HierarchyCacheMode, PresentationManagerMode, PresentationBackendProps }
|
|
|
6
7
|
export interface PresentationTestingInitProps {
|
|
7
8
|
/** Properties for backend initialization */
|
|
8
9
|
backendProps?: PresentationBackendProps;
|
|
10
|
+
/** Properties for `IModelHost` */
|
|
11
|
+
backendHostProps?: IModelHostOptions;
|
|
9
12
|
/** Properties for frontend initialization */
|
|
10
13
|
frontendProps?: PresentationFrontendProps;
|
|
11
14
|
/** IModelApp implementation */
|
|
12
15
|
frontendApp?: {
|
|
13
16
|
startup: (opts?: IModelAppOptions) => Promise<void>;
|
|
14
17
|
};
|
|
15
|
-
/** IModelApp options */
|
|
18
|
+
/** `IModelApp` options */
|
|
16
19
|
frontendAppOptions?: IModelAppOptions;
|
|
17
20
|
}
|
|
18
21
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Helpers.d.ts","sourceRoot":"","sources":["../../../src/presentation-testing/Helpers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Helpers.d.ts","sourceRoot":"","sources":["../../../src/presentation-testing/Helpers.ts"],"names":[],"mappings":"AASA,OAAO,EAAc,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAKpE,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAe,MAAM,sBAAsB,CAAC;AAChF,OAAO,EACL,kBAAkB,EAAuC,wBAAwB,IAAI,wBAAwB,EAAE,uBAAuB,EACvI,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAAwC,iBAAiB,IAAI,yBAAyB,EAAE,MAAM,8BAA8B,CAAC;AAsBpI,OAAO,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,wBAAwB,EAAE,CAAC;AAEjF,cAAc;AACd,MAAM,WAAW,4BAA4B;IAC3C,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;CACvC;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,UAAU,qEA8BtB,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,SAAS,mDAuBrB,CAAC"}
|
|
@@ -27,9 +27,10 @@ exports.terminate = exports.initialize = exports.PresentationManagerMode = expor
|
|
|
27
27
|
/** @packageDocumentation
|
|
28
28
|
* @module Helpers
|
|
29
29
|
*/
|
|
30
|
+
const path_1 = require("path");
|
|
30
31
|
const rimraf = __importStar(require("rimraf"));
|
|
31
|
-
const core_bentley_1 = require("@itwin/core-bentley");
|
|
32
32
|
const core_backend_1 = require("@itwin/core-backend");
|
|
33
|
+
const core_bentley_1 = require("@itwin/core-bentley");
|
|
33
34
|
const core_common_1 = require("@itwin/core-common");
|
|
34
35
|
const core_frontend_1 = require("@itwin/core-frontend");
|
|
35
36
|
const presentation_backend_1 = require("@itwin/presentation-backend");
|
|
@@ -37,7 +38,6 @@ Object.defineProperty(exports, "HierarchyCacheMode", { enumerable: true, get: fu
|
|
|
37
38
|
Object.defineProperty(exports, "PresentationManagerMode", { enumerable: true, get: function () { return presentation_backend_1.PresentationManagerMode; } });
|
|
38
39
|
const presentation_common_1 = require("@itwin/presentation-common");
|
|
39
40
|
const presentation_frontend_1 = require("@itwin/presentation-frontend");
|
|
40
|
-
const path_1 = require("path");
|
|
41
41
|
function initializeRpcInterfaces(interfaces) {
|
|
42
42
|
const config = class extends core_common_1.RpcDefaultConfiguration {
|
|
43
43
|
constructor() {
|
|
@@ -78,7 +78,7 @@ const initialize = async (props) => {
|
|
|
78
78
|
props.backendProps = (_a = props.backendProps) !== null && _a !== void 0 ? _a : {};
|
|
79
79
|
if (!props.backendProps.id)
|
|
80
80
|
props.backendProps.id = `test-${core_bentley_1.Guid.createValue()}`;
|
|
81
|
-
await core_backend_1.IModelHost.startup({ cacheDir: (0, path_1.join)(__dirname, ".cache") });
|
|
81
|
+
await core_backend_1.IModelHost.startup({ cacheDir: (0, path_1.join)(__dirname, ".cache"), ...props.backendHostProps });
|
|
82
82
|
presentation_backend_1.Presentation.initialize(props.backendProps);
|
|
83
83
|
// init frontend
|
|
84
84
|
if (!props.frontendApp)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Helpers.js","sourceRoot":"","sources":["../../../src/presentation-testing/Helpers.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA;;;+FAG+F;AAC/F;;GAEG;AACH,+CAAiC;AACjC,sDAA2C;AAC3C,
|
|
1
|
+
{"version":3,"file":"Helpers.js","sourceRoot":"","sources":["../../../src/presentation-testing/Helpers.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA;;;+FAG+F;AAC/F;;GAEG;AACH,+BAA4B;AAC5B,+CAAiC;AACjC,sDAAoE;AACpE,sDAA2C;AAC3C,oDAE4B;AAC5B,wDAAgF;AAChF,sEAEqC;AAwB5B,mGAzBP,yCAAkB,OAyBO;AAAE,wGAzBoF,8CAAuB,OAyBpF;AAvBpD,oEAAsE;AACtE,wEAAoI;AAEpI,SAAS,uBAAuB,CAAC,UAAoC;IACnE,MAAM,MAAM,GAAG,KAAM,SAAQ,qCAAuB;QAArC;;YACG,eAAU,GAAQ,GAAG,EAAE,CAAC,UAAU,CAAC;QACrD,CAAC;KAAA,CAAC;IAEF,KAAK,MAAM,UAAU,IAAI,UAAU;QACjC,8BAAgB,CAAC,MAAM,CAAC,UAAU,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,CAAC;IAEpD,MAAM,QAAQ,GAAG,8BAAgB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAEjD,IAAI;QACF,8BAAgB,CAAC,oBA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,EAAE,CAAC,CAAC;IAE3F,aAAa,GAAG,IAAI,CAAC;AACvB,CAAC,CAAC;AA9BW,QAAA,UAAU,cA8BrB;AAEF;;;;;;;GAOG;AACI,MAAM,SAAS,GAAG,KAAK,EAAE,WAAW,GAAG,yBAAS,EAAE,EAAE;;IACzD,IAAI,CAAC,aAAa;QAChB,OAAO;IAET,8CAA8C;IAC9C,IAAI,yBAA6C,CAAC;IAClD,MAAM,sBAAsB,GAAG,MAAA,MAAA,mCAAmB,CAAC,SAAS,0CAAE,OAAO,0CAAE,WAAW,CAAC;IACnF,IAAI,CAAA,sBAAsB,aAAtB,sBAAsB,uBAAtB,sBAAsB,CAAE,IAAI,MAAK,yCAAkB,CAAC,IAAI;QAC1D,yBAAyB,GAAG,sBAAsB,aAAtB,sBAAsB,uBAAtB,sBAAsB,CAAE,SAAS,CAAC;SAC3D,IAAI,CAAA,sBAAsB,aAAtB,sBAAsB,uBAAtB,sBAAsB,CAAE,IAAI,MAAK,yCAAkB,CAAC,MAAM;QACjE,yBAAyB,GAAG,MAAA,sBAAsB,aAAtB,sBAAsB,uBAAtB,sBAAsB,CAAE,IAAI,0CAAE,SAAS,CAAC;IAEtE,oBAAoB;IACpB,mCAAmB,CAAC,SAAS,EAAE,CAAC;IAChC,MAAM,yBAAU,CAAC,QAAQ,EAAE,CAAC;IAC5B,IAAI,yBAAyB;QAC3B,MAAM,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC;IAEzC,qBAAqB;IACrB,oCAAoB,CAAC,SAAS,EAAE,CAAC;IACjC,MAAM,WAAW,CAAC,QAAQ,EAAE,CAAC;IAE7B,aAAa,GAAG,KAAK,CAAC;AACxB,CAAC,CAAC;AAvBW,QAAA,SAAS,aAuBpB","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/** @packageDocumentation\r\n * @module Helpers\r\n */\r\nimport { join } from \"path\";\r\nimport * as rimraf from \"rimraf\";\r\nimport { IModelHost, IModelHostOptions } from \"@itwin/core-backend\";\r\nimport { Guid } from \"@itwin/core-bentley\";\r\nimport {\r\n IModelReadRpcInterface, RpcConfiguration, RpcDefaultConfiguration, RpcInterfaceDefinition, SnapshotIModelRpcInterface,\r\n} from \"@itwin/core-common\";\r\nimport { IModelApp, IModelAppOptions, NoRenderApp } from \"@itwin/core-frontend\";\r\nimport {\r\n HierarchyCacheMode, Presentation as PresentationBackend, PresentationManagerProps as PresentationBackendProps, PresentationManagerMode,\r\n} from \"@itwin/presentation-backend\";\r\nimport { PresentationRpcInterface } from \"@itwin/presentation-common\";\r\nimport { Presentation as PresentationFrontend, PresentationProps as PresentationFrontendProps } from \"@itwin/presentation-frontend\";\r\n\r\nfunction initializeRpcInterfaces(interfaces: RpcInterfaceDefinition[]) {\r\n const config = class extends RpcDefaultConfiguration {\r\n public override interfaces: any = () => interfaces;\r\n };\r\n\r\n for (const definition of interfaces)\r\n RpcConfiguration.assign(definition, () => config);\r\n\r\n const instance = RpcConfiguration.obtain(config);\r\n\r\n try {\r\n RpcConfiguration.initializeInterfaces(instance);\r\n } catch {\r\n // this may fail with \"Error: RPC interface \"xxx\" is already initialized.\" because\r\n // multiple different tests want to set up rpc interfaces\r\n }\r\n}\r\n\r\nlet isInitialized = false;\r\n\r\nexport { HierarchyCacheMode, PresentationManagerMode, PresentationBackendProps };\r\n\r\n/** @public */\r\nexport interface PresentationTestingInitProps {\r\n /** Properties for backend initialization */\r\n backendProps?: PresentationBackendProps;\r\n /** Properties for `IModelHost` */\r\n backendHostProps?: IModelHostOptions;\r\n /** Properties for frontend initialization */\r\n frontendProps?: PresentationFrontendProps;\r\n /** IModelApp implementation */\r\n frontendApp?: { startup: (opts?: IModelAppOptions) => Promise<void> };\r\n /** `IModelApp` options */\r\n frontendAppOptions?: IModelAppOptions;\r\n}\r\n\r\n/**\r\n * Initialize the framework for presentation testing. The function sets up backend,\r\n * frontend and RPC communication between them.\r\n *\r\n * @see `terminate`\r\n *\r\n * @public\r\n */\r\nexport const initialize = async (props?: PresentationTestingInitProps) => {\r\n if (isInitialized)\r\n return;\r\n\r\n if (!props)\r\n props = {};\r\n\r\n // set up rpc interfaces\r\n initializeRpcInterfaces([SnapshotIModelRpcInterface, IModelReadRpcInterface, PresentationRpcInterface]);\r\n\r\n // init backend\r\n // make sure backend gets assigned an id which puts its resources into a unique directory\r\n props.backendProps = props.backendProps ?? {};\r\n if (!props.backendProps.id)\r\n props.backendProps.id = `test-${Guid.createValue()}`;\r\n await IModelHost.startup({ cacheDir: join(__dirname, \".cache\"), ...props.backendHostProps });\r\n PresentationBackend.initialize(props.backendProps);\r\n\r\n // init frontend\r\n if (!props.frontendApp)\r\n props.frontendApp = NoRenderApp;\r\n await props.frontendApp.startup(props.frontendAppOptions);\r\n const defaultFrontendProps: PresentationFrontendProps = {\r\n presentation: {\r\n activeLocale: IModelApp.localization.getLanguageList()[0],\r\n },\r\n };\r\n await PresentationFrontend.initialize({ ...defaultFrontendProps, ...props.frontendProps });\r\n\r\n isInitialized = true;\r\n};\r\n\r\n/**\r\n * Undoes the setup made by `initialize`.\r\n * @param frontendApp IModelApp implementation\r\n *\r\n * @see `initialize`\r\n *\r\n * @public\r\n */\r\nexport const terminate = async (frontendApp = IModelApp) => {\r\n if (!isInitialized)\r\n return;\r\n\r\n // store directory that needs to be cleaned-up\r\n let hierarchiesCacheDirectory: string | undefined;\r\n const hierarchiesCacheConfig = PresentationBackend.initProps?.caching?.hierarchies;\r\n if (hierarchiesCacheConfig?.mode === HierarchyCacheMode.Disk)\r\n hierarchiesCacheDirectory = hierarchiesCacheConfig?.directory;\r\n else if (hierarchiesCacheConfig?.mode === HierarchyCacheMode.Hybrid)\r\n hierarchiesCacheDirectory = hierarchiesCacheConfig?.disk?.directory;\r\n\r\n // terminate backend\r\n PresentationBackend.terminate();\r\n await IModelHost.shutdown();\r\n if (hierarchiesCacheDirectory)\r\n rimraf.sync(hierarchiesCacheDirectory);\r\n\r\n // terminate frontend\r\n PresentationFrontend.terminate();\r\n await frontendApp.shutdown();\r\n\r\n isInitialized = false;\r\n};\r\n"]}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/** @packageDocumentation
|
|
2
|
+
* @module IModel
|
|
3
|
+
*/
|
|
4
|
+
import { Element, IModelDb } from "@itwin/core-backend";
|
|
5
|
+
import { Id64String } from "@itwin/core-bentley";
|
|
6
|
+
import { Code, CodeProps, LocalFileName, RelatedElement } from "@itwin/core-common";
|
|
7
|
+
export declare class IModelBuilder {
|
|
8
|
+
/**
|
|
9
|
+
* Create and insert a PhysicalPartition element (in the repositoryModel) and an associated PhysicalModel.
|
|
10
|
+
* @return [modeledElementId, modelId]
|
|
11
|
+
*/
|
|
12
|
+
static createAndInsertPhysicalPartitionAndModel(testImodel: IModelDb, newModelCode: CodeProps, privateModel?: boolean, parent?: Id64String): Id64String[];
|
|
13
|
+
/** Create and insert a PhysicalPartition element (in the repositoryModel) and an associated PhysicalModel. */
|
|
14
|
+
static createAndInsertPhysicalPartition(testDb: IModelDb, newModelCode: CodeProps, parentId?: Id64String): Id64String;
|
|
15
|
+
/** Create and insert a PhysicalPartition element (in the repositoryModel) and an associated PhysicalModel. */
|
|
16
|
+
static createAndInsertPhysicalModel(testDb: IModelDb, modeledElementRef: RelatedElement, privateModel?: boolean): Id64String;
|
|
17
|
+
/**
|
|
18
|
+
* Create and insert a DrawingPartition element (in the repositoryModel) and an associated DrawingModel.
|
|
19
|
+
* @return [modeledElementId, modelId]
|
|
20
|
+
*/
|
|
21
|
+
static createAndInsertDrawingPartitionAndModel(testImodel: IModelDb, newModelCode: CodeProps, privateModel?: boolean, parent?: Id64String): Id64String[];
|
|
22
|
+
/** Create and insert a DrawingPartition element (in the repositoryModel) and an associated DrawingModel. */
|
|
23
|
+
static createAndInsertDrawingPartition(testDb: IModelDb, newModelCode: CodeProps, parentId?: Id64String): Id64String;
|
|
24
|
+
/** Create and insert a DrawingPartition element (in the repositoryModel) and an associated DrawingModel. */
|
|
25
|
+
static createAndInsertDrawingModel(testDb: IModelDb, modeledElementRef: RelatedElement, privateModel?: boolean): Id64String;
|
|
26
|
+
static createDrawingGraphic(testImodel: IModelDb, modelId: Id64String, categoryId: Id64String, elemCode?: Code): Element;
|
|
27
|
+
static createPhysicalObject(testImodel: IModelDb, modelId: Id64String, categoryId: Id64String, elemCode?: Code): Element;
|
|
28
|
+
static getUniqueModelCode(testDb: IModelDb, newModelCodeBase: string): Code;
|
|
29
|
+
/** Generate a name for an iModel that's unique using the baseName provided and appending a new GUID. */
|
|
30
|
+
static generateUniqueName(baseName: string): string;
|
|
31
|
+
/** Prepare for an output file by:
|
|
32
|
+
* - Resolving the output file name under the known test output directory
|
|
33
|
+
* - Making directories as necessary
|
|
34
|
+
* - Removing a previous copy of the output file
|
|
35
|
+
* @param subDirName Sub-directory under known test output directory. Should match the name of the test file minus the .test.ts file extension.
|
|
36
|
+
* @param fileName Name of output fille
|
|
37
|
+
*/
|
|
38
|
+
static prepareOutputFile(subDirName: string, fileName: string): LocalFileName;
|
|
39
|
+
}
|
|
40
|
+
export declare class KnownTestLocations {
|
|
41
|
+
/** The directory where test assets are stored. Keep in mind that the test is playing the role of the app. */
|
|
42
|
+
static get assetsDir(): string;
|
|
43
|
+
/** The directory where tests can write. */
|
|
44
|
+
static get outputDir(): string;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=IModelBuilder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IModelBuilder.d.ts","sourceRoot":"","sources":["../../../src/presentation-testing/IModelBuilder.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAyB,OAAO,EAAE,QAAQ,EAA2G,MAAM,qBAAqB,CAAC;AACxL,OAAO,EAAc,UAAU,EAAmB,MAAM,qBAAqB,CAAC;AAC9E,OAAO,EAAE,IAAI,EAAE,SAAS,EAAiD,aAAa,EAAw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,MAAM;IAIjD;;;;;;OAMG;WACW,iBAAiB,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,aAAa;CAcrF;AAED,qBAAa,kBAAkB;IAE7B,6GAA6G;IAC7G,WAAkB,SAAS,IAAI,MAAM,CAEpC;IAED,2CAA2C;IAC3C,WAAkB,SAAS,IAAI,MAAM,CAOpC;CACF"}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*---------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
/** @packageDocumentation
|
|
7
|
+
* @module IModel
|
|
8
|
+
*/
|
|
9
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
17
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
18
|
+
}) : function(o, v) {
|
|
19
|
+
o["default"] = v;
|
|
20
|
+
});
|
|
21
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
22
|
+
if (mod && mod.__esModule) return mod;
|
|
23
|
+
var result = {};
|
|
24
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
25
|
+
__setModuleDefault(result, mod);
|
|
26
|
+
return result;
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.KnownTestLocations = exports.IModelBuilder = void 0;
|
|
30
|
+
const core_backend_1 = require("@itwin/core-backend");
|
|
31
|
+
const core_bentley_1 = require("@itwin/core-bentley");
|
|
32
|
+
const core_common_1 = require("@itwin/core-common");
|
|
33
|
+
const chai_1 = require("chai");
|
|
34
|
+
const os_1 = require("os");
|
|
35
|
+
const path_1 = __importStar(require("path"));
|
|
36
|
+
class IModelBuilder {
|
|
37
|
+
/**
|
|
38
|
+
* Create and insert a PhysicalPartition element (in the repositoryModel) and an associated PhysicalModel.
|
|
39
|
+
* @return [modeledElementId, modelId]
|
|
40
|
+
*/
|
|
41
|
+
static createAndInsertPhysicalPartitionAndModel(testImodel, newModelCode, privateModel = false, parent) {
|
|
42
|
+
const eid = IModelBuilder.createAndInsertPhysicalPartition(testImodel, newModelCode, parent);
|
|
43
|
+
const modeledElementRef = new core_common_1.RelatedElement({ id: eid });
|
|
44
|
+
const mid = IModelBuilder.createAndInsertPhysicalModel(testImodel, modeledElementRef, privateModel);
|
|
45
|
+
return [eid, mid];
|
|
46
|
+
}
|
|
47
|
+
/** Create and insert a PhysicalPartition element (in the repositoryModel) and an associated PhysicalModel. */
|
|
48
|
+
static createAndInsertPhysicalPartition(testDb, newModelCode, parentId) {
|
|
49
|
+
const model = parentId ? testDb.elements.getElement(parentId).model : core_common_1.IModel.repositoryModelId;
|
|
50
|
+
const parent = new core_backend_1.SubjectOwnsPartitionElements(parentId || core_common_1.IModel.rootSubjectId);
|
|
51
|
+
const modeledElementProps = {
|
|
52
|
+
classFullName: core_backend_1.PhysicalPartition.classFullName,
|
|
53
|
+
parent,
|
|
54
|
+
model,
|
|
55
|
+
code: newModelCode,
|
|
56
|
+
};
|
|
57
|
+
const modeledElement = testDb.elements.createElement(modeledElementProps);
|
|
58
|
+
return testDb.elements.insertElement(modeledElement.toJSON());
|
|
59
|
+
}
|
|
60
|
+
/** Create and insert a PhysicalPartition element (in the repositoryModel) and an associated PhysicalModel. */
|
|
61
|
+
static createAndInsertPhysicalModel(testDb, modeledElementRef, privateModel = false) {
|
|
62
|
+
const newModel = testDb.models.createModel({ modeledElement: modeledElementRef, classFullName: core_backend_1.PhysicalModel.classFullName, isPrivate: privateModel });
|
|
63
|
+
const newModelId = newModel.id = testDb.models.insertModel(newModel.toJSON());
|
|
64
|
+
chai_1.assert.isTrue(core_bentley_1.Id64.isValidId64(newModelId));
|
|
65
|
+
chai_1.assert.isTrue(core_bentley_1.Id64.isValidId64(newModel.id));
|
|
66
|
+
chai_1.assert.deepEqual(newModelId, newModel.id);
|
|
67
|
+
return newModelId;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Create and insert a DrawingPartition element (in the repositoryModel) and an associated DrawingModel.
|
|
71
|
+
* @return [modeledElementId, modelId]
|
|
72
|
+
*/
|
|
73
|
+
static createAndInsertDrawingPartitionAndModel(testImodel, newModelCode, privateModel = false, parent) {
|
|
74
|
+
const eid = IModelBuilder.createAndInsertDrawingPartition(testImodel, newModelCode, parent);
|
|
75
|
+
const modeledElementRef = new core_common_1.RelatedElement({ id: eid });
|
|
76
|
+
const mid = IModelBuilder.createAndInsertDrawingModel(testImodel, modeledElementRef, privateModel);
|
|
77
|
+
return [eid, mid];
|
|
78
|
+
}
|
|
79
|
+
/** Create and insert a DrawingPartition element (in the repositoryModel) and an associated DrawingModel. */
|
|
80
|
+
static createAndInsertDrawingPartition(testDb, newModelCode, parentId) {
|
|
81
|
+
const model = parentId ? testDb.elements.getElement(parentId).model : core_common_1.IModel.repositoryModelId;
|
|
82
|
+
const parent = new core_backend_1.SubjectOwnsPartitionElements(parentId || core_common_1.IModel.rootSubjectId);
|
|
83
|
+
const modeledElementProps = {
|
|
84
|
+
classFullName: core_backend_1.Drawing.classFullName,
|
|
85
|
+
parent,
|
|
86
|
+
model,
|
|
87
|
+
code: newModelCode,
|
|
88
|
+
};
|
|
89
|
+
const modeledElement = testDb.elements.createElement(modeledElementProps);
|
|
90
|
+
return testDb.elements.insertElement(modeledElement.toJSON());
|
|
91
|
+
}
|
|
92
|
+
/** Create and insert a DrawingPartition element (in the repositoryModel) and an associated DrawingModel. */
|
|
93
|
+
static createAndInsertDrawingModel(testDb, modeledElementRef, privateModel = false) {
|
|
94
|
+
const newModel = testDb.models.createModel({ modeledElement: modeledElementRef, classFullName: core_backend_1.DrawingModel.classFullName, isPrivate: privateModel });
|
|
95
|
+
const newModelId = newModel.id = testDb.models.insertModel(newModel.toJSON());
|
|
96
|
+
chai_1.assert.isTrue(core_bentley_1.Id64.isValidId64(newModelId));
|
|
97
|
+
chai_1.assert.isTrue(core_bentley_1.Id64.isValidId64(newModel.id));
|
|
98
|
+
chai_1.assert.deepEqual(newModelId, newModel.id);
|
|
99
|
+
return newModelId;
|
|
100
|
+
}
|
|
101
|
+
// Create a DrawingObject. (Does not insert it.)
|
|
102
|
+
static createDrawingGraphic(testImodel, modelId, categoryId, elemCode) {
|
|
103
|
+
const elementProps = {
|
|
104
|
+
classFullName: "BisCore:DrawingGraphic",
|
|
105
|
+
model: modelId,
|
|
106
|
+
category: categoryId,
|
|
107
|
+
code: elemCode ? elemCode : core_common_1.Code.createEmpty(),
|
|
108
|
+
};
|
|
109
|
+
return testImodel.elements.createElement(elementProps);
|
|
110
|
+
}
|
|
111
|
+
// Create a PhysicalObject. (Does not insert it.)
|
|
112
|
+
static createPhysicalObject(testImodel, modelId, categoryId, elemCode) {
|
|
113
|
+
const elementProps = {
|
|
114
|
+
classFullName: "Generic:PhysicalObject",
|
|
115
|
+
model: modelId,
|
|
116
|
+
category: categoryId,
|
|
117
|
+
code: elemCode ? elemCode : core_common_1.Code.createEmpty(),
|
|
118
|
+
};
|
|
119
|
+
return testImodel.elements.createElement(elementProps);
|
|
120
|
+
}
|
|
121
|
+
static getUniqueModelCode(testDb, newModelCodeBase) {
|
|
122
|
+
let newModelCode = newModelCodeBase;
|
|
123
|
+
let iter = 0;
|
|
124
|
+
while (true) {
|
|
125
|
+
const modelCode = core_backend_1.InformationPartitionElement.createCode(testDb, core_common_1.IModel.rootSubjectId, newModelCode);
|
|
126
|
+
if (testDb.elements.queryElementIdByCode(modelCode) === undefined)
|
|
127
|
+
return modelCode;
|
|
128
|
+
newModelCode = newModelCodeBase + iter;
|
|
129
|
+
++iter;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
/** Generate a name for an iModel that's unique using the baseName provided and appending a new GUID. */
|
|
133
|
+
static generateUniqueName(baseName) {
|
|
134
|
+
return `${baseName} - ${core_bentley_1.Guid.createValue()}`;
|
|
135
|
+
}
|
|
136
|
+
/** Prepare for an output file by:
|
|
137
|
+
* - Resolving the output file name under the known test output directory
|
|
138
|
+
* - Making directories as necessary
|
|
139
|
+
* - Removing a previous copy of the output file
|
|
140
|
+
* @param subDirName Sub-directory under known test output directory. Should match the name of the test file minus the .test.ts file extension.
|
|
141
|
+
* @param fileName Name of output fille
|
|
142
|
+
*/
|
|
143
|
+
static prepareOutputFile(subDirName, fileName) {
|
|
144
|
+
if (!core_backend_1.IModelJsFs.existsSync(KnownTestLocations.outputDir))
|
|
145
|
+
core_backend_1.IModelJsFs.mkdirSync(KnownTestLocations.outputDir);
|
|
146
|
+
const outputDir = path_1.default.join(KnownTestLocations.outputDir, subDirName);
|
|
147
|
+
if (!core_backend_1.IModelJsFs.existsSync(outputDir))
|
|
148
|
+
core_backend_1.IModelJsFs.mkdirSync(outputDir);
|
|
149
|
+
const outputFile = path_1.default.join(outputDir, fileName);
|
|
150
|
+
if (core_backend_1.IModelJsFs.existsSync(outputFile))
|
|
151
|
+
core_backend_1.IModelJsFs.unlinkSync(outputFile);
|
|
152
|
+
return outputFile;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
exports.IModelBuilder = IModelBuilder;
|
|
156
|
+
class KnownTestLocations {
|
|
157
|
+
/** The directory where test assets are stored. Keep in mind that the test is playing the role of the app. */
|
|
158
|
+
static get assetsDir() {
|
|
159
|
+
return (0, path_1.join)(__dirname, "assets");
|
|
160
|
+
}
|
|
161
|
+
/** The directory where tests can write. */
|
|
162
|
+
static get outputDir() {
|
|
163
|
+
if (core_bentley_1.ProcessDetector.isMobileAppBackend) {
|
|
164
|
+
return (0, path_1.join)((0, os_1.tmpdir)(), "output");
|
|
165
|
+
}
|
|
166
|
+
// Assume that we are running in nodejs
|
|
167
|
+
return (0, path_1.join)(__dirname, "output");
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
exports.KnownTestLocations = KnownTestLocations;
|
|
171
|
+
//# sourceMappingURL=IModelBuilder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IModelBuilder.js","sourceRoot":"","sources":["../../../src/presentation-testing/IModelBuilder.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;;;;;;;;;;;;;;;;;;;;AAEH,sDAAwL;AACxL,sDAA8E;AAC9E,oDAAyJ;AACzJ,+BAA8B;AAC9B,2BAA4B;AAC5B,6CAAkC;AAElC,MAAa,aAAa;IACxB;;;OAGG;IACI,MAAM,CAAC,wCAAwC,CAAC,UAAoB,EAAE,YAAuB,EAAE,eAAwB,KAAK,EAAE,MAAmB;QACtJ,MAAM,GAAG,GAAG,aAAa,CAAC,gCAAgC,CAAC,UAAU,EAAE,YAAY,EAAE,MAAM,CAAC,CAAC;QAC7F,MAAM,iBAAiB,GAAG,IAAI,4BAAc,CAAC,EAAE,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC;QAC1D,MAAM,GAAG,GAAG,aAAa,CAAC,4BAA4B,CAAC,UAAU,EAAE,iBAAiB,EAAE,YAAY,CAAC,CAAC;QACpG,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IACpB,CAAC;IAED,8GAA8G;IACvG,MAAM,CAAC,gCAAgC,CAAC,MAAgB,EAAE,YAAuB,EAAE,QAAqB;QAC7G,MAAM,KAAK,GAAG,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC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,CAAC;IAED,2CAA2C;IACpC,MAAM,KAAK,SAAS;QACzB,IAAI,8BAAe,CAAC,kBAAkB,EAAE;YACtC,OAAO,IAAA,WAAI,EAAC,IAAA,WAAM,GAAE,EAAE,QAAQ,CAAC,CAAC;SACjC;QAED,uCAAuC;QACvC,OAAO,IAAA,WAAI,EAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;IACnC,CAAC;CACF;AAhBD,gDAgBC","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/** @packageDocumentation\r\n * @module IModel\r\n */\r\n\r\nimport { Drawing, DrawingModel, Element, IModelDb, IModelJsFs, InformationPartitionElement, PhysicalModel, PhysicalPartition, SubjectOwnsPartitionElements } from \"@itwin/core-backend\";\r\nimport { Guid, Id64, Id64String, ProcessDetector } from \"@itwin/core-bentley\";\r\nimport { Code, CodeProps, ElementProps, GeometricElement2dProps, IModel, LocalFileName, PhysicalElementProps, RelatedElement } from \"@itwin/core-common\";\r\nimport { assert } from \"chai\";\r\nimport { tmpdir } from \"os\";\r\nimport path, { join } from \"path\";\r\n\r\nexport class IModelBuilder {\r\n /**\r\n * Create and insert a PhysicalPartition element (in the repositoryModel) and an associated PhysicalModel.\r\n * @return [modeledElementId, modelId]\r\n */\r\n public static createAndInsertPhysicalPartitionAndModel(testImodel: IModelDb, newModelCode: CodeProps, privateModel: boolean = false, parent?: Id64String): Id64String[] {\r\n const eid = IModelBuilder.createAndInsertPhysicalPartition(testImodel, newModelCode, parent);\r\n const modeledElementRef = new RelatedElement({ id: eid });\r\n const mid = IModelBuilder.createAndInsertPhysicalModel(testImodel, modeledElementRef, privateModel);\r\n return [eid, mid];\r\n }\r\n\r\n /** Create and insert a PhysicalPartition element (in the repositoryModel) and an associated PhysicalModel. */\r\n public static createAndInsertPhysicalPartition(testDb: IModelDb, newModelCode: CodeProps, parentId?: Id64String): Id64String {\r\n const model = parentId ? testDb.elements.getElement(parentId).model : IModel.repositoryModelId;\r\n const parent = new SubjectOwnsPartitionElements(parentId || IModel.rootSubjectId);\r\n\r\n const modeledElementProps: ElementProps = {\r\n classFullName: PhysicalPartition.classFullName,\r\n parent,\r\n model,\r\n code: newModelCode,\r\n };\r\n const modeledElement: Element = testDb.elements.createElement(modeledElementProps);\r\n return testDb.elements.insertElement(modeledElement.toJSON());\r\n }\r\n\r\n /** Create and insert a PhysicalPartition element (in the repositoryModel) and an associated PhysicalModel. */\r\n public static createAndInsertPhysicalModel(testDb: IModelDb, modeledElementRef: RelatedElement, privateModel: boolean = false): Id64String {\r\n const newModel = testDb.models.createModel({ modeledElement: modeledElementRef, classFullName: PhysicalModel.classFullName, isPrivate: privateModel });\r\n const newModelId = newModel.id = testDb.models.insertModel(newModel.toJSON());\r\n assert.isTrue(Id64.isValidId64(newModelId));\r\n assert.isTrue(Id64.isValidId64(newModel.id));\r\n assert.deepEqual(newModelId, newModel.id);\r\n return newModelId;\r\n }\r\n\r\n /**\r\n * Create and insert a DrawingPartition element (in the repositoryModel) and an associated DrawingModel.\r\n * @return [modeledElementId, modelId]\r\n */\r\n public static createAndInsertDrawingPartitionAndModel(testImodel: IModelDb, newModelCode: CodeProps, privateModel: boolean = false, parent?: Id64String): Id64String[] {\r\n const eid = IModelBuilder.createAndInsertDrawingPartition(testImodel, newModelCode, parent);\r\n const modeledElementRef = new RelatedElement({ id: eid });\r\n const mid = IModelBuilder.createAndInsertDrawingModel(testImodel, modeledElementRef, privateModel);\r\n return [eid, mid];\r\n }\r\n\r\n /** Create and insert a DrawingPartition element (in the repositoryModel) and an associated DrawingModel. */\r\n public static createAndInsertDrawingPartition(testDb: IModelDb, newModelCode: CodeProps, parentId?: Id64String): Id64String {\r\n const model = parentId ? testDb.elements.getElement(parentId).model : IModel.repositoryModelId;\r\n const parent = new SubjectOwnsPartitionElements(parentId || IModel.rootSubjectId);\r\n\r\n const modeledElementProps: ElementProps = {\r\n classFullName: Drawing.classFullName,\r\n parent,\r\n model,\r\n code: newModelCode,\r\n };\r\n const modeledElement: Element = testDb.elements.createElement(modeledElementProps);\r\n return testDb.elements.insertElement(modeledElement.toJSON());\r\n }\r\n\r\n /** Create and insert a DrawingPartition element (in the repositoryModel) and an associated DrawingModel. */\r\n public static createAndInsertDrawingModel(testDb: IModelDb, modeledElementRef: RelatedElement, privateModel: boolean = false): Id64String {\r\n const newModel = testDb.models.createModel({ modeledElement: modeledElementRef, classFullName: DrawingModel.classFullName, isPrivate: privateModel });\r\n const newModelId = newModel.id = testDb.models.insertModel(newModel.toJSON());\r\n assert.isTrue(Id64.isValidId64(newModelId));\r\n assert.isTrue(Id64.isValidId64(newModel.id));\r\n assert.deepEqual(newModelId, newModel.id);\r\n return newModelId;\r\n }\r\n\r\n // Create a DrawingObject. (Does not insert it.)\r\n public static createDrawingGraphic(testImodel: IModelDb, modelId: Id64String, categoryId: Id64String, elemCode?: Code): Element {\r\n const elementProps: GeometricElement2dProps = {\r\n classFullName: \"BisCore:DrawingGraphic\",\r\n model: modelId,\r\n category: categoryId,\r\n code: elemCode ? elemCode : Code.createEmpty(),\r\n };\r\n return testImodel.elements.createElement(elementProps);\r\n }\r\n\r\n // Create a PhysicalObject. (Does not insert it.)\r\n public static createPhysicalObject(testImodel: IModelDb, modelId: Id64String, categoryId: Id64String, elemCode?: Code): Element {\r\n const elementProps: PhysicalElementProps = {\r\n classFullName: \"Generic:PhysicalObject\",\r\n model: modelId,\r\n category: categoryId,\r\n code: elemCode ? elemCode : Code.createEmpty(),\r\n };\r\n return testImodel.elements.createElement(elementProps);\r\n }\r\n\r\n public static getUniqueModelCode(testDb: IModelDb, newModelCodeBase: string): Code {\r\n let newModelCode: string = newModelCodeBase;\r\n let iter: number = 0;\r\n while (true) {\r\n const modelCode = InformationPartitionElement.createCode(testDb, IModel.rootSubjectId, newModelCode);\r\n if (testDb.elements.queryElementIdByCode(modelCode) === undefined)\r\n return modelCode;\r\n\r\n newModelCode = newModelCodeBase + iter;\r\n ++iter;\r\n }\r\n }\r\n\r\n /** Generate a name for an iModel that's unique using the baseName provided and appending a new GUID. */\r\n public static generateUniqueName(baseName: string) {\r\n return `${baseName} - ${Guid.createValue()}`;\r\n }\r\n\r\n /** Prepare for an output file by:\r\n * - Resolving the output file name under the known test output directory\r\n * - Making directories as necessary\r\n * - Removing a previous copy of the output file\r\n * @param subDirName Sub-directory under known test output directory. Should match the name of the test file minus the .test.ts file extension.\r\n * @param fileName Name of output fille\r\n */\r\n public static prepareOutputFile(subDirName: string, fileName: string): LocalFileName {\r\n if (!IModelJsFs.existsSync(KnownTestLocations.outputDir))\r\n IModelJsFs.mkdirSync(KnownTestLocations.outputDir);\r\n\r\n const outputDir = path.join(KnownTestLocations.outputDir, subDirName);\r\n if (!IModelJsFs.existsSync(outputDir))\r\n IModelJsFs.mkdirSync(outputDir);\r\n\r\n const outputFile = path.join(outputDir, fileName);\r\n if (IModelJsFs.existsSync(outputFile))\r\n IModelJsFs.unlinkSync(outputFile);\r\n\r\n return outputFile;\r\n }\r\n}\r\n\r\nexport class KnownTestLocations {\r\n\r\n /** The directory where test assets are stored. Keep in mind that the test is playing the role of the app. */\r\n public static get assetsDir(): string {\r\n return join(__dirname, \"assets\");\r\n }\r\n\r\n /** The directory where tests can write. */\r\n public static get outputDir(): string {\r\n if (ProcessDetector.isMobileAppBackend) {\r\n return join(tmpdir(), \"output\");\r\n }\r\n\r\n // Assume that we are running in nodejs\r\n return join(__dirname, \"output\");\r\n }\r\n}\r\n"]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { GuidString } from "@itwin/core-bentley";
|
|
2
|
+
import { Code, ElementProps } from "@itwin/core-common";
|
|
3
|
+
/**
|
|
4
|
+
* Test utility to push an iModel.
|
|
5
|
+
*
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
8
|
+
export declare class IModelTestUtility {
|
|
9
|
+
iTwinId: GuidString;
|
|
10
|
+
iModelId: string;
|
|
11
|
+
outputFile: string;
|
|
12
|
+
private _iModel;
|
|
13
|
+
private _modelId;
|
|
14
|
+
createIModel(): void;
|
|
15
|
+
addPhysicalModel(): string;
|
|
16
|
+
addDrawingModel(): string;
|
|
17
|
+
addSpatialCategory(elementProps: ElementProps): string;
|
|
18
|
+
addDrawingCategory(elementProps: ElementProps): string;
|
|
19
|
+
addPhysicalObject(categoryId: string): void;
|
|
20
|
+
addDrawingGraphic(categoryId: string): void;
|
|
21
|
+
getSpatialCategoryCode(codeValue: string): Code;
|
|
22
|
+
getDrawingCategoryCode(codeValue: string): Code;
|
|
23
|
+
closeIModel(): void;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=IModelTestUtility.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IModelTestUtility.d.ts","sourceRoot":"","sources":["../../../src/presentation-testing/IModelTestUtility.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAGxD;;;;GAIG;AACH,qBAAa,iBAAiB;IACrB,OAAO,EAAG,UAAU,CAAC;IACrB,QAAQ,EAAG,MAAM,CAAC;IAClB,UAAU,EAAG,MAAM,CAAC;IAC3B,OAAO,CAAC,OAAO,CAAY;IAC3B,OAAO,CAAC,QAAQ,CAAU;IAEnB,YAAY,IAAI,IAAI;IAMpB,gBAAgB,IAAI,MAAM;IAM1B,eAAe,IAAI,MAAM;IAMzB,kBAAkB,CAAC,YAAY,EAAE,YAAY,GAAG,MAAM;IAMtD,kBAAkB,CAAC,YAAY,EAAE,YAAY,GAAG,MAAM;IAMtD,iBAAiB,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAK3C,iBAAiB,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAK3C,sBAAsB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IAI/C,sBAAsB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IAI/C,WAAW,IAAI,IAAI;CAG3B"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IModelTestUtility = void 0;
|
|
4
|
+
/*---------------------------------------------------------------------------------------------
|
|
5
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
6
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
7
|
+
*--------------------------------------------------------------------------------------------*/
|
|
8
|
+
/** @packageDocumentation
|
|
9
|
+
* @module TestUtilities
|
|
10
|
+
*/
|
|
11
|
+
const core_backend_1 = require("@itwin/core-backend");
|
|
12
|
+
const IModelBuilder_1 = require("./IModelBuilder");
|
|
13
|
+
/**
|
|
14
|
+
* Test utility to push an iModel.
|
|
15
|
+
*
|
|
16
|
+
* @internal
|
|
17
|
+
*/
|
|
18
|
+
class IModelTestUtility {
|
|
19
|
+
createIModel() {
|
|
20
|
+
this.outputFile = IModelBuilder_1.IModelBuilder.prepareOutputFile("IModelTest", IModelBuilder_1.IModelBuilder.generateUniqueName("IModelTest.bim"));
|
|
21
|
+
this._iModel = core_backend_1.SnapshotDb.createEmpty(this.outputFile, { rootSubject: { name: "IModelTest" } });
|
|
22
|
+
this.iModelId = this._iModel.iModelId;
|
|
23
|
+
}
|
|
24
|
+
addPhysicalModel() {
|
|
25
|
+
[, this._modelId] = IModelBuilder_1.IModelBuilder.createAndInsertPhysicalPartitionAndModel(this._iModel, IModelBuilder_1.IModelBuilder.getUniqueModelCode(this._iModel, "TestPhysicalModel"), false);
|
|
26
|
+
this._iModel.saveChanges("Added test model");
|
|
27
|
+
return this._modelId;
|
|
28
|
+
}
|
|
29
|
+
addDrawingModel() {
|
|
30
|
+
[, this._modelId] = IModelBuilder_1.IModelBuilder.createAndInsertDrawingPartitionAndModel(this._iModel, IModelBuilder_1.IModelBuilder.getUniqueModelCode(this._iModel, "TestDrawingModel"), false);
|
|
31
|
+
this._iModel.saveChanges("Added test model");
|
|
32
|
+
return this._modelId;
|
|
33
|
+
}
|
|
34
|
+
addSpatialCategory(elementProps) {
|
|
35
|
+
const categoryId = this._iModel.elements.insertElement(new core_backend_1.SpatialCategory(elementProps, this._iModel).toJSON());
|
|
36
|
+
this._iModel.saveChanges("Added spatial category");
|
|
37
|
+
return categoryId;
|
|
38
|
+
}
|
|
39
|
+
addDrawingCategory(elementProps) {
|
|
40
|
+
const categoryId = this._iModel.elements.insertElement(new core_backend_1.DrawingCategory(elementProps, this._iModel).toJSON());
|
|
41
|
+
this._iModel.saveChanges("Added drawing category");
|
|
42
|
+
return categoryId;
|
|
43
|
+
}
|
|
44
|
+
addPhysicalObject(categoryId) {
|
|
45
|
+
this._iModel.elements.insertElement(IModelBuilder_1.IModelBuilder.createPhysicalObject(this._iModel, this._modelId, categoryId).toJSON());
|
|
46
|
+
this._iModel.saveChanges("Added physical object");
|
|
47
|
+
}
|
|
48
|
+
addDrawingGraphic(categoryId) {
|
|
49
|
+
this._iModel.elements.insertElement(IModelBuilder_1.IModelBuilder.createDrawingGraphic(this._iModel, this._modelId, categoryId).toJSON());
|
|
50
|
+
this._iModel.saveChanges("Added drawing graphic");
|
|
51
|
+
}
|
|
52
|
+
getSpatialCategoryCode(codeValue) {
|
|
53
|
+
return core_backend_1.SpatialCategory.createCode(this._iModel, this._modelId, codeValue);
|
|
54
|
+
}
|
|
55
|
+
getDrawingCategoryCode(codeValue) {
|
|
56
|
+
return core_backend_1.DrawingCategory.createCode(this._iModel, this._modelId, codeValue);
|
|
57
|
+
}
|
|
58
|
+
closeIModel() {
|
|
59
|
+
this._iModel.close();
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
exports.IModelTestUtility = IModelTestUtility;
|
|
63
|
+
//# sourceMappingURL=IModelTestUtility.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IModelTestUtility.js","source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O,8BAAe,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;IAC5E,CAAC;IAEM,WAAW;QAChB,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;IACvB,CAAC;CACF;AA1DD,8CA0DC","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/** @packageDocumentation\r\n * @module TestUtilities\r\n */\r\nimport { DrawingCategory, IModelDb, SnapshotDb, SpatialCategory } from \"@itwin/core-backend\";\r\nimport { GuidString } from \"@itwin/core-bentley\";\r\nimport { Code, ElementProps } from \"@itwin/core-common\";\r\nimport { IModelBuilder } from \"./IModelBuilder\";\r\n\r\n/**\r\n * Test utility to push an iModel.\r\n *\r\n * @internal\r\n */\r\nexport class IModelTestUtility {\r\n public iTwinId!: GuidString;\r\n public iModelId!: string;\r\n public outputFile!: string;\r\n private _iModel!: IModelDb;\r\n private _modelId!: string;\r\n\r\n public createIModel(): void {\r\n this.outputFile = IModelBuilder.prepareOutputFile(\"IModelTest\", IModelBuilder.generateUniqueName(\"IModelTest.bim\"));\r\n this._iModel = SnapshotDb.createEmpty(this.outputFile, { rootSubject: { name: \"IModelTest\" } });\r\n this.iModelId = this._iModel.iModelId;\r\n }\r\n\r\n public addPhysicalModel(): string {\r\n [, this._modelId] = IModelBuilder.createAndInsertPhysicalPartitionAndModel(this._iModel, IModelBuilder.getUniqueModelCode(this._iModel, \"TestPhysicalModel\"), false);\r\n this._iModel.saveChanges(\"Added test model\");\r\n return this._modelId;\r\n }\r\n\r\n public addDrawingModel(): string {\r\n [, this._modelId] = IModelBuilder.createAndInsertDrawingPartitionAndModel(this._iModel, IModelBuilder.getUniqueModelCode(this._iModel, \"TestDrawingModel\"), false);\r\n this._iModel.saveChanges(\"Added test model\");\r\n return this._modelId;\r\n }\r\n\r\n public addSpatialCategory(elementProps: ElementProps): string {\r\n const categoryId = this._iModel.elements.insertElement(new SpatialCategory(elementProps, this._iModel).toJSON());\r\n this._iModel.saveChanges(\"Added spatial category\");\r\n return categoryId;\r\n }\r\n\r\n public addDrawingCategory(elementProps: ElementProps): string {\r\n const categoryId = this._iModel.elements.insertElement(new DrawingCategory(elementProps, this._iModel).toJSON());\r\n this._iModel.saveChanges(\"Added drawing category\");\r\n return categoryId;\r\n }\r\n\r\n public addPhysicalObject(categoryId: string): void {\r\n this._iModel.elements.insertElement(IModelBuilder.createPhysicalObject(this._iModel, this._modelId, categoryId).toJSON());\r\n this._iModel.saveChanges(\"Added physical object\");\r\n }\r\n\r\n public addDrawingGraphic(categoryId: string): void {\r\n this._iModel.elements.insertElement(IModelBuilder.createDrawingGraphic(this._iModel, this._modelId, categoryId).toJSON());\r\n this._iModel.saveChanges(\"Added drawing graphic\");\r\n }\r\n\r\n public getSpatialCategoryCode(codeValue: string): Code {\r\n return SpatialCategory.createCode(this._iModel, this._modelId, codeValue);\r\n }\r\n\r\n public getDrawingCategoryCode(codeValue: string): Code {\r\n return DrawingCategory.createCode(this._iModel, this._modelId, codeValue);\r\n }\r\n\r\n public closeIModel(): void {\r\n this._iModel.close();\r\n }\r\n}\r\n"]}
|
|
@@ -19,4 +19,11 @@ export * from "./presentation-testing/ContentBuilder";
|
|
|
19
19
|
* Various test helpers.
|
|
20
20
|
*/
|
|
21
21
|
export * from "./presentation-testing/Helpers";
|
|
22
|
+
/**
|
|
23
|
+
* @module TestUtilities
|
|
24
|
+
*
|
|
25
|
+
* @docs-group-description TestUtilities
|
|
26
|
+
* Various test helpers.
|
|
27
|
+
*/
|
|
28
|
+
export * from "./presentation-testing/IModelTestUtility";
|
|
22
29
|
//# sourceMappingURL=presentation-testing.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presentation-testing.d.ts","sourceRoot":"","sources":["../../src/presentation-testing.ts"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,cAAc,yCAAyC,CAAC;AAExD;;;;;GAKG;AACH,cAAc,uCAAuC,CAAC;AAEtD;;;;;GAKG;AACH,cAAc,gCAAgC,CAAC"}
|
|
1
|
+
{"version":3,"file":"presentation-testing.d.ts","sourceRoot":"","sources":["../../src/presentation-testing.ts"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,cAAc,yCAAyC,CAAC;AAExD;;;;;GAKG;AACH,cAAc,uCAAuC,CAAC;AAEtD;;;;;GAKG;AACH,cAAc,gCAAgC,CAAC;AAE/C;;;;;GAKG;AACH,cAAc,0CAA0C,CAAC"}
|
|
@@ -35,4 +35,11 @@ __exportStar(require("./presentation-testing/ContentBuilder"), exports);
|
|
|
35
35
|
* Various test helpers.
|
|
36
36
|
*/
|
|
37
37
|
__exportStar(require("./presentation-testing/Helpers"), exports);
|
|
38
|
+
/**
|
|
39
|
+
* @module TestUtilities
|
|
40
|
+
*
|
|
41
|
+
* @docs-group-description TestUtilities
|
|
42
|
+
* Various test helpers.
|
|
43
|
+
*/
|
|
44
|
+
__exportStar(require("./presentation-testing/IModelTestUtility"), exports);
|
|
38
45
|
//# sourceMappingURL=presentation-testing.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presentation-testing.js","sourceRoot":"","sources":["../../src/presentation-testing.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;+FAG+F;AAC/F;;;;;GAKG;AACH,0EAAwD;AAExD;;;;;GAKG;AACH,wEAAsD;AAEtD;;;;;GAKG;AACH,iEAA+C","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\n * @module Hierarchies\r\n *\r\n * @docs-group-description Hierarchies\r\n * Types for testing hierarchies.\r\n */\r\nexport * from \"./presentation-testing/HierarchyBuilder\";\r\n\r\n/**\r\n * @module Content\r\n *\r\n * @docs-group-description Content\r\n * Types for testing content.\r\n */\r\nexport * from \"./presentation-testing/ContentBuilder\";\r\n\r\n/**\r\n * @module Helpers\r\n *\r\n * @docs-group-description Helpers\r\n * Various test helpers.\r\n */\r\nexport * from \"./presentation-testing/Helpers\";\r\n"]}
|
|
1
|
+
{"version":3,"file":"presentation-testing.js","sourceRoot":"","sources":["../../src/presentation-testing.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;+FAG+F;AAC/F;;;;;GAKG;AACH,0EAAwD;AAExD;;;;;GAKG;AACH,wEAAsD;AAEtD;;;;;GAKG;AACH,iEAA+C;AAE/C;;;;;GAKG;AACH,2EAAyD","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\n * @module Hierarchies\r\n *\r\n * @docs-group-description Hierarchies\r\n * Types for testing hierarchies.\r\n */\r\nexport * from \"./presentation-testing/HierarchyBuilder\";\r\n\r\n/**\r\n * @module Content\r\n *\r\n * @docs-group-description Content\r\n * Types for testing content.\r\n */\r\nexport * from \"./presentation-testing/ContentBuilder\";\r\n\r\n/**\r\n * @module Helpers\r\n *\r\n * @docs-group-description Helpers\r\n * Various test helpers.\r\n */\r\nexport * from \"./presentation-testing/Helpers\";\r\n\r\n/**\r\n * @module TestUtilities\r\n *\r\n * @docs-group-description TestUtilities\r\n * Various test helpers.\r\n */\r\nexport * from \"./presentation-testing/IModelTestUtility\";\r\n"]}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { IModelHostOptions } from "@itwin/core-backend";
|
|
1
2
|
import { IModelApp, IModelAppOptions } from "@itwin/core-frontend";
|
|
2
3
|
import { HierarchyCacheMode, PresentationManagerProps as PresentationBackendProps, PresentationManagerMode } from "@itwin/presentation-backend";
|
|
3
4
|
import { PresentationProps as PresentationFrontendProps } from "@itwin/presentation-frontend";
|
|
@@ -6,13 +7,15 @@ export { HierarchyCacheMode, PresentationManagerMode, PresentationBackendProps }
|
|
|
6
7
|
export interface PresentationTestingInitProps {
|
|
7
8
|
/** Properties for backend initialization */
|
|
8
9
|
backendProps?: PresentationBackendProps;
|
|
10
|
+
/** Properties for `IModelHost` */
|
|
11
|
+
backendHostProps?: IModelHostOptions;
|
|
9
12
|
/** Properties for frontend initialization */
|
|
10
13
|
frontendProps?: PresentationFrontendProps;
|
|
11
14
|
/** IModelApp implementation */
|
|
12
15
|
frontendApp?: {
|
|
13
16
|
startup: (opts?: IModelAppOptions) => Promise<void>;
|
|
14
17
|
};
|
|
15
|
-
/** IModelApp options */
|
|
18
|
+
/** `IModelApp` options */
|
|
16
19
|
frontendAppOptions?: IModelAppOptions;
|
|
17
20
|
}
|
|
18
21
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Helpers.d.ts","sourceRoot":"","sources":["../../../src/presentation-testing/Helpers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Helpers.d.ts","sourceRoot":"","sources":["../../../src/presentation-testing/Helpers.ts"],"names":[],"mappings":"AASA,OAAO,EAAc,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAKpE,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAe,MAAM,sBAAsB,CAAC;AAChF,OAAO,EACL,kBAAkB,EAAuC,wBAAwB,IAAI,wBAAwB,EAAE,uBAAuB,EACvI,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAAwC,iBAAiB,IAAI,yBAAyB,EAAE,MAAM,8BAA8B,CAAC;AAsBpI,OAAO,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,wBAAwB,EAAE,CAAC;AAEjF,cAAc;AACd,MAAM,WAAW,4BAA4B;IAC3C,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;CACvC;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,UAAU,qEA8BtB,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,SAAS,mDAuBrB,CAAC"}
|
|
@@ -5,15 +5,15 @@
|
|
|
5
5
|
/** @packageDocumentation
|
|
6
6
|
* @module Helpers
|
|
7
7
|
*/
|
|
8
|
+
import { join } from "path";
|
|
8
9
|
import * as rimraf from "rimraf";
|
|
9
|
-
import { Guid } from "@itwin/core-bentley";
|
|
10
10
|
import { IModelHost } from "@itwin/core-backend";
|
|
11
|
+
import { Guid } from "@itwin/core-bentley";
|
|
11
12
|
import { IModelReadRpcInterface, RpcConfiguration, RpcDefaultConfiguration, SnapshotIModelRpcInterface, } from "@itwin/core-common";
|
|
12
13
|
import { IModelApp, NoRenderApp } from "@itwin/core-frontend";
|
|
13
|
-
import { HierarchyCacheMode, Presentation as PresentationBackend, PresentationManagerMode } from "@itwin/presentation-backend";
|
|
14
|
+
import { HierarchyCacheMode, Presentation as PresentationBackend, PresentationManagerMode, } from "@itwin/presentation-backend";
|
|
14
15
|
import { PresentationRpcInterface } from "@itwin/presentation-common";
|
|
15
16
|
import { Presentation as PresentationFrontend } from "@itwin/presentation-frontend";
|
|
16
|
-
import { join } from "path";
|
|
17
17
|
function initializeRpcInterfaces(interfaces) {
|
|
18
18
|
const config = class extends RpcDefaultConfiguration {
|
|
19
19
|
constructor() {
|
|
@@ -55,7 +55,7 @@ export const initialize = async (props) => {
|
|
|
55
55
|
props.backendProps = (_a = props.backendProps) !== null && _a !== void 0 ? _a : {};
|
|
56
56
|
if (!props.backendProps.id)
|
|
57
57
|
props.backendProps.id = `test-${Guid.createValue()}`;
|
|
58
|
-
await IModelHost.startup({ cacheDir: join(__dirname, ".cache") });
|
|
58
|
+
await IModelHost.startup({ cacheDir: join(__dirname, ".cache"), ...props.backendHostProps });
|
|
59
59
|
PresentationBackend.initialize(props.backendProps);
|
|
60
60
|
// init frontend
|
|
61
61
|
if (!props.frontendApp)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Helpers.js","sourceRoot":"","sources":["../../../src/presentation-testing/Helpers.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AACH,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"Helpers.js","sourceRoot":"","sources":["../../../src/presentation-testing/Helpers.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AACH,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,EACL,sBAAsB,EAAE,gBAAgB,EAAE,uBAAuB,EAA0B,0BAA0B,GACtH,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,SAAS,EAAoB,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAChF,OAAO,EACL,kBAAkB,EAAE,YAAY,IAAI,mBAAmB,EAAwD,uBAAuB,GACvI,MAAM,6BAA6B,CAAC;AACrC,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,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zC,qBAAqB;IACrB,oBAAoB,CAAC,SAAS,EAAE,CAAC;IACjC,MAAM,WAAW,CAAC,QAAQ,EAAE,CAAC;IAE7B,aAAa,GAAG,KAAK,CAAC;AACxB,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/** @packageDocumentation\r\n * @module Helpers\r\n */\r\nimport { join } from \"path\";\r\nimport * as rimraf from \"rimraf\";\r\nimport { IModelHost, IModelHostOptions } from \"@itwin/core-backend\";\r\nimport { Guid } from \"@itwin/core-bentley\";\r\nimport {\r\n IModelReadRpcInterface, RpcConfiguration, RpcDefaultConfiguration, RpcInterfaceDefinition, SnapshotIModelRpcInterface,\r\n} from \"@itwin/core-common\";\r\nimport { IModelApp, IModelAppOptions, NoRenderApp } from \"@itwin/core-frontend\";\r\nimport {\r\n HierarchyCacheMode, Presentation as PresentationBackend, PresentationManagerProps as PresentationBackendProps, PresentationManagerMode,\r\n} from \"@itwin/presentation-backend\";\r\nimport { PresentationRpcInterface } from \"@itwin/presentation-common\";\r\nimport { Presentation as PresentationFrontend, PresentationProps as PresentationFrontendProps } from \"@itwin/presentation-frontend\";\r\n\r\nfunction initializeRpcInterfaces(interfaces: RpcInterfaceDefinition[]) {\r\n const config = class extends RpcDefaultConfiguration {\r\n public override interfaces: any = () => interfaces;\r\n };\r\n\r\n for (const definition of interfaces)\r\n RpcConfiguration.assign(definition, () => config);\r\n\r\n const instance = RpcConfiguration.obtain(config);\r\n\r\n try {\r\n RpcConfiguration.initializeInterfaces(instance);\r\n } catch {\r\n // this may fail with \"Error: RPC interface \"xxx\" is already initialized.\" because\r\n // multiple different tests want to set up rpc interfaces\r\n }\r\n}\r\n\r\nlet isInitialized = false;\r\n\r\nexport { HierarchyCacheMode, PresentationManagerMode, PresentationBackendProps };\r\n\r\n/** @public */\r\nexport interface PresentationTestingInitProps {\r\n /** Properties for backend initialization */\r\n backendProps?: PresentationBackendProps;\r\n /** Properties for `IModelHost` */\r\n backendHostProps?: IModelHostOptions;\r\n /** Properties for frontend initialization */\r\n frontendProps?: PresentationFrontendProps;\r\n /** IModelApp implementation */\r\n frontendApp?: { startup: (opts?: IModelAppOptions) => Promise<void> };\r\n /** `IModelApp` options */\r\n frontendAppOptions?: IModelAppOptions;\r\n}\r\n\r\n/**\r\n * Initialize the framework for presentation testing. The function sets up backend,\r\n * frontend and RPC communication between them.\r\n *\r\n * @see `terminate`\r\n *\r\n * @public\r\n */\r\nexport const initialize = async (props?: PresentationTestingInitProps) => {\r\n if (isInitialized)\r\n return;\r\n\r\n if (!props)\r\n props = {};\r\n\r\n // set up rpc interfaces\r\n initializeRpcInterfaces([SnapshotIModelRpcInterface, IModelReadRpcInterface, PresentationRpcInterface]);\r\n\r\n // init backend\r\n // make sure backend gets assigned an id which puts its resources into a unique directory\r\n props.backendProps = props.backendProps ?? {};\r\n if (!props.backendProps.id)\r\n props.backendProps.id = `test-${Guid.createValue()}`;\r\n await IModelHost.startup({ cacheDir: join(__dirname, \".cache\"), ...props.backendHostProps });\r\n PresentationBackend.initialize(props.backendProps);\r\n\r\n // init frontend\r\n if (!props.frontendApp)\r\n props.frontendApp = NoRenderApp;\r\n await props.frontendApp.startup(props.frontendAppOptions);\r\n const defaultFrontendProps: PresentationFrontendProps = {\r\n presentation: {\r\n activeLocale: IModelApp.localization.getLanguageList()[0],\r\n },\r\n };\r\n await PresentationFrontend.initialize({ ...defaultFrontendProps, ...props.frontendProps });\r\n\r\n isInitialized = true;\r\n};\r\n\r\n/**\r\n * Undoes the setup made by `initialize`.\r\n * @param frontendApp IModelApp implementation\r\n *\r\n * @see `initialize`\r\n *\r\n * @public\r\n */\r\nexport const terminate = async (frontendApp = IModelApp) => {\r\n if (!isInitialized)\r\n return;\r\n\r\n // store directory that needs to be cleaned-up\r\n let hierarchiesCacheDirectory: string | undefined;\r\n const hierarchiesCacheConfig = PresentationBackend.initProps?.caching?.hierarchies;\r\n if (hierarchiesCacheConfig?.mode === HierarchyCacheMode.Disk)\r\n hierarchiesCacheDirectory = hierarchiesCacheConfig?.directory;\r\n else if (hierarchiesCacheConfig?.mode === HierarchyCacheMode.Hybrid)\r\n hierarchiesCacheDirectory = hierarchiesCacheConfig?.disk?.directory;\r\n\r\n // terminate backend\r\n PresentationBackend.terminate();\r\n await IModelHost.shutdown();\r\n if (hierarchiesCacheDirectory)\r\n rimraf.sync(hierarchiesCacheDirectory);\r\n\r\n // terminate frontend\r\n PresentationFrontend.terminate();\r\n await frontendApp.shutdown();\r\n\r\n isInitialized = false;\r\n};\r\n"]}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/** @packageDocumentation
|
|
2
|
+
* @module IModel
|
|
3
|
+
*/
|
|
4
|
+
import { Element, IModelDb } from "@itwin/core-backend";
|
|
5
|
+
import { Id64String } from "@itwin/core-bentley";
|
|
6
|
+
import { Code, CodeProps, LocalFileName, RelatedElement } from "@itwin/core-common";
|
|
7
|
+
export declare class IModelBuilder {
|
|
8
|
+
/**
|
|
9
|
+
* Create and insert a PhysicalPartition element (in the repositoryModel) and an associated PhysicalModel.
|
|
10
|
+
* @return [modeledElementId, modelId]
|
|
11
|
+
*/
|
|
12
|
+
static createAndInsertPhysicalPartitionAndModel(testImodel: IModelDb, newModelCode: CodeProps, privateModel?: boolean, parent?: Id64String): Id64String[];
|
|
13
|
+
/** Create and insert a PhysicalPartition element (in the repositoryModel) and an associated PhysicalModel. */
|
|
14
|
+
static createAndInsertPhysicalPartition(testDb: IModelDb, newModelCode: CodeProps, parentId?: Id64String): Id64String;
|
|
15
|
+
/** Create and insert a PhysicalPartition element (in the repositoryModel) and an associated PhysicalModel. */
|
|
16
|
+
static createAndInsertPhysicalModel(testDb: IModelDb, modeledElementRef: RelatedElement, privateModel?: boolean): Id64String;
|
|
17
|
+
/**
|
|
18
|
+
* Create and insert a DrawingPartition element (in the repositoryModel) and an associated DrawingModel.
|
|
19
|
+
* @return [modeledElementId, modelId]
|
|
20
|
+
*/
|
|
21
|
+
static createAndInsertDrawingPartitionAndModel(testImodel: IModelDb, newModelCode: CodeProps, privateModel?: boolean, parent?: Id64String): Id64String[];
|
|
22
|
+
/** Create and insert a DrawingPartition element (in the repositoryModel) and an associated DrawingModel. */
|
|
23
|
+
static createAndInsertDrawingPartition(testDb: IModelDb, newModelCode: CodeProps, parentId?: Id64String): Id64String;
|
|
24
|
+
/** Create and insert a DrawingPartition element (in the repositoryModel) and an associated DrawingModel. */
|
|
25
|
+
static createAndInsertDrawingModel(testDb: IModelDb, modeledElementRef: RelatedElement, privateModel?: boolean): Id64String;
|
|
26
|
+
static createDrawingGraphic(testImodel: IModelDb, modelId: Id64String, categoryId: Id64String, elemCode?: Code): Element;
|
|
27
|
+
static createPhysicalObject(testImodel: IModelDb, modelId: Id64String, categoryId: Id64String, elemCode?: Code): Element;
|
|
28
|
+
static getUniqueModelCode(testDb: IModelDb, newModelCodeBase: string): Code;
|
|
29
|
+
/** Generate a name for an iModel that's unique using the baseName provided and appending a new GUID. */
|
|
30
|
+
static generateUniqueName(baseName: string): string;
|
|
31
|
+
/** Prepare for an output file by:
|
|
32
|
+
* - Resolving the output file name under the known test output directory
|
|
33
|
+
* - Making directories as necessary
|
|
34
|
+
* - Removing a previous copy of the output file
|
|
35
|
+
* @param subDirName Sub-directory under known test output directory. Should match the name of the test file minus the .test.ts file extension.
|
|
36
|
+
* @param fileName Name of output fille
|
|
37
|
+
*/
|
|
38
|
+
static prepareOutputFile(subDirName: string, fileName: string): LocalFileName;
|
|
39
|
+
}
|
|
40
|
+
export declare class KnownTestLocations {
|
|
41
|
+
/** The directory where test assets are stored. Keep in mind that the test is playing the role of the app. */
|
|
42
|
+
static get assetsDir(): string;
|
|
43
|
+
/** The directory where tests can write. */
|
|
44
|
+
static get outputDir(): string;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=IModelBuilder.d.ts.map
|
|
@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AAE,QAAQ,CAAC,EAAE,IAAI,GAAG,OAAO;WAWjH,oBAAoB,CAAC,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,QAAQ,CAAC,EAAE,IAAI,GAAG,OAAO;WAUjH,kBAAkB,CAAC,MAAM,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,GAAG,IAAI;IAalF,yGAAyG;WAC3F,kBAAkB,CAAC,QAAQ,EAAE,MAAM;IAIjD;;;;;;OAMG;WACW,iBAAiB,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,aAAa;CAcrF;AAED,qBAAa,kBAAkB;IAE7B,6GAA6G;IAC7G,WAAkB,SAAS,IAAI,MAAM,CAEpC;IAED,2CAA2C;IAC3C,WAAkB,SAAS,IAAI,MAAM,CAOpC;CACF"}
|
|
@@ -0,0 +1,147 @@
|
|
|
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
|
+
/** @packageDocumentation
|
|
6
|
+
* @module IModel
|
|
7
|
+
*/
|
|
8
|
+
import { Drawing, DrawingModel, IModelJsFs, InformationPartitionElement, PhysicalModel, PhysicalPartition, SubjectOwnsPartitionElements } from "@itwin/core-backend";
|
|
9
|
+
import { Guid, Id64, ProcessDetector } from "@itwin/core-bentley";
|
|
10
|
+
import { Code, IModel, RelatedElement } from "@itwin/core-common";
|
|
11
|
+
import { assert } from "chai";
|
|
12
|
+
import { tmpdir } from "os";
|
|
13
|
+
import path, { join } from "path";
|
|
14
|
+
export class IModelBuilder {
|
|
15
|
+
/**
|
|
16
|
+
* Create and insert a PhysicalPartition element (in the repositoryModel) and an associated PhysicalModel.
|
|
17
|
+
* @return [modeledElementId, modelId]
|
|
18
|
+
*/
|
|
19
|
+
static createAndInsertPhysicalPartitionAndModel(testImodel, newModelCode, privateModel = false, parent) {
|
|
20
|
+
const eid = IModelBuilder.createAndInsertPhysicalPartition(testImodel, newModelCode, parent);
|
|
21
|
+
const modeledElementRef = new RelatedElement({ id: eid });
|
|
22
|
+
const mid = IModelBuilder.createAndInsertPhysicalModel(testImodel, modeledElementRef, privateModel);
|
|
23
|
+
return [eid, mid];
|
|
24
|
+
}
|
|
25
|
+
/** Create and insert a PhysicalPartition element (in the repositoryModel) and an associated PhysicalModel. */
|
|
26
|
+
static createAndInsertPhysicalPartition(testDb, newModelCode, parentId) {
|
|
27
|
+
const model = parentId ? testDb.elements.getElement(parentId).model : IModel.repositoryModelId;
|
|
28
|
+
const parent = new SubjectOwnsPartitionElements(parentId || IModel.rootSubjectId);
|
|
29
|
+
const modeledElementProps = {
|
|
30
|
+
classFullName: PhysicalPartition.classFullName,
|
|
31
|
+
parent,
|
|
32
|
+
model,
|
|
33
|
+
code: newModelCode,
|
|
34
|
+
};
|
|
35
|
+
const modeledElement = testDb.elements.createElement(modeledElementProps);
|
|
36
|
+
return testDb.elements.insertElement(modeledElement.toJSON());
|
|
37
|
+
}
|
|
38
|
+
/** Create and insert a PhysicalPartition element (in the repositoryModel) and an associated PhysicalModel. */
|
|
39
|
+
static createAndInsertPhysicalModel(testDb, modeledElementRef, privateModel = false) {
|
|
40
|
+
const newModel = testDb.models.createModel({ modeledElement: modeledElementRef, classFullName: PhysicalModel.classFullName, isPrivate: privateModel });
|
|
41
|
+
const newModelId = newModel.id = testDb.models.insertModel(newModel.toJSON());
|
|
42
|
+
assert.isTrue(Id64.isValidId64(newModelId));
|
|
43
|
+
assert.isTrue(Id64.isValidId64(newModel.id));
|
|
44
|
+
assert.deepEqual(newModelId, newModel.id);
|
|
45
|
+
return newModelId;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Create and insert a DrawingPartition element (in the repositoryModel) and an associated DrawingModel.
|
|
49
|
+
* @return [modeledElementId, modelId]
|
|
50
|
+
*/
|
|
51
|
+
static createAndInsertDrawingPartitionAndModel(testImodel, newModelCode, privateModel = false, parent) {
|
|
52
|
+
const eid = IModelBuilder.createAndInsertDrawingPartition(testImodel, newModelCode, parent);
|
|
53
|
+
const modeledElementRef = new RelatedElement({ id: eid });
|
|
54
|
+
const mid = IModelBuilder.createAndInsertDrawingModel(testImodel, modeledElementRef, privateModel);
|
|
55
|
+
return [eid, mid];
|
|
56
|
+
}
|
|
57
|
+
/** Create and insert a DrawingPartition element (in the repositoryModel) and an associated DrawingModel. */
|
|
58
|
+
static createAndInsertDrawingPartition(testDb, newModelCode, parentId) {
|
|
59
|
+
const model = parentId ? testDb.elements.getElement(parentId).model : IModel.repositoryModelId;
|
|
60
|
+
const parent = new SubjectOwnsPartitionElements(parentId || IModel.rootSubjectId);
|
|
61
|
+
const modeledElementProps = {
|
|
62
|
+
classFullName: Drawing.classFullName,
|
|
63
|
+
parent,
|
|
64
|
+
model,
|
|
65
|
+
code: newModelCode,
|
|
66
|
+
};
|
|
67
|
+
const modeledElement = testDb.elements.createElement(modeledElementProps);
|
|
68
|
+
return testDb.elements.insertElement(modeledElement.toJSON());
|
|
69
|
+
}
|
|
70
|
+
/** Create and insert a DrawingPartition element (in the repositoryModel) and an associated DrawingModel. */
|
|
71
|
+
static createAndInsertDrawingModel(testDb, modeledElementRef, privateModel = false) {
|
|
72
|
+
const newModel = testDb.models.createModel({ modeledElement: modeledElementRef, classFullName: DrawingModel.classFullName, isPrivate: privateModel });
|
|
73
|
+
const newModelId = newModel.id = testDb.models.insertModel(newModel.toJSON());
|
|
74
|
+
assert.isTrue(Id64.isValidId64(newModelId));
|
|
75
|
+
assert.isTrue(Id64.isValidId64(newModel.id));
|
|
76
|
+
assert.deepEqual(newModelId, newModel.id);
|
|
77
|
+
return newModelId;
|
|
78
|
+
}
|
|
79
|
+
// Create a DrawingObject. (Does not insert it.)
|
|
80
|
+
static createDrawingGraphic(testImodel, modelId, categoryId, elemCode) {
|
|
81
|
+
const elementProps = {
|
|
82
|
+
classFullName: "BisCore:DrawingGraphic",
|
|
83
|
+
model: modelId,
|
|
84
|
+
category: categoryId,
|
|
85
|
+
code: elemCode ? elemCode : Code.createEmpty(),
|
|
86
|
+
};
|
|
87
|
+
return testImodel.elements.createElement(elementProps);
|
|
88
|
+
}
|
|
89
|
+
// Create a PhysicalObject. (Does not insert it.)
|
|
90
|
+
static createPhysicalObject(testImodel, modelId, categoryId, elemCode) {
|
|
91
|
+
const elementProps = {
|
|
92
|
+
classFullName: "Generic:PhysicalObject",
|
|
93
|
+
model: modelId,
|
|
94
|
+
category: categoryId,
|
|
95
|
+
code: elemCode ? elemCode : Code.createEmpty(),
|
|
96
|
+
};
|
|
97
|
+
return testImodel.elements.createElement(elementProps);
|
|
98
|
+
}
|
|
99
|
+
static getUniqueModelCode(testDb, newModelCodeBase) {
|
|
100
|
+
let newModelCode = newModelCodeBase;
|
|
101
|
+
let iter = 0;
|
|
102
|
+
while (true) {
|
|
103
|
+
const modelCode = InformationPartitionElement.createCode(testDb, IModel.rootSubjectId, newModelCode);
|
|
104
|
+
if (testDb.elements.queryElementIdByCode(modelCode) === undefined)
|
|
105
|
+
return modelCode;
|
|
106
|
+
newModelCode = newModelCodeBase + iter;
|
|
107
|
+
++iter;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
/** Generate a name for an iModel that's unique using the baseName provided and appending a new GUID. */
|
|
111
|
+
static generateUniqueName(baseName) {
|
|
112
|
+
return `${baseName} - ${Guid.createValue()}`;
|
|
113
|
+
}
|
|
114
|
+
/** Prepare for an output file by:
|
|
115
|
+
* - Resolving the output file name under the known test output directory
|
|
116
|
+
* - Making directories as necessary
|
|
117
|
+
* - Removing a previous copy of the output file
|
|
118
|
+
* @param subDirName Sub-directory under known test output directory. Should match the name of the test file minus the .test.ts file extension.
|
|
119
|
+
* @param fileName Name of output fille
|
|
120
|
+
*/
|
|
121
|
+
static prepareOutputFile(subDirName, fileName) {
|
|
122
|
+
if (!IModelJsFs.existsSync(KnownTestLocations.outputDir))
|
|
123
|
+
IModelJsFs.mkdirSync(KnownTestLocations.outputDir);
|
|
124
|
+
const outputDir = path.join(KnownTestLocations.outputDir, subDirName);
|
|
125
|
+
if (!IModelJsFs.existsSync(outputDir))
|
|
126
|
+
IModelJsFs.mkdirSync(outputDir);
|
|
127
|
+
const outputFile = path.join(outputDir, fileName);
|
|
128
|
+
if (IModelJsFs.existsSync(outputFile))
|
|
129
|
+
IModelJsFs.unlinkSync(outputFile);
|
|
130
|
+
return outputFile;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
export class KnownTestLocations {
|
|
134
|
+
/** The directory where test assets are stored. Keep in mind that the test is playing the role of the app. */
|
|
135
|
+
static get assetsDir() {
|
|
136
|
+
return join(__dirname, "assets");
|
|
137
|
+
}
|
|
138
|
+
/** The directory where tests can write. */
|
|
139
|
+
static get outputDir() {
|
|
140
|
+
if (ProcessDetector.isMobileAppBackend) {
|
|
141
|
+
return join(tmpdir(), "output");
|
|
142
|
+
}
|
|
143
|
+
// Assume that we are running in nodejs
|
|
144
|
+
return join(__dirname, "output");
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
//# sourceMappingURL=IModelBuilder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IModelBuilder.js","sourceRoot":"","sources":["../../../src/presentation-testing/IModelBuilder.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,YAAY,EAAqB,UAAU,EAAE,2BAA2B,EAAE,aAAa,EAAE,iBAAiB,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAC;AACxL,OAAO,EAAE,IAAI,EAAE,IAAI,EAAc,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC9E,OAAO,EAAE,IAAI,EAAoD,MAAM,EAAuC,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzJ,OAAO,EAAE,MAAM,EAAE,M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,CAAC;IAED;;;;;;OAMG;IACI,MAAM,CAAC,iBAAiB,CAAC,UAAkB,EAAE,QAAgB;QAClE,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,kBAAkB,CAAC,SAAS,CAAC;YACtD,UAAU,CAAC,SAAS,CAAC,kBAAkB,CAAC,SAAS,CAAC,CAAC;QAErD,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,kBAAkB,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;QACtE,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,SAAS,CAAC;YACnC,UAAU,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;QAElC,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;QAClD,IAAI,UAAU,CAAC,UAAU,CAAC,UAAU,CAAC;YACnC,UAAU,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;QAEpC,OAAO,UAAU,CAAC;IACpB,CAAC;CACF;AAED,MAAM,OAAO,kBAAkB;IAE7B,6GAA6G;IACtG,MAAM,KAAK,SAAS;QACzB,OAAO,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;IACnC,CAAC;IAED,2CAA2C;IACpC,MAAM,KAAK,SAAS;QACzB,IAAI,eAAe,CAAC,kBAAkB,EAAE;YACtC,OAAO,IAAI,CAAC,MAAM,EAAE,EAAE,QAAQ,CAAC,CAAC;SACjC;QAED,uCAAuC;QACvC,OAAO,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;IACnC,CAAC;CACF","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/** @packageDocumentation\r\n * @module IModel\r\n */\r\n\r\nimport { Drawing, DrawingModel, Element, IModelDb, IModelJsFs, InformationPartitionElement, PhysicalModel, PhysicalPartition, SubjectOwnsPartitionElements } from \"@itwin/core-backend\";\r\nimport { Guid, Id64, Id64String, ProcessDetector } from \"@itwin/core-bentley\";\r\nimport { Code, CodeProps, ElementProps, GeometricElement2dProps, IModel, LocalFileName, PhysicalElementProps, RelatedElement } from \"@itwin/core-common\";\r\nimport { assert } from \"chai\";\r\nimport { tmpdir } from \"os\";\r\nimport path, { join } from \"path\";\r\n\r\nexport class IModelBuilder {\r\n /**\r\n * Create and insert a PhysicalPartition element (in the repositoryModel) and an associated PhysicalModel.\r\n * @return [modeledElementId, modelId]\r\n */\r\n public static createAndInsertPhysicalPartitionAndModel(testImodel: IModelDb, newModelCode: CodeProps, privateModel: boolean = false, parent?: Id64String): Id64String[] {\r\n const eid = IModelBuilder.createAndInsertPhysicalPartition(testImodel, newModelCode, parent);\r\n const modeledElementRef = new RelatedElement({ id: eid });\r\n const mid = IModelBuilder.createAndInsertPhysicalModel(testImodel, modeledElementRef, privateModel);\r\n return [eid, mid];\r\n }\r\n\r\n /** Create and insert a PhysicalPartition element (in the repositoryModel) and an associated PhysicalModel. */\r\n public static createAndInsertPhysicalPartition(testDb: IModelDb, newModelCode: CodeProps, parentId?: Id64String): Id64String {\r\n const model = parentId ? testDb.elements.getElement(parentId).model : IModel.repositoryModelId;\r\n const parent = new SubjectOwnsPartitionElements(parentId || IModel.rootSubjectId);\r\n\r\n const modeledElementProps: ElementProps = {\r\n classFullName: PhysicalPartition.classFullName,\r\n parent,\r\n model,\r\n code: newModelCode,\r\n };\r\n const modeledElement: Element = testDb.elements.createElement(modeledElementProps);\r\n return testDb.elements.insertElement(modeledElement.toJSON());\r\n }\r\n\r\n /** Create and insert a PhysicalPartition element (in the repositoryModel) and an associated PhysicalModel. */\r\n public static createAndInsertPhysicalModel(testDb: IModelDb, modeledElementRef: RelatedElement, privateModel: boolean = false): Id64String {\r\n const newModel = testDb.models.createModel({ modeledElement: modeledElementRef, classFullName: PhysicalModel.classFullName, isPrivate: privateModel });\r\n const newModelId = newModel.id = testDb.models.insertModel(newModel.toJSON());\r\n assert.isTrue(Id64.isValidId64(newModelId));\r\n assert.isTrue(Id64.isValidId64(newModel.id));\r\n assert.deepEqual(newModelId, newModel.id);\r\n return newModelId;\r\n }\r\n\r\n /**\r\n * Create and insert a DrawingPartition element (in the repositoryModel) and an associated DrawingModel.\r\n * @return [modeledElementId, modelId]\r\n */\r\n public static createAndInsertDrawingPartitionAndModel(testImodel: IModelDb, newModelCode: CodeProps, privateModel: boolean = false, parent?: Id64String): Id64String[] {\r\n const eid = IModelBuilder.createAndInsertDrawingPartition(testImodel, newModelCode, parent);\r\n const modeledElementRef = new RelatedElement({ id: eid });\r\n const mid = IModelBuilder.createAndInsertDrawingModel(testImodel, modeledElementRef, privateModel);\r\n return [eid, mid];\r\n }\r\n\r\n /** Create and insert a DrawingPartition element (in the repositoryModel) and an associated DrawingModel. */\r\n public static createAndInsertDrawingPartition(testDb: IModelDb, newModelCode: CodeProps, parentId?: Id64String): Id64String {\r\n const model = parentId ? testDb.elements.getElement(parentId).model : IModel.repositoryModelId;\r\n const parent = new SubjectOwnsPartitionElements(parentId || IModel.rootSubjectId);\r\n\r\n const modeledElementProps: ElementProps = {\r\n classFullName: Drawing.classFullName,\r\n parent,\r\n model,\r\n code: newModelCode,\r\n };\r\n const modeledElement: Element = testDb.elements.createElement(modeledElementProps);\r\n return testDb.elements.insertElement(modeledElement.toJSON());\r\n }\r\n\r\n /** Create and insert a DrawingPartition element (in the repositoryModel) and an associated DrawingModel. */\r\n public static createAndInsertDrawingModel(testDb: IModelDb, modeledElementRef: RelatedElement, privateModel: boolean = false): Id64String {\r\n const newModel = testDb.models.createModel({ modeledElement: modeledElementRef, classFullName: DrawingModel.classFullName, isPrivate: privateModel });\r\n const newModelId = newModel.id = testDb.models.insertModel(newModel.toJSON());\r\n assert.isTrue(Id64.isValidId64(newModelId));\r\n assert.isTrue(Id64.isValidId64(newModel.id));\r\n assert.deepEqual(newModelId, newModel.id);\r\n return newModelId;\r\n }\r\n\r\n // Create a DrawingObject. (Does not insert it.)\r\n public static createDrawingGraphic(testImodel: IModelDb, modelId: Id64String, categoryId: Id64String, elemCode?: Code): Element {\r\n const elementProps: GeometricElement2dProps = {\r\n classFullName: \"BisCore:DrawingGraphic\",\r\n model: modelId,\r\n category: categoryId,\r\n code: elemCode ? elemCode : Code.createEmpty(),\r\n };\r\n return testImodel.elements.createElement(elementProps);\r\n }\r\n\r\n // Create a PhysicalObject. (Does not insert it.)\r\n public static createPhysicalObject(testImodel: IModelDb, modelId: Id64String, categoryId: Id64String, elemCode?: Code): Element {\r\n const elementProps: PhysicalElementProps = {\r\n classFullName: \"Generic:PhysicalObject\",\r\n model: modelId,\r\n category: categoryId,\r\n code: elemCode ? elemCode : Code.createEmpty(),\r\n };\r\n return testImodel.elements.createElement(elementProps);\r\n }\r\n\r\n public static getUniqueModelCode(testDb: IModelDb, newModelCodeBase: string): Code {\r\n let newModelCode: string = newModelCodeBase;\r\n let iter: number = 0;\r\n while (true) {\r\n const modelCode = InformationPartitionElement.createCode(testDb, IModel.rootSubjectId, newModelCode);\r\n if (testDb.elements.queryElementIdByCode(modelCode) === undefined)\r\n return modelCode;\r\n\r\n newModelCode = newModelCodeBase + iter;\r\n ++iter;\r\n }\r\n }\r\n\r\n /** Generate a name for an iModel that's unique using the baseName provided and appending a new GUID. */\r\n public static generateUniqueName(baseName: string) {\r\n return `${baseName} - ${Guid.createValue()}`;\r\n }\r\n\r\n /** Prepare for an output file by:\r\n * - Resolving the output file name under the known test output directory\r\n * - Making directories as necessary\r\n * - Removing a previous copy of the output file\r\n * @param subDirName Sub-directory under known test output directory. Should match the name of the test file minus the .test.ts file extension.\r\n * @param fileName Name of output fille\r\n */\r\n public static prepareOutputFile(subDirName: string, fileName: string): LocalFileName {\r\n if (!IModelJsFs.existsSync(KnownTestLocations.outputDir))\r\n IModelJsFs.mkdirSync(KnownTestLocations.outputDir);\r\n\r\n const outputDir = path.join(KnownTestLocations.outputDir, subDirName);\r\n if (!IModelJsFs.existsSync(outputDir))\r\n IModelJsFs.mkdirSync(outputDir);\r\n\r\n const outputFile = path.join(outputDir, fileName);\r\n if (IModelJsFs.existsSync(outputFile))\r\n IModelJsFs.unlinkSync(outputFile);\r\n\r\n return outputFile;\r\n }\r\n}\r\n\r\nexport class KnownTestLocations {\r\n\r\n /** The directory where test assets are stored. Keep in mind that the test is playing the role of the app. */\r\n public static get assetsDir(): string {\r\n return join(__dirname, \"assets\");\r\n }\r\n\r\n /** The directory where tests can write. */\r\n public static get outputDir(): string {\r\n if (ProcessDetector.isMobileAppBackend) {\r\n return join(tmpdir(), \"output\");\r\n }\r\n\r\n // Assume that we are running in nodejs\r\n return join(__dirname, \"output\");\r\n }\r\n}\r\n"]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { GuidString } from "@itwin/core-bentley";
|
|
2
|
+
import { Code, ElementProps } from "@itwin/core-common";
|
|
3
|
+
/**
|
|
4
|
+
* Test utility to push an iModel.
|
|
5
|
+
*
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
8
|
+
export declare class IModelTestUtility {
|
|
9
|
+
iTwinId: GuidString;
|
|
10
|
+
iModelId: string;
|
|
11
|
+
outputFile: string;
|
|
12
|
+
private _iModel;
|
|
13
|
+
private _modelId;
|
|
14
|
+
createIModel(): void;
|
|
15
|
+
addPhysicalModel(): string;
|
|
16
|
+
addDrawingModel(): string;
|
|
17
|
+
addSpatialCategory(elementProps: ElementProps): string;
|
|
18
|
+
addDrawingCategory(elementProps: ElementProps): string;
|
|
19
|
+
addPhysicalObject(categoryId: string): void;
|
|
20
|
+
addDrawingGraphic(categoryId: string): void;
|
|
21
|
+
getSpatialCategoryCode(codeValue: string): Code;
|
|
22
|
+
getDrawingCategoryCode(codeValue: string): Code;
|
|
23
|
+
closeIModel(): void;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=IModelTestUtility.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IModelTestUtility.d.ts","sourceRoot":"","sources":["../../../src/presentation-testing/IModelTestUtility.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAGxD;;;;GAIG;AACH,qBAAa,iBAAiB;IACrB,OAAO,EAAG,UAAU,CAAC;IACrB,QAAQ,EAAG,MAAM,CAAC;IAClB,UAAU,EAAG,MAAM,CAAC;IAC3B,OAAO,CAAC,OAAO,CAAY;IAC3B,OAAO,CAAC,QAAQ,CAAU;IAEnB,YAAY,IAAI,IAAI;IAMpB,gBAAgB,IAAI,MAAM;IAM1B,eAAe,IAAI,MAAM;IAMzB,kBAAkB,CAAC,YAAY,EAAE,YAAY,GAAG,MAAM;IAMtD,kBAAkB,CAAC,YAAY,EAAE,YAAY,GAAG,MAAM;IAMtD,iBAAiB,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAK3C,iBAAiB,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAK3C,sBAAsB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IAI/C,sBAAsB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IAI/C,WAAW,IAAI,IAAI;CAG3B"}
|
|
@@ -0,0 +1,59 @@
|
|
|
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
|
+
/** @packageDocumentation
|
|
6
|
+
* @module TestUtilities
|
|
7
|
+
*/
|
|
8
|
+
import { DrawingCategory, SnapshotDb, SpatialCategory } from "@itwin/core-backend";
|
|
9
|
+
import { IModelBuilder } from "./IModelBuilder";
|
|
10
|
+
/**
|
|
11
|
+
* Test utility to push an iModel.
|
|
12
|
+
*
|
|
13
|
+
* @internal
|
|
14
|
+
*/
|
|
15
|
+
export class IModelTestUtility {
|
|
16
|
+
createIModel() {
|
|
17
|
+
this.outputFile = IModelBuilder.prepareOutputFile("IModelTest", IModelBuilder.generateUniqueName("IModelTest.bim"));
|
|
18
|
+
this._iModel = SnapshotDb.createEmpty(this.outputFile, { rootSubject: { name: "IModelTest" } });
|
|
19
|
+
this.iModelId = this._iModel.iModelId;
|
|
20
|
+
}
|
|
21
|
+
addPhysicalModel() {
|
|
22
|
+
[, this._modelId] = IModelBuilder.createAndInsertPhysicalPartitionAndModel(this._iModel, IModelBuilder.getUniqueModelCode(this._iModel, "TestPhysicalModel"), false);
|
|
23
|
+
this._iModel.saveChanges("Added test model");
|
|
24
|
+
return this._modelId;
|
|
25
|
+
}
|
|
26
|
+
addDrawingModel() {
|
|
27
|
+
[, this._modelId] = IModelBuilder.createAndInsertDrawingPartitionAndModel(this._iModel, IModelBuilder.getUniqueModelCode(this._iModel, "TestDrawingModel"), false);
|
|
28
|
+
this._iModel.saveChanges("Added test model");
|
|
29
|
+
return this._modelId;
|
|
30
|
+
}
|
|
31
|
+
addSpatialCategory(elementProps) {
|
|
32
|
+
const categoryId = this._iModel.elements.insertElement(new SpatialCategory(elementProps, this._iModel).toJSON());
|
|
33
|
+
this._iModel.saveChanges("Added spatial category");
|
|
34
|
+
return categoryId;
|
|
35
|
+
}
|
|
36
|
+
addDrawingCategory(elementProps) {
|
|
37
|
+
const categoryId = this._iModel.elements.insertElement(new DrawingCategory(elementProps, this._iModel).toJSON());
|
|
38
|
+
this._iModel.saveChanges("Added drawing category");
|
|
39
|
+
return categoryId;
|
|
40
|
+
}
|
|
41
|
+
addPhysicalObject(categoryId) {
|
|
42
|
+
this._iModel.elements.insertElement(IModelBuilder.createPhysicalObject(this._iModel, this._modelId, categoryId).toJSON());
|
|
43
|
+
this._iModel.saveChanges("Added physical object");
|
|
44
|
+
}
|
|
45
|
+
addDrawingGraphic(categoryId) {
|
|
46
|
+
this._iModel.elements.insertElement(IModelBuilder.createDrawingGraphic(this._iModel, this._modelId, categoryId).toJSON());
|
|
47
|
+
this._iModel.saveChanges("Added drawing graphic");
|
|
48
|
+
}
|
|
49
|
+
getSpatialCategoryCode(codeValue) {
|
|
50
|
+
return SpatialCategory.createCode(this._iModel, this._modelId, codeValue);
|
|
51
|
+
}
|
|
52
|
+
getDrawingCategoryCode(codeValue) {
|
|
53
|
+
return DrawingCategory.createCode(this._iModel, this._modelId, codeValue);
|
|
54
|
+
}
|
|
55
|
+
closeIModel() {
|
|
56
|
+
this._iModel.close();
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=IModelTestUtility.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IModelTestUtility.js","sourceRoot":"","sources":["../../../src/presentation-testing/IModelTestUtility.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AACH,OAAO,EAAE,eAAe,EAAY,UAAU,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAG7F,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD;;;;GAIG;AACH,MAAM,OAAO,iBAAiB;IAOrB,YAAY;QACjB,IAAI,CAAC,UAAU,GAAG,aAAa,CAAC,iBAAiB,CAAC,YAAY,EAAE,aAAa,CAAC,kBAAkB,CAAC,gBAAgB,CAAC,CAAC,CAAC;QACpH,IAAI,CAAC,OAAO,GAAG,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU,EAAE,EAAE,WAAW,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,EAAE,CAAC,CAAC;QAChG,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC;IACxC,CAAC;IAEM,gBAAgB;QACrB,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC,GAAG,aAAa,CAAC,wCAAwC,CAAC,IAAI,CAAC,OAAO,EAAE,aAAa,CAAC,kBAAkB,CAAC,IAAI,CAAC,OAAO,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C,CAAC;QAC1H,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,uBAAuB,CAAC,CAAC;IACpD,CAAC;IAEM,iBAAiB,CAAC,UAAkB;QACzC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAC,aAAa,CAAC,oBAAoB,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;QAC1H,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,uBAAuB,CAAC,CAAC;IACpD,CAAC;IAEM,sBAAsB,CAAC,SAAiB;QAC7C,OAAO,eAAe,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;IAC5E,CAAC;IAEM,sBAAsB,CAAC,SAAiB;QAC7C,OAAO,eAAe,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;IAC5E,CAAC;IAEM,WAAW;QAChB,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;IACvB,CAAC;CACF","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/** @packageDocumentation\r\n * @module TestUtilities\r\n */\r\nimport { DrawingCategory, IModelDb, SnapshotDb, SpatialCategory } from \"@itwin/core-backend\";\r\nimport { GuidString } from \"@itwin/core-bentley\";\r\nimport { Code, ElementProps } from \"@itwin/core-common\";\r\nimport { IModelBuilder } from \"./IModelBuilder\";\r\n\r\n/**\r\n * Test utility to push an iModel.\r\n *\r\n * @internal\r\n */\r\nexport class IModelTestUtility {\r\n public iTwinId!: GuidString;\r\n public iModelId!: string;\r\n public outputFile!: string;\r\n private _iModel!: IModelDb;\r\n private _modelId!: string;\r\n\r\n public createIModel(): void {\r\n this.outputFile = IModelBuilder.prepareOutputFile(\"IModelTest\", IModelBuilder.generateUniqueName(\"IModelTest.bim\"));\r\n this._iModel = SnapshotDb.createEmpty(this.outputFile, { rootSubject: { name: \"IModelTest\" } });\r\n this.iModelId = this._iModel.iModelId;\r\n }\r\n\r\n public addPhysicalModel(): string {\r\n [, this._modelId] = IModelBuilder.createAndInsertPhysicalPartitionAndModel(this._iModel, IModelBuilder.getUniqueModelCode(this._iModel, \"TestPhysicalModel\"), false);\r\n this._iModel.saveChanges(\"Added test model\");\r\n return this._modelId;\r\n }\r\n\r\n public addDrawingModel(): string {\r\n [, this._modelId] = IModelBuilder.createAndInsertDrawingPartitionAndModel(this._iModel, IModelBuilder.getUniqueModelCode(this._iModel, \"TestDrawingModel\"), false);\r\n this._iModel.saveChanges(\"Added test model\");\r\n return this._modelId;\r\n }\r\n\r\n public addSpatialCategory(elementProps: ElementProps): string {\r\n const categoryId = this._iModel.elements.insertElement(new SpatialCategory(elementProps, this._iModel).toJSON());\r\n this._iModel.saveChanges(\"Added spatial category\");\r\n return categoryId;\r\n }\r\n\r\n public addDrawingCategory(elementProps: ElementProps): string {\r\n const categoryId = this._iModel.elements.insertElement(new DrawingCategory(elementProps, this._iModel).toJSON());\r\n this._iModel.saveChanges(\"Added drawing category\");\r\n return categoryId;\r\n }\r\n\r\n public addPhysicalObject(categoryId: string): void {\r\n this._iModel.elements.insertElement(IModelBuilder.createPhysicalObject(this._iModel, this._modelId, categoryId).toJSON());\r\n this._iModel.saveChanges(\"Added physical object\");\r\n }\r\n\r\n public addDrawingGraphic(categoryId: string): void {\r\n this._iModel.elements.insertElement(IModelBuilder.createDrawingGraphic(this._iModel, this._modelId, categoryId).toJSON());\r\n this._iModel.saveChanges(\"Added drawing graphic\");\r\n }\r\n\r\n public getSpatialCategoryCode(codeValue: string): Code {\r\n return SpatialCategory.createCode(this._iModel, this._modelId, codeValue);\r\n }\r\n\r\n public getDrawingCategoryCode(codeValue: string): Code {\r\n return DrawingCategory.createCode(this._iModel, this._modelId, codeValue);\r\n }\r\n\r\n public closeIModel(): void {\r\n this._iModel.close();\r\n }\r\n}\r\n"]}
|
|
@@ -19,4 +19,11 @@ export * from "./presentation-testing/ContentBuilder";
|
|
|
19
19
|
* Various test helpers.
|
|
20
20
|
*/
|
|
21
21
|
export * from "./presentation-testing/Helpers";
|
|
22
|
+
/**
|
|
23
|
+
* @module TestUtilities
|
|
24
|
+
*
|
|
25
|
+
* @docs-group-description TestUtilities
|
|
26
|
+
* Various test helpers.
|
|
27
|
+
*/
|
|
28
|
+
export * from "./presentation-testing/IModelTestUtility";
|
|
22
29
|
//# sourceMappingURL=presentation-testing.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presentation-testing.d.ts","sourceRoot":"","sources":["../../src/presentation-testing.ts"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,cAAc,yCAAyC,CAAC;AAExD;;;;;GAKG;AACH,cAAc,uCAAuC,CAAC;AAEtD;;;;;GAKG;AACH,cAAc,gCAAgC,CAAC"}
|
|
1
|
+
{"version":3,"file":"presentation-testing.d.ts","sourceRoot":"","sources":["../../src/presentation-testing.ts"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,cAAc,yCAAyC,CAAC;AAExD;;;;;GAKG;AACH,cAAc,uCAAuC,CAAC;AAEtD;;;;;GAKG;AACH,cAAc,gCAAgC,CAAC;AAE/C;;;;;GAKG;AACH,cAAc,0CAA0C,CAAC"}
|
|
@@ -23,4 +23,11 @@ export * from "./presentation-testing/ContentBuilder";
|
|
|
23
23
|
* Various test helpers.
|
|
24
24
|
*/
|
|
25
25
|
export * from "./presentation-testing/Helpers";
|
|
26
|
+
/**
|
|
27
|
+
* @module TestUtilities
|
|
28
|
+
*
|
|
29
|
+
* @docs-group-description TestUtilities
|
|
30
|
+
* Various test helpers.
|
|
31
|
+
*/
|
|
32
|
+
export * from "./presentation-testing/IModelTestUtility";
|
|
26
33
|
//# sourceMappingURL=presentation-testing.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presentation-testing.js","sourceRoot":"","sources":["../../src/presentation-testing.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;;;;GAKG;AACH,cAAc,yCAAyC,CAAC;AAExD;;;;;GAKG;AACH,cAAc,uCAAuC,CAAC;AAEtD;;;;;GAKG;AACH,cAAc,gCAAgC,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\n * @module Hierarchies\r\n *\r\n * @docs-group-description Hierarchies\r\n * Types for testing hierarchies.\r\n */\r\nexport * from \"./presentation-testing/HierarchyBuilder\";\r\n\r\n/**\r\n * @module Content\r\n *\r\n * @docs-group-description Content\r\n * Types for testing content.\r\n */\r\nexport * from \"./presentation-testing/ContentBuilder\";\r\n\r\n/**\r\n * @module Helpers\r\n *\r\n * @docs-group-description Helpers\r\n * Various test helpers.\r\n */\r\nexport * from \"./presentation-testing/Helpers\";\r\n"]}
|
|
1
|
+
{"version":3,"file":"presentation-testing.js","sourceRoot":"","sources":["../../src/presentation-testing.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;;;;GAKG;AACH,cAAc,yCAAyC,CAAC;AAExD;;;;;GAKG;AACH,cAAc,uCAAuC,CAAC;AAEtD;;;;;GAKG;AACH,cAAc,gCAAgC,CAAC;AAE/C;;;;;GAKG;AACH,cAAc,0CAA0C,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\n * @module Hierarchies\r\n *\r\n * @docs-group-description Hierarchies\r\n * Types for testing hierarchies.\r\n */\r\nexport * from \"./presentation-testing/HierarchyBuilder\";\r\n\r\n/**\r\n * @module Content\r\n *\r\n * @docs-group-description Content\r\n * Types for testing content.\r\n */\r\nexport * from \"./presentation-testing/ContentBuilder\";\r\n\r\n/**\r\n * @module Helpers\r\n *\r\n * @docs-group-description Helpers\r\n * Various test helpers.\r\n */\r\nexport * from \"./presentation-testing/Helpers\";\r\n\r\n/**\r\n * @module TestUtilities\r\n *\r\n * @docs-group-description TestUtilities\r\n * Various test helpers.\r\n */\r\nexport * from \"./presentation-testing/IModelTestUtility\";\r\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itwin/presentation-testing",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.5.0-dev.4",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -25,18 +25,18 @@
|
|
|
25
25
|
"ignore-styles": "^5.0.1"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@itwin/appui-abstract": "3.
|
|
29
|
-
"@itwin/build-tools": "3.
|
|
30
|
-
"@itwin/components-react": "3.
|
|
31
|
-
"@itwin/core-backend": "3.
|
|
32
|
-
"@itwin/core-bentley": "3.
|
|
33
|
-
"@itwin/core-common": "3.
|
|
34
|
-
"@itwin/core-frontend": "3.
|
|
35
|
-
"@itwin/eslint-plugin": "3.
|
|
36
|
-
"@itwin/presentation-backend": "3.
|
|
37
|
-
"@itwin/presentation-common": "3.
|
|
38
|
-
"@itwin/presentation-components": "3.
|
|
39
|
-
"@itwin/presentation-frontend": "3.
|
|
28
|
+
"@itwin/appui-abstract": "3.5.0-dev.4",
|
|
29
|
+
"@itwin/build-tools": "3.5.0-dev.4",
|
|
30
|
+
"@itwin/components-react": "3.5.0-dev.4",
|
|
31
|
+
"@itwin/core-backend": "3.5.0-dev.4",
|
|
32
|
+
"@itwin/core-bentley": "3.5.0-dev.4",
|
|
33
|
+
"@itwin/core-common": "3.5.0-dev.4",
|
|
34
|
+
"@itwin/core-frontend": "3.5.0-dev.4",
|
|
35
|
+
"@itwin/eslint-plugin": "3.5.0-dev.4",
|
|
36
|
+
"@itwin/presentation-backend": "3.5.0-dev.4",
|
|
37
|
+
"@itwin/presentation-common": "3.5.0-dev.4",
|
|
38
|
+
"@itwin/presentation-components": "3.5.0-dev.4",
|
|
39
|
+
"@itwin/presentation-frontend": "3.5.0-dev.4",
|
|
40
40
|
"@types/chai": "4.3.1",
|
|
41
41
|
"@types/chai-as-promised": "^7",
|
|
42
42
|
"@types/chai-jest-snapshot": "^1.3.0",
|