Skip to content

Commit

Permalink
chore: remove lit mount for cypress tests (SAP#10722)
Browse files Browse the repository at this point in the history
Testing syntax has been switched to TSX, making the lit mount setup redundant.
  • Loading branch information
nnaydenow authored Jan 31, 2025
1 parent 973bc46 commit 5fe02fd
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 41 deletions.
3 changes: 2 additions & 1 deletion packages/base/cypress/specs/ConfigurationScript.cy.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { getAnimationMode } from "../../src/config/AnimationMode.js";
import { getCalendarType } from "../../src/config/CalendarType.js";
import { getDefaultFontLoading } from "../../src/config/Fonts.js";
import TestGeneric from "../../test/test-elements/Generic.js";
import { getFirstDayOfWeek, getLegacyDateCalendarCustomizing } from "../../src/config/FormatSettings.js";
import { getLanguage } from "../../src/config/Language.js";
import { getNoConflict } from "../../src/config/NoConflict.js";
Expand Down Expand Up @@ -43,7 +44,7 @@ describe("Configuration script", () => {
};

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

Expand Down
14 changes: 7 additions & 7 deletions packages/base/cypress/specs/ConfigurationURL.cy.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { internals } from "../../src/Location.js";
import "../../test/test-elements/Generic.js";
import TestGeneric from "../../test/test-elements/Generic.js";
import { resetConfiguration } from "../../src/InitialConfiguration.js";
import { getLanguage } from "../../src/config/Language.js";
import { getCalendarType } from "../../src/config/CalendarType.js";
Expand All @@ -23,7 +23,7 @@ describe("Some settings can be set via SAP UI URL params", () => {
.invoke("search")
.should("be.equal", searchParams);

cy.mount(`<ui5-test-generic></ui5-test-generic>`);
cy.mount(<TestGeneric />);
});

it("Tests that language is applied", () => {
Expand Down Expand Up @@ -66,7 +66,7 @@ describe("Different themeRoot configurations", () => {
.invoke("search")
.should("be.equal", searchParams);

cy.mount(`<ui5-test-generic></ui5-test-generic>`);
cy.mount(<TestGeneric />);

cy.wrap({ getThemeRoot })
.invoke("getThemeRoot")
Expand All @@ -87,7 +87,7 @@ describe("Different themeRoot configurations", () => {
.invoke("search")
.should("be.equal", searchParams);

cy.mount(`<ui5-test-generic></ui5-test-generic>`);
cy.mount(<TestGeneric />);

cy.wrap({ getThemeRoot })
.invoke("getThemeRoot")
Expand All @@ -108,7 +108,7 @@ describe("Different themeRoot configurations", () => {
.invoke("search")
.should("be.equal", searchParams);

cy.mount(`<ui5-test-generic></ui5-test-generic>`);
cy.mount(<TestGeneric />);

cy.wrap({ getThemeRoot })
.invoke("getThemeRoot")
Expand All @@ -134,7 +134,7 @@ describe("Some settings can be set via SAP URL params", () => {
.invoke("search")
.should("be.equal", searchParams);

cy.mount(`<ui5-test-generic></ui5-test-generic>`);
cy.mount(<TestGeneric />);
});

it("Tests that language is applied via sap-ui-language", () => {
Expand Down Expand Up @@ -165,7 +165,7 @@ describe("Some settings can be set via SAP UI URL params", () => {
.invoke("search")
.should("be.equal", searchParams);

cy.mount(`<ui5-test-generic></ui5-test-generic>`);
cy.mount(<TestGeneric />);
});

it("Tests that language is applied via sap-ui-language", () => {
Expand Down
4 changes: 2 additions & 2 deletions packages/base/cypress/specs/CustomTheme.cy.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { registerThemePropertiesLoader } from "../../src/AssetRegistry.js";
import { setTheme } from "../../src/config/Theme.js";
import { getCurrentRuntimeIndex } from "../../src/Runtimes.js";
import "../../test/test-elements/Generic.js";
import TestGeneric from "../../test/test-elements/Generic.js";

describe("Custom themes can be registered", () => {
it("Tests that theme parameters are changed on theme change", () => {
Expand All @@ -10,7 +10,7 @@ describe("Custom themes can be registered", () => {
const currentRuntime = 0;
const dataPropAttr = `data-ui5-component-properties-${currentRuntime}`;

cy.mount(`<ui5-test-generic></ui5-test-generic>`);
cy.mount(<TestGeneric />);

cy.wrap({ getCurrentRuntimeIndex })
.invoke("getCurrentRuntimeIndex")
Expand Down
2 changes: 1 addition & 1 deletion packages/base/cypress/specs/UI5ElementLifecycle.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ describe("Lifecycle works", () => {
it("Tests element destruction callback", () => {
const el = document.createElement("ui5-test-generic");

cy.mount(`<div id="container"></div>`);
cy.mount(<div id="container"></div>);

cy.spy<UI5Element>((el as UI5Element), "onExitDOM").as("onExitDOM");
cy.spy<UI5Element>((el as UI5Element), "onEnterDOM").as("onEnterDOM");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import "../../test/test-elements/WithComplexTemplate.js";
import WithComplexTemplate from "../../test/test-elements/WithComplexTemplate.js";

describe("Complex templates", () => {
it("Tests context maintained in the HBS template before, after and inside 'each' statements", () => {
const EXPTECTED_LOOP_CONTENT = "Root text: root, Item text: positives";
const EXPTECTED_NESTED_LOOP_CONTENT = "Root Text: root, Word text: word1_good";

cy.mount(`<ui5-test-complex-template></ui5-test-complex-template>`);
cy.mount(<WithComplexTemplate />);

cy.get("[ui5-test-complex-template]")
.shadow()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/// <reference types="cypress" />
import { RenderOptions, HTMLTemplateResult } from 'lit';
import "cypress-real-events";

export type Renderable = HTMLTemplateResult;
Expand All @@ -13,7 +12,7 @@ declare global {
interface Chainable {
/**
* Mount your component into Cypress sandbox
* @param component content to render by lit-html render function
* @param component content to render by preact render function
* @param options render options for custom rendering
*/
mount: typeof mount;
Expand Down
15 changes: 1 addition & 14 deletions packages/tools/components-package/cypress/support/component.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import "@cypress/code-coverage/support";
import { setupHooks, getContainerEl} from "@cypress/mount-utils";
import { unsafeHTML } from "lit-html/directives/unsafe-html.js";
import { mount as preactMount } from "./cypress-ct-preact.js";
import { mount as litMount } from "cypress-ct-lit";
import "./commands.js";

function applyConfiguration(options) {
Expand All @@ -23,18 +21,7 @@ function mount(component, options = {}) {
// Apply custom configuration
applyConfiguration(options);

// Mount string - remove after migrating all
if (typeof component === "string") {
return litMount(unsafeHTML(component), options)
}

// Mount lit template - - remove after migrating all
const legacyMount = component?.strings?.length > 0;
if (legacyMount) {
return litMount(component, options);
}

// Mount JSX template
// Mount JSX Element
return preactMount(component, container);
}

Expand Down
2 changes: 1 addition & 1 deletion packages/tools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
}
},
"devDependencies": {
"cypress-ct-lit": "^0.4.0",
"@cypress/mount-utils": "^4.1.2",
"cypress-real-events": "^1.12.0",
"esbuild": "^0.19.9",
"yargs": "^17.5.1"
Expand Down
15 changes: 4 additions & 11 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1814,10 +1814,10 @@
js-yaml "4.1.0"
nyc "15.1.0"

"@cypress/mount-utils@^4.0.0":
version "4.1.1"
resolved "https://registry.yarnpkg.com/@cypress/mount-utils/-/mount-utils-4.1.1.tgz#458a664e2d137d98805aaa454320f3ebc6dc1609"
integrity sha512-rW49MH5P47LQQ+hr2o+vTD0smht+hSE0vG4Cdai0dLmg0QJ0L+remfikC87omy1VSo0lz226vmW1xOUx350U/w==
"@cypress/mount-utils@^4.1.2":
version "4.1.2"
resolved "https://registry.yarnpkg.com/@cypress/mount-utils/-/mount-utils-4.1.2.tgz#c2c869e473621319a7723e7bee9757477ab34441"
integrity sha512-904bOLLJqtjwWpkmVUQtaYwGSfpBV1G4kYZCq/xytcrTYqZcDjZkyYi1bjEIr5GMUR1FURNg4ZGDP0P6Zy7FGA==

"@cypress/request@^3.0.0":
version "3.0.1"
Expand Down Expand Up @@ -8018,13 +8018,6 @@ [email protected]:
resolved "https://registry.yarnpkg.com/custom-elements-manifest/-/custom-elements-manifest-1.0.0.tgz#b35c2129076a1dc9f95d720c6f7b5b71a857274b"
integrity sha512-j59k0ExGCKA8T6Mzaq+7axc+KVHwpEphEERU7VZ99260npu/p/9kd+Db+I3cGKxHkM5y6q5gnlXn00mzRQkX2A==

cypress-ct-lit@^0.4.0:
version "0.4.1"
resolved "https://registry.yarnpkg.com/cypress-ct-lit/-/cypress-ct-lit-0.4.1.tgz#f21341ab0d37e30cea45a9ce44b959fe5db1b8fa"
integrity sha512-iYVoBU605anRDstyxVWxQKFoiuzeA0gvj4I80aj0cym7VUCoarYFMjYA2CBEynLzJxS4yoTZC+jdff8dWYdgiA==
dependencies:
"@cypress/mount-utils" "^4.0.0"

cypress-real-events@^1.12.0:
version "1.12.0"
resolved "https://registry.yarnpkg.com/cypress-real-events/-/cypress-real-events-1.12.0.tgz#ffeb2b23686ba5b16ac91dd9bc3b6785d36d38d3"
Expand Down

0 comments on commit 5fe02fd

Please sign in to comment.