Skip to content

chore: enable JSX in Cypress tests #10653

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 52 commits into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
83e7c44
chore: enable JSX in Cypress tests
ilhan007 Jan 24, 2025
788ab93
chore: more tests
ilhan007 Jan 24, 2025
bdf0aec
chore: more conversions
ilhan007 Jan 24, 2025
819d9a3
chore: fiori cy.tsx
ilhan007 Jan 24, 2025
fdb6dbc
chore: add UserMenu
ilhan007 Jan 24, 2025
bc3eedf
chore: migrate Shellbar cy
ilhan007 Jan 24, 2025
97bc76e
chore: convert f6 cy
ilhan007 Jan 24, 2025
d34443b
chore: convert more cy tests
ilhan007 Jan 24, 2025
c522e28
Merge branch 'main' into chore-jsx-in-cypress
ilhan007 Jan 24, 2025
8ec908d
chore: add more
ilhan007 Jan 24, 2025
72abaf2
chore: enable jsx in base cypress tests
ilhan007 Jan 25, 2025
b59e809
chore: enable cypress in the ai lib
ilhan007 Jan 25, 2025
7ec76ae
chore: convert more tests to use jsx
ilhan007 Jan 25, 2025
ed16a4d
chore: convert more tests
ilhan007 Jan 25, 2025
82da0ae
Merge branch 'main' into chore-jsx-in-cypress
ilhan007 Jan 27, 2025
455e0b2
Merge branch 'main' into chore-jsx-in-cypress
ilhan007 Jan 28, 2025
6cf1591
chore: fix RatingIndicator px perfect assertions
ilhan007 Jan 28, 2025
121ab4a
chore: fix lint errors
ilhan007 Jan 28, 2025
99f0c7c
chore: fix lint
ilhan007 Jan 28, 2025
a1791ca
chore: update node version
ilhan007 Jan 28, 2025
e2fa6be
chore: update ai tsconfig
ilhan007 Jan 28, 2025
2cf551b
chore: update
ilhan007 Jan 28, 2025
7a66054
Merge branch 'main' into chore-jsx-in-cypress
ilhan007 Jan 28, 2025
56d0eb6
chore: form
nnaydenow Jan 28, 2025
8427809
chore: update
ilhan007 Jan 28, 2025
f770883
chore: temp skip test in SideNav
ilhan007 Jan 28, 2025
0369bce
chore: update
ilhan007 Jan 28, 2025
be3bb2e
chore: fallback to lit mount
ilhan007 Jan 28, 2025
b19b955
chore: use standard preact directly
ilhan007 Jan 29, 2025
e64f527
Merge branch 'main' into chore-jsx-in-cypress
ilhan007 Jan 29, 2025
36321ce
chore: overwrite commands and migrate formsupport
nnaydenow Jan 29, 2025
165d1d8
chore: migrate base cypress tests
ilhan007 Jan 29, 2025
4294446
Merge branch 'main' into chore-jsx-in-cypress
ilhan007 Jan 29, 2025
4123ace
chore: add SideNav test
ilhan007 Jan 29, 2025
670e16c
chore: enable previously skipped SideNav tests
ilhan007 Jan 29, 2025
704691e
chore: fix failing tests
nnaydenow Jan 29, 2025
69658d3
chore: fix sn tests
nnaydenow Jan 30, 2025
506757b
chore: commands fix
nnaydenow Jan 30, 2025
59adebf
Merge remote-tracking branch 'origin/main' into chore-jsx-in-cypress
nnaydenow Jan 30, 2025
4b76d7c
chore: rebase
nnaydenow Jan 30, 2025
16f0802
chore: convert TableGrowing
ilhan007 Jan 30, 2025
ff84994
fix: base tests
nnaydenow Jan 30, 2025
1fb872b
chore: add stronger check for component actionabiltiy
nnaydenow Jan 30, 2025
7e86706
chore: table tests
nnaydenow Jan 30, 2025
9a8e5bc
chore: menu and new command
nnaydenow Jan 30, 2025
e0b7d6e
chore: table
nnaydenow Jan 30, 2025
b62337b
chore: lint
nnaydenow Jan 30, 2025
8449385
chore: check Menu
ilhan007 Jan 30, 2025
45554e7
chore: preload Input Suggestions in Events.cy.tsx
ilhan007 Jan 30, 2025
41bdda9
chore: skip Menu tests
ilhan007 Jan 30, 2025
a4f60cb
Merge branch 'main' into chore-jsx-in-cypress
ilhan007 Jan 30, 2025
3aa2b5b
Merge branch 'main' into chore-jsx-in-cypress
ilhan007 Jan 30, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci-test-website.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4.1.0
with:
node-version: 20
node-version: 22
cache: 'yarn'

- name: Install and Build
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:

- uses: actions/setup-node@v4.1.0
with:
node-version: 20
node-version: 22
cache: 'yarn'

- name: Install Dependencies
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy-website-auto.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4.1.0
with:
node-version: 20
node-version: 22
cache: 'yarn'

- name: Install and Build
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy-website-manually.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4.1.0
with:
node-version: 20
node-version: 22
cache: 'yarn'

- name: Install and Build
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy-website-on-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4.1.0
with:
node-version: 20
node-version: 22
cache: 'yarn'

- name: Install and Build
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/issues-handling.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
fetch-depth: 0
- uses: actions/setup-node@v4.1.0
with:
node-version: 20
node-version: 22
cache: 'yarn'

- name: Install
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:

- uses: actions/setup-node@v4.1.0
with:
node-version: 20
node-version: 22
cache: 'yarn'

- name: Install Dependencies
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/merge-release-changelog.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
fetch-depth: 0
- uses: actions/setup-node@v4.1.0
with:
node-version: 20
node-version: 22
cache: 'yarn'

- name: Install
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-downport.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
fetch-depth: 0
- uses: actions/setup-node@v4.1.0
with:
node-version: 20
node-version: 22
cache: 'yarn'

- name: Install
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-experimental.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4.1.0
with:
node-version: 20
node-version: 22
cache: 'yarn'

- name: Install
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-rc-auto.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
fetch-depth: 0
- uses: actions/setup-node@v4.1.0
with:
node-version: 20
node-version: 22
cache: 'yarn'

- name: Install
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-rc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
fetch-depth: 0
- uses: actions/setup-node@v4.1.0
with:
node-version: 20
node-version: 22
cache: 'yarn'

- name: Install
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-stable.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
fetch-depth: 0
- uses: actions/setup-node@v4.1.0
with:
node-version: 20
node-version: 22
cache: 'yarn'

- name: Install
Expand Down
14 changes: 7 additions & 7 deletions docs/4-development/02-component.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,39 +58,39 @@ class MyDemoComponent extends UI5Element {
**Note:** As per the HTML specification, the tag name must contain a dash ('-').

### renderer
This option specifies the rendering engine for the component. UI5 Web Components are agnostic of the DOM rendering engine used. However, all standard UI5 Web Components (`@ui5/webcomponents`, `@ui5/webcomponents-fiori`, etc.) use [lit-html](https://github.com/Polymer/lit-html) as the rendering technology of choice.
This option specifies the rendering engine for the component. UI5 Web Components are agnostic of the DOM rendering engine used. However, all standard UI5 Web Components (`@ui5/webcomponents`, `@ui5/webcomponents-fiori`, etc.) use [preact](https://github.com/preactjs/preact) as the rendering technology of choice.

```ts
import UI5Element from "@ui5/webcomponents-base/dist/UI5Element.js";
import customElement from "@ui5/webcomponents-base/dist/decorators/customElement.js";
import litRender from "@ui5/webcomponents-base/dist/renderer/LitRenderer.js";
import jsxRenderer from "@ui5/webcomponents-base/dist/renderer/JsxRenderer.js";

@customElement({
renderer: litRender
renderer: jsxRenderer
})
class MyDemoComponent extends UI5Element {
// class implementation
}
```

### template
This option accepts a template in a format that your defined renderer will understand.
This option accepts a template in a format that your defined renderer will understand. Standard UI5 Web Components use JSX templates.

```ts
import UI5Element from "@ui5/webcomponents-base/dist/UI5Element.js";
import customElement from "@ui5/webcomponents-base/dist/decorators/customElement.js";
import MyDemoComponentTemplate from "./generated/templates/MyDemoComponentTemplate.lit.js";
import jsxRenderer from "@ui5/webcomponents-base/dist/renderer/JsxRenderer.js";
import MyDemoComponentTemplate from "./MyDemoComponentTemplate.js";

@customElement({
renderer: jsxRenderer,
template: MyDemoComponentTemplate
})
class MyDemoComponent extends UI5Element {
// class implementation
}
```

**Note:** Standard UI5 Web Components use Handlebars templates that are automatically converted to `lit-html` syntax by the build script. If you have a `MyDemoComponentTemplate.hbs`, the build script will create a `generated/templates/DemoTemplate.lit.ts` file for you.

### styles
This option accepts either component styles or an array of component styles that should be inserted inside the shadow root of the component.

Expand Down
22 changes: 10 additions & 12 deletions docs/4-development/10-testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -225,21 +225,19 @@ For each package in your project, include a `cypress` folder at the root level w
To write tests for a specific component, create a file in the respective package's specs folder:

```
{packageName}/cypress/specs/MyComponent.cy.ts
{packageName}/cypress/specs/MyComponent.cy.tsx
```

We utilize component testing for UI5 web components, which involves mounting the component you intend to test. Our custom `mount` function leverages Lit for rendering components.
We utilize component testing for UI5 web components, which involves mounting the component you intend to test. Our custom `mount` function leverages `preact` with `JSX` syntax for rendering components.

**Example Test File:**

```typescript
import { html } from "lit";
describe("MyComponent Rendering", () => {
it("MyComponent exists", () => {
cy.mount(<MyComponent></MyComponent>);

describe("Demo", () => {
it("Button exists", () => {
cy.mount(html`<ui5-test-generic></ui5-test-generic>`);

cy.get("[ui5-button]").should("exist");
cy.get("[my-component]").should("exist");
});
});
```
Expand Down Expand Up @@ -301,7 +299,7 @@ With Cypress component testing, we can efficiently verify if events are fired us
**Example:**

```typescript
cy.mount(html`<ui5-button></ui5-button>`);
cy.mount(<Button></Button>`);

cy.get("[ui5-button]").then(($button) => {
cy.spy($button[0], "click").as("clickEvent");
Expand Down Expand Up @@ -332,7 +330,7 @@ describe("Configuration Example", () => {
};

before(() => {
cy.mount(html`<ui5-test-generic></ui5-test-generic>`, {
cy.mount(<MyComponent></MyComponent>, {
ui5Configuration: config,
});

Expand Down Expand Up @@ -381,7 +379,7 @@ To simulate mobile testing conditions, use the `ui5SimulateDevice` Cypress comma
**Example:**

```typescript
cy.mount(html`<ui5-button></ui5-button>`);
cy.mount(<Button></Button>);

cy.ui5SimulateDevice("phone"); // Simulates a phone device

Expand Down Expand Up @@ -426,7 +424,7 @@ import "./myComponentCommands";
```typescript
describe("My Component Tests", () => {
it("should click my component", () => {
cy.mount(html`<my-component></my-component>`);
cy.mount(<MyComponent></MyComponent>);

cy.clickMyComponent("my-component");
});
Expand Down
1 change: 1 addition & 0 deletions packages/ai/.eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ bundle.*.js
rollup.config*.js
wdio.conf.cjs
postcss.config.cjs
cypress.config.js
package-scripts.cjs
.eslintrc.cjs
10 changes: 10 additions & 0 deletions packages/ai/cypress.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import cypressConfig from "@ui5/webcomponents-tools/components-package/cypress.config.js";
import path from "path";
import { fileURLToPath } from "node:url";

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

cypressConfig.component.supportFile = path.join(__dirname, "cypress/support/component.ts");

export default cypressConfig;
14 changes: 14 additions & 0 deletions packages/ai/cypress/specs/Button.cy.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import Button from "../../src/Button.js";
import ButtonState from "../../src/ButtonState.js";

describe("Initial rendering", () => {
it("tests no config provided", () => {
cy.mount(
<Button>
<ButtonState name="generate" text="Generate" icon="ai">Click me</ButtonState>
<ButtonState name="generating" text="Stop Generating" icon="stop">Click me</ButtonState>
<ButtonState name="revise" text="Revise" icon="ai">Click me</ButtonState>
</Button>
);
});
});
1 change: 1 addition & 0 deletions packages/ai/cypress/support/commands.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import "../../../main/cypress/support/commands.js";
3 changes: 3 additions & 0 deletions packages/ai/cypress/support/component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import "@ui5/webcomponents-tools/components-package/cypress/support/component.js";

import "./commands.js";
44 changes: 44 additions & 0 deletions packages/ai/cypress/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"extends": "@ui5/webcomponents-tools/tsconfig.json",
"include": [
"./**/*"
],
"compilerOptions": {
"types": ["@ui5/webcomponents-tools"],
"composite": true,
"tsBuildInfoFile": "dist/.tsbuildinfobuild",
"module": "NodeNext",
"moduleResolution": "nodenext",
"paths": {
"@ui5/webcomponents-base/dist/*": [
"../../base/src/*"
],
"@ui5/webcomponents/dist/*": [
"../../main/src/*"
],
"@ui5/webcomponents-localization/dist/*": [
"../../localization/src/*"
],
"@ui5/webcomponents-theming/dist/*": [
"../../theming/src/*"
],
"@ui5/webcomponents-icons/dist/*": [
"../../icons/src/*"
],
"@ui5/webcomponents-icons-business-suite/dist/*": [
"../../icons-business-suite/src/*"
],
"@ui5/webcomponents-icons-tnt/dist/*": [
"../../icons-tnt/src/*"
]
},
},
"references": [
{
"path": "../"
},
{
"path": "../../main/cypress"
}
]
}
4 changes: 3 additions & 1 deletion packages/ai/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
"generate": "nps generate",
"generateAPI": "nps generateAPI",
"bundle": "nps build.bundle",
"test": "wc-dev test",
"test": "nps test-cy-ci",
"test:cypress": "nps test-cy-ci",
"test:cypress:open": "nps test-cy-open",
"test:ssr": "node -e \"import('./test/ssr/component-imports.js')\"",
"create-ui5-element": "wc-create-ui5-element",
"prepublishOnly": "tsc -b"
Expand Down
7 changes: 0 additions & 7 deletions packages/ai/test/specs/Button.spec.js

This file was deleted.

29 changes: 25 additions & 4 deletions packages/ai/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,51 @@
"compilerOptions": {
"outDir": "dist",
"experimentalDecorators": true,
"verbatimModuleSyntax": true,
"composite": true,
"rootDir": "src",
"tsBuildInfoFile": "dist/.tsbuildinfo",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"verbatimModuleSyntax": true,
"paths": {
"@ui5/webcomponents-base/dist/*": [
"../base/src/*"
],
"@ui5/webcomponents/dist/*": [
"../main/src/*"
"@ui5/webcomponents-localization/dist/*": [
"../localization/src/*"
],
"@ui5/webcomponents-theming/dist/*": [
"../theming/src/*"
],
"@ui5/webcomponents-icons/dist/*": [
"../icons/src/*"
],
"@ui5/webcomponents-icons-business-suite/dist/*": [
"../icons-business-suite/src/*"
],
"@ui5/webcomponents-icons-tnt/dist/*": [
"../icons-tnt/src/*"
]
},
},
"references": [
{
"path": "../base"
},
{
"path": "../main"
"path": "../localization"
},
{
"path": "../theming"
},
{
"path": "../icons"
},
{
"path": "../icons-business-suite"
},
{
"path": "../icons-tnt"
},
]
}
Loading