mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-23 02:10:12 +01:00
74 lines
2.6 KiB
JavaScript
74 lines
2.6 KiB
JavaScript
const { strict: assert } = require('assert');
|
|
const { convertToHexValue, withFixtures } = require('../helpers');
|
|
const { SMART_CONTRACTS } = require('../seeder/smart-contracts');
|
|
|
|
describe('Send ERC20 token to contract address', function () {
|
|
const smartContract = SMART_CONTRACTS.HST;
|
|
const ganacheOptions = {
|
|
accounts: [
|
|
{
|
|
secretKey:
|
|
'0x7C9529A67102755B7E6102D6D950AC5D5863C98713805CEC576B945B15B71EAC',
|
|
balance: convertToHexValue(25000000000000000000),
|
|
},
|
|
],
|
|
};
|
|
it('should display the token contract warning to the user', async function () {
|
|
await withFixtures(
|
|
{
|
|
dapp: true,
|
|
fixtures: 'connected-state',
|
|
ganacheOptions,
|
|
smartContract,
|
|
title: this.test.title,
|
|
failOnConsoleError: false,
|
|
},
|
|
async ({ driver, contractRegistry }) => {
|
|
const contractAddress = await contractRegistry.getContractAddress(
|
|
smartContract,
|
|
);
|
|
await driver.navigate();
|
|
await driver.fill('#password', 'correct horse battery staple');
|
|
await driver.press('#password', driver.Key.ENTER);
|
|
|
|
// Create TST
|
|
await driver.openNewPage(
|
|
`http://127.0.0.1:8080/?contract=${contractAddress}`,
|
|
);
|
|
let windowHandles = await driver.getAllWindowHandles();
|
|
const extension = windowHandles[0];
|
|
|
|
// Add token
|
|
await driver.findClickableElement('#deployButton');
|
|
await driver.clickElement('#watchAsset');
|
|
await driver.waitUntilXWindowHandles(3);
|
|
windowHandles = await driver.getAllWindowHandles();
|
|
await driver.switchToWindowWithTitle(
|
|
'MetaMask Notification',
|
|
windowHandles,
|
|
);
|
|
await driver.clickElement({ text: 'Add token', tag: 'button' });
|
|
await driver.waitUntilXWindowHandles(2);
|
|
await driver.switchToWindow(extension);
|
|
|
|
// Send TST
|
|
await driver.clickElement('[data-testid="home__asset-tab"]');
|
|
await driver.clickElement('.token-cell');
|
|
await driver.clickElement('[data-testid="eth-overview-send"]');
|
|
|
|
// Type contract address
|
|
await driver.fill(
|
|
'input[placeholder="Search, public address (0x), or ENS"]',
|
|
contractAddress,
|
|
);
|
|
|
|
// Verify warning
|
|
const warningText =
|
|
'Warning: you are about to send to a token contract which could result in a loss of funds. Learn more\nI understand';
|
|
const warning = await driver.findElement('.send__warning-container');
|
|
assert.equal(await warning.getText(), warningText);
|
|
},
|
|
);
|
|
});
|
|
});
|