Skip to content
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

chore: add testing package #10065

Draft
wants to merge 12 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
"packages/main",
"packages/compat",
"packages/ai",
"packages/testing",
"packages/fiori",
"packages/icons",
"packages/icons-business-suite",
Expand Down
5 changes: 5 additions & 0 deletions packages/base/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
const config = require("@ui5/webcomponents-tools/components-package/eslint.js");
const testEslint = require("@ui5/webcomponents-testing/src/eslint.cjs");

testEslint.forEach(override => {
config.overrides?.push(override);
});

module.exports = config;
2 changes: 1 addition & 1 deletion packages/base/cypress.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import cypressConfig from "@ui5/webcomponents-tools/components-package/cypress.config.js";
import cypressConfig from "@ui5/webcomponents-testing/src/cypress.config.js";

export default cypressConfig;
2 changes: 1 addition & 1 deletion packages/base/cypress/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"./**/*"
],
"compilerOptions": {
"types": ["@ui5/webcomponents-tools"],
"types": ["@ui5/webcomponents-testing"],
"outDir": "dist",
"composite": true,
"tsBuildInfoFile": "dist/.tsbuildinfobuild",
Expand Down
1 change: 1 addition & 0 deletions packages/base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
"devDependencies": {
"@openui5/sap.ui.core": "1.120.17",
"@ui5/webcomponents-tools": "2.4.0-rc.1",
"@ui5/webcomponents-testing": "0.0.0",
"chromedriver": "^129.0.0",
"clean-css": "^5.2.2",
"copy-and-watch": "^0.1.5",
Expand Down
1 change: 0 additions & 1 deletion packages/base/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"src/global.d.ts",
],
"compilerOptions": {
"types": ["@ui5/webcomponents-tools"],
"outDir": "dist",
"composite": true,
"rootDir": "src",
Expand Down
5 changes: 5 additions & 0 deletions packages/fiori/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
const config = require("@ui5/webcomponents-tools/components-package/eslint.js");
const testEslint = require("@ui5/webcomponents-testing/src/eslint.cjs");

testEslint.forEach(override => {
config.overrides?.push(override);
});

module.exports = config;
2 changes: 1 addition & 1 deletion packages/fiori/cypress.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import cypressConfig from "@ui5/webcomponents-tools/components-package/cypress.config.js";
import cypressConfig from "@ui5/webcomponents-testing/src/cypress.config.js";
import path from "path";
import { fileURLToPath } from "node:url";

Expand Down
2 changes: 1 addition & 1 deletion packages/fiori/cypress/specs/BarcodeScannerDialog.cy.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { html } from "lit";
import { html } from "lit-html";
import "@ui5/webcomponents-icons/dist/camera.js";
import "../../src/BarcodeScannerDialog.js";
import type BarcodeScannerDialog from "../../src/BarcodeScannerDialog.js";
Expand Down
2 changes: 1 addition & 1 deletion packages/fiori/cypress/specs/FCL.cy.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { html } from "lit";
import { html } from "lit-html";
import { setAnimationMode } from "@ui5/webcomponents-base/dist/config/AnimationMode.js";
import "../../src/FlexibleColumnLayout.js";

Expand Down
2 changes: 1 addition & 1 deletion packages/fiori/cypress/specs/Page.cy.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { html } from "lit";
import { html } from "lit-html";
import "../../src/Page.js";
import "@ui5/webcomponents/dist/Bar.js";
import "@ui5/webcomponents/dist/Button.js";
Expand Down
2 changes: 1 addition & 1 deletion packages/fiori/cypress/support/component.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import "@ui5/webcomponents-tools/components-package/cypress/support/component.js";
import "@ui5/webcomponents-testing/src/cypress/support/component.js";

import "./commands.js";
2 changes: 1 addition & 1 deletion packages/fiori/cypress/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"./**/*"
],
"compilerOptions": {
"types": ["@ui5/webcomponents-tools"],
"types": ["@ui5/webcomponents-testing"],
"composite": true,
"tsBuildInfoFile": "dist/.tsbuildinfobuild",
"paths": {
Expand Down
3 changes: 2 additions & 1 deletion packages/fiori/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@
},
"devDependencies": {
"@ui5/webcomponents-tools": "2.4.0-rc.1",
"@ui5/webcomponents-testing": "0.0.0",
"chromedriver": "^129.0.0",
"lit": "^2.0.0"
"lit-html": "^2.0.0"
}
}
5 changes: 5 additions & 0 deletions packages/main/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
const config = require("@ui5/webcomponents-tools/components-package/eslint.js");
const testEslint = require("@ui5/webcomponents-testing/src/eslint.cjs");

testEslint.forEach(override => {
config.overrides?.push(override);
});

module.exports = config;
4 changes: 2 additions & 2 deletions packages/main/cypress.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import cypressConfig from "@ui5/webcomponents-tools/components-package/cypress.config.js";
import cypressConfig from "@ui5/webcomponents-testing/src/cypress.config.js";
import path from "path";
import { fileURLToPath } from "node:url";

Expand All @@ -7,4 +7,4 @@ const __dirname = path.dirname(__filename);

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

export default cypressConfig;
export default cypressConfig;
2 changes: 1 addition & 1 deletion packages/main/cypress/specs/Button.cy.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { html } from "lit";
import { html } from "lit-html";
import "../../src/Button.js";
import type Button from "../../src/Button.js";
import "@ui5/webcomponents-icons/dist/download.js";
Expand Down
2 changes: 1 addition & 1 deletion packages/main/cypress/specs/Eventing.cy.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// import { html } from "lit";
// import { html } from "lit-html";
import "../../src/Button.js";

describe("Eventing", () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/main/cypress/specs/F6.cy.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { html } from "lit";
import { html } from "lit-html";
import "@ui5/webcomponents-base/dist/features/F6Navigation.js";
import "../../src/Button.js";

Expand Down
2 changes: 1 addition & 1 deletion packages/main/cypress/specs/Form.cy.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { html } from "lit";
import { html } from "lit-html";
import "../../src/Form.js";
import "../../src/FormItem.js";
import "../../src/FormGroup.js";
Expand Down
2 changes: 1 addition & 1 deletion packages/main/cypress/specs/FormSupport.cy.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { html } from "lit";
import { html } from "lit-html";
import "../../src/Button.js";
import "../../src/CheckBox.js";
import "../../src/ColorPicker.js";
Expand Down
2 changes: 1 addition & 1 deletion packages/main/cypress/specs/List.cy.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { html } from "lit";
import { html } from "lit-html";
import "../../src/List.js";
import type List from "../../src/List.js";

Expand Down
2 changes: 1 addition & 1 deletion packages/main/cypress/specs/LitKeyFunction.cy.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { html } from "lit";
import { html } from "lit-html";
import "../../src/MultiComboBox.js";
import "../../src/MultiComboBoxItem.js";

Expand Down
2 changes: 1 addition & 1 deletion packages/main/cypress/specs/Menu.cy.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { html } from "lit";
import { html } from "lit-html";
import "../../src/Button.js";
import "../../src/Menu.js";
import "../../src/MenuItem.js";
Expand Down
2 changes: 1 addition & 1 deletion packages/main/cypress/specs/RTL.cy.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { html } from "lit";
import { html } from "lit-html";
import "../../src/CheckBox.js";

describe("RTL", () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/main/cypress/specs/ResponsivePopover.mobile.cy.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { html } from "lit";
import { html } from "lit-html";
import "../../src/ResponsivePopover.js";
import "../../src/Button.js";
import "../../src/Input.js";
Expand Down
2 changes: 1 addition & 1 deletion packages/main/cypress/specs/Select.cy.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { html } from "lit";
import { html } from "lit-html";
import "../../src/Select.js";
import "../../src/Option.js";
import "../../src/OptionCustom.js";
Expand Down
2 changes: 1 addition & 1 deletion packages/main/cypress/specs/TableLoading.cy.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { html } from "lit";
import { html } from "lit-html";
import "../../src/Table.js";
import "../../src/TableHeaderRow.js";
import "../../src/TableCell.js";
Expand Down
2 changes: 1 addition & 1 deletion packages/main/cypress/specs/TextArea.cy.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { html } from "lit";
import { html } from "lit-html";
import "../../src/TextArea.js";
import "../../src/Label.js";

Expand Down
2 changes: 1 addition & 1 deletion packages/main/cypress/specs/base/AriaLabelHelper.cy.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { html } from "lit";
import { html } from "lit-html";
import "../../../src/Label.js";
import "../../../src/Input.js";

Expand Down
4 changes: 2 additions & 2 deletions packages/main/cypress/specs/base/Events.cy.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { html } from "lit";
import { html } from "lit-html";
import "../../../src/Dialog.js";
import "../../../src/Select.js";
import "../../../src/Option.js";
Expand Down Expand Up @@ -124,7 +124,7 @@ describe("Event bubbling", () => {
<ui5-option>Hello</ui5-option>
<ui5-option>World</ui5-option>
<ui5-option>Hello</ui5-option>
</ui5-select>
</ui5-select>
</ui5-dialog>
</div>
`);
Expand Down
2 changes: 1 addition & 1 deletion packages/main/cypress/specs/base/IconCollection.cy.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import "./css/redfish.custom.theme.css";
import getEffectiveIconCollection from "@ui5/webcomponents-base/dist/asset-registries/util/getIconCollectionByTheme.js";
import { setTheme, isLegacyThemeFamily } from "@ui5/webcomponents-base/dist/config/Theme.js";
import { html } from "lit";
import { html } from "lit-html";
import "../../../src/Assets.js";
import "../../../src/Icon.js";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { html } from "lit";
import { html } from "lit-html";
import "../../../src/Card.js";
import "../../../src/CardHeader.js";

Expand Down
2 changes: 1 addition & 1 deletion packages/main/cypress/specs/base/Tooltips.cy.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { setEnableDefaultTooltips } from "@ui5/webcomponents-base/dist/config/Tooltips.js";
import { html } from "lit";
import { html } from "lit-html";
import "../../../src/Icon.js";
import "../../../src/Button.js";
import "../../../src/ToggleButton.js";
Expand Down
2 changes: 1 addition & 1 deletion packages/main/cypress/support/component.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import "@ui5/webcomponents-tools/components-package/cypress/support/component.js";
import "@ui5/webcomponents-testing/src/cypress/support/component.js";

import "./commands.js";
2 changes: 1 addition & 1 deletion packages/main/cypress/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"./**/*"
],
"compilerOptions": {
"types": ["@ui5/webcomponents-tools"],
"types": ["@ui5/webcomponents-testing"],
"composite": true,
"tsBuildInfoFile": "dist/.tsbuildinfobuild",
"paths": {
Expand Down
3 changes: 2 additions & 1 deletion packages/main/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@
},
"devDependencies": {
"@ui5/webcomponents-tools": "2.4.0-rc.1",
"@ui5/webcomponents-testing": "0.0.0",
"chromedriver": "^129.0.0",
"lit": "^2.0.0"
"lit-html": "^2.0.0"
}
}
30 changes: 30 additions & 0 deletions packages/testing/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"name": "@ui5/webcomponents-testing",
"version": "0.0.0",
"description": "UI5 Web Components: webcomponents.testing",
"author": "SAP SE (https://www.sap.com)",
"license": "Apache-2.0",
"private": false,
"type": "module",
"keywords": [
"openui5",
"sapui5",
"ui5"
],
"types": "./types/index.d.ts",
"scripts": {},
"repository": {
"type": "git",
"url": "https://github.com/SAP/ui5-webcomponents.git",
"directory": "packages/testing"
},
"dependencies": {
"cypress": "^13.11.0",
"cypress-real-events": "^1.12.0",
"eslint": "^7.22.0",
"eslint-plugin-cypress": "^3.4.0",
"vite": "^5.4.8",
"cypress-ct-lit": "^0.5.0",
"@cypress/mount-utils": "^4.0.0"
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
const { defineConfig } = require('cypress')
const path = require("path");
import { defineConfig } from 'cypress';
import path from 'path';
import { fileURLToPath } from 'url';

module.exports = defineConfig({
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

export default defineConfig({
component: {
supportFile: path.join(__dirname, "cypress/support/component.js"),
indexHtmlFile: path.join(__dirname, "cypress/support/component-index.html"),
Expand All @@ -16,4 +20,4 @@ module.exports = defineConfig({
scrollBehavior: false,
viewportHeight: 1080,
viewportWidth: 1440,
})
});
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,32 @@
// }
// }

import "cypress-real-events";
import "cypress-real-events";
import { setupHooks } from '@cypress/mount-utils';
import { mount } from 'cypress-ct-lit'

let dispose;

function cleanup() {
dispose?.();
}

function ui5Mount(component, options = {}) {
const configurationScript = document.head.querySelector("script[data-ui5-config]")
cleanup();

if (options.ui5Configuration) {
configurationScript.innerHTML = JSON.stringify(options.ui5Configuration);

}

dispose = () => {
configurationScript.innerHTML = "{}";
}

return mount(component, options)
}

setupHooks(cleanup);

Cypress.Commands.add('mount', ui5Mount)
1 change: 1 addition & 0 deletions packages/testing/src/cypress/support/component.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import "./commands.js";
32 changes: 32 additions & 0 deletions packages/testing/src/eslint.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
module.exports = [{
"files": ["**/cypress/**/*.ts"],

"plugins": [
"cypress"
],
extends: [
"plugin:cypress/recommended"
],
"env": {
"cypress/globals": true
},
"rules": {
"max-nested-callbacks": 0,
"@typescript-eslint/no-namespace": "off",
"cypress/no-assigning-return-values": "error",
"cypress/no-unnecessary-waiting": "error",
"cypress/assertion-before-screenshot": "warn",
"cypress/no-force": "warn",
"cypress/no-async-tests": "error",
"cypress/no-async-before": "error",
"cypress/no-pause": "error",
"import/no-extraneous-dependencies": [
"error",
{
"devDependencies": [
"**/cypress/**/*.ts"
]
}
]
}
}];
1 change: 1 addition & 0 deletions packages/testing/types/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import "../src/cypress/support/component"
Loading