2021-04-03 04:40:53 +02:00
|
|
|
const { strict: assert } = require('assert');
|
2022-01-19 00:08:41 +01:00
|
|
|
const { convertToHexValue, withFixtures } = require('../helpers');
|
2022-10-28 10:42:12 +02:00
|
|
|
const FixtureBuilder = require('../fixture-builder');
|
2021-04-03 04:40:53 +02:00
|
|
|
|
|
|
|
describe('Address Book', function () {
|
|
|
|
const ganacheOptions = {
|
|
|
|
accounts: [
|
|
|
|
{
|
|
|
|
secretKey:
|
|
|
|
'0x7C9529A67102755B7E6102D6D950AC5D5863C98713805CEC576B945B15B71EAC',
|
2022-01-19 00:08:41 +01:00
|
|
|
balance: convertToHexValue(25000000000000000000),
|
2021-04-03 04:40:53 +02:00
|
|
|
},
|
|
|
|
],
|
|
|
|
};
|
|
|
|
it('Adds an entry to the address book and sends eth to that address', async function () {
|
|
|
|
await withFixtures(
|
|
|
|
{
|
2022-10-28 10:42:12 +02:00
|
|
|
fixtures: new FixtureBuilder().build(),
|
2021-04-03 04:40:53 +02:00
|
|
|
ganacheOptions,
|
|
|
|
title: this.test.title,
|
|
|
|
},
|
|
|
|
async ({ driver }) => {
|
|
|
|
await driver.navigate();
|
2021-04-12 17:32:38 +02:00
|
|
|
await driver.fill('#password', 'correct horse battery staple');
|
|
|
|
await driver.press('#password', driver.Key.ENTER);
|
2021-04-03 04:40:53 +02:00
|
|
|
|
2021-04-07 16:57:40 +02:00
|
|
|
await driver.clickElement('[data-testid="eth-overview-send"]');
|
2021-04-03 04:40:53 +02:00
|
|
|
|
2021-04-12 17:32:38 +02:00
|
|
|
await driver.fill(
|
2021-04-07 16:57:40 +02:00
|
|
|
'input[placeholder="Search, public address (0x), or ENS"]',
|
2021-04-03 04:40:53 +02:00
|
|
|
'0x2f318C334780961FB129D2a6c30D0763d9a5C970',
|
|
|
|
);
|
|
|
|
|
2021-04-07 16:57:40 +02:00
|
|
|
await driver.clickElement('.dialog.send__dialog.dialog--message');
|
2021-04-03 04:40:53 +02:00
|
|
|
|
2021-04-13 23:36:02 +02:00
|
|
|
// wait for address book modal to be visible
|
2021-12-01 18:22:08 +01:00
|
|
|
const addressModal = await driver.findElement('.nickname-popover');
|
2021-04-13 23:36:02 +02:00
|
|
|
|
2021-12-01 18:22:08 +01:00
|
|
|
await driver.clickElement('.nickname-popover__footer-button');
|
|
|
|
await driver.findElement('.update-nickname__wrapper');
|
|
|
|
|
|
|
|
await driver.fill(
|
|
|
|
'.update-nickname__content__text-field input',
|
|
|
|
'Test Name 1',
|
2021-04-03 04:40:53 +02:00
|
|
|
);
|
2021-12-01 18:22:08 +01:00
|
|
|
await driver.clickElement('.update-nickname__save');
|
2021-04-13 23:36:02 +02:00
|
|
|
// wait for address book modal to be removed from DOM
|
|
|
|
await addressModal.waitForElementState('hidden');
|
2021-04-03 04:40:53 +02:00
|
|
|
|
2021-04-07 16:57:40 +02:00
|
|
|
const inputAmount = await driver.findElement('.unit-input__input');
|
2021-04-12 17:32:38 +02:00
|
|
|
await inputAmount.fill('1');
|
2021-04-03 04:40:53 +02:00
|
|
|
|
2021-12-02 19:28:24 +01:00
|
|
|
const inputValue = await inputAmount.getProperty('value');
|
2021-04-03 04:40:53 +02:00
|
|
|
assert.equal(inputValue, '1');
|
|
|
|
|
2021-04-07 16:57:40 +02:00
|
|
|
await driver.clickElement({ text: 'Next', tag: 'button' });
|
2021-04-03 04:40:53 +02:00
|
|
|
|
2021-04-07 16:57:40 +02:00
|
|
|
await driver.clickElement({ text: 'Confirm', tag: 'button' });
|
2021-04-03 04:40:53 +02:00
|
|
|
|
2021-04-07 16:57:40 +02:00
|
|
|
await driver.clickElement('[data-testid="home__activity-tab"]');
|
2021-04-03 04:40:53 +02:00
|
|
|
await driver.wait(async () => {
|
|
|
|
const confirmedTxes = await driver.findElements(
|
2021-04-07 16:57:40 +02:00
|
|
|
'.transaction-list__completed-transactions .transaction-list-item',
|
2021-04-03 04:40:53 +02:00
|
|
|
);
|
|
|
|
return confirmedTxes.length === 1;
|
|
|
|
}, 10000);
|
|
|
|
|
2021-04-13 23:36:02 +02:00
|
|
|
await driver.waitForSelector(
|
|
|
|
{
|
|
|
|
css: '.transaction-list-item__primary-currency',
|
|
|
|
text: '-1 ETH',
|
|
|
|
},
|
|
|
|
{ timeout: 10000 },
|
2021-04-03 04:40:53 +02:00
|
|
|
);
|
|
|
|
},
|
|
|
|
);
|
|
|
|
});
|
|
|
|
it('Sends to an address book entry', async function () {
|
|
|
|
await withFixtures(
|
|
|
|
{
|
2022-10-28 10:42:12 +02:00
|
|
|
fixtures: new FixtureBuilder()
|
|
|
|
.withAddressBookController({
|
|
|
|
addressBook: {
|
|
|
|
'0x539': {
|
|
|
|
'0x2f318C334780961FB129D2a6c30D0763d9a5C970': {
|
|
|
|
address: '0x2f318C334780961FB129D2a6c30D0763d9a5C970',
|
|
|
|
chainId: '0x539',
|
|
|
|
isEns: false,
|
|
|
|
memo: '',
|
|
|
|
name: 'Test Name 1',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
.build(),
|
2021-04-03 04:40:53 +02:00
|
|
|
ganacheOptions,
|
|
|
|
title: this.test.title,
|
|
|
|
},
|
|
|
|
async ({ driver }) => {
|
|
|
|
await driver.navigate();
|
2021-04-12 17:32:38 +02:00
|
|
|
await driver.fill('#password', 'correct horse battery staple');
|
|
|
|
await driver.press('#password', driver.Key.ENTER);
|
2021-04-03 04:40:53 +02:00
|
|
|
|
2021-04-07 16:57:40 +02:00
|
|
|
await driver.clickElement('[data-testid="eth-overview-send"]');
|
2021-04-03 04:40:53 +02:00
|
|
|
const recipientRowTitle = await driver.findElement(
|
2021-04-07 16:57:40 +02:00
|
|
|
'.send__select-recipient-wrapper__group-item__title',
|
2021-04-03 04:40:53 +02:00
|
|
|
);
|
2022-11-02 15:28:17 +01:00
|
|
|
|
2021-04-03 04:40:53 +02:00
|
|
|
const recipientRowTitleString = await recipientRowTitle.getText();
|
|
|
|
assert.equal(recipientRowTitleString, 'Test Name 1');
|
|
|
|
await driver.clickElement(
|
2021-04-07 16:57:40 +02:00
|
|
|
'.send__select-recipient-wrapper__group-item',
|
2021-04-03 04:40:53 +02:00
|
|
|
);
|
|
|
|
|
2021-04-12 17:32:38 +02:00
|
|
|
await driver.fill('.unit-input__input', '2');
|
2021-04-03 04:40:53 +02:00
|
|
|
|
2021-04-07 16:57:40 +02:00
|
|
|
await driver.clickElement({ text: 'Next', tag: 'button' });
|
2021-04-03 04:40:53 +02:00
|
|
|
|
2021-04-07 16:57:40 +02:00
|
|
|
await driver.clickElement({ text: 'Confirm', tag: 'button' });
|
2021-04-03 04:40:53 +02:00
|
|
|
|
2021-04-07 16:57:40 +02:00
|
|
|
await driver.clickElement('[data-testid="home__activity-tab"]');
|
2021-04-03 04:40:53 +02:00
|
|
|
await driver.wait(async () => {
|
|
|
|
const confirmedTxes = await driver.findElements(
|
2021-04-07 16:57:40 +02:00
|
|
|
'.transaction-list__completed-transactions .transaction-list-item',
|
2021-04-03 04:40:53 +02:00
|
|
|
);
|
|
|
|
return confirmedTxes.length === 1;
|
|
|
|
}, 10000);
|
|
|
|
|
2021-04-13 23:36:02 +02:00
|
|
|
await driver.waitForSelector(
|
|
|
|
{
|
|
|
|
css: '.transaction-list-item__primary-currency',
|
|
|
|
text: '-2 ETH',
|
|
|
|
},
|
|
|
|
{ timeout: 10000 },
|
2021-04-03 04:40:53 +02:00
|
|
|
);
|
|
|
|
},
|
|
|
|
);
|
|
|
|
});
|
2022-11-02 15:28:17 +01:00
|
|
|
it('Edit entry in address book', async function () {
|
|
|
|
await withFixtures(
|
|
|
|
{
|
|
|
|
fixtures: new FixtureBuilder()
|
|
|
|
.withAddressBookController({
|
|
|
|
addressBook: {
|
|
|
|
'0x539': {
|
|
|
|
'0x2f318C334780961FB129D2a6c30D0763d9a5C970': {
|
|
|
|
address: '0x2f318C334780961FB129D2a6c30D0763d9a5C970',
|
|
|
|
chainId: '0x539',
|
|
|
|
isEns: false,
|
|
|
|
memo: '',
|
|
|
|
name: 'Test Name 1',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
.build(),
|
|
|
|
ganacheOptions,
|
|
|
|
title: this.test.title,
|
|
|
|
},
|
|
|
|
async ({ driver }) => {
|
|
|
|
await driver.navigate();
|
|
|
|
await driver.fill('#password', 'correct horse battery staple');
|
|
|
|
await driver.press('#password', driver.Key.ENTER);
|
|
|
|
|
|
|
|
await driver.clickElement('.identicon__address-wrapper');
|
|
|
|
await driver.clickElement({ text: 'Settings', tag: 'div' });
|
|
|
|
await driver.clickElement({ text: 'Contacts', tag: 'div' });
|
|
|
|
await driver.clickElement('[data-testid="recipient"]');
|
|
|
|
|
|
|
|
await driver.clickElement({ text: 'Edit', tag: 'button' });
|
|
|
|
const inputUsername = await driver.findElement('#nickname');
|
|
|
|
await inputUsername.fill('Test Name Edit');
|
|
|
|
|
|
|
|
const inputAddress = await driver.findElement('#address');
|
|
|
|
await inputAddress.fill('0x74cE91B75935D6Bedc27eE002DeFa566c5946f74');
|
|
|
|
|
|
|
|
await driver.clickElement('[data-testid="page-container-footer-next"]');
|
|
|
|
|
|
|
|
const recipientUsername = await driver.findElement({
|
|
|
|
text: 'Test Name Edit',
|
|
|
|
tag: 'div',
|
|
|
|
});
|
|
|
|
assert.equal(
|
|
|
|
await recipientUsername.getText(),
|
|
|
|
'Test Name Edit',
|
|
|
|
'Username is not edited correctly',
|
|
|
|
);
|
|
|
|
|
|
|
|
const recipientAddress = await driver.findElement(
|
|
|
|
'.send__select-recipient-wrapper__group-item__subtitle',
|
|
|
|
);
|
|
|
|
assert.equal(
|
|
|
|
await recipientAddress.getText(),
|
|
|
|
'0x74cE...6f74',
|
|
|
|
'Recipient address is not edited correctly',
|
|
|
|
);
|
|
|
|
},
|
|
|
|
);
|
|
|
|
});
|
|
|
|
it('Deletes existing entry from address book', async function () {
|
|
|
|
await withFixtures(
|
|
|
|
{
|
|
|
|
fixtures: new FixtureBuilder()
|
|
|
|
.withAddressBookController({
|
|
|
|
addressBook: {
|
|
|
|
'0x539': {
|
|
|
|
'0x2f318C334780961FB129D2a6c30D0763d9a5C970': {
|
|
|
|
address: '0x2f318C334780961FB129D2a6c30D0763d9a5C970',
|
|
|
|
chainId: '0x539',
|
|
|
|
isEns: false,
|
|
|
|
memo: '',
|
|
|
|
name: 'Test Name 1',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
.build(),
|
|
|
|
ganacheOptions,
|
|
|
|
title: this.test.title,
|
|
|
|
},
|
|
|
|
async ({ driver }) => {
|
|
|
|
await driver.navigate();
|
|
|
|
await driver.fill('#password', 'correct horse battery staple');
|
|
|
|
await driver.press('#password', driver.Key.ENTER);
|
|
|
|
|
|
|
|
await driver.clickElement('.identicon__address-wrapper');
|
|
|
|
await driver.clickElement({ text: 'Settings', tag: 'div' });
|
|
|
|
await driver.clickElement({ text: 'Contacts', tag: 'div' });
|
|
|
|
|
|
|
|
await driver.clickElement({ text: 'Test Name 1', tag: 'div' });
|
|
|
|
await driver.clickElement({ text: 'Edit', tag: 'button' });
|
|
|
|
await driver.clickElement({ text: 'Delete account', tag: 'a' });
|
|
|
|
// it checks if account is deleted
|
|
|
|
const contact = await driver.findElement(
|
|
|
|
'.send__select-recipient-wrapper__group-item',
|
|
|
|
);
|
|
|
|
const exists = await driver.isElementPresent(contact);
|
|
|
|
assert.equal(exists, false, 'Contact is not deleted');
|
|
|
|
},
|
|
|
|
);
|
|
|
|
});
|
2021-04-03 04:40:53 +02:00
|
|
|
});
|