@open-pioneer/test-utils 0.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 +13 -0
- package/LICENSE +202 -0
- package/README.md +113 -0
- package/package.json +37 -0
- package/react.js +79 -0
- package/react.js.map +1 -0
- package/services.js +44 -0
- package/services.js.map +1 -0
- package/web-components.js +52 -0
- package/web-components.js.map +1 -0
package/CHANGELOG.md
ADDED
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
# @open-pioneer/test-utils
|
|
2
|
+
|
|
3
|
+
This package contains test utilities that make it easier to test parts of a pioneer application.
|
|
4
|
+
|
|
5
|
+
## Web Component utilities
|
|
6
|
+
|
|
7
|
+
Provides a few helpers to render web components into the DOM.
|
|
8
|
+
|
|
9
|
+
The helpers can be used to make testing web components that use a Shadow DOM easier.
|
|
10
|
+
|
|
11
|
+
Example:
|
|
12
|
+
|
|
13
|
+
```js
|
|
14
|
+
/**
|
|
15
|
+
* @vitest-environment jsdom
|
|
16
|
+
*/
|
|
17
|
+
import { it, expect } from "vitest";
|
|
18
|
+
import { createElement } from "react";
|
|
19
|
+
import { createCustomElement } from "@open-pioneer/runtime";
|
|
20
|
+
import { renderComponentShadowDOM } from "@open-pioneer/test-utils/web-components";
|
|
21
|
+
|
|
22
|
+
it("should render a custom component into the dom", async () => {
|
|
23
|
+
// Define a custom element class.
|
|
24
|
+
// The shadow root must be open for testing to work (which is the default during development).
|
|
25
|
+
const elem = createCustomElement({
|
|
26
|
+
component: () => createElement("div", { className: "test" }, "hello world")
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
// Waits until the component is rendered.
|
|
30
|
+
// Returns an inner container from the shadow dom (`.pioneer-root` by default).
|
|
31
|
+
// The queries object searches in that inner container.
|
|
32
|
+
const { queries } = await renderComponentShadowDOM(elem);
|
|
33
|
+
const div = await queries.findByText("hello world");
|
|
34
|
+
expect(div.className).toBe("test");
|
|
35
|
+
});
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Take a look at the tests in this package for more examples.
|
|
39
|
+
|
|
40
|
+
## React utilities
|
|
41
|
+
|
|
42
|
+
Provides helpers to make testing of react components easier that use the hooks from the `"open-pioneer:react-hooks"` module (e.g. `useService`).
|
|
43
|
+
|
|
44
|
+
The developer can provide custom service implementations, properties etc. using a simple parent component.
|
|
45
|
+
|
|
46
|
+
Example:
|
|
47
|
+
|
|
48
|
+
```js
|
|
49
|
+
import { expect, it } from "vitest";
|
|
50
|
+
import { screen, render } from "@testing-library/react";
|
|
51
|
+
import { PackageContextProvider } from "@open-pioneer/test-utils/react";
|
|
52
|
+
import { useProperties, useService, useServices } from "open-pioneer:react-hooks";
|
|
53
|
+
|
|
54
|
+
it("should allow injection of service from the test", async () => {
|
|
55
|
+
// A simple component that uses a service.
|
|
56
|
+
function Component() {
|
|
57
|
+
const service = useService("testService");
|
|
58
|
+
return <div>Message: {service.getMessage()}</div>;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Setup test services.
|
|
62
|
+
const mocks = {
|
|
63
|
+
services: {
|
|
64
|
+
testService: {
|
|
65
|
+
getMessage() {
|
|
66
|
+
return "Hello World!";
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
// The PackageContextProvider parent ensures that the useService() in our test component works.
|
|
73
|
+
render(
|
|
74
|
+
<PackageContextProvider {...mocks}>
|
|
75
|
+
<Component />
|
|
76
|
+
</PackageContextProvider>
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
const div = await screen.findByText(/^Message:/);
|
|
80
|
+
expect(div).toMatchSnapshot();
|
|
81
|
+
});
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Take a look at the tests in this package for more examples.
|
|
85
|
+
|
|
86
|
+
## Service utilities
|
|
87
|
+
|
|
88
|
+
Provides a utility to construct new service instances.
|
|
89
|
+
References to other service instances can be mocked with user defined test values.
|
|
90
|
+
|
|
91
|
+
Example:
|
|
92
|
+
|
|
93
|
+
```js
|
|
94
|
+
import { expect, it } from "vitest";
|
|
95
|
+
import { createService } from "@open-pioneer/test-utils/services";
|
|
96
|
+
import { MyService } from "./MyService"; // User defined service
|
|
97
|
+
|
|
98
|
+
it("creates a new service instance with the defined references", async () => {
|
|
99
|
+
const service = await createService(MyService, {
|
|
100
|
+
references: {
|
|
101
|
+
// Will be injected into the constructor.
|
|
102
|
+
// TypeScript checks are intentionally relaxed a bit.
|
|
103
|
+
someReference: {
|
|
104
|
+
bar() {
|
|
105
|
+
return 123;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
expect(service).toBeInstanceOf(MyService);
|
|
111
|
+
// ... other assertions ...
|
|
112
|
+
});
|
|
113
|
+
```
|
package/package.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"type": "module",
|
|
3
|
+
"name": "@open-pioneer/test-utils",
|
|
4
|
+
"version": "0.1.0",
|
|
5
|
+
"dependencies": {
|
|
6
|
+
"@testing-library/react": "^14.0.0",
|
|
7
|
+
"react": "^18.2.0",
|
|
8
|
+
"react-dom": "^18.2.0",
|
|
9
|
+
"@testing-library/dom": "^9.3.0",
|
|
10
|
+
"@formatjs/intl": "^2.7.2",
|
|
11
|
+
"@open-pioneer/runtime": "^0.1.0",
|
|
12
|
+
"@open-pioneer/chakra-integration": "^0.1.0"
|
|
13
|
+
},
|
|
14
|
+
"exports": {
|
|
15
|
+
"./package.json": "./package.json",
|
|
16
|
+
"./web-components": {
|
|
17
|
+
"import": "./web-components.js"
|
|
18
|
+
},
|
|
19
|
+
"./react": {
|
|
20
|
+
"import": "./react.js"
|
|
21
|
+
},
|
|
22
|
+
"./services": {
|
|
23
|
+
"import": "./services.js"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"openPioneerFramework": {
|
|
27
|
+
"services": [],
|
|
28
|
+
"i18n": {
|
|
29
|
+
"languages": []
|
|
30
|
+
},
|
|
31
|
+
"ui": {
|
|
32
|
+
"references": []
|
|
33
|
+
},
|
|
34
|
+
"properties": [],
|
|
35
|
+
"packageFormatVersion": "1.0.0"
|
|
36
|
+
}
|
|
37
|
+
}
|
package/react.js
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { createIntlCache, createIntl } from '@formatjs/intl';
|
|
3
|
+
import { CustomChakraProvider } from '@open-pioneer/chakra-integration';
|
|
4
|
+
import { PackageContext } from '@open-pioneer/runtime/react-integration';
|
|
5
|
+
import { useMemo } from 'react';
|
|
6
|
+
|
|
7
|
+
const PackageContextProvider = (props) => {
|
|
8
|
+
const { children, ...rest } = props;
|
|
9
|
+
const contextMethods = useMemo(() => createPackageContextMethods(rest), [rest]);
|
|
10
|
+
return /* @__PURE__ */ jsx(CustomChakraProvider, { container: document.body, children: /* @__PURE__ */ jsx(PackageContext.Provider, { value: contextMethods, children }) });
|
|
11
|
+
};
|
|
12
|
+
function createPackageContextMethods(options) {
|
|
13
|
+
const services = options?.services ?? {};
|
|
14
|
+
const qualifiedServices = options?.qualifiedServices ?? {};
|
|
15
|
+
const properties = options?.properties ?? {};
|
|
16
|
+
const locale = options?.locale ?? "en";
|
|
17
|
+
const messages = options?.messages ?? {};
|
|
18
|
+
const cachedIntl = {};
|
|
19
|
+
return {
|
|
20
|
+
getService(packageName, interfaceName, options2) {
|
|
21
|
+
if (!options2.qualifier) {
|
|
22
|
+
const service = services[interfaceName];
|
|
23
|
+
if (service) {
|
|
24
|
+
return service;
|
|
25
|
+
}
|
|
26
|
+
const qualified = qualifiedServices[interfaceName];
|
|
27
|
+
if (qualified) {
|
|
28
|
+
for (const value of Object.values(qualified)) {
|
|
29
|
+
return value;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
throw new Error(
|
|
33
|
+
`Interface name not bound for testing: '${interfaceName}'. Update the configuration of PackageContextProvider.`
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
const qualifiedService = qualifiedServices[interfaceName]?.[options2.qualifier];
|
|
37
|
+
if (!qualifiedService) {
|
|
38
|
+
throw new Error(
|
|
39
|
+
`Interface name not bound for testing: '${interfaceName}' (qualifier '${options2.qualifier}'). Update the configuration of PackageContextProvider.`
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
return qualifiedService;
|
|
43
|
+
},
|
|
44
|
+
getServices(packageName, interfaceName) {
|
|
45
|
+
const unqualified = services[interfaceName];
|
|
46
|
+
const results = Object.values(qualifiedServices[interfaceName] ?? {});
|
|
47
|
+
if (unqualified) {
|
|
48
|
+
results.push(unqualified);
|
|
49
|
+
}
|
|
50
|
+
return results;
|
|
51
|
+
},
|
|
52
|
+
getProperties(packageName) {
|
|
53
|
+
const packageProperties = properties[packageName];
|
|
54
|
+
if (!packageProperties) {
|
|
55
|
+
throw new Error(
|
|
56
|
+
`No properties for package '${packageName}' bound for testing. Update the configuration of PackageContextProvider.`
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
return packageProperties;
|
|
60
|
+
},
|
|
61
|
+
getIntl(packageName) {
|
|
62
|
+
const initIntl = () => {
|
|
63
|
+
const packageMessages = messages[packageName];
|
|
64
|
+
const cache = createIntlCache();
|
|
65
|
+
return createIntl(
|
|
66
|
+
{
|
|
67
|
+
locale,
|
|
68
|
+
messages: packageMessages
|
|
69
|
+
},
|
|
70
|
+
cache
|
|
71
|
+
);
|
|
72
|
+
};
|
|
73
|
+
return cachedIntl[packageName] ??= initIntl();
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export { PackageContextProvider };
|
|
79
|
+
//# sourceMappingURL=react.js.map
|
package/react.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react.js","sources":["open-pioneer://external-pioneer-packages/@open-pioneer/test-utils/react.tsx"],"sourcesContent":["// SPDX-FileCopyrightText: con terra GmbH and contributors\n// SPDX-License-Identifier: Apache-2.0\nimport { createIntl, createIntlCache, IntlShape } from \"@formatjs/intl\";\nimport { CustomChakraProvider } from \"@open-pioneer/chakra-integration\";\nimport { Service } from \"@open-pioneer/runtime\";\nimport {\n PackageContext as InternalPackageContext,\n PackageContextMethods\n} from \"@open-pioneer/runtime/react-integration\";\nimport { FC, ReactNode, useMemo } from \"react\";\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 pioneer 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 contextMethods = useMemo(() => createPackageContextMethods(rest), [rest]);\n return (\n <CustomChakraProvider container={document.body}>\n <InternalPackageContext.Provider value={contextMethods}>\n {children}\n </InternalPackageContext.Provider>\n </CustomChakraProvider>\n );\n};\n\nfunction createPackageContextMethods(\n options: Omit<PackageContextProviderProps, \"children\">\n): 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, IntlShape> = {};\n return {\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 const cache = createIntlCache();\n return createIntl(\n {\n locale,\n messages: packageMessages\n },\n cache\n );\n };\n return (cachedIntl[packageName] ??= initIntl());\n }\n };\n}\n"],"names":["InternalPackageContext","options"],"mappings":";;;;;;AA6Da,MAAA,sBAAA,GAA0D,CAAC,KAAU,KAAA;AAC9E,EAAA,MAAM,EAAE,QAAA,EA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,MAAA;AAAA,YACA,QAAU,EAAA,eAAA;AAAA,WACd;AAAA,UACA,KAAA;AAAA,SACJ,CAAA;AAAA,OACJ,CAAA;AACA,MAAQ,OAAA,UAAA,CAAW,WAAW,CAAA,KAAM,QAAS,EAAA,CAAA;AAAA,KACjD;AAAA,GACJ,CAAA;AACJ;;;;"}
|
package/services.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { createIntlCache, createIntl } from '@formatjs/intl';
|
|
2
|
+
|
|
3
|
+
async function createService(clazz, options) {
|
|
4
|
+
const references = options?.references ?? {};
|
|
5
|
+
const referencesMeta = Object.fromEntries(
|
|
6
|
+
Object.entries(references).map(([referenceName, reference]) => [
|
|
7
|
+
referenceName,
|
|
8
|
+
referenceMeta(referenceName, reference)
|
|
9
|
+
])
|
|
10
|
+
);
|
|
11
|
+
const locale = options?.locale ?? "en";
|
|
12
|
+
const defaultMessageLocale = options?.defaultMessageLocale ?? "en";
|
|
13
|
+
const messages = options?.messages ?? {};
|
|
14
|
+
const cache = createIntlCache();
|
|
15
|
+
const intl = createIntl(
|
|
16
|
+
{
|
|
17
|
+
locale,
|
|
18
|
+
defaultLocale: defaultMessageLocale,
|
|
19
|
+
messages
|
|
20
|
+
},
|
|
21
|
+
cache
|
|
22
|
+
);
|
|
23
|
+
return new clazz({
|
|
24
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
25
|
+
references,
|
|
26
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
27
|
+
referencesMeta,
|
|
28
|
+
properties: options?.properties ?? {},
|
|
29
|
+
intl
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
function referenceMeta(referenceName, reference) {
|
|
33
|
+
if (Array.isArray(reference)) {
|
|
34
|
+
return reference.map((_, index) => ({
|
|
35
|
+
serviceId: `test-utils::${referenceName}-${index}`
|
|
36
|
+
}));
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
serviceId: `test-utils::${referenceName}`
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export { createService };
|
|
44
|
+
//# sourceMappingURL=services.js.map
|
package/services.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"services.js","sources":["open-pioneer://external-pioneer-packages/@open-pioneer/test-utils/services.ts"],"sourcesContent":["// SPDX-FileCopyrightText: con terra GmbH and contributors\n// SPDX-License-Identifier: Apache-2.0\nimport { ReferenceMeta, Service, ServiceConstructor } from \"@open-pioneer/runtime\";\nimport { createIntl, createIntlCache } from \"@formatjs/intl\";\n\n/**\n * Options for the {@link createService} function.\n */\nexport interface CreateServiceOptions<References> {\n /**\n * References provided to the service constructor.\n *\n * @default {}\n */\n references?: PartialServiceReferences<References>;\n\n /**\n * Properties provided to the service constructor.\n *\n * @default {}\n */\n properties?: Record<string, unknown>;\n\n /**\n * The locale for i18n messages and formatting.\n *\n * @default \"en\"\n */\n locale?: string;\n\n /**\n * The locale for embedded default messages.\n *\n * See also https://formatjs.io/docs/intl#message-descriptor\n *\n * @default \"en\"\n */\n defaultMessageLocale?: string;\n\n /**\n * I18n messages as (messageId, message) entries.\n *\n * @default {}\n */\n messages?: Record<string, string>;\n}\n\ntype PartialServiceReferences<References> = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [referenceName in keyof References]?: References[referenceName] extends any[]\n ? Partial<References[referenceName][number]>[]\n : Partial<References[referenceName]>;\n};\n\n/**\n * Creates a new service instance of `clazz`.\n *\n * The options passed into the constructor of `clazz` are taking from the `options` parameter.\n *\n * This function allows the user to define mock- or test objects as service references.\n *\n * Most type-checking features are disabled for convenience, but by default this function's types\n * enforce that a value provided for a reference must match the partial interface of the actually required type.\n *\n * For example, if a service depends on `{ ctx: ApplicationContext }`, this function ensures\n * that the test value for `ctx` implements `Partial<ApplicationContext>`.\n * This can of course be disabled by casting the value explicitly.\n *\n * @param clazz a service class\n * @param options options passed to the service constructor\n * @returns a new instance of the given service class\n */\nexport async function createService<References extends {}, Interface extends {}>(\n clazz: ServiceConstructor<References, Interface>,\n options?: CreateServiceOptions<References>\n): Promise<Service<Interface>> {\n const references = options?.references ?? {};\n const referencesMeta = Object.fromEntries(\n Object.entries(references).map(([referenceName, reference]) => [\n referenceName,\n referenceMeta(referenceName, reference)\n ])\n );\n\n const locale = options?.locale ?? \"en\";\n const defaultMessageLocale = options?.defaultMessageLocale ?? \"en\";\n const messages = options?.messages ?? {};\n const cache = createIntlCache();\n const intl = createIntl(\n {\n locale,\n defaultLocale: defaultMessageLocale,\n messages\n },\n cache\n );\n\n return new clazz({\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n references: references as any,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n referencesMeta: referencesMeta as any,\n properties: options?.properties ?? {},\n intl\n });\n}\n\nfunction referenceMeta(referenceName: string, reference: unknown): ReferenceMeta | ReferenceMeta[] {\n if (Array.isArray(reference)) {\n return reference.map<ReferenceMeta>((_, index) => ({\n serviceId: `test-utils::${referenceName}-${index}`\n }));\n }\n return {\n serviceId: `test-utils::${referenceName}`\n };\n}\n"],"names":[],"mappings":";;AAwEsB,eAAA,aAAA,CAClB,OACA,OAC2B,EAAA;AAC3B,EAAM,MAAA,UAAA,GAAa,OAAS,EAAA,UAAA,IAAc,EAAC,CAAA;AAC3C,EAAA,MAAM,iBAAiB,MAAO,CAAA,WAAA;AAAA,IAC1B,MAAA,CAAO,QAAQ,UAAU,CAAA,CAAE,IAAI,CAAC,CAAC,aAAe,EAAA,SAAS,CAAM,KAAA;AAAA,MAC3D,aAAA;AAAA,MACA,aAAA,CAAc,eAAe,SAAS,CAAA;AAAA,KACzC,CAAA;AAAA,GACL,CAAA;AAEA,EAAM,MAAA,MAAA,GAAS,SAAS,MAAU,IAAA,IAAA,CAAA;AAClC,EAAM,MAAA,oBAAA,GAAuB,SAAS,oBAAwB,IAAA,IAAA,CAAA;AAC9D,EAAM,MAAA,QAAA,GAAW,OAAS,EAAA,QAAA,IAAY,EAAC,CAAA;AACvC,EAAA,MAAM,QAAQ,eAAgB,EAAA,CAAA;AAC9B,EAAA,MAAM,IAAO,GAAA,UAAA;AAAA,IACT;AAAA,MACI,MAAA;AAAA,MACA,aAAe,EAAA,oBAAA;AAAA,MACf,QAAA;AAAA,KACJ;AAAA,IACA,KAAA;AAAA,GACJ,CAAA;AAEA,EAAA,OAAO,IAAI,KAAM,CAAA;AAAA;AAAA,IAEb,UAAA;AAAA;AAAA,IAEA,cAAA;AAAA,IACA,UAAA,EAAY,OAAS,EAAA,UAAA,IAAc,EAAC;AAAA,IACpC,IAAA;AAAA,GACH,CAAA,CAAA;AACL,CAAA;AAEA,SAAS,aAAA,CAAc,eAAuB,SAAqD,EAAA;AAC/F,EAAI,IAAA,KAAA,CAAM,OAAQ,CAAA,SAAS,CAAG,EAAA;AAC1B,IAAA,OAAO,SAAU,CAAA,GAAA,CAAmB,CAAC,CAAA,EAAG,KAAW,MAAA;AAAA,MAC/C,SAAA,EAAW,eAAe,aAAiB,CAAA,CAAA,EAAA,KAAA,CAAA,CAAA;AAAA,KAC7C,CAAA,CAAA,CAAA;AAAA,GACN;AACA,EAAO,OAAA;AAAA,IACH,WAAW,CAAe,YAAA,EAAA,aAAA,CAAA,CAAA;AAAA,GAC9B,CAAA;AACJ;;;;"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { waitFor, within } from '@testing-library/dom';
|
|
2
|
+
|
|
3
|
+
const GLOBAL = global;
|
|
4
|
+
function nextId() {
|
|
5
|
+
GLOBAL["__WEB_COMPONENT_COUNT__"] ??= 0;
|
|
6
|
+
const id = GLOBAL["__WEB_COMPONENT_COUNT__"] += 1;
|
|
7
|
+
return id;
|
|
8
|
+
}
|
|
9
|
+
async function renderComponent(component, options) {
|
|
10
|
+
const tag = typeof component === "string" ? component : defineComponent(component);
|
|
11
|
+
const container = options?.container ?? document.body;
|
|
12
|
+
const node = container.ownerDocument.createElement(tag);
|
|
13
|
+
for (const [key, value] of Object.entries(options?.attributes ?? {})) {
|
|
14
|
+
node.setAttribute(key, value);
|
|
15
|
+
}
|
|
16
|
+
container.innerHTML = "";
|
|
17
|
+
container.appendChild(node);
|
|
18
|
+
return {
|
|
19
|
+
node
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
async function renderComponentShadowDOM(component, options) {
|
|
23
|
+
const { node } = await renderComponent(component, options);
|
|
24
|
+
const selector = options?.innerContainerSelector ?? ".pioneer-root";
|
|
25
|
+
const { shadowRoot, innerContainer } = await waitFor(() => {
|
|
26
|
+
const shadowRoot2 = node.shadowRoot;
|
|
27
|
+
if (!shadowRoot2) {
|
|
28
|
+
throw new Error("Shadow root not attached.");
|
|
29
|
+
}
|
|
30
|
+
const innerContainer2 = shadowRoot2.querySelector(selector);
|
|
31
|
+
if (!innerContainer2) {
|
|
32
|
+
throw new Error("Inner container not ready.");
|
|
33
|
+
}
|
|
34
|
+
return { shadowRoot: shadowRoot2, innerContainer: innerContainer2 };
|
|
35
|
+
});
|
|
36
|
+
const queries = within(innerContainer);
|
|
37
|
+
return {
|
|
38
|
+
node,
|
|
39
|
+
shadowRoot,
|
|
40
|
+
innerContainer,
|
|
41
|
+
queries
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
function defineComponent(component, options) {
|
|
45
|
+
const nameHint = options?.nameHint ?? "test-component";
|
|
46
|
+
const tag = `${nameHint}-${nextId()}`;
|
|
47
|
+
customElements.define(tag, component);
|
|
48
|
+
return tag;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export { defineComponent, renderComponent, renderComponentShadowDOM };
|
|
52
|
+
//# sourceMappingURL=web-components.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web-components.js","sources":["open-pioneer://external-pioneer-packages/@open-pioneer/test-utils/web-components.ts"],"sourcesContent":["// SPDX-FileCopyrightText: con terra GmbH and contributors\n// SPDX-License-Identifier: Apache-2.0\nimport { waitFor, within } from \"@testing-library/dom\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst GLOBAL = global as any;\n\nfunction nextId(): number {\n GLOBAL[\"__WEB_COMPONENT_COUNT__\"] ??= 0;\n const id = (GLOBAL[\"__WEB_COMPONENT_COUNT__\"] += 1);\n return id;\n}\n\n/**\n * Renders the given component into the DOM and returns the new node.\n */\nexport async function renderComponent(\n component: CustomElementConstructor | string,\n options?: {\n container?: HTMLElement;\n attributes?: Record<string, string>;\n }\n) {\n const tag = typeof component === \"string\" ? component : defineComponent(component);\n const container = options?.container ?? document.body;\n const node = container.ownerDocument.createElement(tag);\n for (const [key, value] of Object.entries(options?.attributes ?? {})) {\n node.setAttribute(key, value);\n }\n container.innerHTML = \"\";\n container.appendChild(node);\n return {\n node\n };\n}\n\n/**\n * Renders the given component into the DOM (via {@link renderComponent}) and works on its shadow root.\n * In order to use this function, the shadow root should be attached as `open` from inside the component class.\n *\n * After the shadow root has been accessed, the function searches (and waits) for an inner root container (by default `.pioneer-root`)\n * where all other searches should be executed.\n *\n * Returns the shadow root, the inner container, and a bound queries object that automatically searches in the inner container\n * instead of the whole document.\n */\nexport async function renderComponentShadowDOM(\n component: CustomElementConstructor | string,\n options?: {\n container?: HTMLElement;\n attributes?: Record<string, string>;\n innerContainerSelector?: string;\n }\n) {\n const { node } = await renderComponent(component, options);\n const selector = options?.innerContainerSelector ?? \".pioneer-root\";\n const { shadowRoot, innerContainer } = await waitFor(() => {\n const shadowRoot = node.shadowRoot;\n if (!shadowRoot) {\n throw new Error(\"Shadow root not attached.\");\n }\n const innerContainer = shadowRoot.querySelector<HTMLElement>(selector);\n if (!innerContainer) {\n throw new Error(\"Inner container not ready.\");\n }\n return { shadowRoot, innerContainer };\n });\n\n const queries = within(innerContainer);\n return {\n node,\n shadowRoot,\n innerContainer,\n queries\n };\n}\n\n/**\n * Defines the given component and returns the unique tag name.\n * This helper is necessary because tag names must not collide in the global elements registry (and\n * un-registration is not possible).\n */\nexport function defineComponent(\n component: CustomElementConstructor,\n options?: {\n nameHint?: string;\n }\n) {\n const nameHint = options?.nameHint ?? \"test-component\";\n const tag = `${nameHint}-${nextId()}`;\n customElements.define(tag, component);\n return tag;\n}\n"],"names":["shadowRoot","innerContainer"],"mappings":";;AAKA,MAAM,MAAS,GAAA,MAAA,CAAA;AAEf,SAAS,MAAiB,GAAA;AACtB,EAAA,MAAA,CAAO,yBAAyB,CAAM,KAAA,CAAA,CAAA;AACtC,EAAM,MAAA,EAAA,GAAM,MAAO,CAAA,yBAAyB,CAAK,IAAA,CAAA,CAAA;AACjD,EAAO,OAAA,EAAA,CAAA;AACX,CAAA;AAKsB,eAAA,eAAA,CAClB,WACA,OAIF,EAAA;AACE,EAAA,MAAM,MAAM,OAAO,SAAA,KAAc,QAAW,GAAA,SAAA,GAAY,gBAAgB,SAAS,CAAA,CAAA;AACjF,EAAM,MAAA,SAAA,GAAY,OAAS,EAAA,SAAA,IAAa,QAAS,CAAA,IAAA,CAAA;AACjD,EAAA,MAAM,IAAO,GAAA,SAAA,CAAU,aAAc,CAAA,aAAA,CAAc,GAAG,CAAA,CAAA;AACtD,EAAW,KAAA,MAAA,CAAC,GAAK,EAAA,KAAK,CAAK,IAAA,MAAA,CAAO,QAAQ,OAAS,EAAA,UAAA,IAAc,EAAE,CAAG,EAAA;AAClE,IAAK,IAAA,CAAA,YAAA,CAAa,KAAK,KAAK,CAAA,CAAA;AAAA,GAChC;AACA,EAAA,SAAA,CAAU,SAAY,GAAA,EAAA,CAAA;AACtB,EAAA,SAAA,CAAU,YAAY,IAAI,CAAA,CAAA;AAC1B,EAAO,OAAA;AAAA,IACH,IAAA;AAAA,GACJ,CAAA;AACJ,CAAA;AAYsB,eAAA,wBAAA,CAClB,WACA,OAKF,EAAA;AACE,EAAA,MAAM,EAAE,IAAK,EAAA,GAAI,MAAM,eAAA,CAAgB,WAAW,OAAO,CAAA,CAAA;AACzD,EAAM,MAAA,QAAA,GAAW,SAAS,sBAA0B,IAAA,eAAA,CAAA;AACpD,EAAA,MAAM,EAAE,UAAY,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