@open-pioneer/test-utils 4.3.0 → 4.4.0-dev-notifier-offsets.20260119130556
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 +16 -0
- package/package.json +6 -6
- package/react.js +8 -2
- package/react.js.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @open-pioneer/test-utils
|
|
2
2
|
|
|
3
|
+
## 4.4.0-dev-notifier-offsets.20260119130556
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- f9aaf46: Bump various dependencies
|
|
8
|
+
- 9c4ff00: Apply chakra theme correctly when rendering react components in (browser-) tests within the `PackageContextProvider`.
|
|
9
|
+
Previously, chakra components were actually unstyled.
|
|
10
|
+
- 554d58e: Use `workspace:*` instead of `workspace:^` for local package references as default. This ensures that trails packages from this repository are always referenced with their exact version to avoid potential issues with version mismatches. If a project specifically wants to use other versions for some trails packages, a pnpm override can be used to force other versions.
|
|
11
|
+
- Updated dependencies [f9aaf46]
|
|
12
|
+
- Updated dependencies [554d58e]
|
|
13
|
+
- Updated dependencies [1cc3415]
|
|
14
|
+
- Updated dependencies [1872a6d]
|
|
15
|
+
- Updated dependencies [84068f2]
|
|
16
|
+
- Updated dependencies [2f6f69e]
|
|
17
|
+
- @open-pioneer/runtime@4.4.0-dev-notifier-offsets.20260119130556
|
|
18
|
+
|
|
3
19
|
## 4.3.0
|
|
4
20
|
|
|
5
21
|
### Minor Changes
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@open-pioneer/test-utils",
|
|
4
|
-
"version": "4.
|
|
4
|
+
"version": "4.4.0-dev-notifier-offsets.20260119130556",
|
|
5
5
|
"description": "Contains test utilities that make it easier to test parts of an Open Pioneer Trails application.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"open-pioneer-trails"
|
|
@@ -14,12 +14,12 @@
|
|
|
14
14
|
"directory": "src/packages/test-utils"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@testing-library/react": "^16.3.
|
|
18
|
-
"react": "^19.2.
|
|
19
|
-
"react-dom": "^19.2.
|
|
17
|
+
"@testing-library/react": "^16.3.1",
|
|
18
|
+
"react": "^19.2.3",
|
|
19
|
+
"react-dom": "^19.2.3",
|
|
20
20
|
"@testing-library/dom": "^10.4.1",
|
|
21
|
-
"@formatjs/intl": "^
|
|
22
|
-
"@open-pioneer/runtime": "
|
|
21
|
+
"@formatjs/intl": "^4.0.9",
|
|
22
|
+
"@open-pioneer/runtime": "4.4.0-dev-notifier-offsets.20260119130556"
|
|
23
23
|
},
|
|
24
24
|
"exports": {
|
|
25
25
|
"./package.json": "./package.json",
|
package/react.js
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
|
-
import { CustomChakraProvider, PackageContext } from '@open-pioneer/runtime/test-support';
|
|
3
|
-
import { useMemo } from 'react';
|
|
2
|
+
import { APP_ROOT_CLASS, CustomChakraProvider, PackageContext } from '@open-pioneer/runtime/test-support';
|
|
3
|
+
import { useMemo, useInsertionEffect } from 'react';
|
|
4
4
|
import { createIntl } from './vanilla.js';
|
|
5
5
|
|
|
6
6
|
const PackageContextProvider = (props) => {
|
|
7
7
|
const { children, ...rest } = props;
|
|
8
8
|
const [locale, contextMethods] = useMemo(() => createPackageContextMethods(rest), [rest]);
|
|
9
|
+
useInsertionEffect(() => {
|
|
10
|
+
document.body.classList.add(APP_ROOT_CLASS);
|
|
11
|
+
return () => {
|
|
12
|
+
document.body.classList.remove(APP_ROOT_CLASS);
|
|
13
|
+
};
|
|
14
|
+
}, []);
|
|
9
15
|
return /* @__PURE__ */ jsx(CustomChakraProvider, { rootNode: document, appRoot: document.body, locale, children: /* @__PURE__ */ jsx(PackageContext.Provider, { value: contextMethods, children }) });
|
|
10
16
|
};
|
|
11
17
|
function createPackageContextMethods(options) {
|
package/react.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react.js","sources":["react.tsx"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport type { PackageIntl, Service } from \"@open-pioneer/runtime\";\nimport {\n CustomChakraProvider,\n PackageContext,\n PackageContextMethods\n} from \"@open-pioneer/runtime/test-support\";\nimport { FC, ReactNode, useMemo } from \"react\";\nimport { createIntl } from \"./vanilla\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type AnyService = Service<any>;\n\nexport interface PackageContextProviderProps {\n /** Interface implementations, keyed by interface name. */\n services?: {\n [interfaceName: string]: AnyService;\n };\n\n /** Interface implementations, keyed by interface name and then by qualifier. */\n qualifiedServices?: {\n [interfaceName: string]: {\n [qualifier: string]: AnyService;\n };\n };\n\n /** Package properties (keyed by package name). */\n properties?: {\n [packageName: string]: Record<string, unknown>;\n };\n\n /**\n * The locale for i18n messages and formatting.\n *\n * @default \"en\"\n */\n locale?: string;\n\n /**\n * I18n messages for packages\n */\n messages?: {\n /**\n * I18n messages as (messageId, message) entries.\n *\n * @default {}\n */\n [packageName: string]: Record<string, string>;\n };\n\n /** Children to render */\n children?: ReactNode;\n}\n\n/**\n * Injects services and properties into the component tree.\n * React components using Open Pioneer Trails hooks like `useService` and `useProperties`\n * will receive the mocked properties here instead.\n * Currently also wrapped with the CustomChakraProvider to support chakra-ui elements\n */\nexport const PackageContextProvider: FC<PackageContextProviderProps> = (props) => {\n const { children, ...rest } = props;\n const [locale, contextMethods] = useMemo(() => createPackageContextMethods(rest), [rest]);\n\n return (\n <CustomChakraProvider rootNode={document} appRoot={document.body} locale={locale}>\n <PackageContext.Provider value={contextMethods}>{children}</PackageContext.Provider>\n </CustomChakraProvider>\n );\n};\n\nfunction createPackageContextMethods(\n options: Omit<PackageContextProviderProps, \"children\">\n): [locale: string, PackageContextMethods] {\n const services = options?.services ?? {};\n const qualifiedServices = options?.qualifiedServices ?? {};\n const properties = options?.properties ?? {};\n const locale = options?.locale ?? \"en\";\n const messages = options?.messages ?? {};\n const cachedIntl: Record<string, PackageIntl> = {};\n const methods: PackageContextMethods = {\n getService(packageName, interfaceName, options) {\n if (!options.qualifier) {\n const service = services[interfaceName];\n if (service) {\n return service;\n }\n const qualified = qualifiedServices[interfaceName];\n if (qualified) {\n for (const value of Object.values(qualified)) {\n return value; // Return any implementation\n }\n }\n throw new Error(\n `Interface name not bound for testing: '${interfaceName}'. Update the configuration of PackageContextProvider.`\n );\n }\n\n const qualifiedService = qualifiedServices[interfaceName]?.[options.qualifier];\n if (!qualifiedService) {\n throw new Error(\n `Interface name not bound for testing: '${interfaceName}' (qualifier '${options.qualifier}'). Update the configuration of PackageContextProvider.`\n );\n }\n return qualifiedService;\n },\n getServices(packageName, interfaceName) {\n const unqualified = services[interfaceName];\n const results = Object.values(qualifiedServices[interfaceName] ?? {});\n if (unqualified) {\n results.push(unqualified);\n }\n return results;\n },\n getProperties(packageName) {\n const packageProperties = properties[packageName];\n if (!packageProperties) {\n throw new Error(\n `No properties for package '${packageName}' bound for testing. Update the configuration of PackageContextProvider.`\n );\n }\n return packageProperties;\n },\n getIntl(packageName) {\n const initIntl = () => {\n const packageMessages = messages[packageName];\n return createIntl({\n locale,\n messages: packageMessages\n });\n };\n return (cachedIntl[packageName] ??= initIntl());\n }\n };\n return [locale, methods];\n}\n"],"names":["options"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"react.js","sources":["react.tsx"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport type { PackageIntl, Service } from \"@open-pioneer/runtime\";\nimport {\n APP_ROOT_CLASS,\n CustomChakraProvider,\n PackageContext,\n PackageContextMethods\n} from \"@open-pioneer/runtime/test-support\";\nimport { FC, ReactNode, useInsertionEffect, useMemo } from \"react\";\nimport { createIntl } from \"./vanilla\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type AnyService = Service<any>;\n\nexport interface PackageContextProviderProps {\n /** Interface implementations, keyed by interface name. */\n services?: {\n [interfaceName: string]: AnyService;\n };\n\n /** Interface implementations, keyed by interface name and then by qualifier. */\n qualifiedServices?: {\n [interfaceName: string]: {\n [qualifier: string]: AnyService;\n };\n };\n\n /** Package properties (keyed by package name). */\n properties?: {\n [packageName: string]: Record<string, unknown>;\n };\n\n /**\n * The locale for i18n messages and formatting.\n *\n * @default \"en\"\n */\n locale?: string;\n\n /**\n * I18n messages for packages\n */\n messages?: {\n /**\n * I18n messages as (messageId, message) entries.\n *\n * @default {}\n */\n [packageName: string]: Record<string, string>;\n };\n\n /** Children to render */\n children?: ReactNode;\n}\n\n/**\n * Injects services and properties into the component tree.\n * React components using Open Pioneer Trails hooks like `useService` and `useProperties`\n * will receive the mocked properties here instead.\n * Currently also wrapped with the CustomChakraProvider to support chakra-ui elements\n */\nexport const PackageContextProvider: FC<PackageContextProviderProps> = (props) => {\n const { children, ...rest } = props;\n const [locale, contextMethods] = useMemo(() => createPackageContextMethods(rest), [rest]);\n\n useInsertionEffect(() => {\n // Needed for chakra tokens / theme etc. to be applied correctly.\n // In real applications, this is done as part of the web component startup code.\n // In test scenarios, the body is used as the root node (see props below).\n document.body.classList.add(APP_ROOT_CLASS);\n return () => {\n document.body.classList.remove(APP_ROOT_CLASS);\n };\n }, []);\n\n return (\n <CustomChakraProvider rootNode={document} appRoot={document.body} locale={locale}>\n <PackageContext.Provider value={contextMethods}>{children}</PackageContext.Provider>\n </CustomChakraProvider>\n );\n};\n\nfunction createPackageContextMethods(\n options: Omit<PackageContextProviderProps, \"children\">\n): [locale: string, PackageContextMethods] {\n const services = options?.services ?? {};\n const qualifiedServices = options?.qualifiedServices ?? {};\n const properties = options?.properties ?? {};\n const locale = options?.locale ?? \"en\";\n const messages = options?.messages ?? {};\n const cachedIntl: Record<string, PackageIntl> = {};\n const methods: PackageContextMethods = {\n getService(packageName, interfaceName, options) {\n if (!options.qualifier) {\n const service = services[interfaceName];\n if (service) {\n return service;\n }\n const qualified = qualifiedServices[interfaceName];\n if (qualified) {\n for (const value of Object.values(qualified)) {\n return value; // Return any implementation\n }\n }\n throw new Error(\n `Interface name not bound for testing: '${interfaceName}'. Update the configuration of PackageContextProvider.`\n );\n }\n\n const qualifiedService = qualifiedServices[interfaceName]?.[options.qualifier];\n if (!qualifiedService) {\n throw new Error(\n `Interface name not bound for testing: '${interfaceName}' (qualifier '${options.qualifier}'). Update the configuration of PackageContextProvider.`\n );\n }\n return qualifiedService;\n },\n getServices(packageName, interfaceName) {\n const unqualified = services[interfaceName];\n const results = Object.values(qualifiedServices[interfaceName] ?? {});\n if (unqualified) {\n results.push(unqualified);\n }\n return results;\n },\n getProperties(packageName) {\n const packageProperties = properties[packageName];\n if (!packageProperties) {\n throw new Error(\n `No properties for package '${packageName}' bound for testing. Update the configuration of PackageContextProvider.`\n );\n }\n return packageProperties;\n },\n getIntl(packageName) {\n const initIntl = () => {\n const packageMessages = messages[packageName];\n return createIntl({\n locale,\n messages: packageMessages\n });\n };\n return (cachedIntl[packageName] ??= initIntl());\n }\n };\n return [locale, methods];\n}\n"],"names":["options"],"mappings":";;;;;AA8DO,MAAM,sBAAA,GAA0D,CAAC,KAAA,KAAU;AAC9E,EAAA,MAAM,EAAE,QAAA,EAAU,GAAG,IAAA,EAAK,GAAI,KAAA;AAC9B,EAAA,MAAM,CAAC,MAAA,EAAQ,cAAc,CAAA,GAAI,OAAA,CAAQ,MAAM,2BAAA,CAA4B,IAAI,CAAA,EAAG,CAAC,IAAI,CAAC,CAAA;AAExF,EAAA,kBAAA,CAAmB,MAAM;AAIrB,IAAA,QAAA,CAAS,IAAA,CAAK,SAAA,CAAU,GAAA,CAAI,cAAc,CAAA;AAC1C,IAAA,OAAO,MAAM;AACT,MAAA,QAAA,CAAS,IAAA,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