This repository has been archived by the owner on Jan 10, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathcreate_safe_migration.test.js
157 lines (126 loc) · 6.78 KB
/
create_safe_migration.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
import {
assertElementPresent,
clickElement,
assertTextPresent,
isTextPresent,
getInnerText,
clickSomething,
} from '../../utils/selectorsHelpers'
import { PuppeteerScreenRecorder } from 'puppeteer-screen-recorder'
import { accountsSelectors } from '../../utils/selectors/accounts'
import { createSafePage } from '../../utils/selectors/createSafePage'
import { generalInterface } from '../../utils/selectors/generalInterface'
import { getShortNameAddress } from '../../utils/addresses'
import { getEnvUrl, initWithWalletConnected } from '../../utils/testSetup'
import config from '../../utils/config'
/*
Create safe
-- Enters into the create safe form with the Create button
-- Type a name for the safe
-- Adds a new owner row
-- Check that owner names and addresses are required when clicking submit
-- Type names and addresses only for "owner2"
-- Checks that the policies selector matches the amount of owners
-- Checks in review step the name of the safe, name and address of owner2
-- Checks "block explorer" and "back" button during the safe creation
-- Checks safe name on the sidebar once the safe is loaded
*/
let browser
let metamask
let gnosisPage
let recorder
const { FUNDS_RECEIVER_ADDRESS } = config
beforeAll(async () => {
;[browser, metamask, gnosisPage] = await initWithWalletConnected()
}, 60000)
afterAll(async () => {
await recorder.stop()
await gnosisPage.waitForTimeout(2000)
await browser.close()
})
describe('Create New Safe Migration', () => {
test('Create Safe with a Old MultiSig migration url', async () => {
recorder = new PuppeteerScreenRecorder(gnosisPage)
await recorder.start('./e2e-tests-assets/create_safe_migration.mp4')
console.log('Create Safe with a Old MultiSig migration')
const newSafeName = accountsSelectors.safeNames.create_safe_name
const firstOwnerName = 'custom_first_owner_name'
const firstOwnerAddress = FUNDS_RECEIVER_ADDRESS
const secondOwnerName = accountsSelectors.accountNames.owner2_name
const secondOwnerAddress = accountsSelectors.testAccountsHash.acc2
const customThresholdValue = '2'
const firstOwnerIndex = 0
const secondOwnerIndex = 1
const migrationUrl = `${getEnvUrl()}app/open?name=${newSafeName}&threshold=${customThresholdValue}&owneraddresses=${firstOwnerAddress},${secondOwnerAddress}&ownernames=${firstOwnerName},${secondOwnerName}`
await gnosisPage.goto(migrationUrl)
await assertElementPresent({ selector: createSafePage.form, type: 'css' }, gnosisPage)
// [Step 1] Select Network
console.log('Shows Connect wallet & select network step')
await assertElementPresent(createSafePage.select_network_step, gnosisPage)
await assertTextPresent(createSafePage.select_network_step, 'Rinkeby', gnosisPage)
await clickElement(generalInterface.submit_btn, gnosisPage)
// [Step 2] Naming The Safe
console.log('Shows naming the Safe step')
await assertElementPresent(createSafePage.naming_safe_step, gnosisPage)
console.log('Check the name of the safe')
expect(await getInnerText(createSafePage.safe_name_field, gnosisPage)).toBe(newSafeName)
await clickSomething(generalInterface.submit_btn.selector, gnosisPage, 'css')
// [Step 3] Owners and Confirmations
console.log('Shows Owners and Confirmations step')
await assertElementPresent(createSafePage.owners_and_confirmations_step, gnosisPage)
console.log('Shows Owners from migration URL')
// assert first owner
expect(await getInnerText(createSafePage.get_owner_name_field(firstOwnerIndex), gnosisPage)).toBe(firstOwnerName)
expect(await getInnerText(createSafePage.get_owner_address_field(firstOwnerIndex), gnosisPage)).toBe(
getShortNameAddress(firstOwnerAddress),
)
await assertElementPresent(createSafePage.get_valid_address_check_icon(firstOwnerIndex), gnosisPage)
// assert second owner
expect(await getInnerText(createSafePage.get_owner_name_field(secondOwnerIndex), gnosisPage)).toBe(secondOwnerName)
expect(await getInnerText(createSafePage.get_owner_address_field(secondOwnerIndex), gnosisPage)).toBe(
getShortNameAddress(secondOwnerAddress),
)
await assertElementPresent(createSafePage.get_valid_address_check_icon(secondOwnerIndex), gnosisPage)
// assert custom Threshold
console.log('Selects the custom Threshold from the migration URL')
expect(await getInnerText(createSafePage.threshold_hidden_input, gnosisPage)).toBe(customThresholdValue)
await clickSomething(generalInterface.submit_btn.selector, gnosisPage, 'css')
// [Step 4] Owners and Confirmations
console.log('Shows Review Safe step')
await assertElementPresent(createSafePage.review_safe_step, gnosisPage)
// review the name
console.log('Checks the name of the new Safe')
expect(await getInnerText(createSafePage.review_safe_name_label, gnosisPage)).toBe(newSafeName)
// review the threshold
console.log('Checks the threshold of the new Safe')
expect(await getInnerText(createSafePage.review_safe_threshold_label, gnosisPage)).toBe('2 out of 2 owners')
// review the owners
console.log('Checks owners of the new Safe')
expect(await getInnerText(createSafePage.review_owner_name(firstOwnerAddress), gnosisPage)).toBe(firstOwnerName)
expect(await getInnerText(createSafePage.review_owner_address(firstOwnerAddress), gnosisPage)).toBe(
getShortNameAddress(firstOwnerAddress),
)
expect(await getInnerText(createSafePage.review_owner_name(secondOwnerAddress), gnosisPage)).toBe(secondOwnerName)
expect(await getInnerText(createSafePage.review_owner_address(secondOwnerAddress), gnosisPage)).toBe(
getShortNameAddress(secondOwnerAddress),
)
console.log('Submits the Create Safe Form')
await clickSomething(generalInterface.submit_btn.selector, gnosisPage, 'css')
await gnosisPage.waitForTimeout(2000)
await metamask.confirmTransaction()
// Assert Safe Creation
await gnosisPage.bringToFront()
console.log('Checks "block explorer" and "back" button during the safe creation')
await assertElementPresent({ selector: createSafePage.back_btn, type: 'css' }, gnosisPage)
await assertElementPresent({ selector: createSafePage.etherscan_link, type: 'css' }, gnosisPage)
await assertElementPresent({ selector: createSafePage.continue_btn, type: 'css' }, gnosisPage)
await clickElement({ selector: createSafePage.continue_btn }, gnosisPage)
// Safe Created Popup
console.log('Checks if the Safe Created popup is showed')
await assertElementPresent(createSafePage.safe_created_dialog, gnosisPage)
await clickElement(createSafePage.safe_created_button, gnosisPage)
// Checks your created safe
console.log('Checks safe name on the sidebar once the safe is loaded')
await isTextPresent(generalInterface.sidebar, accountsSelectors.safeNames.create_safe_name, gnosisPage)
}, 180000)
})