Skip to content

Commit f8c6543

Browse files
refactoring to use fixture
1 parent 0040b66 commit f8c6543

File tree

3 files changed

+281
-6
lines changed

3 files changed

+281
-6
lines changed
Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
{
2+
"data": {
3+
"AppStateController": {
4+
"mkrMigrationReminderTimestamp": null,
5+
"swapsWelcomeMessageHasBeenShown": true
6+
},
7+
"CachedBalancesController": {
8+
"cachedBalances": {
9+
"4": {}
10+
}
11+
},
12+
"CurrencyController": {
13+
"conversionDate": 1575697244.188,
14+
"conversionRate": 149.61,
15+
"currentCurrency": "usd",
16+
"nativeCurrency": "ETH"
17+
},
18+
"IncomingTransactionsController": {
19+
"incomingTransactions": {},
20+
"incomingTxLastFetchedBlocksByNetwork": {
21+
"goerli": null,
22+
"kovan": null,
23+
"mainnet": null,
24+
"rinkeby": 5570536
25+
}
26+
},
27+
"KeyringController": {
28+
"vault": "{\"data\":\"s6TpYjlUNsn7ifhEFTkuDGBUM1GyOlPrim7JSjtfIxgTt8/6MiXgiR/CtFfR4dWW2xhq85/NGIBYEeWrZThGdKGarBzeIqBfLFhw9n509jprzJ0zc2Rf+9HVFGLw+xxC4xPxgCS0IIWeAJQ+XtGcHmn0UZXriXm8Ja4kdlow6SWinB7sr/WM3R0+frYs4WgllkwggDf2/Tv6VHygvLnhtzp6hIJFyTjh+l/KnyJTyZW1TkZhDaNDzX3SCOHT\",\"iv\":\"FbeHDAW5afeWNORfNJBR0Q==\",\"salt\":\"TxZ+WbCW6891C9LK/hbMAoUsSEW1E8pyGLVBU6x5KR8=\"}"
29+
},
30+
"NetworkController": {
31+
"network": "1337",
32+
"provider": {
33+
"nickname": "Localhost 8545",
34+
"rpcUrl": "http://localhost:8545",
35+
"chainId": "0x539",
36+
"ticker": "ETH",
37+
"type": "rpc"
38+
}
39+
},
40+
"OnboardingController": {
41+
"onboardingTabs": {},
42+
"seedPhraseBackedUp": false
43+
},
44+
"PermissionsMetadata": {
45+
"domainMetadata": {
46+
"metamask.github.io": {
47+
"icon": null,
48+
"name": "M E T A M A S K M E S H T E S T"
49+
}
50+
},
51+
"permissionsHistory": {},
52+
"permissionsLog": [
53+
{
54+
"id": 746677923,
55+
"method": "eth_accounts",
56+
"methodType": "restricted",
57+
"origin": "metamask.github.io",
58+
"request": {
59+
"id": 746677923,
60+
"jsonrpc": "2.0",
61+
"method": "eth_accounts",
62+
"origin": "metamask.github.io",
63+
"params": []
64+
},
65+
"requestTime": 1575697241368,
66+
"response": {
67+
"id": 746677923,
68+
"jsonrpc": "2.0",
69+
"result": []
70+
},
71+
"responseTime": 1575697241370,
72+
"success": true
73+
}
74+
]
75+
},
76+
"PreferencesController": {
77+
"accountTokens": {
78+
"0x5cfe73b6021e818b776b421b1c4db2474086a7e1": {
79+
"rinkeby": [],
80+
"ropsten": []
81+
}
82+
},
83+
"assetImages": {},
84+
"completedOnboarding": true,
85+
"currentLocale": "en",
86+
"featureFlags": {
87+
"showIncomingTransactions": true,
88+
"transactionTime": false
89+
},
90+
"firstTimeFlowType": "create",
91+
"forgottenPassword": false,
92+
"frequentRpcListDetail": [],
93+
"identities": {
94+
"0x5cfe73b6021e818b776b421b1c4db2474086a7e1": {
95+
"address": "0x5cfe73b6021e818b776b421b1c4db2474086a7e1",
96+
"name": "Account 1"
97+
}
98+
},
99+
"knownMethodData": {},
100+
"lostIdentities": {},
101+
"metaMetricsId": null,
102+
"metaMetricsSendCount": 0,
103+
"participateInMetaMetrics": false,
104+
"preferences": {
105+
"useNativeCurrencyAsPrimaryCurrency": true
106+
},
107+
"selectedAddress": "0x5cfe73b6021e818b776b421b1c4db2474086a7e1",
108+
"suggestedTokens": {},
109+
"tokens": [],
110+
"useBlockie": false,
111+
"useNonceField": false,
112+
"usePhishDetect": true
113+
},
114+
"TransactionController": {
115+
"transactions": {
116+
"4046084157914634": {
117+
"chainId": "0x539",
118+
"history": [
119+
{
120+
"chainId": "0x539",
121+
"id": 4046084157914634,
122+
"loadingDefaults": true,
123+
"metamaskNetworkId": "1337",
124+
"origin": "metamask",
125+
"status": "unapproved",
126+
"time": 1617228030067,
127+
"txParams": {
128+
"from": "0x5cfe73b6021e818b776b421b1c4db2474086a7e1",
129+
"gas": "0x61a8",
130+
"gasPrice": "0x2540be400",
131+
"to": "0x2f318C334780961FB129D2a6c30D0763d9a5C970",
132+
"value": "0xde0b6b3a7640000"
133+
},
134+
"type": "sentEther"
135+
},
136+
[
137+
{
138+
"note": "Added new unapproved transaction.",
139+
"op": "replace",
140+
"path": "/loadingDefaults",
141+
"timestamp": 1617228030069,
142+
"value": false
143+
}
144+
]
145+
],
146+
"id": 4046084157914634,
147+
"loadingDefaults": false,
148+
"metamaskNetworkId": "1337",
149+
"origin": "metamask",
150+
"status": "unapproved",
151+
"time": 1617228030067,
152+
"txParams": {
153+
"from": "0x5cfe73b6021e818b776b421b1c4db2474086a7e1",
154+
"gas": "0x61a8",
155+
"gasPrice": "0x2540be400",
156+
"to": "0x2f318C334780961FB129D2a6c30D0763d9a5C970",
157+
"value": "0xde0b6b3a7640000"
158+
},
159+
"type": "sentEther"
160+
}
161+
}
162+
},
163+
"config": {},
164+
"firstTimeInfo": {
165+
"date": 1575697234195,
166+
"version": "7.7.0"
167+
}
168+
},
169+
"meta": {
170+
"version": 40
171+
}
172+
}

test/e2e/run-all.sh

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,6 @@ retry concurrently --kill-others \
5555
--success first \
5656
'mocha test/e2e/from-import-ui.spec'
5757

58-
retry concurrently --kill-others \
59-
--names 'e2e' \
60-
--prefix '[{time}][{name}]' \
61-
--success first \
62-
'mocha test/e2e/send-edit.spec'
63-
6458
retry concurrently --kill-others \
6559
--names 'dapp,e2e' \
6660
--prefix '[{time}][{name}]' \

test/e2e/tests/send-edit.spec.js

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
const { strict: assert } = require('assert');
2+
const { By, Key, until } = require('selenium-webdriver');
3+
const {
4+
withFixtures,
5+
tinyDelayMs,
6+
regularDelayMs,
7+
largeDelayMs,
8+
} = require('../helpers');
9+
10+
describe('Editing Confirm Transaction', function () {
11+
it('goes back from confirm page to edit eth value, gas price and gas limit', async function () {
12+
const ganacheOptions = {
13+
accounts: [
14+
{
15+
secretKey:
16+
'0x7C9529A67102755B7E6102D6D950AC5D5863C98713805CEC576B945B15B71EAC',
17+
balance: 25000000000000000000,
18+
},
19+
],
20+
};
21+
await withFixtures(
22+
{
23+
dapp: true,
24+
fixtures: 'send-edit',
25+
ganacheOptions,
26+
title: this.test.title,
27+
},
28+
async ({ driver }) => {
29+
await driver.navigate();
30+
const passwordField = await driver.findElement(By.css('#password'));
31+
await passwordField.sendKeys('correct horse battery staple');
32+
await passwordField.sendKeys(Key.ENTER);
33+
34+
const transactionAmounts = await driver.findElements(
35+
By.css('.currency-display-component__text'),
36+
);
37+
const transactionAmount = transactionAmounts[0];
38+
assert.equal(await transactionAmount.getText(), '1');
39+
40+
const transactionFee = transactionAmounts[1];
41+
assert.equal(await transactionFee.getText(), '0.00025');
42+
43+
await driver.clickElement(
44+
By.css('.confirm-page-container-header__back-button'),
45+
);
46+
const inputAmount = await driver.findElement(
47+
By.css('.unit-input__input'),
48+
);
49+
await inputAmount.clear();
50+
await inputAmount.sendKeys('2.2');
51+
52+
await driver.clickElement(By.css('.advanced-gas-options-btn'));
53+
await driver.delay(regularDelayMs);
54+
55+
const gasModal = await driver.findElement(By.css('span .modal'));
56+
57+
const [gasPriceInput, gasLimitInput] = await driver.findElements(
58+
By.css('.advanced-gas-inputs__gas-edit-row__input'),
59+
);
60+
61+
await gasPriceInput.clear();
62+
await gasPriceInput.sendKeys('8');
63+
await driver.delay(tinyDelayMs);
64+
65+
await gasLimitInput.clear();
66+
await gasLimitInput.sendKeys('100000');
67+
await driver.delay(largeDelayMs);
68+
69+
await driver.clickElement(
70+
By.xpath(`//button[contains(text(), 'Save')]`),
71+
);
72+
await driver.wait(until.stalenessOf(gasModal));
73+
await driver.clickElement(
74+
By.xpath(`//button[contains(text(), 'Next')]`),
75+
);
76+
// await driver.delay(regularDelayMs);
77+
const editedTransactionAmounts = await driver.findElements(
78+
By.css('.currency-display-component__text'),
79+
);
80+
const editedTransactionAmount = editedTransactionAmounts[0];
81+
assert.equal(await editedTransactionAmount.getText(), '2.2');
82+
83+
const editedTransactionFee = editedTransactionAmounts[1];
84+
assert.equal(await editedTransactionFee.getText(), '0.0008');
85+
86+
await driver.clickElement(
87+
By.xpath(`//button[contains(text(), 'Confirm')]`),
88+
);
89+
await driver.delay(regularDelayMs);
90+
91+
await driver.clickElement(By.css('[data-testid="home__activity-tab"]'));
92+
await driver.wait(async () => {
93+
const confirmedTxes = await driver.findElements(
94+
By.css(
95+
'.transaction-list__completed-transactions .transaction-list-item',
96+
),
97+
);
98+
return confirmedTxes.length === 1;
99+
}, 10000);
100+
101+
const txValues = await driver.findElements(
102+
By.css('.transaction-list-item__primary-currency'),
103+
);
104+
assert.equal(txValues.length, 1);
105+
assert.ok(/-2.2\s*ETH/u.test(await txValues[0].getText()));
106+
},
107+
);
108+
});
109+
});

0 commit comments

Comments
 (0)