@ui5/webcomponents-tools 2.7.0-rc.2 → 2.7.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 CHANGED
@@ -3,6 +3,14 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [2.7.0](https://github.com/SAP/ui5-webcomponents/compare/v2.7.0-rc.2...v2.7.0) (2025-02-03)
7
+
8
+ **Note:** Version bump only for package @ui5/webcomponents-tools
9
+
10
+
11
+
12
+
13
+
6
14
  # [2.7.0-rc.2](https://github.com/SAP/ui5-webcomponents/compare/v2.7.0-rc.1...v2.7.0-rc.2) (2025-01-30)
7
15
 
8
16
  **Note:** Version bump only for package @ui5/webcomponents-tools
@@ -36,4 +36,33 @@
36
36
  // }
37
37
  // }
38
38
 
39
- import "cypress-real-events";
39
+ import "cypress-real-events";
40
+
41
+ const realEventCmdCallback = (originalFn, element, ...args) => {
42
+ cy.get(element)
43
+ .should($el => {
44
+ if ($el[0].tagName.includes("-") && $el[0].shadowRoot) {
45
+ expect($el[0].shadowRoot.hasChildNodes()).to.be.true;
46
+ } else {
47
+ expect(true).to.be.true;
48
+ }
49
+ })
50
+ .and("be.visible")
51
+ .then(() => {
52
+ return originalFn(element, ...args)
53
+ });
54
+ };
55
+
56
+ const commands = [
57
+ "realClick",
58
+ "realHover",
59
+ "realTouch",
60
+ "realSwipe",
61
+ "realMouseDown",
62
+ "realMouseUp",
63
+ "realMouseMove"
64
+ ];
65
+
66
+ commands.forEach(cmd => {
67
+ Cypress.Commands.overwrite(cmd, realEventCmdCallback)
68
+ });
@@ -1,5 +1,4 @@
1
1
  /// <reference types="cypress" />
2
- import { RenderOptions, HTMLTemplateResult } from 'lit';
3
2
  import "cypress-real-events";
4
3
 
5
4
  export type Renderable = HTMLTemplateResult;
@@ -7,13 +6,13 @@ export interface MountUI5Options extends MountLitTemplateOptions {
7
6
  ui5Configuration: object;
8
7
  }
9
8
  export type MountOptions = Partial<MountUI5Options>;
10
- export declare function mount<T extends keyof HTMLElementTagNameMap = any>(component: string | Renderable, options?: MountOptions): Cypress.Chainable<JQuery<HTMLElementTagNameMap[T]>>;
9
+ export declare function mount<T extends keyof HTMLElementTagNameMap = any>(component: JSX.Element, options?: MountOptions): Cypress.Chainable<JQuery<HTMLElementTagNameMap[T]>>;
11
10
  declare global {
12
11
  namespace Cypress {
13
12
  interface Chainable {
14
13
  /**
15
14
  * Mount your component into Cypress sandbox
16
- * @param component content to render by lit-html render function
15
+ * @param component content to render by preact render function
17
16
  * @param options render options for custom rendering
18
17
  */
19
18
  mount: typeof mount;
@@ -1,35 +1,46 @@
1
- import '@cypress/code-coverage/support'
2
- import { setupHooks } from '@cypress/mount-utils';
3
- import { unsafeHTML } from 'lit-html/directives/unsafe-html.js';
4
- import { mount } from 'cypress-ct-lit'
1
+ import "@cypress/code-coverage/support";
2
+ import { setupHooks, getContainerEl } from "@cypress/mount-utils";
3
+ import { mount as preactMount } from "./cypress-ct-preact.js";
5
4
  import "./commands.js";
6
5
 
7
- let dispose;
8
-
9
- function cleanup() {
10
- dispose?.();
11
- }
12
-
13
- function ui5Mount(component, options = {}) {
14
- const configurationScript = document.head.querySelector("script[data-ui5-config]")
15
- cleanup();
6
+ function applyConfiguration(options) {
7
+ const configurationScript = document.head.querySelector("script[data-ui5-config]");
16
8
 
17
9
  if (options.ui5Configuration) {
18
10
  configurationScript.innerHTML = JSON.stringify(options.ui5Configuration);
19
-
20
- }
21
-
22
- dispose = () => {
23
- configurationScript.innerHTML = "{}";
24
11
  }
12
+ }
25
13
 
26
- if (typeof component === "string") {
27
- return mount(unsafeHTML(component), options)
28
- }
14
+ function cleanup() {
15
+ preactMount(null, getContainerEl());
16
+ }
29
17
 
30
- return mount(component, options)
18
+ function mount(component, options = {}) {
19
+ const container = getContainerEl();
20
+
21
+ // Apply custom configuration
22
+ applyConfiguration(options);
23
+
24
+ // Mount JSX Element
25
+ return cy.wrap({ preactMount })
26
+ .invoke("preactMount", component, container)
27
+ .then(() => {
28
+ cy.get(container)
29
+ .find("*")
30
+ .should($el => {
31
+ const shadowrootsExist = [...$el].every(el => {
32
+ if (el.tagName.includes("-") && el.shadowRoot) {
33
+ return el.shadowRoot.hasChildNodes();
34
+ }
35
+
36
+ return true;
37
+ })
38
+
39
+ expect(shadowrootsExist, "Custom elements with shadow DOM have content in their shadow DOM").to.be.true;
40
+ })
41
+ });
31
42
  }
32
43
 
33
44
  setupHooks(cleanup);
34
45
 
35
- Cypress.Commands.add('mount', ui5Mount)
46
+ Cypress.Commands.add('mount', mount)
@@ -0,0 +1,11 @@
1
+ import { render } from 'preact';
2
+
3
+ function mount(component, container) {
4
+ render(null, container);
5
+
6
+ return render(component, container);
7
+ }
8
+
9
+ export {
10
+ mount,
11
+ };
@@ -2,6 +2,16 @@ const { defineConfig } = require('cypress')
2
2
  const path = require("path");
3
3
  const coverageTask = require('@cypress/code-coverage/task');
4
4
 
5
+ const suites = {
6
+ SUITE1: [
7
+ "**/specs/base/*.cy.{jsx,tsx}",
8
+ "**/specs/[A-I]*.cy.{js,jsx,ts,tsx}",
9
+ ],
10
+ SUITE2: [
11
+ "**/specs/[^A-I]*.cy.{js,jsx,ts,tsx}",
12
+ ],
13
+ };
14
+
5
15
  module.exports = defineConfig({
6
16
  component: {
7
17
  setupNodeEvents(on, config) {
@@ -10,9 +20,8 @@ module.exports = defineConfig({
10
20
  },
11
21
  supportFile: path.join(__dirname, "cypress/support/component.js"),
12
22
  indexHtmlFile: path.join(__dirname, "cypress/support/component-index.html"),
13
- specPattern: ["**/specs/*.cy.{js,ts}", "**/specs/**/*.cy.{js,ts}"],
23
+ specPattern: suites[process.env.TEST_SUITE] || ["**/specs/**/*.cy.{js,ts,jsx,tsx}"],
14
24
  devServer: {
15
- framework: 'cypress-ct-lit',
16
25
  bundler: 'vite',
17
26
  }
18
27
  },
@@ -21,4 +30,4 @@ module.exports = defineConfig({
21
30
  scrollBehavior: false,
22
31
  viewportHeight: 1080,
23
32
  viewportWidth: 1440,
24
- })
33
+ })
@@ -56,7 +56,7 @@ const getTsModeOverrides = () => {
56
56
  };
57
57
 
58
58
  const cypressConfiguration = {
59
- "files": ["**/cypress/**/*.ts"],
59
+ "files": ["**/cypress/**/*.ts", "**/cypress/**/*.tsx"],
60
60
 
61
61
  "plugins": [
62
62
  "cypress"
@@ -69,6 +69,7 @@ const getTsModeOverrides = () => {
69
69
  },
70
70
  "rules": {
71
71
  "max-nested-callbacks": 0,
72
+ "no-unused-expressions": 0,
72
73
  "@typescript-eslint/no-namespace": "off",
73
74
  "cypress/no-assigning-return-values": "error",
74
75
  "cypress/no-unnecessary-waiting": "error",
@@ -123,6 +123,8 @@ const getScripts = (options) => {
123
123
  start: "nps prepare watch.devServer",
124
124
  test: `node "${LIB}/test-runner/test-runner.js"`,
125
125
  "test-cy-ci": `cross-env CYPRESS_COVERAGE=true yarn cypress run --component --browser chrome`,
126
+ "test-cy-ci-suite-1": `cross-env CYPRESS_COVERAGE=true TEST_SUITE=SUITE1 yarn cypress run --component --browser chrome`,
127
+ "test-cy-ci-suite-2": `cross-env CYPRESS_COVERAGE=true TEST_SUITE=SUITE2 yarn cypress run --component --browser chrome`,
126
128
  "test-cy-open": `cross-env CYPRESS_COVERAGE=true yarn cypress open --component --browser chrome`,
127
129
  "test-suite-1": `node "${LIB}/test-runner/test-runner.js" --suite suite1`,
128
130
  "test-suite-2": `node "${LIB}/test-runner/test-runner.js" --suite suite2`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ui5/webcomponents-tools",
3
- "version": "2.7.0-rc.2",
3
+ "version": "2.7.0",
4
4
  "description": "UI5 Web Components: webcomponents.tools",
5
5
  "author": "SAP SE (https://www.sap.com)",
6
6
  "license": "Apache-2.0",
@@ -64,6 +64,7 @@
64
64
  "postcss": "^8.4.5",
65
65
  "postcss-cli": "^9.1.0",
66
66
  "postcss-selector-parser": "^6.0.10",
67
+ "preact": "^10.25.4",
67
68
  "prompts": "^2.4.2",
68
69
  "properties-reader": "^2.2.0",
69
70
  "recursive-readdir": "^2.2.2",
@@ -84,10 +85,10 @@
84
85
  }
85
86
  },
86
87
  "devDependencies": {
87
- "cypress-ct-lit": "^0.4.0",
88
+ "@cypress/mount-utils": "^4.1.2",
88
89
  "cypress-real-events": "^1.12.0",
89
90
  "esbuild": "^0.19.9",
90
91
  "yargs": "^17.5.1"
91
92
  },
92
- "gitHead": "26546e81e1e1e3c9186a9540b979ec7032a8cf95"
93
+ "gitHead": "91c56c48e906a28c476cfe304bf13edbbbad34a5"
93
94
  }