|
| 1 | +import { withFixtures, WINDOW_TITLES } from '../../helpers'; |
| 2 | +import FixtureBuilder from '../../fixture-builder'; |
| 3 | +import { loginWithBalanceValidation } from '../../page-objects/flows/login.flow'; |
| 4 | +import TestDapp from '../../page-objects/pages/test-dapp'; |
| 5 | +import Petnames from './petnames-helpers'; |
| 6 | + |
| 7 | +const ADDRESS_MOCK = '0x0c54fccd2e384b4bb6f2e405bf5cbc15a017aafb'; |
| 8 | +const ABBREVIATED_ADDRESS_MOCK = '0x0c54F...7AaFb'; |
| 9 | +const CUSTOM_NAME_MOCK = 'Custom Name'; |
| 10 | +const PROPOSED_NAME_MOCK = 'test4.lens'; |
| 11 | + |
| 12 | +describe('Petnames - Transactions', function () { |
| 13 | + it('can save petnames for addresses in dapp send transactions', async function () { |
| 14 | + await withFixtures( |
| 15 | + { |
| 16 | + dapp: true, |
| 17 | + fixtures: new FixtureBuilder() |
| 18 | + .withPermissionControllerConnectedToTestDapp() |
| 19 | + .withNoNames() |
| 20 | + .build(), |
| 21 | + title: this.test?.fullTitle() ?? 'Default Title', |
| 22 | + }, |
| 23 | + async ({ driver }) => { |
| 24 | + const testDapp = new TestDapp(driver); |
| 25 | + const petnames = new Petnames(driver); |
| 26 | + await loginWithBalanceValidation(driver); |
| 27 | + await testDapp.openTestDappPage(); |
| 28 | + await testDapp.clickSimpleSendButton(); |
| 29 | + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); |
| 30 | + await petnames.expectName(ABBREVIATED_ADDRESS_MOCK, false); |
| 31 | + |
| 32 | + // Test custom name. |
| 33 | + await petnames.saveName( |
| 34 | + ABBREVIATED_ADDRESS_MOCK, |
| 35 | + CUSTOM_NAME_MOCK, |
| 36 | + undefined, |
| 37 | + ); |
| 38 | + await driver.clickElement({ tag: 'button', text: 'Cancel' }); |
| 39 | + await driver.switchToWindowWithTitle(WINDOW_TITLES.TestDApp); |
| 40 | + await testDapp.clickSimpleSendButton(); |
| 41 | + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); |
| 42 | + await petnames.expectName(CUSTOM_NAME_MOCK, true); |
| 43 | + |
| 44 | + // Test proposed name. |
| 45 | + await petnames.saveName( |
| 46 | + CUSTOM_NAME_MOCK, |
| 47 | + undefined, |
| 48 | + PROPOSED_NAME_MOCK, |
| 49 | + ); |
| 50 | + await driver.clickElement({ tag: 'button', text: 'Cancel' }); |
| 51 | + await driver.switchToWindowWithTitle(WINDOW_TITLES.TestDApp); |
| 52 | + await testDapp.clickSimpleSendButton(); |
| 53 | + await driver.switchToWindowWithTitle(WINDOW_TITLES.Dialog); |
| 54 | + await petnames.expectName(PROPOSED_NAME_MOCK, true); |
| 55 | + }, |
| 56 | + ); |
| 57 | + }); |
| 58 | + |
| 59 | + it('can save petnames for addresses in wallet send transactions', async function () { |
| 60 | + await withFixtures( |
| 61 | + { |
| 62 | + fixtures: new FixtureBuilder() |
| 63 | + .withPreferencesController({ |
| 64 | + featureFlags: { |
| 65 | + sendHexData: true, |
| 66 | + }, |
| 67 | + }) |
| 68 | + .withNoNames() |
| 69 | + .build(), |
| 70 | + title: this.test?.fullTitle() ?? 'Default Title', |
| 71 | + }, |
| 72 | + async ({ driver }) => { |
| 73 | + const petnames = new Petnames(driver); |
| 74 | + await loginWithBalanceValidation(driver); |
| 75 | + await petnames.createWalletSendTransaction(ADDRESS_MOCK); |
| 76 | + await petnames.expectName(ABBREVIATED_ADDRESS_MOCK, false); |
| 77 | + |
| 78 | + // Test custom name. |
| 79 | + await petnames.saveName( |
| 80 | + ABBREVIATED_ADDRESS_MOCK, |
| 81 | + CUSTOM_NAME_MOCK, |
| 82 | + undefined, |
| 83 | + ); |
| 84 | + await driver.clickElement({ tag: 'button', text: 'Cancel' }); |
| 85 | + await petnames.createWalletSendTransaction(ADDRESS_MOCK); |
| 86 | + await petnames.expectName(CUSTOM_NAME_MOCK, true); |
| 87 | + |
| 88 | + // Test proposed name. |
| 89 | + await petnames.saveName( |
| 90 | + CUSTOM_NAME_MOCK, |
| 91 | + undefined, |
| 92 | + PROPOSED_NAME_MOCK, |
| 93 | + ); |
| 94 | + await driver.clickElement({ tag: 'button', text: 'Cancel' }); |
| 95 | + await petnames.createWalletSendTransaction(ADDRESS_MOCK); |
| 96 | + await petnames.expectName(PROPOSED_NAME_MOCK, true); |
| 97 | + }, |
| 98 | + ); |
| 99 | + }); |
| 100 | +}); |
0 commit comments