Skip to content

Commit 471f209

Browse files
authored
test(extension): LW-12680 (#1853)
* test(extension): add assertions for 'Add shared wallet' and 'Add Bitcoin wallet' items * test(extension): add coverage for LW-12403 and LW-12404
1 parent ba7fab5 commit 471f209

File tree

12 files changed

+124
-15
lines changed

12 files changed

+124
-15
lines changed

apps/browser-extension-wallet/src/components/MainMenu/DropdownMenuOverlay/components/AddNewBitcoinWalletLink.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@ import { useBackgroundServiceAPIContext } from '@providers';
77
import { BrowserViewSections } from '@lib/scripts/types';
88
import { useBackgroundPage } from '@providers/BackgroundPageProvider';
99
import { PostHogAction } from '@lace/common';
10+
import { useTranslation } from 'react-i18next';
1011

1112
interface Props {
1213
isPopup?: boolean;
1314
sendAnalyticsEvent?: (event: PostHogAction) => void;
1415
}
1516

1617
export const AddNewBitcoinWalletLink = ({ isPopup }: Props): React.ReactElement => {
18+
const { t } = useTranslation();
1719
const location = useLocation();
1820
const backgroundServices = useBackgroundServiceAPIContext();
1921
const { setBackgroundPage } = useBackgroundPage();
@@ -33,8 +35,8 @@ export const AddNewBitcoinWalletLink = ({ isPopup }: Props): React.ReactElement
3335
}}
3436
onClick={openNewWallet}
3537
>
36-
<Menu.Item data-testid="header-menu-new-wallet" className={styles.menuItem}>
37-
Add Bitcoin wallet
38+
<Menu.Item data-testid="header-menu-add-bitcoin-wallet" className={styles.menuItem}>
39+
{t('browserView.sideMenu.links.addBitcoinWallet')}
3840
</Menu.Item>
3941
</Link>
4042
);

apps/browser-extension-wallet/src/features/dapp/components/confirm-transaction/__tests__/DappTransactionContainer.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ describe('Testing DappTransactionContainer component', () => {
443443
fireEvent.click(queryByTestId('cbor-detail_toggle'));
444444
});
445445

446-
expect(queryByTestId('cbor')).toHaveTextContent('cbor');
446+
expect(queryByTestId('cbor-value')).toHaveTextContent('cbor');
447447
});
448448

449449
it('should display drep registration certificate', async () => {

packages/core/src/ui/components/ActivityDetail/TxDetailsGroup.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ export const TxDetailsGroup = ({
4343
>
4444
<div className={styles.expanderHeader}>
4545
<Flex alignItems="center" className={styles.title}>
46-
<Text.Body.Normal weight="$semibold">{title}</Text.Body.Normal>
46+
<Text.Body.Normal weight="$semibold" data-testid={`${testId}_label`}>
47+
{title}
48+
</Text.Body.Normal>
4749
{tooltipContent && (
4850
<Tooltip title={tooltipContent}>
4951
<InfoCircleOutlined className={styles.infoIcon} />

packages/core/src/ui/components/ActivityDetail/components/TxDetailsCBOR/TxDetailsCBOR.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ export const TxDetailsCBOR = ({ cbor }: TxDetailsCBORProps): React.ReactElement
2626
<Flex flexDirection="column" gap="$20">
2727
<Flex w="$fill" justifyContent="flex-end">
2828
<CopyToClipboard text={cbor}>
29-
<CopyIcon className={styles.copyButton} data-testid="copy-address-btn" onClick={doToast} />
29+
<CopyIcon className={styles.copyButton} data-testid="copy-cbor-btn" onClick={doToast} />
3030
</CopyToClipboard>
3131
</Flex>
32-
<Text.Body.Normal data-testid="cbor" className={styles.cbor} weight="$medium">
32+
<Text.Body.Normal data-testid="cbor-value" className={styles.cbor} weight="$medium">
3333
{cbor}
3434
</Text.Body.Normal>
3535
</Flex>

packages/e2e-tests/src/assert/dAppConnectorAssert.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,8 @@ class DAppConnectorAssert {
282282
await t('core.dappTransaction.toAddress')
283283
);
284284

285+
await this.assertSeeCBORSection('collapsed');
286+
285287
await ConfirmTransactionPage.confirmButton.waitForDisplayed();
286288
expect(await ConfirmTransactionPage.confirmButton.getText()).to.equal(await t('dapp.confirm.btn.confirm'));
287289

@@ -392,6 +394,15 @@ class DAppConnectorAssert {
392394
`);
393395
expect(String(result)).to.equal(magic);
394396
}
397+
398+
async assertSeeCBORSection(state: 'collapsed' | 'expanded') {
399+
await ConfirmTransactionPage.transactionCBORSectionExpanderButton.waitForClickable();
400+
expect(await ConfirmTransactionPage.transactionCBORSectionExpanderLabel.getText()).to.equal(
401+
await t('core.activityDetails.CBOR')
402+
);
403+
await ConfirmTransactionPage.copyCborButton.waitForDisplayed({ reverse: state === 'collapsed' });
404+
await ConfirmTransactionPage.cborValue.waitForDisplayed({ reverse: state === 'collapsed' });
405+
}
395406
}
396407

397408
export default new DAppConnectorAssert();

packages/e2e-tests/src/assert/topNavigationAssert.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,16 @@ class TopNavigationAssert {
6868
expect(await MenuHeader.menuAddNewWalletButton.getText()).to.equal(
6969
await t('browserView.sideMenu.links.addNewWallet')
7070
);
71+
await MenuHeader.menuAddBitcoinWalletButton.waitForDisplayed({ reverse: extensionUtils.isMainnet() });
72+
await MenuHeader.menuAddSharedWalletButton.waitForDisplayed({ reverse: extensionUtils.isMainnet() });
73+
if (!extensionUtils.isMainnet()) {
74+
expect(await MenuHeader.menuAddBitcoinWalletButton.getText()).to.equal(
75+
await t('browserView.sideMenu.links.addBitcoinWallet')
76+
);
77+
expect(await MenuHeader.menuAddSharedWalletButton.getText()).to.equal(
78+
await t('browserView.sideMenu.links.addSharedWallet')
79+
);
80+
}
7181
await MenuHeader.menuAddressBookButton.waitForDisplayed();
7282
expect(await MenuHeader.menuAddressBookButton.getText()).to.equal(
7383
await t('browserView.sideMenu.links.addressBook')

packages/e2e-tests/src/elements/dappConnector/confirmTransactionPage.ts

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ class ConfirmTransactionPage extends CommonDappPageElements {
2929
'[data-testid="dapp-transaction-from-section-expander"] [data-testid="expander-button"]';
3030
private TRANSACTION_FROM_SECTION_EXPANDER_LABEL =
3131
'[data-testid="dapp-transaction-from-section-expander"] [data-testid="expander-title"]';
32+
private TRANSACTION_CBOR_SECTION_EXPANDER_BUTTON = '[data-testid="cbor-detail_toggle"]';
33+
private TRANSACTION_CBOR_SECTION_EXPANDER_LABEL = '[data-testid="cbor-detail_label"]';
34+
private TRANSACTION_CBOR_SECTION_COPY_BUTTON = '[data-testid="copy-cbor-btn"]';
35+
private TRANSACTION_CBOR_SECTION_CBOR_VALUE = '[data-testid="cbor-value"]';
3236
private CONFIRM_BUTTON = '[data-testid="dapp-transaction-confirm"]';
3337
private CANCEL_BUTTON = '[data-testid="dapp-transaction-cancel"]';
3438
private ADDRESS_TAG_FROM_SECTION =
@@ -103,6 +107,22 @@ class ConfirmTransactionPage extends CommonDappPageElements {
103107
return $(this.TRANSACTION_ORIGIN_EXPANDER_BUTTON);
104108
}
105109

110+
get transactionCBORSectionExpanderLabel(): ChainablePromiseElement<WebdriverIO.Element> {
111+
return $(this.TRANSACTION_CBOR_SECTION_EXPANDER_LABEL);
112+
}
113+
114+
get transactionCBORSectionExpanderButton(): ChainablePromiseElement<WebdriverIO.Element> {
115+
return $(this.TRANSACTION_CBOR_SECTION_EXPANDER_BUTTON);
116+
}
117+
118+
get copyCborButton(): ChainablePromiseElement<WebdriverIO.Element> {
119+
return $(this.TRANSACTION_CBOR_SECTION_COPY_BUTTON);
120+
}
121+
122+
get cborValue(): ChainablePromiseElement<WebdriverIO.Element> {
123+
return $(this.TRANSACTION_CBOR_SECTION_CBOR_VALUE);
124+
}
125+
106126
get transactionSummaryAssetsRows(): ChainablePromiseArray<WebdriverIO.ElementArray> {
107127
return $$(this.TRANSACTION_SUMMARY_ROW);
108128
}
@@ -133,7 +153,9 @@ class ConfirmTransactionPage extends CommonDappPageElements {
133153
return textArray.map((str) => str.replace(/\n/g, ' '));
134154
}
135155

136-
async expandSectionInDappTransactionWindow(section: 'Origin' | 'From address' | 'To address') {
156+
async expandSectionInDappTransactionWindow(
157+
section: 'Origin' | 'From address' | 'To address' | 'Raw Transaction (CBOR)'
158+
) {
137159
await this.transactionOriginSectionExpanderButton.waitForDisplayed();
138160
switch (section) {
139161
case 'Origin':
@@ -148,11 +170,20 @@ class ConfirmTransactionPage extends CommonDappPageElements {
148170
await this.transactionToSectionExpanderButton.scrollIntoView();
149171
await this.transactionToSectionExpanderButton.click();
150172
break;
173+
case 'Raw Transaction (CBOR)':
174+
await this.transactionCBORSectionExpanderButton.scrollIntoView();
175+
await this.transactionCBORSectionExpanderButton.click();
176+
break;
151177
default:
152178
throw new Error(`Unsupported section name: ${section}`);
153179
}
154180
}
155181

182+
async clickOnCopyCborButton() {
183+
await this.copyCborButton.waitForClickable();
184+
await this.copyCborButton.click();
185+
}
186+
156187
async saveDAppTransactionFeeValue() {
157188
const [feeValue] = (await this.transactionFeeValueAda.getText()).split(' ');
158189
await testContext.save('feeValueDAppTx', feeValue);

packages/e2e-tests/src/elements/menuHeader.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ export class MenuHeader {
1515
private MENU_BUTTON = '//button[@data-testid="profile-dropdown-trigger-menu"]';
1616
private MENU_ADDRESS_BOOK_BUTTON = '//li[@data-testid="header-menu-address-book"]';
1717
private MENU_ADD_NEW_WALLET_BUTTON = '[data-testid="header-menu-new-wallet"]';
18+
private MENU_ADD_BITCOIN_WALLET_BUTTON = '[data-testid="header-menu-add-bitcoin-wallet"]';
19+
private MENU_ADD_SHARED_WALLET_BUTTON = '[data-testid="header-menu-add-shared-wallet"]';
1820
private MENU_SETTINGS_BUTTON = '//li[@data-testid="header-menu-settings"]';
1921
private MENU_SIGN_MESSAGE_BUTTON = '//li[@data-testid="header-menu-sign-message"]';
2022
private MENU_LOCK_BUTTON = '//li[@data-testid="header-menu-lock"]';
@@ -102,6 +104,14 @@ export class MenuHeader {
102104
return $(this.MENU_ADD_NEW_WALLET_BUTTON);
103105
}
104106

107+
get menuAddBitcoinWalletButton(): ChainablePromiseElement<WebdriverIO.Element> {
108+
return $(this.MENU_ADD_BITCOIN_WALLET_BUTTON);
109+
}
110+
111+
get menuAddSharedWalletButton(): ChainablePromiseElement<WebdriverIO.Element> {
112+
return $(this.MENU_ADD_SHARED_WALLET_BUTTON);
113+
}
114+
105115
get menuSettingsButton(): ChainablePromiseElement<WebdriverIO.Element> {
106116
return $(this.MENU_SETTINGS_BUTTON);
107117
}
@@ -179,6 +189,16 @@ export class MenuHeader {
179189
await this.menuAddNewWalletButton.click();
180190
}
181191

192+
async clickOnAddBitcoinWalletOption(): Promise<void> {
193+
await this.menuAddBitcoinWalletButton.waitForClickable();
194+
await this.menuAddBitcoinWalletButton.click();
195+
}
196+
197+
async clickOnAddSharedWalletOption(): Promise<void> {
198+
await this.menuAddSharedWalletButton.waitForClickable();
199+
await this.menuAddSharedWalletButton.click();
200+
}
201+
182202
async clickMenuButton(): Promise<void> {
183203
await this.menuButton.waitForClickable({ timeout: 15_000 });
184204
await this.menuButton.click();

packages/e2e-tests/src/features/e2e/SendTransactionDappE2E.feature

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Feature: Send Transactions from Dapp - E2E
3434
And I click on a transaction: 1
3535
Then The Tx details are displayed as "core.activityDetails.received" for ADA with value: 3.00 and wallet: "WalletSendDappTransactionE2E" address
3636

37-
@LW-6797 @Testnet @memory-snapshot
37+
@LW-6797 @LW-12403 @LW-12404 @Testnet @memory-snapshot
3838
Scenario: Send Token from DApp E2E
3939
And I de-authorize all DApps in extended mode
4040
And I save token: "LaceCoin2" balance
@@ -58,7 +58,13 @@ Feature: Send Transactions from Dapp - E2E
5858
| 1.38 tADA |
5959
| 2 LaceCoin2 |
6060
And I save fee value on DApp "Confirm transaction" page
61-
And I click "Confirm" button on "Confirm transaction" page
61+
When I expand "Raw Transaction (CBOR)" section in DApp transaction window
62+
Then "Raw Transaction (CBOR)" section is displayed
63+
And I save CBOR in test context
64+
When I click on "Copy" button inside "Raw Transaction (CBOR)" section
65+
Then I see a toast with text: "Copied to clipboard"
66+
And clipboard contains CBOR
67+
When I click "Confirm" button on "Confirm transaction" page
6268
And I see DApp connector "Sign transaction" page
6369
And I fill correct password
6470
And I click "Confirm" button on "Sign transaction" page

packages/e2e-tests/src/steps/dAppConnectorSteps.ts

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import RemoveDAppModal from '../elements/dappConnector/removeDAppModal';
2424
import ConfirmDataPage from '../elements/dappConnector/ConfirmDataPage';
2525
import ConfirmDataPageAssert from '../assert/ConfirmDataPageAssert';
2626
import extensionUtils from '../utils/utils';
27+
import testContext from '../utils/testContext';
2728

2829
const testDAppDetails: ExpectedDAppDetails = {
2930
hasLogo: true,
@@ -97,6 +98,10 @@ Then(
9798
}
9899
);
99100

101+
Then(/^"Raw Transaction \(CBOR\)" section is displayed$/, async () => {
102+
await DAppConnectorAssert.assertSeeCBORSection('expanded');
103+
});
104+
100105
Then(
101106
/^I see DApp connector "(Confirm transaction|Something went wrong|All done)" page on (\d) window handle$/,
102107
async (expectedPage: 'Confirm transaction' | 'Something went wrong' | 'All done', handleNumber: number) => {
@@ -156,22 +161,35 @@ Then(/^I see DApp removal confirmation window$/, async () => {
156161
await DAppConnectorAssert.assertSeeDAppRemovalConfirmationModal();
157162
});
158163

159-
Then(/^I click "(Authorize|Cancel)" button in DApp authorization window$/, async (button: 'Authorize' | 'Cancel') => {
164+
When(/^I click "(Authorize|Cancel)" button in DApp authorization window$/, async (button: 'Authorize' | 'Cancel') => {
160165
await AuthorizeDAppPage.clickButton(button);
161166
});
162167

163-
Then(
164-
/^I expand "(Origin|From address|To address)" section in DApp transaction window$/,
165-
async (section: 'Origin' | 'From address' | 'To address') => {
168+
When(
169+
/^I expand "(Origin|From address|To address|Raw Transaction \(CBOR\))" section in DApp transaction window$/,
170+
async (section: 'Origin' | 'From address' | 'To address' | 'Raw Transaction (CBOR)') => {
166171
await ConfirmTransactionPage.expandSectionInDappTransactionWindow(section);
167172
}
168173
);
169174

170-
Then(/^I click "(Always|Only once)" button in DApp authorization window$/, async (button: 'Always' | 'Only once') => {
175+
When(/^I click on "Copy" button inside "Raw Transaction \(CBOR\)" section/, async () => {
176+
await ConfirmTransactionPage.clickOnCopyCborButton();
177+
});
178+
179+
Then(/^I save CBOR in test context$/, async () => {
180+
testContext.save('cbor', await ConfirmTransactionPage.cborValue.getText());
181+
});
182+
183+
Then(/^clipboard contains CBOR$/, async () => {
184+
const expectedCbor = String(testContext.load('cbor'));
185+
await CommonAssert.assertClipboardContains(expectedCbor);
186+
});
187+
188+
When(/^I click "(Always|Only once)" button in DApp authorization window$/, async (button: 'Always' | 'Only once') => {
171189
await AuthorizeDAppModal.clickButton(button);
172190
});
173191

174-
Then(
192+
When(
175193
/^I click "(Add funds|Cancel)" button in DApp insufficient funds window/,
176194
async (button: 'Add funds' | 'Cancel') => {
177195
await DAppConnectorUtils.waitAndSwitchToDAppConnectorWindow(3);

0 commit comments

Comments
 (0)