@helvetia-design/playwright 0.0.0-stage → 0.0.2

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.
Files changed (76) hide show
  1. package/LICENSE +210 -0
  2. package/dist/src/index.js +8 -0
  3. package/dist/src/lib/components/accordion.po.js +74 -0
  4. package/dist/src/lib/components/app-footer.po.js +132 -0
  5. package/dist/src/lib/components/app-navbar.po.js +106 -0
  6. package/dist/src/lib/components/badge.po.js +32 -0
  7. package/dist/src/lib/components/brand-icon.po.js +13 -0
  8. package/dist/src/lib/components/button.po.js +86 -0
  9. package/dist/src/lib/components/card.po.js +148 -0
  10. package/dist/src/lib/components/carousel.po.js +92 -0
  11. package/dist/src/lib/components/checkbox.po.js +107 -0
  12. package/dist/src/lib/components/close.po.js +31 -0
  13. package/dist/src/lib/components/content.po.js +32 -0
  14. package/dist/src/lib/components/counter.po.js +121 -0
  15. package/dist/src/lib/components/data-item.po.js +235 -0
  16. package/dist/src/lib/components/data.po.js +110 -0
  17. package/dist/src/lib/components/datepicker.po.js +260 -0
  18. package/dist/src/lib/components/divider.po.js +10 -0
  19. package/dist/src/lib/components/drawer.po.js +55 -0
  20. package/dist/src/lib/components/file-upload.po.js +200 -0
  21. package/dist/src/lib/components/heading.po.js +32 -0
  22. package/dist/src/lib/components/hint.po.js +71 -0
  23. package/dist/src/lib/components/icon.po.js +13 -0
  24. package/dist/src/lib/components/index.js +49 -0
  25. package/dist/src/lib/components/input.po.js +107 -0
  26. package/dist/src/lib/components/label.po.js +32 -0
  27. package/dist/src/lib/components/list.po.js +68 -0
  28. package/dist/src/lib/components/logo.po.js +13 -0
  29. package/dist/src/lib/components/modal.po.js +97 -0
  30. package/dist/src/lib/components/notification.po.js +56 -0
  31. package/dist/src/lib/components/number-input.po.js +107 -0
  32. package/dist/src/lib/components/page-object.js +47 -0
  33. package/dist/src/lib/components/pagination.po.js +146 -0
  34. package/dist/src/lib/components/phone-input.po.js +302 -0
  35. package/dist/src/lib/components/popup.po.js +55 -0
  36. package/dist/src/lib/components/radio.po.js +89 -0
  37. package/dist/src/lib/components/root.po.js +32 -0
  38. package/dist/src/lib/components/segment.po.js +135 -0
  39. package/dist/src/lib/components/select.po.js +257 -0
  40. package/dist/src/lib/components/shape.po.js +10 -0
  41. package/dist/src/lib/components/sheet.po.js +88 -0
  42. package/dist/src/lib/components/slider.po.js +101 -0
  43. package/dist/src/lib/components/snackbar.po.js +115 -0
  44. package/dist/src/lib/components/spinner.po.js +13 -0
  45. package/dist/src/lib/components/stack.po.js +32 -0
  46. package/dist/src/lib/components/steps.po.js +112 -0
  47. package/dist/src/lib/components/tabs.po.js +110 -0
  48. package/dist/src/lib/components/tag.po.js +53 -0
  49. package/dist/src/lib/components/text.po.js +32 -0
  50. package/dist/src/lib/components/textarea.po.js +89 -0
  51. package/dist/src/lib/components/toast.po.js +92 -0
  52. package/dist/src/lib/components/toggle.po.js +107 -0
  53. package/dist/src/lib/components/tooltip.po.js +32 -0
  54. package/dist/src/lib/devices.js +6 -0
  55. package/dist/src/lib/extend.js +375 -0
  56. package/dist/src/lib/functions/a11y.js +31 -0
  57. package/dist/src/lib/matchers/index.js +12 -0
  58. package/dist/src/lib/matchers/to-have-first-received-event-detail.js +44 -0
  59. package/dist/src/lib/matchers/to-have-nth-received-event-detail.js +53 -0
  60. package/dist/src/lib/matchers/to-have-received-event-detail.js +44 -0
  61. package/dist/src/lib/matchers/to-have-received-event-times.js +33 -0
  62. package/dist/src/lib/matchers/to-have-received-event.js +33 -0
  63. package/dist/src/lib/page/event-spy.js +198 -0
  64. package/dist/src/lib/page/utils/goto.js +71 -0
  65. package/dist/src/lib/page/utils/index.js +6 -0
  66. package/dist/src/lib/page/utils/locator.js +38 -0
  67. package/dist/src/lib/page/utils/mount-ssr.js +118 -0
  68. package/dist/src/lib/page/utils/mount.js +70 -0
  69. package/dist/src/lib/page/utils/spy-on-event.js +34 -0
  70. package/dist/src/lib/page/utils/wait-for-changes.js +99 -0
  71. package/dist/src/lib/screenshot.js +13 -0
  72. package/dist/src/lib/test-expect.js +1 -0
  73. package/dist/src/lib/types.js +54 -0
  74. package/package.json +31 -3
  75. package/sbom.cdx.json +80472 -0
  76. package/README.md +0 -3
@@ -0,0 +1,70 @@
1
+ import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
2
+ import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
3
+ import { waitForChanges } from './wait-for-changes';
4
+ export var mount = function mount(page, content, testInfo) {
5
+ return _async_to_generator(function() {
6
+ var baseUrl;
7
+ return _ts_generator(this, function(_state) {
8
+ switch(_state.label){
9
+ case 0:
10
+ if (page.isClosed()) {
11
+ throw new Error('setContent unavailable: page is already closed');
12
+ }
13
+ baseUrl = testInfo.project.use.baseURL;
14
+ if (!baseUrl) return [
15
+ 3,
16
+ 4
17
+ ];
18
+ return [
19
+ 4,
20
+ page.route(baseUrl + '**', function(route) {
21
+ var url = route.request().url();
22
+ // Match both http://localhost:4000/ and http://localhost:4000# (with or without trailing slash)
23
+ if (url === "" + baseUrl + "/" || url === "" + baseUrl + "/#" || url === "" + baseUrl + "#" || url === baseUrl) {
24
+ /**
25
+ * Intercepts the empty page request and returns the
26
+ * HTML content that was passed in.
27
+ */ route.fulfill({
28
+ status: 200,
29
+ contentType: 'text/html',
30
+ body: template(content)
31
+ });
32
+ } else {
33
+ // Allow all other requests to pass through
34
+ route.continue();
35
+ }
36
+ })
37
+ ];
38
+ case 1:
39
+ _state.sent();
40
+ return [
41
+ 4,
42
+ page.goto("" + baseUrl + "#", {
43
+ waitUntil: 'domcontentloaded'
44
+ })
45
+ ];
46
+ case 2:
47
+ _state.sent();
48
+ return [
49
+ 4,
50
+ waitForChanges(page)
51
+ ];
52
+ case 3:
53
+ _state.sent();
54
+ return [
55
+ 3,
56
+ 5
57
+ ];
58
+ case 4:
59
+ throw new Error('setContent unavailable: no dev server base URL provided');
60
+ case 5:
61
+ return [
62
+ 2
63
+ ];
64
+ }
65
+ });
66
+ })();
67
+ };
68
+ export var template = function template(html) {
69
+ return '\n<!doctype html>\n<html dir="ltr" lang="en">\n <head>\n <meta charset="utf-8" />\n <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=5.0" />\n <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />\n\n <link rel="stylesheet" href="/assets/section.css" />\n <link rel="stylesheet" href="/assets/tokens/base.tokens.css" />\n <link rel="stylesheet" href="/assets/css/design-system.local.min.css" />\n <link rel="stylesheet" href="/assets/css/utilities.min.css" />\n\n <script type="module" src="/build/design-system.esm.js"></script>\n <script nomodule src="/build/design-system.js"></script>\n </head>\n\n <body>\n <ds-root animated="false">\n <main id="root">' + html + "</main>\n </ds-root>\n </body>\n</html>\n";
70
+ };
@@ -0,0 +1,34 @@
1
+ import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
2
+ import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
3
+ import { addE2EListener, EventSpy } from '../event-spy';
4
+ export var spyOnEvent = function spyOnEvent(page, eventName) {
5
+ return _async_to_generator(function() {
6
+ var spy, handle;
7
+ return _ts_generator(this, function(_state) {
8
+ switch(_state.label){
9
+ case 0:
10
+ spy = new EventSpy(eventName);
11
+ return [
12
+ 4,
13
+ page.evaluateHandle(function() {
14
+ return window;
15
+ })
16
+ ];
17
+ case 1:
18
+ handle = _state.sent();
19
+ return [
20
+ 4,
21
+ addE2EListener(page, handle, eventName, function(ev) {
22
+ return spy.push(ev);
23
+ })
24
+ ];
25
+ case 2:
26
+ _state.sent();
27
+ return [
28
+ 2,
29
+ spy
30
+ ];
31
+ }
32
+ });
33
+ })();
34
+ };
@@ -0,0 +1,99 @@
1
+ import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
2
+ import { _ as _instanceof } from "@swc/helpers/_/_instanceof";
3
+ import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
4
+ export var waitForChanges = function waitForChanges(page, timeoutMs) {
5
+ if (timeoutMs === void 0) timeoutMs = 300;
6
+ return _async_to_generator(function() {
7
+ var e;
8
+ return _ts_generator(this, function(_state) {
9
+ switch(_state.label){
10
+ case 0:
11
+ _state.trys.push([
12
+ 0,
13
+ 4,
14
+ ,
15
+ 5
16
+ ]);
17
+ if (page.isClosed()) {
18
+ /**
19
+ * If the page is already closed, we can skip the long execution of this method
20
+ * and return early.
21
+ */ return [
22
+ 2
23
+ ];
24
+ }
25
+ return [
26
+ 4,
27
+ page.evaluate(function() {
28
+ // BROWSER CONTEXT
29
+ return new Promise(function(resolve) {
30
+ // Wait for the next repaint to happen
31
+ requestAnimationFrame(function() {
32
+ var promiseChain = [];
33
+ var waitComponentOnReady = function waitComponentOnReady1(elm, promises) {
34
+ if ('shadowRoot' in elm && _instanceof(elm.shadowRoot, ShadowRoot)) {
35
+ waitComponentOnReady(elm.shadowRoot, promises);
36
+ }
37
+ var children = elm.children;
38
+ var len = children.length;
39
+ for(var i = 0; i < len; i++){
40
+ var childElm = children[i];
41
+ var childStencilElm = childElm;
42
+ if (childElm.tagName.includes('-') && typeof childStencilElm.componentOnReady === 'function') {
43
+ /**
44
+ * We are only using the lazy loaded bundle
45
+ * here so we can safely use the
46
+ * componentOnReady method.
47
+ */ promises.push(childStencilElm.componentOnReady());
48
+ }
49
+ waitComponentOnReady(childElm, promises);
50
+ }
51
+ };
52
+ waitComponentOnReady(document.documentElement, promiseChain);
53
+ Promise.all(promiseChain).then(function() {
54
+ return resolve();
55
+ }).catch(function() {
56
+ return resolve();
57
+ });
58
+ });
59
+ });
60
+ })
61
+ ];
62
+ case 1:
63
+ _state.sent();
64
+ if (page.isClosed()) {
65
+ return [
66
+ 2
67
+ ];
68
+ }
69
+ return [
70
+ 4,
71
+ page.waitForLoadState('networkidle')
72
+ ];
73
+ case 2:
74
+ _state.sent();
75
+ return [
76
+ 4,
77
+ page.waitForTimeout(timeoutMs)
78
+ ];
79
+ case 3:
80
+ _state.sent();
81
+ return [
82
+ 3,
83
+ 5
84
+ ];
85
+ case 4:
86
+ e = _state.sent();
87
+ console.error(e);
88
+ return [
89
+ 3,
90
+ 5
91
+ ];
92
+ case 5:
93
+ return [
94
+ 2
95
+ ];
96
+ }
97
+ });
98
+ })();
99
+ };
@@ -0,0 +1,13 @@
1
+ export var screenshot = function screenshot(tag) {
2
+ return function(name) {
3
+ return tag + "__" + name + ".png";
4
+ };
5
+ };
6
+ export var wait = function wait(ms) {
7
+ if (ms === void 0) ms = 0;
8
+ return new Promise(function(resolve) {
9
+ setTimeout(function() {
10
+ return resolve();
11
+ }, ms);
12
+ });
13
+ };
@@ -0,0 +1 @@
1
+ /* eslint-disable @typescript-eslint/no-namespace */ export { };
@@ -0,0 +1,54 @@
1
+ export { }; // /**
2
+ // * Returns the main resource response. In case of multiple redirects, the navigation will resolve with the response of the
3
+ // * last redirect.
4
+ // *
5
+ // * The method will throw an error if:
6
+ // * - there's an SSL error (e.g. in case of self-signed certificates).
7
+ // * - target URL is invalid.
8
+ // * - the `timeout` is exceeded during navigation.
9
+ // * - the remote server does not respond or is unreachable.
10
+ // * - the main resource failed to load.
11
+ // *
12
+ // * The method will not throw an error when any valid HTTP status code is returned by the remote server, including 404 "Not
13
+ // * Found" and 500 "Internal Server Error". The status code for such responses can be retrieved by calling
14
+ // * [response.status()](https://playwright.dev/docs/api/class-response#response-status).
15
+ // *
16
+ // * > NOTE: The method either throws an error or returns a main resource response. The only exceptions are navigation to
17
+ // * `about:blank` or navigation to the same URL with a different hash, which would succeed and return `null`.
18
+ // * > NOTE: Headless mode doesn't support navigation to a PDF document. See the
19
+ // * [upstream issue](https://bugs.chromium.org/p/chromium/issues/detail?id=761295).
20
+ // *
21
+ // * Shortcut for main frame's [frame.goto(url[, options])](https://playwright.dev/docs/api/class-frame#frame-goto)
22
+ // * @param url URL to navigate page to. The url should include scheme, e.g. `https://`. When a `baseURL` via the context options was
23
+ // * provided and the passed URL is a path, it gets merged via the [`new URL()`](https://developer.mozilla.org/en-US/docs/Web/API/URL/URL) constructor.
24
+ // */
25
+ // goto: (url: string, options?: BalPageOptions) => Promise<null | Response>
26
+ // /**
27
+ // * Assigns HTML markup to a page.
28
+ // * @param html - The HTML markup to assign to the page
29
+ // */
30
+ // mount: (html: string) => Promise<void>
31
+ // /**
32
+ // * After changes have been made to a component, such as an update to a property or attribute,
33
+ // * we need to wait until the changes have been applied to the DOM.
34
+ // */
35
+ // waitForChanges: (timeoutMs?: number) => Promise<void>
36
+ // /**
37
+ // * Find an element by selector.
38
+ // * See https://playwright.dev/docs/locators for more information.
39
+ // */
40
+ // locator: (selector: string, options?: LocatorOptions) => E2ELocator
41
+ // /**
42
+ // * Creates a new EventSpy and listens on the window for an event.
43
+ // * The test will timeout if the event never fires.
44
+ // *
45
+ // * Usage:
46
+ // * ```ts
47
+ // * const ionChange = await page.spyOnEvent('ionChange');
48
+ // * ...
49
+ // * await ionChange.next();
50
+ // * ```
51
+ // */
52
+ // spyOnEvent: (eventName: string) => Promise<EventSpy>
53
+ // _e2eEventsIds: number
54
+ // _e2eEvents: Map<number, any>
package/package.json CHANGED
@@ -1,6 +1,34 @@
1
1
  {
2
2
  "name": "@helvetia-design/playwright",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.0.2",
4
+ "description": "The Helvetia Design System is an open source project for styling awesome web applications that follow the Helvetia corporate styling guidelines.",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/helvetia-design/system.git"
8
+ },
9
+ "publishConfig": {
10
+ "access": "public"
11
+ },
12
+ "homepage": "https://helvetia-design.vercel.app",
13
+ "security": "https://github.com/helvetia-design/system/security/advisories/new",
14
+ "license": "Apache-2.0",
15
+ "type": "module",
16
+ "main": "dist/src/index.js",
17
+ "files": [
18
+ "dist/",
19
+ "sbom.cdx.json"
20
+ ],
21
+ "dependencies": {
22
+ "@axe-core/playwright": "4.13.0",
23
+ "fast-deep-equal": "3.1.3"
24
+ },
25
+ "devDependencies": {
26
+ "eslint": "10.11.0",
27
+ "vitest": "4.1.11"
28
+ },
29
+ "scripts": {
30
+ "build": "swc src -d dist --config-file .swcrc",
31
+ "test": "vitest --run",
32
+ "lint": "eslint ."
33
+ }
6
34
  }