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

feat(cypress-commands): support cypress v14 #6828

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
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
6 changes: 3 additions & 3 deletions cypress/support/commands.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { MountOptions, MountReturn } from 'cypress/react18';
import { mount } from 'cypress/react18';
import type { ReactNode } from 'react';
import type { ThemeProviderPropTypes } from '@ui5/webcomponents-react';
import { ThemeProvider } from '@ui5/webcomponents-react';
import type { MountOptions, MountReturn } from 'cypress/react';
import { mount } from 'cypress/react';
import type { ReactNode } from 'react';

declare global {
namespace Cypress {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
"@vitejs/plugin-react": "^4.2.0",
"chromatic": "^11.0.0",
"cssnano": "^7.0.0",
"cypress": "13.17.0",
"cypress": "14.0.0",
"cypress-real-events": "^1.8.1",
"dedent": "^1.0.0",
"documentation": "14.0.3",
Expand Down
4 changes: 2 additions & 2 deletions packages/base/src/hooks/useStylesheet.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ describe('useStyleSheet', () => {
</>
);
cy.findAllByText('Content').should('be.visible').and('have.length', 2);
cy.findAllByText('Object Status').should('not.be.visible');
cy.findAllByText('Object Status').should('have.css', 'font-size', '0px');
cy.findAllByText('Object Status').should('have.length', 2);

cy.findByTestId('btn-1').click();
cy.findAllByText('Content').should('be.visible').and('have.length', 1);
cy.findAllByText('Object Status').should('not.be.visible');
cy.findAllByText('Object Status').should('have.css', 'font-size', '0px');
cy.findAllByText('Object Status').should('have.length', 1);
});
});
4 changes: 3 additions & 1 deletion packages/cypress-commands/TestSetup.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ You can define the command for example in the `commands.ts/js` file:
<summary>Example file</summary>

```tsx
import { mount } from 'cypress/react18';
import { mount } from 'cypress/react';
// if you are using Cypress v12 or v13, you need to import the mount command from 'cypress/react18'
// import { mount } from 'cypress/react18';
import { ThemeProvider } from '@ui5/webcomponents-react';

declare global {
Expand Down
2 changes: 1 addition & 1 deletion packages/cypress-commands/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"peerDependencies": {
"@ui5/webcomponents": "~2.6.0",
"@ui5/webcomponents-base": "~2.6.0",
"cypress": "^12.0.0 || ^13.0.0"
"cypress": "^12 || ^13 || ^14"
},
"peerDependenciesMeta": {
"@ui5/webcomponents": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1937,8 +1937,23 @@ describe('AnalyticalTable', () => {
subComponentsBehavior={AnalyticalTableSubComponentsBehavior.Visible}
/>
);
cy.wait(300);

// ToDo: with Cypress 14 the "not.be.visible" assertion is false here, check if this is still the case for next updates
// cy.findByText('SubComponent 1').should('exist').and('not.be.visible');
cy.findByText('SubComponent 1')
.should('exist')
.then(($sub) => {
if (!$sub.is(':visible')) {
throw new Error('Remove workaround for visibility check in "AnalyticalTable - render subcomponents" test!');
}
const [sub] = $sub;
const container = document.querySelector('[data-component-name="AnalyticalTableBody"]');
const isNotVisible = container.getBoundingClientRect().bottom < sub.getBoundingClientRect().top;
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
expect(isNotVisible).to.be.true;
});

cy.findByText('SubComponent 1').should('exist').and('not.be.visible');
cy.findByTitle('Expand Node').should('not.exist');
cy.findByTitle('Collapse Node').should('not.exist');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ describe('ObjectStatus', () => {
</ObjectStatus>
);
if (stateObj.hiddenText) {
cy.findByText(stateObj.hiddenText).should('exist').and('not.be.visible');
cy.findByText(stateObj.hiddenText).should('exist').and('have.css', 'font-size', '0px');
}
if (!item.inverted) {
cy.findByText('Content').should('have.css', 'color', rgbValColorString);
Expand All @@ -235,7 +235,7 @@ describe('ObjectStatus', () => {
cy.findByText('Content').click();
cy.get('@clickSpy').should('not.be.called');
cy.findByRole('button').should('not.exist');
cy.findByText('Object Status').should('exist').and('not.be.visible');
cy.findByText('Object Status').should('exist').and('have.css', 'font-size', '0px');

cy.mount(
<ObjectStatus onClick={click} interactive>
Expand All @@ -249,7 +249,7 @@ describe('ObjectStatus', () => {
cy.get('@clickSpy').should('have.been.calledTwice');
cy.findByText('Content').realPress('Space');
cy.get('@clickSpy').should('have.been.calledThrice');
cy.findByText('Object Status Button').should('exist').and('not.be.visible');
cy.findByText('Object Status Button').should('exist').and('have.css', 'font-size', '0px');
});

it('emptyIndicator', () => {
Expand All @@ -267,7 +267,7 @@ describe('ObjectStatus', () => {
</ObjectStatus>
);
cy.findByText(VALUE_STATE_ERROR.defaultText).should('not.exist');
cy.findByText('Custom Text').should('exist').and('not.be.visible');
cy.findByText('Custom Text').should('exist').and('have.css', 'font-size', '0px');
});

it('large', () => {
Expand Down
12 changes: 6 additions & 6 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5936,7 +5936,7 @@ __metadata:
peerDependencies:
"@ui5/webcomponents": ~2.6.0
"@ui5/webcomponents-base": ~2.6.0
cypress: ^12.0.0 || ^13.0.0
cypress: ^12 || ^13 || ^14
peerDependenciesMeta:
"@ui5/webcomponents":
optional: true
Expand Down Expand Up @@ -9021,9 +9021,9 @@ __metadata:
languageName: node
linkType: hard

"cypress@npm:13.17.0":
version: 13.17.0
resolution: "cypress@npm:13.17.0"
"cypress@npm:14.0.0":
version: 14.0.0
resolution: "cypress@npm:14.0.0"
dependencies:
"@cypress/request": "npm:^3.0.6"
"@cypress/xvfb": "npm:^1.2.4"
Expand Down Expand Up @@ -9070,7 +9070,7 @@ __metadata:
yauzl: "npm:^2.10.0"
bin:
cypress: bin/cypress
checksum: 10c0/159ce620e32d2785082aaa1f4f30f203dcec466df4a8e80dfa299035358772fd513c35820070ba8db52e2bf58078a372ff7009068e26967f993656e7da62e221
checksum: 10c0/231af826d394b9a9f35200ab56e531e911f774b86b2ecb17a3183685982ac93d534e7c80cfe24ca36f74c99525025472fe28a3ccf2f246c8e67f85ecb768086b
languageName: node
linkType: hard

Expand Down Expand Up @@ -23121,7 +23121,7 @@ __metadata:
"@vitejs/plugin-react": "npm:^4.2.0"
chromatic: "npm:^11.0.0"
cssnano: "npm:^7.0.0"
cypress: "npm:13.17.0"
cypress: "npm:14.0.0"
cypress-real-events: "npm:^1.8.1"
dedent: "npm:^1.0.0"
documentation: "npm:14.0.3"
Expand Down
Loading