Skip to content

Commit e4564f1

Browse files
authored
feat: integrate @ui5/webcomponents-cypress-commands into cra template (#4341)
1 parent 8da6280 commit e4564f1

File tree

4 files changed

+20
-3
lines changed

4 files changed

+20
-3
lines changed

packages/cra-template/template.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
"web-vitals": "^2.1.0"
99
},
1010
"devDependencies": {
11-
"cypress": "^12.1.0"
11+
"cypress": "^12.1.0",
12+
"@ui5/webcomponents-cypress-commands": "latest"
1213
},
1314
"scripts": {
1415
"test": "cypress run --component --browser chrome",

packages/cra-template/template/cypress/support/component.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ import './commands';
2121

2222
import { mount } from 'cypress/react18';
2323
import { ThemeProvider } from '@ui5/webcomponents-react';
24+
// Cypress commands and queries that help interacting with ui5-webcomponents
25+
import '@ui5/webcomponents-cypress-commands';
2426

2527
/**
2628
* Cypress mount with ThemeProvider
Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
import App from './App';
22

33
describe('Component tests', () => {
4-
it('render Link', () => {
4+
it('render Link component with text', () => {
55
cy.mount(<App />);
6-
cy.get('[ui5-link]').should('be.visible').should('have.text', 'Getting Started with UI5 Web Component for React');
6+
cy.get('[ui5-link]').should('be.visible').and('have.text', 'Getting Started with UI5 Web Component for React');
7+
});
8+
it('type into Input component', () => {
9+
cy.mount(<App />);
10+
cy.get('[ui5-input]').typeIntoUi5Input('Hello there!');
11+
cy.get('[ui5-label]').should('be.visible').and('have.text', 'Hello there!');
712
});
813
});

packages/cra-template/template/src/App.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,22 @@
1+
import { useState } from 'react';
12
import {
23
FlexBox,
34
FlexBoxAlignItems,
45
FlexBoxDirection,
56
FlexBoxJustifyContent,
7+
Input,
8+
Label,
69
Link,
710
LinkDesign,
811
ShellBar
912
} from '@ui5/webcomponents-react';
1013
import './App.css';
1114

1215
function App() {
16+
const [inputVal, setInputVal] = useState('');
17+
const handleInput = (e) => {
18+
setInputVal(e.target.value);
19+
};
1320
return (
1421
<>
1522
<ShellBar primaryTitle="UI5 Web Components for React Template" />
@@ -22,6 +29,8 @@ function App() {
2229
<Link href="https://sap.github.io/ui5-webcomponents-react/" target="_blank" design={LinkDesign.Emphasized}>
2330
Getting Started with UI5 Web Component for React
2431
</Link>
32+
<Input placeholder="Hello World" onInput={handleInput} value={inputVal} />
33+
<Label>{inputVal}</Label>
2534
</FlexBox>
2635
</>
2736
);

0 commit comments

Comments
 (0)