add test for removing owner
This commit is contained in:
parent
8d82e19fcc
commit
93a3731160
|
@ -1,10 +1,10 @@
|
|||
// @flow
|
||||
import * as React from 'react'
|
||||
import classNames from 'classnames'
|
||||
import { getNamesFrom, getAccountsFrom } from '~/routes/open/utils/safeDataExtractor'
|
||||
import Block from '~/components/layout/Block'
|
||||
import { withStyles } from '@material-ui/core/styles'
|
||||
import OpenInNew from '@material-ui/icons/OpenInNew'
|
||||
import { getNamesFrom, getAccountsFrom } from '~/routes/open/utils/safeDataExtractor'
|
||||
import Block from '~/components/layout/Block'
|
||||
import Identicon from '~/components/Identicon'
|
||||
import OpenPaper from '~/components/Stepper/OpenPaper'
|
||||
import Col from '~/components/layout/Col'
|
||||
|
|
|
@ -17,6 +17,8 @@ import { getEtherScanLink } from '~/logic/wallets/getWeb3'
|
|||
import { styles } from './style'
|
||||
import { secondary } from '~/theme/variables'
|
||||
|
||||
export const REMOVE_OWNER_MODAL_NEXT_BTN_TESTID = 'remove-owner-next-btn'
|
||||
|
||||
const openIconStyle = {
|
||||
height: '16px',
|
||||
color: secondary,
|
||||
|
@ -93,6 +95,7 @@ const CheckOwner = ({
|
|||
minWidth={140}
|
||||
color="primary"
|
||||
onClick={handleSubmit}
|
||||
testId={REMOVE_OWNER_MODAL_NEXT_BTN_TESTID}
|
||||
>
|
||||
Next
|
||||
</Button>
|
||||
|
|
|
@ -19,6 +19,8 @@ import { getEtherScanLink } from '~/logic/wallets/getWeb3'
|
|||
import { secondary } from '~/theme/variables'
|
||||
import { styles } from './style'
|
||||
|
||||
export const REMOVE_OWNER_REVIEW_BTN_TESTID = 'remove-owner-review-btn'
|
||||
|
||||
const openIconStyle = {
|
||||
height: '16px',
|
||||
color: secondary,
|
||||
|
@ -180,7 +182,7 @@ const ReviewRemoveOwner = ({
|
|||
variant="contained"
|
||||
minWidth={140}
|
||||
color="primary"
|
||||
data-testid="review-tx-btn"
|
||||
testId={REMOVE_OWNER_REVIEW_BTN_TESTID}
|
||||
>
|
||||
Submit
|
||||
</Button>
|
||||
|
|
|
@ -20,6 +20,8 @@ import {
|
|||
} from '~/components/forms/validator'
|
||||
import { styles } from './style'
|
||||
|
||||
export const REMOVE_OWNER_THRESHOLD_NEXT_BTN_TESTID = 'remove-owner-threshold-next-btn'
|
||||
|
||||
type Props = {
|
||||
onClose: () => void,
|
||||
classes: Object,
|
||||
|
@ -112,7 +114,7 @@ owner(s)
|
|||
variant="contained"
|
||||
minWidth={140}
|
||||
color="primary"
|
||||
data-testid="review-tx-btn"
|
||||
data-testid={REMOVE_OWNER_THRESHOLD_NEXT_BTN_TESTID}
|
||||
>
|
||||
Review
|
||||
</Button>
|
||||
|
|
|
@ -29,6 +29,7 @@ import RenameOwnerIcon from './assets/icons/rename-owner.svg'
|
|||
import RemoveOwnerIcon from '../assets/icons/bin.svg'
|
||||
|
||||
export const RENAME_OWNER_BTN_TESTID = 'rename-owner-btn'
|
||||
export const REMOVE_OWNER_BTN_TESTID = 'remove-owner-btn'
|
||||
export const OWNERS_ROW_TESTID = 'owners-row'
|
||||
|
||||
const controlsStyle = {
|
||||
|
@ -153,6 +154,7 @@ class ManageOwners extends React.Component<Props, State> {
|
|||
className={classes.removeOwnerIcon}
|
||||
src={RemoveOwnerIcon}
|
||||
onClick={this.onShow('RemoveOwner', row)}
|
||||
testId={REMOVE_OWNER_BTN_TESTID}
|
||||
/>
|
||||
</Row>
|
||||
</TableCell>
|
||||
|
|
|
@ -7,8 +7,18 @@ import { sleep } from '~/utils/timer'
|
|||
import 'jest-dom/extend-expect'
|
||||
import { SETTINGS_TAB_BTN_TESTID } from '~/routes/safe/components/Layout'
|
||||
import { OWNERS_SETTINGS_TAB_TEST_ID } from '~/routes/safe/components/Settings'
|
||||
import { RENAME_OWNER_BTN_TESTID, OWNERS_ROW_TESTID } from '~/routes/safe/components/Settings/ManageOwners'
|
||||
import { RENAME_OWNER_INPUT_TESTID, SAVE_OWNER_CHANGES_BTN_TESTID } from '~/routes/safe/components/Settings/ManageOwners/EditOwnerModal'
|
||||
import {
|
||||
RENAME_OWNER_BTN_TESTID,
|
||||
OWNERS_ROW_TESTID,
|
||||
REMOVE_OWNER_BTN_TESTID,
|
||||
} from '~/routes/safe/components/Settings/ManageOwners'
|
||||
import {
|
||||
RENAME_OWNER_INPUT_TESTID,
|
||||
SAVE_OWNER_CHANGES_BTN_TESTID,
|
||||
} from '~/routes/safe/components/Settings/ManageOwners/EditOwnerModal'
|
||||
import { REMOVE_OWNER_MODAL_NEXT_BTN_TESTID } from '~/routes/safe/components/Settings/ManageOwners/RemoveOwnerModal/screens/CheckOwner'
|
||||
import { REMOVE_OWNER_THRESHOLD_NEXT_BTN_TESTID } from '~/routes/safe/components/Settings/ManageOwners/RemoveOwnerModal/screens/ThresholdForm'
|
||||
import { REMOVE_OWNER_REVIEW_BTN_TESTID } from '~/routes/safe/components/Settings/ManageOwners/RemoveOwnerModal/screens/Review'
|
||||
|
||||
afterEach(cleanup)
|
||||
|
||||
|
@ -17,11 +27,10 @@ describe('DOM > Feature > Settings - Manage owners', () => {
|
|||
let safeAddress
|
||||
beforeEach(async () => {
|
||||
store = aNewStore()
|
||||
// using 4th account because other accounts were used in other tests and paid gas
|
||||
safeAddress = await aMinedSafe(store)
|
||||
})
|
||||
|
||||
it('Changes owner\'s name', async () => {
|
||||
it("Changes owner's name", async () => {
|
||||
const NEW_OWNER_NAME = 'NEW OWNER NAME'
|
||||
|
||||
const SafeDom = renderSafeView(store, safeAddress)
|
||||
|
@ -52,4 +61,48 @@ describe('DOM > Feature > Settings - Manage owners', () => {
|
|||
const ownerRow = SafeDom.getByTestId(OWNERS_ROW_TESTID)
|
||||
expect(ownerRow).toHaveTextContent(NEW_OWNER_NAME)
|
||||
})
|
||||
|
||||
it('Removes an owner', async () => {
|
||||
const twoOwnersSafeAddress = await aMinedSafe(store, 2)
|
||||
|
||||
const SafeDom = renderSafeView(store, twoOwnersSafeAddress)
|
||||
await sleep(1300)
|
||||
|
||||
// Travel to settings
|
||||
const settingsBtn = SafeDom.getByTestId(SETTINGS_TAB_BTN_TESTID)
|
||||
fireEvent.click(settingsBtn)
|
||||
await sleep(200)
|
||||
|
||||
// click on owners settings
|
||||
const ownersSettingsBtn = SafeDom.getByTestId(OWNERS_SETTINGS_TAB_TEST_ID)
|
||||
fireEvent.click(ownersSettingsBtn)
|
||||
await sleep(200)
|
||||
|
||||
// check if there are 2 owners
|
||||
let ownerRows = SafeDom.getAllByTestId(OWNERS_ROW_TESTID)
|
||||
expect(ownerRows.length).toBe(2)
|
||||
|
||||
// click remove owner btn which opens the modal
|
||||
const removeOwnerBtn = SafeDom.getAllByTestId(REMOVE_OWNER_BTN_TESTID)[1]
|
||||
fireEvent.click(removeOwnerBtn)
|
||||
|
||||
// modal navigation
|
||||
const nextBtnStep1 = SafeDom.getByTestId(REMOVE_OWNER_MODAL_NEXT_BTN_TESTID)
|
||||
fireEvent.click(nextBtnStep1)
|
||||
|
||||
const nextBtnStep2 = SafeDom.getByTestId(REMOVE_OWNER_THRESHOLD_NEXT_BTN_TESTID)
|
||||
fireEvent.click(nextBtnStep2)
|
||||
|
||||
const nextBtnStep3 = SafeDom.getByTestId(REMOVE_OWNER_REVIEW_BTN_TESTID)
|
||||
fireEvent.click(nextBtnStep3)
|
||||
await sleep(400)
|
||||
|
||||
// check if owner was removed
|
||||
ownerRows = SafeDom.getAllByTestId(OWNERS_ROW_TESTID)
|
||||
expect(ownerRows.length).toBe(1)
|
||||
})
|
||||
|
||||
it('Replaces a owner', async () => {})
|
||||
|
||||
it('Adds a new owner', async () => {})
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue