First POC test

pull/311/head
Vladimir Volek 5 years ago
parent 51b878e5fe
commit d6f1688e1c

@ -40,9 +40,9 @@ COPY yarn.lock /trezor-wallet
RUN yarn RUN yarn
COPY . /trezor-wallet COPY . /trezor-wallet
RUN yarn run build:stable RUN yarn run build:stable
RUN yarn test-integration
# #
# run # run
# #
ENTRYPOINT ["/trezor-wallet/test/docker/run-all.sh"] ENTRYPOINT ["/trezor-wallet/test/docker/run-all.sh"]
EXPOSE 8080 EXPOSE 8080 21325

@ -22,7 +22,7 @@
"test:unit": "npx jest", "test:unit": "npx jest",
"test-unit:watch": "npx jest -o --watch", "test-unit:watch": "npx jest -o --watch",
"test-integration": "npx cypress run", "test-integration": "npx cypress run",
"test-local": "npx cypress open", "test-integration:local": "npx cypress open",
"server:beta": "node ./server/index.js --buildType=beta", "server:beta": "node ./server/index.js --buildType=beta",
"server:stable": "node ./server/index.js --buildType=stable" "server:stable": "node ./server/index.js --buildType=stable"
}, },

@ -132,10 +132,12 @@ const Button = ({
isWhite = false, isWhite = false,
isWebUsb = false, isWebUsb = false,
isTransparent = false, isTransparent = false,
dataTest,
}: Props) => { }: Props) => {
const newClassName = isWebUsb ? `${className} trezor-webusb-button` : className; const newClassName = isWebUsb ? `${className} trezor-webusb-button` : className;
return ( return (
<Wrapper <Wrapper
data-test={dataTest}
className={newClassName} className={newClassName}
onClick={onClick} onClick={onClick}
onMouseEnter={onMouseEnter} onMouseEnter={onMouseEnter}
@ -162,6 +164,7 @@ Button.propTypes = {
isWhite: PropTypes.bool, isWhite: PropTypes.bool,
isWebUsb: PropTypes.bool, isWebUsb: PropTypes.bool,
isTransparent: PropTypes.bool, isTransparent: PropTypes.bool,
dataTest: PropTypes.string,
}; };
export default Button; export default Button;

@ -102,11 +102,13 @@ const DeviceHeader = ({
disabled = false, disabled = false,
isSelected = false, isSelected = false,
className, className,
testId,
}) => { }) => {
const status = getStatus(device); const status = getStatus(device);
return ( return (
<Wrapper <Wrapper
isSelected={isSelected} isSelected={isSelected}
data-test-id={testId}
isOpen={isOpen} isOpen={isOpen}
isHoverable={isHoverable} isHoverable={isHoverable}
disabled={disabled} disabled={disabled}
@ -142,6 +144,7 @@ DeviceHeader.propTypes = {
isSelected: PropTypes.bool, isSelected: PropTypes.bool,
onClickWrapper: PropTypes.func.isRequired, onClickWrapper: PropTypes.func.isRequired,
className: PropTypes.string, className: PropTypes.string,
testId: PropTypes.string,
}; };
export default DeviceHeader; export default DeviceHeader;

@ -68,7 +68,7 @@ const BetaDisclaimer = (props: { close: () => void }) => (
/> />
Please note that the <i>Trezor Beta Wallet</i> might be collecting anonymized usage data, especially error logs, for development purposes. The <i>Trezor Wallet</i> does not log any data. Please note that the <i>Trezor Beta Wallet</i> might be collecting anonymized usage data, especially error logs, for development purposes. The <i>Trezor Wallet</i> does not log any data.
</StyledP> </StyledP>
<StyledButton onClick={props.close}>OK, I understand</StyledButton> <StyledButton dataTest="Modal__disclaimer__button__confirm" onClick={props.close}>OK, I understand</StyledButton>
</ModalWindow> </ModalWindow>
</Wrapper> </Wrapper>
); );

@ -57,7 +57,7 @@ class CoinMenu extends PureComponent<Props> {
render() { render() {
const { config } = this.props.localStorage; const { config } = this.props.localStorage;
return ( return (
<Wrapper> <Wrapper data-test="Main__page__coin__menu">
{config.networks.map(item => ( {config.networks.map(item => (
<NavLink <NavLink
key={item.shortcut} key={item.shortcut}
@ -72,6 +72,7 @@ class CoinMenu extends PureComponent<Props> {
</NavLink> </NavLink>
))} ))}
<Divider <Divider
testId="Main__page__coin__menu__divider"
textLeft="Other coins" textLeft="Other coins"
textRight="(You will be redirected)" textRight="(You will be redirected)"
hasBorder hasBorder

@ -19,9 +19,13 @@ const Wrapper = styled.div`
`; `;
const Divider = ({ const Divider = ({
textLeft, textRight, hasBorder = false, textLeft,
textRight,
hasBorder = false,
testId,
}) => ( }) => (
<Wrapper <Wrapper
data-test={testId}
hasBorder={hasBorder} hasBorder={hasBorder}
> >
<p>{textLeft}</p> <p>{textLeft}</p>
@ -33,6 +37,7 @@ Divider.propTypes = {
textLeft: PropTypes.string, textLeft: PropTypes.string,
textRight: PropTypes.string, textRight: PropTypes.string,
hasBorder: PropTypes.bool, hasBorder: PropTypes.bool,
testId: PropTypes.string,
}; };
export default Divider; export default Divider;

@ -191,6 +191,7 @@ class LeftNavigation extends React.PureComponent<Props, State> {
> >
<Header <Header
isSelected isSelected
testId="Main__page__device__header"
isHoverable={false} isHoverable={false}
onClickWrapper={() => { onClickWrapper={() => {
if (isDeviceAccessible || this.props.devices.length > 1) { if (isDeviceAccessible || this.props.devices.length > 1) {

@ -12,3 +12,6 @@ cd /trezor-emulator/trezor-core && ./emu.sh &
# run wallet # run wallet
cd /trezor-wallet && yarn run server:stable cd /trezor-wallet && yarn run server:stable
# run tests
yarn run test-integration -c baseUrl="https://localhost:8081/#/"

@ -1,24 +0,0 @@
describe('Landing Page', () => {
beforeEach(() => {
cy.visit('http://localhost:8081/#/');
cy.get('[data-test=beta-disclaimer-button]').click();
});
it('top menu', () => {
cy.get('[data-test=top-menu]')
.should('be.visible')
.matchImageSnapshot();
});
it('main text', () => {
cy.get('[data-test=landing-main-title]')
.should('be.visible')
.matchImageSnapshot();
});
it('footer', () => {
cy.get('[data-test=footer]')
.should('be.visible')
.matchImageSnapshot();
});
});

@ -0,0 +1,12 @@
describe('Left Menu', () => {
beforeEach(() => {
cy.visit('https://localhost:8080/#/');
cy.getTestElement('Modal__disclaimer__button__confirm').click();
});
it('divider', () => {
cy.getTestElement('Main__page__coin__menu__divider')
.should('be.visible')
.matchImageSnapshot();
});
});

Binary file not shown.

Before

Width:  |  Height:  |  Size: 85 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 91 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 69 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

@ -1,3 +1,5 @@
import { addMatchImageSnapshotCommand } from 'cypress-image-snapshot/command'; import { addMatchImageSnapshotCommand } from 'cypress-image-snapshot/command';
addMatchImageSnapshotCommand(); addMatchImageSnapshotCommand();
Cypress.Commands.add('getTestElement', selector => cy.get(`[data-test="${selector}"]`));

Loading…
Cancel
Save