Skip to content

feat: integrate @ui5/webcomponents-cypress-commands into cra template #4341

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 3 commits into from
Mar 15, 2023
Merged
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
3 changes: 2 additions & 1 deletion packages/cra-template/template.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"web-vitals": "^2.1.0"
},
"devDependencies": {
"cypress": "^12.1.0"
"cypress": "^12.1.0",
"@ui5/webcomponents-cypress-commands": "latest"
},
"scripts": {
"test": "cypress run --component --browser chrome",
Expand Down
2 changes: 2 additions & 0 deletions packages/cra-template/template/cypress/support/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import './commands';

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

/**
* Cypress mount with ThemeProvider
Expand Down
9 changes: 7 additions & 2 deletions packages/cra-template/template/src/App.cy.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import App from './App';

describe('Component tests', () => {
it('render Link', () => {
it('render Link component with text', () => {
cy.mount(<App />);
cy.get('[ui5-link]').should('be.visible').should('have.text', 'Getting Started with UI5 Web Component for React');
cy.get('[ui5-link]').should('be.visible').and('have.text', 'Getting Started with UI5 Web Component for React');
});
it('type into Input component', () => {
cy.mount(<App />);
cy.get('[ui5-input]').typeIntoUi5Input('Hello there!');
cy.get('[ui5-label]').should('be.visible').and('have.text', 'Hello there!');
});
});
9 changes: 9 additions & 0 deletions packages/cra-template/template/src/App.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
import { useState } from 'react';
import {
FlexBox,
FlexBoxAlignItems,
FlexBoxDirection,
FlexBoxJustifyContent,
Input,
Label,
Link,
LinkDesign,
ShellBar
} from '@ui5/webcomponents-react';
import './App.css';

function App() {
const [inputVal, setInputVal] = useState('');
const handleInput = (e) => {
setInputVal(e.target.value);
};
return (
<>
<ShellBar primaryTitle="UI5 Web Components for React Template" />
Expand All @@ -22,6 +29,8 @@ function App() {
<Link href="https://sap.github.io/ui5-webcomponents-react/" target="_blank" design={LinkDesign.Emphasized}>
Getting Started with UI5 Web Component for React
</Link>
<Input placeholder="Hello World" onInput={handleInput} value={inputVal} />
<Label>{inputVal}</Label>
</FlexBox>
</>
);
Expand Down