Skip to content

Commit 41d7945

Browse files
committed
chore: migrate petnames-transactions test to pom
1 parent b808045 commit 41d7945

File tree

3 files changed

+111
-119
lines changed

3 files changed

+111
-119
lines changed

test/e2e/tests/petnames/petnames-helpers.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import { Driver } from '../../webdriver/driver';
2+
import HomePage from '../../page-objects/pages/home/homepage';
3+
import SendTokenPage from '../../page-objects/pages/send/send-token-page';
24

35
export default class Petnames {
46
private driver: Driver;
@@ -68,4 +70,13 @@ export default class Petnames {
6870
});
6971
}
7072
}
73+
74+
async createWalletSendTransaction(recipientAddress: string): Promise<void> {
75+
const homePage = new HomePage(this.driver);
76+
await homePage.startSendFlow();
77+
const sendToPage = new SendTokenPage(this.driver);
78+
await sendToPage.check_pageIsLoaded();
79+
await sendToPage.fillRecipient(recipientAddress);
80+
await sendToPage.goToNextScreen();
81+
}
7182
}

test/e2e/tests/petnames/petnames-transactions.spec.js

Lines changed: 0 additions & 119 deletions
This file was deleted.
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
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

Comments
 (0)