Adding test (feature) (#1030)

* data-testid for load and create safe

* fix connect button id

* removed buttons data-testid property
This commit is contained in:
francovenica 2020-06-19 19:06:53 -03:00 committed by GitHub
parent a5b4585049
commit b02924f5ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 110 additions and 29 deletions

View File

@ -144,6 +144,7 @@ const CookiesBanner = () => {
onKeyDown={closeCookiesBannerHandler} onKeyDown={closeCookiesBannerHandler}
role="button" role="button"
tabIndex={0} tabIndex={0}
data-testid="accept-preferences"
> >
Accept preferences > Accept preferences >
</span> </span>

View File

@ -61,7 +61,7 @@ const Layout = openHoc(({ classes, clickAway, open, providerDetails, providerInf
<Row className={classes.summary}> <Row className={classes.summary}>
<Col className={classes.logo} middle="xs" start="xs"> <Col className={classes.logo} middle="xs" start="xs">
<Link to="/"> <Link to="/">
<Img alt="Gnosis Team Safe" height={32} src={logo} /> <Img alt="Gnosis Team Safe" height={32} src={logo} testId="heading-gnosis-logo" />
</Link> </Link>
</Col> </Col>
<Divider /> <Divider />

View File

@ -45,7 +45,7 @@ const ConnectDetails = ({ classes }) => (
<CircleDot center circleSize={75} dotRight={25} dotSize={25} dotTop={50} keySize={32} mode="error" /> <CircleDot center circleSize={75} dotRight={25} dotSize={25} dotTop={50} keySize={32} mode="error" />
</Row> </Row>
<Block className={classes.connect}> <Block className={classes.connect}>
<ConnectButton /> <ConnectButton data-testid="heading-connect-btn" />
</Block> </Block>
</> </>
) )

View File

@ -163,7 +163,14 @@ const UserDetails = ({ classes, connected, network, onDisconnect, openDashboard,
</Row> </Row>
)} )}
<Row className={classes.disconnect}> <Row className={classes.disconnect}>
<Button color="primary" fullWidth onClick={onDisconnect} size="medium" variant="contained"> <Button
color="primary"
fullWidth
onClick={onDisconnect}
size="medium"
variant="contained"
data-testid="disconnect-btn"
>
<Paragraph className={classes.disconnectText} color="white" noMargin size="md"> <Paragraph className={classes.disconnectText} color="white" noMargin size="md">
Disconnect Disconnect
</Paragraph> </Paragraph>

View File

@ -62,7 +62,14 @@ const ProviderInfo = ({ classes, connected, network, provider, userAddress }) =>
)} )}
{!connected && <CircleDot circleSize={35} dotRight={11} dotSize={16} dotTop={24} keySize={14} mode="warning" />} {!connected && <CircleDot circleSize={35} dotRight={11} dotSize={16} dotTop={24} keySize={14} mode="warning" />}
<Col className={classes.account} layout="column" start="sm"> <Col className={classes.account} layout="column" start="sm">
<Paragraph className={classes.network} noMargin size="xs" transform="capitalize" weight="bolder"> <Paragraph
className={classes.network}
noMargin
size="xs"
transform="capitalize"
weight="bolder"
data-testid="connected-wallet"
>
{providerText} {providerText}
</Paragraph> </Paragraph>
<Paragraph className={classes.address} color={color} noMargin size="xs"> <Paragraph className={classes.address} color={color} noMargin size="xs">

View File

@ -29,7 +29,14 @@ const ProviderDisconnected = ({ classes }) => (
<> <>
<CircleDot circleSize={35} dotRight={11} dotSize={16} dotTop={24} keySize={17} mode="error" /> <CircleDot circleSize={35} dotRight={11} dotSize={16} dotTop={24} keySize={17} mode="error" />
<Col className={classes.account} end="sm" layout="column" middle="xs"> <Col className={classes.account} end="sm" layout="column" middle="xs">
<Paragraph className={classes.network} noMargin size="sm" transform="capitalize" weight="bold"> <Paragraph
className={classes.network}
noMargin
size="sm"
transform="capitalize"
weight="bold"
data-testid="not-connected-wallet"
>
Not Connected Not Connected
</Paragraph> </Paragraph>
<Paragraph className={classes.connect} color="fancy" noMargin size="sm"> <Paragraph className={classes.connect} color="fancy" noMargin size="sm">

View File

@ -44,7 +44,7 @@ const SafeListHeader = ({ safesCount }) => {
return ( return (
<Col className={classes.container} middle="xs" start="xs"> <Col className={classes.container} middle="xs" start="xs">
Safes Safes
<Paragraph className={classes.counter} size="xs"> <Paragraph className={classes.counter} size="xs" data-testid="safe-counter-heading">
{safesCount} {safesCount}
</Paragraph> </Paragraph>
<IconButton <IconButton

View File

@ -39,6 +39,7 @@ export const ScanQRWrapper = (props) => {
}} }}
role="button" role="button"
src={QRIcon} src={QRIcon}
testId="qr-icon"
/> />
{qrModalOpen && <ScanQRModal isOpen={qrModalOpen} onClose={closeQrModal} onScan={onScanFinished} />} {qrModalOpen && <ScanQRModal isOpen={qrModalOpen} onClose={closeQrModal} onScan={onScanFinished} />}
</> </>

View File

@ -100,6 +100,7 @@ const Details = ({ classes, errors, form }) => {
text="Safe name" text="Safe name"
type="text" type="text"
validate={required} validate={required}
testId="load-safe-name-field"
/> />
</Col> </Col>
</Block> </Block>
@ -114,7 +115,7 @@ const Details = ({ classes, errors, form }) => {
noErrorsOn(FIELD_LOAD_ADDRESS, errors) && { noErrorsOn(FIELD_LOAD_ADDRESS, errors) && {
endAdornment: ( endAdornment: (
<InputAdornment position="end"> <InputAdornment position="end">
<CheckCircle className={classes.check} /> <CheckCircle className={classes.check} data-testid="valid-address" />
</InputAdornment> </InputAdornment>
), ),
} }
@ -123,6 +124,7 @@ const Details = ({ classes, errors, form }) => {
placeholder="Safe Address*" placeholder="Safe Address*"
text="Safe Address" text="Safe Address"
type="text" type="text"
testId="load-safe-address-field"
/> />
</Col> </Col>
<Col center="xs" className={classes} middle="xs" xs={1}> <Col center="xs" className={classes} middle="xs" xs={1}>

View File

@ -109,7 +109,7 @@ const OwnerListComponent = (props) => {
return ( return (
<> <>
<Block className={classes.title}> <Block className={classes.title}>
<Paragraph color="primary" noMargin size="md"> <Paragraph color="primary" noMargin size="md" data-testid="load-safe-step-two">
{`This Safe has ${owners.length} owners. Optional: Provide a name for each owner.`} {`This Safe has ${owners.length} owners. Optional: Provide a name for each owner.`}
</Paragraph> </Paragraph>
</Block> </Block>
@ -122,7 +122,7 @@ const OwnerListComponent = (props) => {
<Hairline /> <Hairline />
<Block margin="md" padding="md"> <Block margin="md" padding="md">
{owners.map((address, index) => ( {owners.map((address, index) => (
<Row className={classes.owner} key={address}> <Row className={classes.owner} key={address} data-testid="owner-row">
<Col className={classes.ownerName} xs={4}> <Col className={classes.ownerName} xs={4}>
<Field <Field
className={classes.name} className={classes.name}
@ -133,6 +133,7 @@ const OwnerListComponent = (props) => {
text="Owner Name" text="Owner Name"
type="text" type="text"
validate={required} validate={required}
testId={`load-safe-owner-name-${index}`}
/> />
</Col> </Col>
<Col xs={8}> <Col xs={8}>

View File

@ -109,7 +109,7 @@ class ReviewComponent extends React.PureComponent<any> {
<Col className={classes.detailsColumn} layout="column" xs={4}> <Col className={classes.detailsColumn} layout="column" xs={4}>
<Block className={classes.details}> <Block className={classes.details}>
<Block margin="lg"> <Block margin="lg">
<Paragraph color="primary" noMargin size="lg"> <Paragraph color="primary" noMargin size="lg" data-testid="load-safe-step-three">
Review details Review details
</Paragraph> </Paragraph>
</Block> </Block>
@ -117,7 +117,14 @@ class ReviewComponent extends React.PureComponent<any> {
<Paragraph color="disabled" noMargin size="sm"> <Paragraph color="disabled" noMargin size="sm">
Name of the Safe Name of the Safe
</Paragraph> </Paragraph>
<Paragraph className={classes.name} color="primary" noMargin size="lg" weight="bolder"> <Paragraph
className={classes.name}
color="primary"
noMargin
size="lg"
weight="bolder"
data-testid="load-form-review-safe-name"
>
{values[FIELD_LOAD_NAME]} {values[FIELD_LOAD_NAME]}
</Paragraph> </Paragraph>
</Block> </Block>
@ -168,7 +175,7 @@ class ReviewComponent extends React.PureComponent<any> {
</Col> </Col>
<Col xs={11}> <Col xs={11}>
<Block className={classNames(classes.name, classes.userName)}> <Block className={classNames(classes.name, classes.userName)}>
<Paragraph noMargin size="lg"> <Paragraph noMargin size="lg" data-testid="load-safe-review-owner-name">
{values[getOwnerNameBy(index)]} {values[getOwnerNameBy(index)]}
</Paragraph> </Paragraph>
<Block className={classes.user} justify="center"> <Block className={classes.user} justify="center">

View File

@ -87,7 +87,9 @@ const Layout = (props) => {
<IconButton disableRipple onClick={back} style={iconStyle}> <IconButton disableRipple onClick={back} style={iconStyle}>
<ChevronLeft /> <ChevronLeft />
</IconButton> </IconButton>
<Heading tag="h2">Create New Safe</Heading> <Heading tag="h2" testId="create-safe-form-title">
Create New Safe
</Heading>
</Row> </Row>
<Stepper <Stepper
initialValues={initialValues} initialValues={initialValues}

View File

@ -112,7 +112,7 @@ const ReviewComponent = ({ classes, userAccount, values }: any) => {
<Col className={classes.detailsColumn} layout="column" xs={4}> <Col className={classes.detailsColumn} layout="column" xs={4}>
<Block className={classes.details}> <Block className={classes.details}>
<Block margin="lg"> <Block margin="lg">
<Paragraph color="primary" noMargin size="lg"> <Paragraph color="primary" noMargin size="lg" data-testid="create-safe-step-three">
Details Details
</Paragraph> </Paragraph>
</Block> </Block>
@ -120,7 +120,14 @@ const ReviewComponent = ({ classes, userAccount, values }: any) => {
<Paragraph color="disabled" noMargin size="sm"> <Paragraph color="disabled" noMargin size="sm">
Name of new Safe Name of new Safe
</Paragraph> </Paragraph>
<Paragraph className={classes.name} color="primary" noMargin size="lg" weight="bolder"> <Paragraph
className={classes.name}
color="primary"
noMargin
size="lg"
weight="bolder"
data-testid="create-safe-review-name"
>
{values[FIELD_NAME]} {values[FIELD_NAME]}
</Paragraph> </Paragraph>
</Block> </Block>
@ -128,7 +135,13 @@ const ReviewComponent = ({ classes, userAccount, values }: any) => {
<Paragraph color="disabled" noMargin size="sm"> <Paragraph color="disabled" noMargin size="sm">
Any transaction requires the confirmation of: Any transaction requires the confirmation of:
</Paragraph> </Paragraph>
<Paragraph color="primary" noMargin size="lg" weight="bolder"> <Paragraph
color="primary"
noMargin
size="lg"
weight="bolder"
data-testid={`create-safe-review-req-owners-${values[FIELD_CONFIRMATIONS]}`}
>
{`${values[FIELD_CONFIRMATIONS]} out of ${numOwners} owners`} {`${values[FIELD_CONFIRMATIONS]} out of ${numOwners} owners`}
</Paragraph> </Paragraph>
</Block> </Block>
@ -150,11 +163,16 @@ const ReviewComponent = ({ classes, userAccount, values }: any) => {
</Col> </Col>
<Col xs={11}> <Col xs={11}>
<Block className={classNames(classes.name, classes.userName)}> <Block className={classNames(classes.name, classes.userName)}>
<Paragraph noMargin size="lg"> <Paragraph noMargin size="lg" data-testid={`create-safe-owner-name-${index}`}>
{name} {name}
</Paragraph> </Paragraph>
<Block className={classes.user} justify="center"> <Block className={classes.user} justify="center">
<Paragraph color="disabled" noMargin size="md"> <Paragraph
color="disabled"
noMargin
size="md"
data-testid={`create-safe-owner-address-${index}`}
>
{addresses[index]} {addresses[index]}
</Paragraph> </Paragraph>
<CopyBtn content={addresses[index]} /> <CopyBtn content={addresses[index]} />

View File

@ -45,6 +45,7 @@ const SafeName = ({ classes, safeName }) => (
text="Safe name" text="Safe name"
type="text" type="text"
validate={required} validate={required}
testId="create-safe-name-field"
/> />
</Block> </Block>
<Block margin="lg"> <Block margin="lg">

View File

@ -99,7 +99,7 @@ const SafeOwners = (props) => {
return ( return (
<> <>
<Block className={classes.title}> <Block className={classes.title}>
<Paragraph color="primary" noMargin size="md"> <Paragraph color="primary" noMargin size="md" data-testid="create-safe-step-two">
Your Safe will have one or more owners. We have prefilled the first owner with your connected wallet details, Your Safe will have one or more owners. We have prefilled the first owner with your connected wallet details,
but you are free to change this to a different owner. but you are free to change this to a different owner.
<br /> <br />
@ -120,7 +120,7 @@ const SafeOwners = (props) => {
const addressName = getOwnerAddressBy(index) const addressName = getOwnerAddressBy(index)
return ( return (
<Row className={classes.owner} key={`owner${index}`}> <Row className={classes.owner} key={`owner${index}`} data-testid={`create-safe-owner-row`}>
<Col className={classes.ownerName} xs={4}> <Col className={classes.ownerName} xs={4}>
<Field <Field
className={classes.name} className={classes.name}
@ -130,6 +130,7 @@ const SafeOwners = (props) => {
text="Owner Name" text="Owner Name"
type="text" type="text"
validate={required} validate={required}
testId={`create-safe-owner-name-field-${index}`}
/> />
</Col> </Col>
<Col className={classes.ownerAddress} xs={6}> <Col className={classes.ownerAddress} xs={6}>
@ -142,7 +143,7 @@ const SafeOwners = (props) => {
noErrorsOn(addressName, errors) && { noErrorsOn(addressName, errors) && {
endAdornment: ( endAdornment: (
<InputAdornment position="end"> <InputAdornment position="end">
<CheckCircle className={classes.check} /> <CheckCircle className={classes.check} data-testid={`valid-address-${index}`} />
</InputAdornment> </InputAdornment>
), ),
} }
@ -152,6 +153,7 @@ const SafeOwners = (props) => {
text="Owner Address" text="Owner Address"
type="text" type="text"
validators={[getAddressValidator(otherAccounts, index)]} validators={[getAddressValidator(otherAccounts, index)]}
testId={`create-safe-address-field-${index}`}
/> />
</Col> </Col>
<Col center="xs" className={classes.remove} middle="xs" xs={1}> <Col center="xs" className={classes.remove} middle="xs" xs={1}>
@ -191,14 +193,20 @@ const SafeOwners = (props) => {
validate={composeValidators(required, mustBeInteger, minValue(1))} validate={composeValidators(required, mustBeInteger, minValue(1))}
> >
{[...Array(Number(validOwners))].map((x, index) => ( {[...Array(Number(validOwners))].map((x, index) => (
<MenuItem key={`selectOwner${index}`} value={`${index + 1}`}> <MenuItem key={`selectOwner${index}`} value={`${index + 1}`} data-testid={`input-${index + 1}`}>
{index + 1} {index + 1}
</MenuItem> </MenuItem>
))} ))}
</Field> </Field>
</Col> </Col>
<Col className={classes.ownersAmountItem} xs={10}> <Col className={classes.ownersAmountItem} xs={10}>
<Paragraph className={classes.owners} color="primary" noMargin size="lg"> <Paragraph
className={classes.owners}
color="primary"
noMargin
size="lg"
data-testid={`create-safe-req-conf-${validOwners}`}
>
out of {validOwners} owner(s) out of {validOwners} owner(s)
</Paragraph> </Paragraph>
</Col> </Col>

View File

@ -38,7 +38,13 @@ export const ContinueFooter = ({
continueButtonDisabled: boolean continueButtonDisabled: boolean
onContinue: (event: SyntheticEvent) => void onContinue: (event: SyntheticEvent) => void
}) => ( }) => (
<Button color="primary" disabled={continueButtonDisabled} onClick={onContinue} variant="contained"> <Button
color="primary"
disabled={continueButtonDisabled}
onClick={onContinue}
variant="contained"
data-testid="continue-btn"
>
Continue Continue
</Button> </Button>
) )

View File

@ -302,7 +302,9 @@ const SafeDeployment = ({ creationTxHash, onCancel, onRetry, onSuccess, provider
return ( return (
<Wrapper> <Wrapper>
<Title tag="h2">Safe creation process</Title> <Title tag="h2" testId="safe-creation-process-title">
Safe creation process
</Title>
<Nav> <Nav>
<Stepper activeStepIndex={stepIndex} error={error} orientation="vertical" steps={steps} /> <Stepper activeStepIndex={stepIndex} error={error} orientation="vertical" steps={steps} />
</Nav> </Nav>
@ -336,7 +338,7 @@ const SafeDeployment = ({ creationTxHash, onCancel, onRetry, onSuccess, provider
) : null} ) : null}
</BodyFooter> </BodyFooter>
</Body> </Body>
<BackButton color="primary" minWidth={140} onClick={onCancel}> <BackButton color="primary" minWidth={140} onClick={onCancel} data-testid="safe-creation-back-btn">
Back Back
</BackButton> </BackButton>
</Wrapper> </Wrapper>

View File

@ -38,7 +38,13 @@ const LayoutHeader = (props) => {
{!granted && <Block className={classes.readonly}>Read Only</Block>} {!granted && <Block className={classes.readonly}>Read Only</Block>}
</Row> </Row>
<Block className={classes.user} justify="center"> <Block className={classes.user} justify="center">
<Paragraph className={classes.address} color="disabled" noMargin size="md"> <Paragraph
className={classes.address}
color="disabled"
noMargin
size="md"
data-testid="safe-address-heading"
>
{address} {address}
</Paragraph> </Paragraph>
<CopyBtn content={address} /> <CopyBtn content={address} />
@ -54,6 +60,7 @@ const LayoutHeader = (props) => {
onClick={() => showSendFunds('')} onClick={() => showSendFunds('')}
size="small" size="small"
variant="contained" variant="contained"
testId="main-send-btn"
> >
<CallMade <CallMade
alt="Send Transaction" alt="Send Transaction"

View File

@ -10,6 +10,7 @@ import {
ADDRESS_BOOK_TAB_BTN_TEST_ID, ADDRESS_BOOK_TAB_BTN_TEST_ID,
BALANCES_TAB_BTN_TEST_ID, BALANCES_TAB_BTN_TEST_ID,
SETTINGS_TAB_BTN_TEST_ID, SETTINGS_TAB_BTN_TEST_ID,
APPS_TAB_BTN_TEST_ID,
TRANSACTIONS_TAB_BTN_TEST_ID, TRANSACTIONS_TAB_BTN_TEST_ID,
} from 'src/routes/safe/components/Layout' } from 'src/routes/safe/components/Layout'
import SettingsTab from 'src/routes/safe/components/Layout/Tabs/SettingsTab' import SettingsTab from 'src/routes/safe/components/Layout/Tabs/SettingsTab'
@ -105,7 +106,7 @@ const TabsComponent = (props: Props) => {
selected: classes.tabWrapperSelected, selected: classes.tabWrapperSelected,
wrapper: classes.tabWrapper, wrapper: classes.tabWrapper,
}} }}
data-testid={TRANSACTIONS_TAB_BTN_TEST_ID} data-testid={APPS_TAB_BTN_TEST_ID}
label={AppsLabel} label={AppsLabel}
value={`${match.url}/apps`} value={`${match.url}/apps`}
/> />

View File

@ -21,6 +21,7 @@ import { wrapInSuspense } from 'src/utils/wrapInSuspense'
export const BALANCES_TAB_BTN_TEST_ID = 'balances-tab-btn' export const BALANCES_TAB_BTN_TEST_ID = 'balances-tab-btn'
export const SETTINGS_TAB_BTN_TEST_ID = 'settings-tab-btn' export const SETTINGS_TAB_BTN_TEST_ID = 'settings-tab-btn'
export const APPS_TAB_BTN_TEST_ID = 'apps-tab-btn'
export const TRANSACTIONS_TAB_BTN_TEST_ID = 'transactions-tab-btn' export const TRANSACTIONS_TAB_BTN_TEST_ID = 'transactions-tab-btn'
export const ADDRESS_BOOK_TAB_BTN_TEST_ID = 'address-book-tab-btn' export const ADDRESS_BOOK_TAB_BTN_TEST_ID = 'address-book-tab-btn'
export const SAFE_VIEW_NAME_HEADING_TEST_ID = 'safe-name-heading' export const SAFE_VIEW_NAME_HEADING_TEST_ID = 'safe-name-heading'

View File

@ -35,6 +35,7 @@ export const CreateSafe = ({ provider, size }: any) => (
size={size || 'medium'} size={size || 'medium'}
to={OPEN_ADDRESS} to={OPEN_ADDRESS}
variant="contained" variant="contained"
testId="create-new-safe-btn"
> >
<Img alt="Safe" height={14} src={plus} /> <Img alt="Safe" height={14} src={plus} />
<div style={buttonStyle}>Create new Safe</div> <div style={buttonStyle}>Create new Safe</div>
@ -50,6 +51,7 @@ export const LoadSafe = ({ provider, size }) => (
size={size || 'medium'} size={size || 'medium'}
to={LOAD_ADDRESS} to={LOAD_ADDRESS}
variant="outlined" variant="outlined"
testId="load-existing-safe-btn"
> >
<Img alt="Safe" height={14} src={safe} /> <Img alt="Safe" height={14} src={safe} />
<div style={buttonStyle}>Load existing Safe</div> <div style={buttonStyle}>Load existing Safe</div>
@ -108,7 +110,7 @@ const Welcome = ({ isOldMultisigMigration, provider }: any) => {
<Heading align="center" margin="md" tag="h3"> <Heading align="center" margin="md" tag="h3">
Get Started by Connecting a Wallet Get Started by Connecting a Wallet
</Heading> </Heading>
<ConnectButton minHeight={42} minWidth={240} /> <ConnectButton minHeight={42} minWidth={240} data-testid="connect-btn" />
</Block> </Block>
)} )}
</Block> </Block>