From 4f54a60866953d2f562481280b4fceee11acdf22 Mon Sep 17 00:00:00 2001 From: mmv Date: Thu, 30 May 2019 13:04:19 +0400 Subject: [PATCH] safe creation test wip --- src/components/Stepper/index.jsx | 5 ++- src/components/forms/GnoForm/index.jsx | 5 ++- src/routes/open/components/Layout.jsx | 53 +++++++++----------------- src/test/safe.dom.create.test.js | 5 +-- 4 files changed, 27 insertions(+), 41 deletions(-) diff --git a/src/components/Stepper/index.jsx b/src/components/Stepper/index.jsx index 0481ce6c..69e3c888 100644 --- a/src/components/Stepper/index.jsx +++ b/src/components/Stepper/index.jsx @@ -21,6 +21,7 @@ type Props = { onReset?: () => void, initialValues?: Object, disabledWhenValidating?: boolean, + testId?: string, } type State = { @@ -145,7 +146,7 @@ class GnoStepper extends React.PureComponent { render() { const { - steps, children, classes, disabledWhenValidating = false, + steps, children, classes, disabledWhenValidating = false, testId, } = this.props const { page, values } = this.state const activePage = this.getActivePageFrom(children) @@ -154,7 +155,7 @@ class GnoStepper extends React.PureComponent { return ( - + {(submitting: boolean, validating: boolean, ...rest: any) => { const disabled = disabledWhenValidating ? submitting || validating : submitting const controls = ( diff --git a/src/components/forms/GnoForm/index.jsx b/src/components/forms/GnoForm/index.jsx index 9ebf3210..d3d690db 100644 --- a/src/components/forms/GnoForm/index.jsx +++ b/src/components/forms/GnoForm/index.jsx @@ -16,6 +16,7 @@ type Props = { validation?: (values: Object) => Object | Promise, initialValues?: Object, formMutators?: Object, + testId?: string, } const stylesBasedOn = (padding: number): $Shape => ({ @@ -25,7 +26,7 @@ const stylesBasedOn = (padding: number): $Shape => ({ }) const GnoForm = ({ - onSubmit, validation, initialValues, children, padding = 0, formMutators, + onSubmit, validation, initialValues, children, padding = 0, formMutators, testId = '', }: Props) => (
( - + {children(rest.submitting, rest.validating, rest, rest.form.mutators)}
)} diff --git a/src/routes/open/components/Layout.jsx b/src/routes/open/components/Layout.jsx index 342e392d..e2a545b4 100644 --- a/src/routes/open/components/Layout.jsx +++ b/src/routes/open/components/Layout.jsx @@ -14,9 +14,7 @@ import { getOwnerNameBy, getOwnerAddressBy, FIELD_CONFIRMATIONS } from '~/routes import { history } from '~/store' import { secondary } from '~/theme/variables' -const getSteps = () => [ - 'Start', 'Owners', 'Confirmations', 'Review', -] +const getSteps = () => ['Start', 'Owners', 'Confirmations', 'Review'] const initialValuesFrom = (userAccount: string) => ({ [getOwnerNameBy(0)]: 'My Metamask (me)', @@ -49,37 +47,24 @@ const Layout = ({ return ( - { provider - ? ( - - - - - - Create New Safe - - - - { SafeNameField } - - - { SafeOwnersFields } - - - { SafeThresholdField } - - - { Review } - - - - ) - :
No metamask detected
- } + {provider ? ( + + + + + + Create New Safe + + + {SafeNameField} + {SafeOwnersFields} + {SafeThresholdField} + {Review} + + + ) : ( +
No metamask detected
+ )}
) } diff --git a/src/test/safe.dom.create.test.js b/src/test/safe.dom.create.test.js index a9a7ecfd..afc6810b 100644 --- a/src/test/safe.dom.create.test.js +++ b/src/test/safe.dom.create.test.js @@ -1,7 +1,6 @@ // @flow import * as React from 'react' import { type Store } from 'redux' -import TestUtils from 'react-dom/test-utils' import { render, fireEvent, cleanup } from 'react-testing-library' import Select from '@material-ui/core/Select' import { Provider } from 'react-redux' @@ -32,12 +31,12 @@ const renderOpenSafeForm = async (localStore: Store) => { ) } -const deploySafe = async (safe: React$Component<{}>, threshold: number, numOwners: number) => { +const deploySafe = async (safe: any, threshold: number, numOwners: number) => { const web3 = getWeb3() const accounts = await web3.eth.getAccounts() expect(threshold).toBeLessThanOrEqual(numOwners) - const form = TestUtils.findRenderedDOMComponentWithTag(safe, 'form') + const form = safe.getByTestId('create-safe-form') // Fill Safe's name const inputs = TestUtils.scryRenderedDOMComponentsWithTag(safe, 'input')