@itwin/presentation-testing 4.0.3 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -2
- package/lib/cjs/presentation-testing/IModelUtilities.d.ts +21 -0
- package/lib/cjs/presentation-testing/IModelUtilities.d.ts.map +1 -1
- package/lib/cjs/presentation-testing/IModelUtilities.js +4 -1
- package/lib/cjs/presentation-testing/IModelUtilities.js.map +1 -1
- package/lib/esm/presentation-testing/IModelUtilities.d.ts +21 -0
- package/lib/esm/presentation-testing/IModelUtilities.d.ts.map +1 -1
- package/lib/esm/presentation-testing/IModelUtilities.js +4 -1
- package/lib/esm/presentation-testing/IModelUtilities.js.map +1 -1
- package/package.json +18 -18
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,24 @@
|
|
|
1
1
|
# Change Log - @itwin/presentation-testing
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
## 4.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#232](https://github.com/iTwin/presentation/pull/232): Added `TestIModelBuilder.importSchema` API to allow creating iModels with custom schemas.
|
|
8
|
+
- [#232](https://github.com/iTwin/presentation/pull/232): Added `buildTestIModel` overloads that take an async callback to set up the iModel. Deprecated the previous ones.
|
|
9
|
+
|
|
10
|
+
### Patch Changes
|
|
11
|
+
|
|
12
|
+
- Updated dependencies:
|
|
13
|
+
- @itwin/presentation-components@4.2.1
|
|
14
|
+
|
|
15
|
+
This log was last generated on Thu, 31 Aug 2023 11:51:06 GMT and should not be manually modified.
|
|
4
16
|
|
|
5
17
|
<!-- Start content -->
|
|
6
18
|
|
|
7
19
|
## 4.0.3
|
|
8
20
|
|
|
9
|
-
Thu, 31 Aug 2023 11:
|
|
21
|
+
Thu, 31 Aug 2023 11:51:06 GMT
|
|
10
22
|
|
|
11
23
|
### Patches
|
|
12
24
|
|
|
@@ -27,21 +27,41 @@ export interface TestIModelBuilder {
|
|
|
27
27
|
* Code value has to be unique within its scope (see [Codes documentation page]($docs/bis/guide/fundamentals/codes.md)).
|
|
28
28
|
*/
|
|
29
29
|
createCode(scopeModelId: CodeScopeProps, codeSpecName: BisCodeSpec, codeValue: string): Code;
|
|
30
|
+
/**
|
|
31
|
+
* Import an ECSchema in a form of XML string into the builder's iModel.
|
|
32
|
+
*/
|
|
33
|
+
importSchema(schemaXml: string): Promise<void>;
|
|
30
34
|
}
|
|
31
35
|
/**
|
|
32
36
|
* Function that creates an iModel and returns a connection to it.
|
|
33
37
|
* @param name Name of test IModel
|
|
34
38
|
* @param cb Callback function that receives an [[TestIModelBuilder]] to fill the iModel with data
|
|
35
39
|
* @beta
|
|
40
|
+
* @deprecated in 4.x. Use an overload with `cb` returning a promise.
|
|
36
41
|
*/
|
|
37
42
|
export declare function buildTestIModel(name: string, cb: (builder: TestIModelBuilder) => void): Promise<IModelConnection>;
|
|
43
|
+
/**
|
|
44
|
+
* Function that creates an iModel and returns a connection to it.
|
|
45
|
+
* @param name Name of test IModel
|
|
46
|
+
* @param cb Callback function that receives an [[TestIModelBuilder]] to fill the iModel with data
|
|
47
|
+
* @beta
|
|
48
|
+
*/
|
|
49
|
+
export declare function buildTestIModel(name: string, cb: (builder: TestIModelBuilder) => Promise<void>): Promise<IModelConnection>;
|
|
38
50
|
/**
|
|
39
51
|
* Function that creates an iModel and returns a connection to it.
|
|
40
52
|
* @param mochaContext Mocha context to generate iModel name from
|
|
41
53
|
* @param cb Callback function that receives an [[TestIModelBuilder]] to fill the iModel with data
|
|
42
54
|
* @beta
|
|
55
|
+
* @deprecated in 4.x. Use an overload with `cb` returning a promise.
|
|
43
56
|
*/
|
|
44
57
|
export declare function buildTestIModel(mochaContext: Mocha.Context, cb: (builder: TestIModelBuilder) => void): Promise<IModelConnection>;
|
|
58
|
+
/**
|
|
59
|
+
* Function that creates an iModel and returns a connection to it.
|
|
60
|
+
* @param mochaContext Mocha context to generate iModel name from
|
|
61
|
+
* @param cb Callback function that receives an [[TestIModelBuilder]] to fill the iModel with data
|
|
62
|
+
* @beta
|
|
63
|
+
*/
|
|
64
|
+
export declare function buildTestIModel(mochaContext: Mocha.Context, cb: (builder: TestIModelBuilder) => Promise<void>): Promise<IModelConnection>;
|
|
45
65
|
/**
|
|
46
66
|
* Default implementation of IModel builder pattern. Used for building IModels to test rulesets.
|
|
47
67
|
*
|
|
@@ -55,6 +75,7 @@ export declare class IModelBuilder implements TestIModelBuilder {
|
|
|
55
75
|
insertAspect<TProps extends ElementAspectProps>(props: TProps): Id64String;
|
|
56
76
|
insertRelationship<TProps extends RelationshipProps>(props: TProps): Id64String;
|
|
57
77
|
createCode(scopeModelId: CodeScopeProps, codeSpecName: BisCodeSpec, codeValue: string): Code;
|
|
78
|
+
importSchema(schemaXml: string): Promise<void>;
|
|
58
79
|
}
|
|
59
80
|
/** @internal */
|
|
60
81
|
export declare function createFileNameFromString(str: string): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IModelUtilities.d.ts","sourceRoot":"","sources":["../../../src/presentation-testing/IModelUtilities.ts"],"names":[],"mappings":"AAIA;;GAEG;;AAIH,OAAO,EAAE,QAAQ,EAA0B,MAAM,qBAAqB,CAAC;AACvE,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EACL,WAAW,EACX,IAAI,EACJ,cAAc,EAEd,kBAAkB,EAClB,YAAY,EAEZ,UAAU,EACV,iBAAiB,EAClB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,gBAAgB,EAAsB,MAAM,sBAAsB,CAAC;AAG5E;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC,+CAA+C;IAC/C,WAAW,CAAC,MAAM,SAAS,UAAU,EAAE,KAAK,EAAE,MAAM,GAAG,UAAU,CAAC;IAClE,kDAAkD;IAClD,aAAa,CAAC,MAAM,SAAS,YAAY,EAAE,KAAK,EAAE,MAAM,GAAG,UAAU,CAAC;IACtE,0DAA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,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI;IAKtF,YAAY,CAAC,SAAS,EAAE,MAAM;CAG5C;AAkBD,gBAAgB;AAChB,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,MAAM,UAEnD"}
|
|
@@ -23,7 +23,7 @@ async function buildTestIModel(nameParam, cb) {
|
|
|
23
23
|
const db = core_backend_1.SnapshotDb.createEmpty(outputFile, { rootSubject: { name } });
|
|
24
24
|
const builder = new IModelBuilder(db);
|
|
25
25
|
try {
|
|
26
|
-
cb(builder);
|
|
26
|
+
await cb(builder);
|
|
27
27
|
}
|
|
28
28
|
finally {
|
|
29
29
|
db.saveChanges("Created test IModel");
|
|
@@ -63,6 +63,9 @@ class IModelBuilder {
|
|
|
63
63
|
const codeSpec = this._iModel.codeSpecs.getByName(codeSpecName);
|
|
64
64
|
return new core_common_1.Code({ spec: codeSpec.id, scope: scopeModelId, value: codeValue });
|
|
65
65
|
}
|
|
66
|
+
async importSchema(schemaXml) {
|
|
67
|
+
await this._iModel.importSchemaStrings([schemaXml]);
|
|
68
|
+
}
|
|
66
69
|
}
|
|
67
70
|
exports.IModelBuilder = IModelBuilder;
|
|
68
71
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IModelUtilities.js","sourceRoot":"","sources":["../../../src/presentation-testing/IModelUtilities.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;AAEH,gDAAwB;AACxB,0EAAyC;AACzC,sDAAuE;AAEvE,oDAU4B;AAC5B,wDAA4E;AAC5E,uCAA6C;
|
|
1
|
+
{"version":3,"file":"IModelUtilities.js","sourceRoot":"","sources":["../../../src/presentation-testing/IModelUtilities.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;AAEH,gDAAwB;AACxB,0EAAyC;AACzC,sDAAuE;AAEvE,oDAU4B;AAC5B,wDAA4E;AAC5E,uCAA6C;AA8DtC,KAAK,UAAU,eAA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CAAC;IAC1D,CAAC;IAEM,UAAU,CAAC,YAA4B,EAAE,YAAyB,EAAE,SAAiB;QAC1F,MAAM,QAAQ,GAAa,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;QAC1E,OAAO,IAAI,kBAAI,CAAC,EAAE,IAAI,EAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;IAChF,CAAC;IAEM,KAAK,CAAC,YAAY,CAAC,SAAiB;QACzC,MAAM,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;IACtD,CAAC;CACF;AA/BD,sCA+BC;AAED;;;;;;GAMG;AACH,SAAS,uBAAuB,CAAC,QAAgB;IAC/C,MAAM,aAAa,GAAG,IAAA,0BAAgB,GAAE,CAAC;IACzC,CAAC,yBAAU,CAAC,UAAU,CAAC,aAAa,CAAC,IAAI,yBAAU,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC;IAE7E,MAAM,UAAU,GAAG,cAAI,CAAC,IAAI,CAAC,aAAa,EAAE,GAAG,QAAQ,MAAM,CAAC,CAAC;IAC/D,yBAAU,CAAC,UAAU,CAAC,UAAU,CAAC,IAAI,yBAAU,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;IACvE,OAAO,UAAU,CAAC;AACpB,CAAC;AAED,gBAAgB;AAChB,SAAgB,wBAAwB,CAAC,GAAW;IAClD,OAAO,IAAA,2BAAQ,EAAC,GAAG,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC,iBAAiB,EAAE,CAAC;AACjE,CAAC;AAFD,4DAEC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module IModel\n */\n\nimport path from \"path\";\nimport sanitize from \"sanitize-filename\";\nimport { IModelDb, IModelJsFs, SnapshotDb } from \"@itwin/core-backend\";\nimport { Id64String } from \"@itwin/core-bentley\";\nimport {\n BisCodeSpec,\n Code,\n CodeScopeProps,\n CodeSpec,\n ElementAspectProps,\n ElementProps,\n LocalFileName,\n ModelProps,\n RelationshipProps,\n} from \"@itwin/core-common\";\nimport { IModelConnection, SnapshotConnection } from \"@itwin/core-frontend\";\nimport { getTestOutputDir } from \"./Helpers\";\n\n/**\n * Interface for IModel builder pattern. Used for building IModels to test rulesets.\n * @beta\n */\nexport interface TestIModelBuilder {\n /** Insert a model into the builder's iModel */\n insertModel<TProps extends ModelProps>(props: TProps): Id64String;\n /** Insert an element into the builder's iModel */\n insertElement<TProps extends ElementProps>(props: TProps): Id64String;\n /** Insert an element aspect into the specified element */\n insertAspect<TProps extends ElementAspectProps>(props: TProps): Id64String;\n /**\n * Insert a relationship between two instances. The relationship is expected to be a subclass\n * of `BisCore:ElementRefersToElements` or `BisCore:ElementDrivesElement`.\n */\n insertRelationship<TProps extends RelationshipProps>(props: TProps): Id64String;\n /**\n * Create code for specified element.\n * Code value has to be unique within its scope (see [Codes documentation page]($docs/bis/guide/fundamentals/codes.md)).\n */\n createCode(scopeModelId: CodeScopeProps, codeSpecName: BisCodeSpec, codeValue: string): Code;\n /**\n * Import an ECSchema in a form of XML string into the builder's iModel.\n */\n importSchema(schemaXml: string): Promise<void>;\n}\n\n/**\n * Function that creates an iModel and returns a connection to it.\n * @param name Name of test IModel\n * @param cb Callback function that receives an [[TestIModelBuilder]] to fill the iModel with data\n * @beta\n * @deprecated in 4.x. Use an overload with `cb` returning a promise.\n */\nexport async function buildTestIModel(name: string, cb: (builder: TestIModelBuilder) => void): Promise<IModelConnection>;\n/**\n * Function that creates an iModel and returns a connection to it.\n * @param name Name of test IModel\n * @param cb Callback function that receives an [[TestIModelBuilder]] to fill the iModel with data\n * @beta\n */\n// eslint-disable-next-line @typescript-eslint/unified-signatures\nexport async function buildTestIModel(name: string, cb: (builder: TestIModelBuilder) => Promise<void>): Promise<IModelConnection>;\n/**\n * Function that creates an iModel and returns a connection to it.\n * @param mochaContext Mocha context to generate iModel name from\n * @param cb Callback function that receives an [[TestIModelBuilder]] to fill the iModel with data\n * @beta\n * @deprecated in 4.x. Use an overload with `cb` returning a promise.\n */\n// eslint-disable-next-line @typescript-eslint/unified-signatures\nexport async function buildTestIModel(mochaContext: Mocha.Context, cb: (builder: TestIModelBuilder) => void): Promise<IModelConnection>;\n/**\n * Function that creates an iModel and returns a connection to it.\n * @param mochaContext Mocha context to generate iModel name from\n * @param cb Callback function that receives an [[TestIModelBuilder]] to fill the iModel with data\n * @beta\n */\n// eslint-disable-next-line @typescript-eslint/unified-signatures\nexport async function buildTestIModel(mochaContext: Mocha.Context, cb: (builder: TestIModelBuilder) => Promise<void>): Promise<IModelConnection>;\nexport async function buildTestIModel(nameParam: string | Mocha.Context, cb: (builder: TestIModelBuilder) => void | Promise<void>): Promise<IModelConnection> {\n const name = typeof nameParam === \"string\" ? nameParam : createFileNameFromString(nameParam.test!.fullTitle());\n const outputFile = setupOutputFileLocation(name);\n const db = SnapshotDb.createEmpty(outputFile, { rootSubject: { name } });\n const builder = new IModelBuilder(db);\n try {\n await cb(builder);\n } finally {\n db.saveChanges(\"Created test IModel\");\n db.close();\n }\n return SnapshotConnection.openFile(outputFile);\n}\n\n/**\n * Default implementation of IModel builder pattern. Used for building IModels to test rulesets.\n *\n * @internal\n */\nexport class IModelBuilder implements TestIModelBuilder {\n private _iModel: IModelDb;\n\n constructor(iModel: IModelDb) {\n this._iModel = iModel;\n }\n\n public insertModel<TProps extends ModelProps>(props: TProps): Id64String {\n return this._iModel.models.insertModel(props);\n }\n\n public insertElement<TProps extends ElementProps>(props: TProps): Id64String {\n return this._iModel.elements.insertElement(props);\n }\n\n public insertAspect<TProps extends ElementAspectProps>(props: TProps): Id64String {\n return this._iModel.elements.insertAspect(props);\n }\n\n public insertRelationship<TProps extends RelationshipProps>(props: TProps): Id64String {\n return this._iModel.relationships.insertInstance(props);\n }\n\n public createCode(scopeModelId: CodeScopeProps, codeSpecName: BisCodeSpec, codeValue: string): Code {\n const codeSpec: CodeSpec = this._iModel.codeSpecs.getByName(codeSpecName);\n return new Code({ spec: codeSpec.id, scope: scopeModelId, value: codeValue });\n }\n\n public async importSchema(schemaXml: string) {\n await this._iModel.importSchemaStrings([schemaXml]);\n }\n}\n\n/**\n * Prepare for an output file by:\n * - Resolving the output file name under the known test output directory\n * - Making directories as necessary\n * - Removing a previous copy of the output file\n * @param fileName Name of output file\n */\nfunction setupOutputFileLocation(fileName: string): LocalFileName {\n const testOutputDir = getTestOutputDir();\n !IModelJsFs.existsSync(testOutputDir) && IModelJsFs.mkdirSync(testOutputDir);\n\n const outputFile = path.join(testOutputDir, `${fileName}.bim`);\n IModelJsFs.existsSync(outputFile) && IModelJsFs.unlinkSync(outputFile);\n return outputFile;\n}\n\n/** @internal */\nexport function createFileNameFromString(str: string) {\n return sanitize(str.replace(/[ ]+/g, \"-\")).toLocaleLowerCase();\n}\n"]}
|
|
@@ -27,21 +27,41 @@ export interface TestIModelBuilder {
|
|
|
27
27
|
* Code value has to be unique within its scope (see [Codes documentation page]($docs/bis/guide/fundamentals/codes.md)).
|
|
28
28
|
*/
|
|
29
29
|
createCode(scopeModelId: CodeScopeProps, codeSpecName: BisCodeSpec, codeValue: string): Code;
|
|
30
|
+
/**
|
|
31
|
+
* Import an ECSchema in a form of XML string into the builder's iModel.
|
|
32
|
+
*/
|
|
33
|
+
importSchema(schemaXml: string): Promise<void>;
|
|
30
34
|
}
|
|
31
35
|
/**
|
|
32
36
|
* Function that creates an iModel and returns a connection to it.
|
|
33
37
|
* @param name Name of test IModel
|
|
34
38
|
* @param cb Callback function that receives an [[TestIModelBuilder]] to fill the iModel with data
|
|
35
39
|
* @beta
|
|
40
|
+
* @deprecated in 4.x. Use an overload with `cb` returning a promise.
|
|
36
41
|
*/
|
|
37
42
|
export declare function buildTestIModel(name: string, cb: (builder: TestIModelBuilder) => void): Promise<IModelConnection>;
|
|
43
|
+
/**
|
|
44
|
+
* Function that creates an iModel and returns a connection to it.
|
|
45
|
+
* @param name Name of test IModel
|
|
46
|
+
* @param cb Callback function that receives an [[TestIModelBuilder]] to fill the iModel with data
|
|
47
|
+
* @beta
|
|
48
|
+
*/
|
|
49
|
+
export declare function buildTestIModel(name: string, cb: (builder: TestIModelBuilder) => Promise<void>): Promise<IModelConnection>;
|
|
38
50
|
/**
|
|
39
51
|
* Function that creates an iModel and returns a connection to it.
|
|
40
52
|
* @param mochaContext Mocha context to generate iModel name from
|
|
41
53
|
* @param cb Callback function that receives an [[TestIModelBuilder]] to fill the iModel with data
|
|
42
54
|
* @beta
|
|
55
|
+
* @deprecated in 4.x. Use an overload with `cb` returning a promise.
|
|
43
56
|
*/
|
|
44
57
|
export declare function buildTestIModel(mochaContext: Mocha.Context, cb: (builder: TestIModelBuilder) => void): Promise<IModelConnection>;
|
|
58
|
+
/**
|
|
59
|
+
* Function that creates an iModel and returns a connection to it.
|
|
60
|
+
* @param mochaContext Mocha context to generate iModel name from
|
|
61
|
+
* @param cb Callback function that receives an [[TestIModelBuilder]] to fill the iModel with data
|
|
62
|
+
* @beta
|
|
63
|
+
*/
|
|
64
|
+
export declare function buildTestIModel(mochaContext: Mocha.Context, cb: (builder: TestIModelBuilder) => Promise<void>): Promise<IModelConnection>;
|
|
45
65
|
/**
|
|
46
66
|
* Default implementation of IModel builder pattern. Used for building IModels to test rulesets.
|
|
47
67
|
*
|
|
@@ -55,6 +75,7 @@ export declare class IModelBuilder implements TestIModelBuilder {
|
|
|
55
75
|
insertAspect<TProps extends ElementAspectProps>(props: TProps): Id64String;
|
|
56
76
|
insertRelationship<TProps extends RelationshipProps>(props: TProps): Id64String;
|
|
57
77
|
createCode(scopeModelId: CodeScopeProps, codeSpecName: BisCodeSpec, codeValue: string): Code;
|
|
78
|
+
importSchema(schemaXml: string): Promise<void>;
|
|
58
79
|
}
|
|
59
80
|
/** @internal */
|
|
60
81
|
export declare function createFileNameFromString(str: string): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IModelUtilities.d.ts","sourceRoot":"","sources":["../../../src/presentation-testing/IModelUtilities.ts"],"names":[],"mappings":"AAIA;;GAEG;;AAIH,OAAO,EAAE,QAAQ,EAA0B,MAAM,qBAAqB,CAAC;AACvE,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EACL,WAAW,EACX,IAAI,EACJ,cAAc,EAEd,kBAAkB,EAClB,YAAY,EAEZ,UAAU,EACV,iBAAiB,EAClB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,gBAAgB,EAAsB,MAAM,sBAAsB,CAAC;AAG5E;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC,+CAA+C;IAC/C,WAAW,CAAC,MAAM,SAAS,UAAU,EAAE,KAAK,EAAE,MAAM,GAAG,UAAU,CAAC;IAClE,kDAAkD;IAClD,aAAa,CAAC,MAAM,SAAS,YAAY,EAAE,KAAK,EAAE,MAAM,GAAG,UAAU,CAAC;IACtE,0DAA0D;IAC1D,YAAY,CAAC,MAAM,SAAS,kBAAkB,EAAE,KAAK,EAAE,MAAM,GAAG,UAAU,CAAC;IAC3E;;;OAGG;IACH,kBAAkB,CAAC,MAAM,SAAS,iBAAiB,EAAE,KAAK,EAAE,MAAM,GAAG,UAAU,CAAC;IAChF;;;OAGG;IACH,UAAU,CAAC,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"IModelUtilities.d.ts","sourceRoot":"","sources":["../../../src/presentation-testing/IModelUtilities.ts"],"names":[],"mappings":"AAIA;;GAEG;;AAIH,OAAO,EAAE,QAAQ,EAA0B,MAAM,qBAAqB,CAAC;AACvE,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OA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O,EAAE,iBAAiB,KAAK,IAAI,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;AACxI;;;;;GAKG;AAEH,wBAAsB,eAAe,CAAC,YAAY,EAAE,KAAK,CAAC,OAAO,EAAE,EAAE,EAAE,CAAC,OAAO,EAAE,iBAAiB,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;AAejJ;;;;GAIG;AACH,qBAAa,aAAc,YAAW,iBAAiB;IACrD,OAAO,CAAC,OAAO,CAAW;gBAEd,MAAM,EAAE,QAAQ;IAIrB,WAAW,CAAC,MAAM,SAAS,UAAU,EAAE,KAAK,EAAE,MAAM,GAAG,UAAU;IAIjE,aAAa,CAAC,MAAM,SAAS,YAAY,EAAE,KAAK,EAAE,MAAM,GAAG,UAAU;IAIrE,YAAY,CAAC,MAAM,SAAS,kBAAkB,EAAE,KAAK,EAAE,MAAM,GAAG,UAAU;IAI1E,kBAAkB,CAAC,MAAM,SAAS,iBAAiB,EAAE,KAAK,EAAE,MAAM,GAAG,UAAU;IAI/E,UAAU,CAAC,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI;IAKtF,YAAY,CAAC,SAAS,EAAE,MAAM;CAG5C;AAkBD,gBAAgB;AAChB,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,MAAM,UAEnD"}
|
|
@@ -17,7 +17,7 @@ export async function buildTestIModel(nameParam, cb) {
|
|
|
17
17
|
const db = SnapshotDb.createEmpty(outputFile, { rootSubject: { name } });
|
|
18
18
|
const builder = new IModelBuilder(db);
|
|
19
19
|
try {
|
|
20
|
-
cb(builder);
|
|
20
|
+
await cb(builder);
|
|
21
21
|
}
|
|
22
22
|
finally {
|
|
23
23
|
db.saveChanges("Created test IModel");
|
|
@@ -56,6 +56,9 @@ export class IModelBuilder {
|
|
|
56
56
|
const codeSpec = this._iModel.codeSpecs.getByName(codeSpecName);
|
|
57
57
|
return new Code({ spec: codeSpec.id, scope: scopeModelId, value: codeValue });
|
|
58
58
|
}
|
|
59
|
+
async importSchema(schemaXml) {
|
|
60
|
+
await this._iModel.importSchemaStrings([schemaXml]);
|
|
61
|
+
}
|
|
59
62
|
}
|
|
60
63
|
/**
|
|
61
64
|
* Prepare for an output file by:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IModelUtilities.js","sourceRoot":"","sources":["../../../src/presentation-testing/IModelUtilities.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,QAAQ,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAY,UAAU,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEvE,OAAO,EAEL,IAAI,GAQL,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAoB,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC5E,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"IModelUtilities.js","sourceRoot":"","sources":["../../../src/presentation-testing/IModelUtilities.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,QAAQ,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAY,UAAU,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEvE,OAAO,EAEL,IAAI,GAQL,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAoB,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC5E,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AA8D7C,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,SAAiC,EAAE,EAAwD;IAC/H,MAAM,IAAI,GAAG,OAAO,SAAS,KAAK,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,wBAAwB,CA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AAC,YAAY,CAAC,CAAC;QAC1E,OAAO,IAAI,IAAI,CAAC,EAAE,IAAI,EAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;IAChF,CAAC;IAEM,KAAK,CAAC,YAAY,CAAC,SAAiB;QACzC,MAAM,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;IACtD,CAAC;CACF;AAED;;;;;;GAMG;AACH,SAAS,uBAAuB,CAAC,QAAgB;IAC/C,MAAM,aAAa,GAAG,gBAAgB,EAAE,CAAC;IACzC,CAAC,UAAU,CAAC,UAAU,CAAC,aAAa,CAAC,IAAI,UAAU,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC;IAE7E,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,GAAG,QAAQ,MAAM,CAAC,CAAC;IAC/D,UAAU,CAAC,UAAU,CAAC,UAAU,CAAC,IAAI,UAAU,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;IACvE,OAAO,UAAU,CAAC;AACpB,CAAC;AAED,gBAAgB;AAChB,MAAM,UAAU,wBAAwB,CAAC,GAAW;IAClD,OAAO,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC,iBAAiB,EAAE,CAAC;AACjE,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module IModel\n */\n\nimport path from \"path\";\nimport sanitize from \"sanitize-filename\";\nimport { IModelDb, IModelJsFs, SnapshotDb } from \"@itwin/core-backend\";\nimport { Id64String } from \"@itwin/core-bentley\";\nimport {\n BisCodeSpec,\n Code,\n CodeScopeProps,\n CodeSpec,\n ElementAspectProps,\n ElementProps,\n LocalFileName,\n ModelProps,\n RelationshipProps,\n} from \"@itwin/core-common\";\nimport { IModelConnection, SnapshotConnection } from \"@itwin/core-frontend\";\nimport { getTestOutputDir } from \"./Helpers\";\n\n/**\n * Interface for IModel builder pattern. Used for building IModels to test rulesets.\n * @beta\n */\nexport interface TestIModelBuilder {\n /** Insert a model into the builder's iModel */\n insertModel<TProps extends ModelProps>(props: TProps): Id64String;\n /** Insert an element into the builder's iModel */\n insertElement<TProps extends ElementProps>(props: TProps): Id64String;\n /** Insert an element aspect into the specified element */\n insertAspect<TProps extends ElementAspectProps>(props: TProps): Id64String;\n /**\n * Insert a relationship between two instances. The relationship is expected to be a subclass\n * of `BisCore:ElementRefersToElements` or `BisCore:ElementDrivesElement`.\n */\n insertRelationship<TProps extends RelationshipProps>(props: TProps): Id64String;\n /**\n * Create code for specified element.\n * Code value has to be unique within its scope (see [Codes documentation page]($docs/bis/guide/fundamentals/codes.md)).\n */\n createCode(scopeModelId: CodeScopeProps, codeSpecName: BisCodeSpec, codeValue: string): Code;\n /**\n * Import an ECSchema in a form of XML string into the builder's iModel.\n */\n importSchema(schemaXml: string): Promise<void>;\n}\n\n/**\n * Function that creates an iModel and returns a connection to it.\n * @param name Name of test IModel\n * @param cb Callback function that receives an [[TestIModelBuilder]] to fill the iModel with data\n * @beta\n * @deprecated in 4.x. Use an overload with `cb` returning a promise.\n */\nexport async function buildTestIModel(name: string, cb: (builder: TestIModelBuilder) => void): Promise<IModelConnection>;\n/**\n * Function that creates an iModel and returns a connection to it.\n * @param name Name of test IModel\n * @param cb Callback function that receives an [[TestIModelBuilder]] to fill the iModel with data\n * @beta\n */\n// eslint-disable-next-line @typescript-eslint/unified-signatures\nexport async function buildTestIModel(name: string, cb: (builder: TestIModelBuilder) => Promise<void>): Promise<IModelConnection>;\n/**\n * Function that creates an iModel and returns a connection to it.\n * @param mochaContext Mocha context to generate iModel name from\n * @param cb Callback function that receives an [[TestIModelBuilder]] to fill the iModel with data\n * @beta\n * @deprecated in 4.x. Use an overload with `cb` returning a promise.\n */\n// eslint-disable-next-line @typescript-eslint/unified-signatures\nexport async function buildTestIModel(mochaContext: Mocha.Context, cb: (builder: TestIModelBuilder) => void): Promise<IModelConnection>;\n/**\n * Function that creates an iModel and returns a connection to it.\n * @param mochaContext Mocha context to generate iModel name from\n * @param cb Callback function that receives an [[TestIModelBuilder]] to fill the iModel with data\n * @beta\n */\n// eslint-disable-next-line @typescript-eslint/unified-signatures\nexport async function buildTestIModel(mochaContext: Mocha.Context, cb: (builder: TestIModelBuilder) => Promise<void>): Promise<IModelConnection>;\nexport async function buildTestIModel(nameParam: string | Mocha.Context, cb: (builder: TestIModelBuilder) => void | Promise<void>): Promise<IModelConnection> {\n const name = typeof nameParam === \"string\" ? nameParam : createFileNameFromString(nameParam.test!.fullTitle());\n const outputFile = setupOutputFileLocation(name);\n const db = SnapshotDb.createEmpty(outputFile, { rootSubject: { name } });\n const builder = new IModelBuilder(db);\n try {\n await cb(builder);\n } finally {\n db.saveChanges(\"Created test IModel\");\n db.close();\n }\n return SnapshotConnection.openFile(outputFile);\n}\n\n/**\n * Default implementation of IModel builder pattern. Used for building IModels to test rulesets.\n *\n * @internal\n */\nexport class IModelBuilder implements TestIModelBuilder {\n private _iModel: IModelDb;\n\n constructor(iModel: IModelDb) {\n this._iModel = iModel;\n }\n\n public insertModel<TProps extends ModelProps>(props: TProps): Id64String {\n return this._iModel.models.insertModel(props);\n }\n\n public insertElement<TProps extends ElementProps>(props: TProps): Id64String {\n return this._iModel.elements.insertElement(props);\n }\n\n public insertAspect<TProps extends ElementAspectProps>(props: TProps): Id64String {\n return this._iModel.elements.insertAspect(props);\n }\n\n public insertRelationship<TProps extends RelationshipProps>(props: TProps): Id64String {\n return this._iModel.relationships.insertInstance(props);\n }\n\n public createCode(scopeModelId: CodeScopeProps, codeSpecName: BisCodeSpec, codeValue: string): Code {\n const codeSpec: CodeSpec = this._iModel.codeSpecs.getByName(codeSpecName);\n return new Code({ spec: codeSpec.id, scope: scopeModelId, value: codeValue });\n }\n\n public async importSchema(schemaXml: string) {\n await this._iModel.importSchemaStrings([schemaXml]);\n }\n}\n\n/**\n * Prepare for an output file by:\n * - Resolving the output file name under the known test output directory\n * - Making directories as necessary\n * - Removing a previous copy of the output file\n * @param fileName Name of output file\n */\nfunction setupOutputFileLocation(fileName: string): LocalFileName {\n const testOutputDir = getTestOutputDir();\n !IModelJsFs.existsSync(testOutputDir) && IModelJsFs.mkdirSync(testOutputDir);\n\n const outputFile = path.join(testOutputDir, `${fileName}.bim`);\n IModelJsFs.existsSync(outputFile) && IModelJsFs.unlinkSync(outputFile);\n return outputFile;\n}\n\n/** @internal */\nexport function createFileNameFromString(str: string) {\n return sanitize(str.replace(/[ ]+/g, \"-\")).toLocaleLowerCase();\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itwin/presentation-testing",
|
|
3
|
-
"version": "4.0
|
|
3
|
+
"version": "4.1.0",
|
|
4
4
|
"description": "Testing utilities for iTwin.js Presentation library",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -21,24 +21,10 @@
|
|
|
21
21
|
"main": "lib/cjs/presentation-testing.js",
|
|
22
22
|
"module": "lib/esm/presentation-testing.js",
|
|
23
23
|
"types": "lib/cjs/presentation-testing.d.ts",
|
|
24
|
-
"scripts": {
|
|
25
|
-
"build": "npm run -s build:cjs && npm run -s build:esm",
|
|
26
|
-
"build:cjs": "tsc -p tsconfig.cjs.json",
|
|
27
|
-
"build:esm": "tsc -p tsconfig.esm.json",
|
|
28
|
-
"build:watch": "npm run -s build:cjs -- -w",
|
|
29
|
-
"clean": "rimraf lib",
|
|
30
|
-
"cover": "nyc npm -s test",
|
|
31
|
-
"docs": "npm run -s docs:reference && npm run -s docs:changelog",
|
|
32
|
-
"docs:changelog": "cpx ./CHANGELOG.md ../../build/docs/reference/presentation-testing",
|
|
33
|
-
"docs:reference": "betools docs --includes=../../build/docs/extract --json=../../build/docs/reference/presentation-testing/file.json --tsIndexFile=presentation-testing.ts --onlyJson --testExcludeGlob=./src/test/**",
|
|
34
|
-
"lint": "eslint ./src/**/*.ts",
|
|
35
|
-
"test": "mocha --config ./.mocharc.json \"./lib/cjs/test/**/*.test.js\"",
|
|
36
|
-
"extract-api": "betools extract-api --entry=presentation-testing --apiReportFolder=./api --apiReportTempFolder=./api/temp --apiSummaryFolder=./api"
|
|
37
|
-
},
|
|
38
24
|
"dependencies": {
|
|
39
|
-
"@itwin/presentation-components": "4.2.0",
|
|
40
25
|
"rimraf": "^5.0.1",
|
|
41
|
-
"sanitize-filename": "^1.6.3"
|
|
26
|
+
"sanitize-filename": "^1.6.3",
|
|
27
|
+
"@itwin/presentation-components": "4.2.1"
|
|
42
28
|
},
|
|
43
29
|
"peerDependencies": {
|
|
44
30
|
"@itwin/appui-abstract": "^3.6.3 || ^4.0.0",
|
|
@@ -92,5 +78,19 @@
|
|
|
92
78
|
"sinon-chai": "^3.7.0",
|
|
93
79
|
"typemoq": "^2.1.0",
|
|
94
80
|
"typescript": "~5.0.4"
|
|
81
|
+
},
|
|
82
|
+
"scripts": {
|
|
83
|
+
"build": "npm run -s build:cjs && npm run -s build:esm",
|
|
84
|
+
"build:cjs": "tsc -p tsconfig.cjs.json",
|
|
85
|
+
"build:esm": "tsc -p tsconfig.esm.json",
|
|
86
|
+
"build:watch": "npm run -s build:cjs -- -w",
|
|
87
|
+
"clean": "rimraf lib build",
|
|
88
|
+
"cover": "nyc npm -s test",
|
|
89
|
+
"docs": "npm run -s docs:reference && npm run -s docs:changelog",
|
|
90
|
+
"docs:changelog": "cpx ./CHANGELOG.md ./build/docs/reference/presentation-testing",
|
|
91
|
+
"docs:reference": "betools docs --includes=./build/docs/extract --json=./build/docs/reference/presentation-testing/file.json --tsIndexFile=presentation-testing.ts --onlyJson --testExcludeGlob=./src/test/**",
|
|
92
|
+
"lint": "eslint ./src/**/*.ts",
|
|
93
|
+
"test": "mocha --config ./.mocharc.json \"./lib/cjs/test/**/*.test.js\"",
|
|
94
|
+
"extract-api": "betools extract-api --entry=presentation-testing --apiReportFolder=./api --apiReportTempFolder=./api/temp --apiSummaryFolder=./api"
|
|
95
95
|
}
|
|
96
|
-
}
|
|
96
|
+
}
|