@itwin/presentation-testing 4.0.0-dev.11 → 4.0.0-dev.12
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/LICENSE.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# MIT License
|
|
2
2
|
|
|
3
|
-
Copyright © 2017-
|
|
3
|
+
Copyright © 2017-2023 Bentley Systems, Incorporated. All rights reserved.
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
6
|
|
|
@@ -53,10 +53,10 @@ function initializeRpcInterfaces(interfaces) {
|
|
|
53
53
|
}
|
|
54
54
|
};
|
|
55
55
|
for (const definition of interfaces)
|
|
56
|
-
core_common_1.RpcConfiguration.assign(definition, () => config);
|
|
57
|
-
const instance = core_common_1.RpcConfiguration.obtain(config);
|
|
56
|
+
core_common_1.RpcConfiguration.assign(definition, () => config); // eslint-disable-line @itwin/no-internal
|
|
57
|
+
const instance = core_common_1.RpcConfiguration.obtain(config); // eslint-disable-line @itwin/no-internal
|
|
58
58
|
try {
|
|
59
|
-
core_common_1.RpcConfiguration.initializeInterfaces(instance);
|
|
59
|
+
core_common_1.RpcConfiguration.initializeInterfaces(instance); // eslint-disable-line @itwin/no-internal
|
|
60
60
|
}
|
|
61
61
|
catch {
|
|
62
62
|
// this may fail with "Error: RPC interface "xxx" is already initialized." because
|
|
@@ -89,8 +89,8 @@ const initialize = async (props) => {
|
|
|
89
89
|
// init backend
|
|
90
90
|
// make sure backend gets assigned an id which puts its resources into a unique directory
|
|
91
91
|
props.backendProps = props.backendProps ?? {};
|
|
92
|
-
if (!props.backendProps.id)
|
|
93
|
-
props.backendProps.id = `test-${core_bentley_1.Guid.createValue()}`;
|
|
92
|
+
if (!props.backendProps.id) // eslint-disable-line @itwin/no-internal
|
|
93
|
+
props.backendProps.id = `test-${core_bentley_1.Guid.createValue()}`; // eslint-disable-line @itwin/no-internal
|
|
94
94
|
await core_backend_1.IModelHost.startup({ cacheDir: (0, path_1.join)(__dirname, ".cache"), ...props.backendHostProps });
|
|
95
95
|
presentation_backend_1.Presentation.initialize(props.backendProps);
|
|
96
96
|
// init frontend
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Helpers.js","sourceRoot":"","sources":["../../../src/presentation-testing/Helpers.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;;;;;;;;;;;;;;;;;;;;AAEH,0BAA0B,CAAE,uGAAuG;AAEnI,2BAA4B;AAC5B,+BAA4B;AAC5B,+CAAiC;AACjC,sDAAoE;AACpE,sDAA2C;AAC3C,oDAE4B;AAC5B,wDAAgF;AAChF,sEAEqC;AAiC5B,mGAlCP,yCAAkB,OAkCO;AAAE,wGAlCoF,8CAAuB,OAkCpF;AAhCpD,oEAAsE;AACtE,wEAAoI;AAEpI,SAAS,uBAAuB,CAAC,UAAoC;IACnE,MAAM,MAAM,GAAG,KAAM,SAAQ,qCAAuB;QAArC;;YACb;;;;uBAAkC,GAAG,EAAE,CAAC,UAAU;eAAC;QACrD,CAAC;KAAA,CAAC;IAEF,KAAK,MAAM,UAAU,IAAI,UAAU;QACjC,8BAAgB,CAAC,MAAM,CAAC,UAAU,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"Helpers.js","sourceRoot":"","sources":["../../../src/presentation-testing/Helpers.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;;;;;;;;;;;;;;;;;;;;AAEH,0BAA0B,CAAE,uGAAuG;AAEnI,2BAA4B;AAC5B,+BAA4B;AAC5B,+CAAiC;AACjC,sDAAoE;AACpE,sDAA2C;AAC3C,oDAE4B;AAC5B,wDAAgF;AAChF,sEAEqC;AAi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AAS,CAAC;SAC3D,IAAI,sBAAsB,EAAE,IAAI,KAAK,yCAAkB,CAAC,MAAM;QACjE,yBAAyB,GAAG,sBAAsB,EAAE,IAAI,EAAE,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":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Helpers\n */\n\n/* istanbul ignore file */ // TODO: Remove istanbul ignore file when https://github.com/iTwin/itwinjs-backlog/issues/463 is fixed.\n\nimport { tmpdir } from \"os\";\nimport { join } from \"path\";\nimport * as rimraf from \"rimraf\";\nimport { IModelHost, IModelHostOptions } from \"@itwin/core-backend\";\nimport { Guid } from \"@itwin/core-bentley\";\nimport {\n IModelReadRpcInterface, RpcConfiguration, RpcDefaultConfiguration, RpcInterfaceDefinition, SnapshotIModelRpcInterface,\n} from \"@itwin/core-common\";\nimport { IModelApp, IModelAppOptions, NoRenderApp } from \"@itwin/core-frontend\";\nimport {\n HierarchyCacheMode, Presentation as PresentationBackend, PresentationManagerProps as PresentationBackendProps, PresentationManagerMode,\n} from \"@itwin/presentation-backend\";\nimport { PresentationRpcInterface } from \"@itwin/presentation-common\";\nimport { Presentation as PresentationFrontend, PresentationProps as PresentationFrontendProps } from \"@itwin/presentation-frontend\";\n\nfunction initializeRpcInterfaces(interfaces: RpcInterfaceDefinition[]) {\n const config = class extends RpcDefaultConfiguration {\n public override interfaces: any = () => interfaces;\n };\n\n for (const definition of interfaces)\n RpcConfiguration.assign(definition, () => config); // eslint-disable-line @itwin/no-internal\n\n const instance = RpcConfiguration.obtain(config); // eslint-disable-line @itwin/no-internal\n\n try {\n RpcConfiguration.initializeInterfaces(instance); // eslint-disable-line @itwin/no-internal\n } catch {\n // this may fail with \"Error: RPC interface \"xxx\" is already initialized.\" because\n // multiple different tests want to set up rpc interfaces\n }\n}\n\nlet isInitialized = false;\n\nconst defaultTestOutputDir = tmpdir();\nlet testOutputDir: string | undefined;\n\n/** @internal */\nexport const getTestOutputDir = (): string => {\n return testOutputDir ?? defaultTestOutputDir;\n};\n\n// eslint-disable-next-line deprecation/deprecation\nexport { HierarchyCacheMode, PresentationManagerMode, PresentationBackendProps };\n\n/** @public */\nexport interface PresentationTestingInitProps {\n /** Properties for backend initialization */\n backendProps?: PresentationBackendProps;\n /** Properties for `IModelHost` */\n backendHostProps?: IModelHostOptions;\n /** Properties for frontend initialization */\n frontendProps?: PresentationFrontendProps;\n /** IModelApp implementation */\n frontendApp?: { startup: (opts?: IModelAppOptions) => Promise<void> };\n /** `IModelApp` options */\n frontendAppOptions?: IModelAppOptions;\n /** Custom test output directory. Defaults to temporary directory provided by the OS. */\n testOutputDir?: string;\n}\n\n/**\n * Initialize the framework for presentation testing. The function sets up backend,\n * frontend and RPC communication between them.\n *\n * @see `terminate`\n *\n * @public\n */\nexport const initialize = async (props?: PresentationTestingInitProps) => {\n if (isInitialized)\n return;\n\n if (!props)\n props = {};\n\n // set up rpc interfaces\n initializeRpcInterfaces([SnapshotIModelRpcInterface, IModelReadRpcInterface, PresentationRpcInterface]);\n\n // init backend\n // make sure backend gets assigned an id which puts its resources into a unique directory\n props.backendProps = props.backendProps ?? {};\n if (!props.backendProps.id) // eslint-disable-line @itwin/no-internal\n props.backendProps.id = `test-${Guid.createValue()}`; // eslint-disable-line @itwin/no-internal\n await IModelHost.startup({ cacheDir: join(__dirname, \".cache\"), ...props.backendHostProps });\n PresentationBackend.initialize(props.backendProps);\n\n // init frontend\n if (!props.frontendApp)\n props.frontendApp = NoRenderApp;\n await props.frontendApp.startup(props.frontendAppOptions);\n const defaultFrontendProps: PresentationFrontendProps = {\n presentation: {\n activeLocale: IModelApp.localization.getLanguageList()[0],\n },\n };\n await PresentationFrontend.initialize({ ...defaultFrontendProps, ...props.frontendProps });\n testOutputDir = props.testOutputDir;\n\n isInitialized = true;\n};\n\n/**\n * Undoes the setup made by `initialize`.\n * @param frontendApp IModelApp implementation\n *\n * @see `initialize`\n *\n * @public\n */\nexport const terminate = async (frontendApp = IModelApp) => {\n if (!isInitialized)\n return;\n\n // store directory that needs to be cleaned-up\n let hierarchiesCacheDirectory: string | undefined;\n const hierarchiesCacheConfig = PresentationBackend.initProps?.caching?.hierarchies;\n if (hierarchiesCacheConfig?.mode === HierarchyCacheMode.Disk)\n hierarchiesCacheDirectory = hierarchiesCacheConfig?.directory;\n else if (hierarchiesCacheConfig?.mode === HierarchyCacheMode.Hybrid)\n hierarchiesCacheDirectory = hierarchiesCacheConfig?.disk?.directory;\n\n // terminate backend\n PresentationBackend.terminate();\n await IModelHost.shutdown();\n if (hierarchiesCacheDirectory)\n rimraf.sync(hierarchiesCacheDirectory);\n\n // terminate frontend\n PresentationFrontend.terminate();\n await frontendApp.shutdown();\n\n isInitialized = false;\n};\n"]}
|
|
@@ -29,10 +29,10 @@ function initializeRpcInterfaces(interfaces) {
|
|
|
29
29
|
}
|
|
30
30
|
};
|
|
31
31
|
for (const definition of interfaces)
|
|
32
|
-
RpcConfiguration.assign(definition, () => config);
|
|
33
|
-
const instance = RpcConfiguration.obtain(config);
|
|
32
|
+
RpcConfiguration.assign(definition, () => config); // eslint-disable-line @itwin/no-internal
|
|
33
|
+
const instance = RpcConfiguration.obtain(config); // eslint-disable-line @itwin/no-internal
|
|
34
34
|
try {
|
|
35
|
-
RpcConfiguration.initializeInterfaces(instance);
|
|
35
|
+
RpcConfiguration.initializeInterfaces(instance); // eslint-disable-line @itwin/no-internal
|
|
36
36
|
}
|
|
37
37
|
catch {
|
|
38
38
|
// this may fail with "Error: RPC interface "xxx" is already initialized." because
|
|
@@ -66,8 +66,8 @@ export const initialize = async (props) => {
|
|
|
66
66
|
// init backend
|
|
67
67
|
// make sure backend gets assigned an id which puts its resources into a unique directory
|
|
68
68
|
props.backendProps = props.backendProps ?? {};
|
|
69
|
-
if (!props.backendProps.id)
|
|
70
|
-
props.backendProps.id = `test-${Guid.createValue()}`;
|
|
69
|
+
if (!props.backendProps.id) // eslint-disable-line @itwin/no-internal
|
|
70
|
+
props.backendProps.id = `test-${Guid.createValue()}`; // eslint-disable-line @itwin/no-internal
|
|
71
71
|
await IModelHost.startup({ cacheDir: join(__dirname, ".cache"), ...props.backendHostProps });
|
|
72
72
|
PresentationBackend.initialize(props.backendProps);
|
|
73
73
|
// init frontend
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Helpers.js","sourceRoot":"","sources":["../../../src/presentation-testing/Helpers.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,0BAA0B,CAAE,uGAAuG;AAEnI,OAAO,EAAE,MAAM,EAAE,MAAM,IAAI,CAAC;AAC5B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,EAAE,UAAU,EAAqB,MAAM,qBAAqB,CAAC;AACpE,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAC3C,OAAO,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;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;IAEtE,oBAAoB;IACpB,mBAAmB,CAAC,SAAS,EAAE,CAAC;IAChC,MAAM,UAAU,CAAC,QAAQ,EAAE,CAAC;IAC5B,IAAI,yBAAyB;QAC3B,MAAM,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC;IAEzC,qBAAqB;IACrB,oBAAoB,CAAC,SAAS,EAAE,CAAC;IACjC,MAAM,WAAW,CAAC,QAAQ,EAAE,CAAC;IAE7B,aAAa,GAAG,KAAK,CAAC;AACxB,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Helpers\n */\n\n/* istanbul ignore file */ // TODO: Remove istanbul ignore file when https://github.com/iTwin/itwinjs-backlog/issues/463 is fixed.\n\nimport { tmpdir } from \"os\";\nimport { join } from \"path\";\nimport * as rimraf from \"rimraf\";\nimport { IModelHost, IModelHostOptions } from \"@itwin/core-backend\";\nimport { Guid } from \"@itwin/core-bentley\";\nimport {\n IModelReadRpcInterface, RpcConfiguration, RpcDefaultConfiguration, RpcInterfaceDefinition, SnapshotIModelRpcInterface,\n} from \"@itwin/core-common\";\nimport { IModelApp, IModelAppOptions, NoRenderApp } from \"@itwin/core-frontend\";\nimport {\n HierarchyCacheMode, Presentation as PresentationBackend, PresentationManagerProps as PresentationBackendProps, PresentationManagerMode,\n} from \"@itwin/presentation-backend\";\nimport { PresentationRpcInterface } from \"@itwin/presentation-common\";\nimport { Presentation as PresentationFrontend, PresentationProps as PresentationFrontendProps } from \"@itwin/presentation-frontend\";\n\nfunction initializeRpcInterfaces(interfaces: RpcInterfaceDefinition[]) {\n const config = class extends RpcDefaultConfiguration {\n public override interfaces: any = () => interfaces;\n };\n\n for (const definition of interfaces)\n RpcConfiguration.assign(definition, () => config); // eslint-disable-line @itwin/no-internal\n\n const instance = RpcConfiguration.obtain(config); // eslint-disable-line @itwin/no-internal\n\n try {\n RpcConfiguration.initializeInterfaces(instance); // eslint-disable-line @itwin/no-internal\n } catch {\n // this may fail with \"Error: RPC interface \"xxx\" is already initialized.\" because\n // multiple different tests want to set up rpc interfaces\n }\n}\n\nlet isInitialized = false;\n\nconst defaultTestOutputDir = tmpdir();\nlet testOutputDir: string | undefined;\n\n/** @internal */\nexport const getTestOutputDir = (): string => {\n return testOutputDir ?? defaultTestOutputDir;\n};\n\n// eslint-disable-next-line deprecation/deprecation\nexport { HierarchyCacheMode, PresentationManagerMode, PresentationBackendProps };\n\n/** @public */\nexport interface PresentationTestingInitProps {\n /** Properties for backend initialization */\n backendProps?: PresentationBackendProps;\n /** Properties for `IModelHost` */\n backendHostProps?: IModelHostOptions;\n /** Properties for frontend initialization */\n frontendProps?: PresentationFrontendProps;\n /** IModelApp implementation */\n frontendApp?: { startup: (opts?: IModelAppOptions) => Promise<void> };\n /** `IModelApp` options */\n frontendAppOptions?: IModelAppOptions;\n /** Custom test output directory. Defaults to temporary directory provided by the OS. */\n testOutputDir?: string;\n}\n\n/**\n * Initialize the framework for presentation testing. The function sets up backend,\n * frontend and RPC communication between them.\n *\n * @see `terminate`\n *\n * @public\n */\nexport const initialize = async (props?: PresentationTestingInitProps) => {\n if (isInitialized)\n return;\n\n if (!props)\n props = {};\n\n // set up rpc interfaces\n initializeRpcInterfaces([SnapshotIModelRpcInterface, IModelReadRpcInterface, PresentationRpcInterface]);\n\n // init backend\n // make sure backend gets assigned an id which puts its resources into a unique directory\n props.backendProps = props.backendProps ?? {};\n if (!props.backendProps.id) // eslint-disable-line @itwin/no-internal\n props.backendProps.id = `test-${Guid.createValue()}`; // eslint-disable-line @itwin/no-internal\n await IModelHost.startup({ cacheDir: join(__dirname, \".cache\"), ...props.backendHostProps });\n PresentationBackend.initialize(props.backendProps);\n\n // init frontend\n if (!props.frontendApp)\n props.frontendApp = NoRenderApp;\n await props.frontendApp.startup(props.frontendAppOptions);\n const defaultFrontendProps: PresentationFrontendProps = {\n presentation: {\n activeLocale: IModelApp.localization.getLanguageList()[0],\n },\n };\n await PresentationFrontend.initialize({ ...defaultFrontendProps, ...props.frontendProps });\n testOutputDir = props.testOutputDir;\n\n isInitialized = true;\n};\n\n/**\n * Undoes the setup made by `initialize`.\n * @param frontendApp IModelApp implementation\n *\n * @see `initialize`\n *\n * @public\n */\nexport const terminate = async (frontendApp = IModelApp) => {\n if (!isInitialized)\n return;\n\n // store directory that needs to be cleaned-up\n let hierarchiesCacheDirectory: string | undefined;\n const hierarchiesCacheConfig = PresentationBackend.initProps?.caching?.hierarchies;\n if (hierarchiesCacheConfig?.mode === HierarchyCacheMode.Disk)\n hierarchiesCacheDirectory = hierarchiesCacheConfig?.directory;\n else if (hierarchiesCacheConfig?.mode === HierarchyCacheMode.Hybrid)\n hierarchiesCacheDirectory = hierarchiesCacheConfig?.disk?.directory;\n\n // terminate backend\n PresentationBackend.terminate();\n await IModelHost.shutdown();\n if (hierarchiesCacheDirectory)\n rimraf.sync(hierarchiesCacheDirectory);\n\n // terminate frontend\n PresentationFrontend.terminate();\n await frontendApp.shutdown();\n\n isInitialized = false;\n};\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itwin/presentation-testing",
|
|
3
|
-
"version": "4.0.0-dev.
|
|
3
|
+
"version": "4.0.0-dev.12",
|
|
4
4
|
"description": "Testing utilities for iTwin.js Presentation library",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"@itwin/presentation-backend": "^3.6.0 || ^4.0.0-dev.7",
|
|
47
47
|
"@itwin/presentation-common": "^3.6.0 || ^4.0.0-dev.7",
|
|
48
48
|
"@itwin/presentation-frontend": "^3.6.0 || ^4.0.0-dev.7",
|
|
49
|
-
"@itwin/presentation-components": "^4.0.0-dev.
|
|
49
|
+
"@itwin/presentation-components": "^4.0.0-dev.12"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@itwin/appui-abstract": "4.0.0-dev.3",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"@itwin/presentation-backend": "^4.0.0-dev.7",
|
|
65
65
|
"@itwin/presentation-common": "^4.0.0-dev.7",
|
|
66
66
|
"@itwin/presentation-frontend": "^4.0.0-dev.7",
|
|
67
|
-
"@itwin/presentation-components": "^4.0.0-dev.
|
|
67
|
+
"@itwin/presentation-components": "^4.0.0-dev.12",
|
|
68
68
|
"@itwin/webgl-compatibility": "^4.0.0-dev.7",
|
|
69
69
|
"@types/chai": "4.3.1",
|
|
70
70
|
"@types/chai-as-promised": "^7",
|