Skip to content

Commit

Permalink
feat(e2e): Convert to PW transaction test (#16316)
Browse files Browse the repository at this point in the history
* feat(e2e): Convert to PW transaction test

remove forgoten already converted cypress tests lookup-account

* chore(e2e): Update rebased tests with a mandatory model cfg
  • Loading branch information
Vere-Grey authored Jan 13, 2025
1 parent 26a8b91 commit cb71804
Show file tree
Hide file tree
Showing 15 changed files with 105 additions and 141 deletions.
5 changes: 4 additions & 1 deletion packages/suite-desktop-core/e2e/support/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import { test as base, Page } from '@playwright/test';

import {
Model,
SetupEmu,
StartEmu,
TrezorUserEnvLink,
Expand Down Expand Up @@ -31,10 +32,12 @@ import { AssetsActions } from './pageActions/assetsActions';
import { MetadataProviderMocks } from './metadataProviderMocks';
import { MetadataActions } from './pageActions/metadataActions';

type StartEmuModelRequired = StartEmu & { model: Model };

type Fixtures = {
startEmulator: boolean;
setupEmulator: boolean;
emulatorStartConf: StartEmu;
emulatorStartConf: StartEmuModelRequired;
emulatorSetupConf: SetupEmu;
apiURL: string;
trezorUserEnvLink: TrezorUserEnvLinkClass;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@ import { Locator, Page, expect } from '@playwright/test';

import { step } from '../common';

export type graphRangeOptions = 'day' | 'week' | 'month' | 'year' | 'all';

export class DashboardActions {
readonly dashboardMenuButton: Locator;
readonly discoveryHeader: Locator;
readonly discoveryBar: Locator;
readonly graph: Locator;
readonly graphRangeSelector = (range: graphRangeOptions) =>
this.page.getByTestId(`@dashboard/graph/range-${range}`);
readonly deviceSwitchingOpenButton: Locator;
readonly modal: Locator;
//TODO: Refactor to wallet page object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@ import { NetworkSymbol } from '@suite-common/wallet-config';

import { step } from '../common';

type WalletParams = { symbol?: NetworkSymbol; atIndex?: number };
type WalletParams = {
symbol?: NetworkSymbol;
type?: 'normal' | 'legacy' | 'ledger';
atIndex?: number;
};

export class WalletActions {
readonly transactionSearch: Locator;
readonly accountSearch: Locator;
readonly accountChevron: Locator;
readonly cardanoAccountLabels: { [key: string]: Locator };
readonly walletStakingButton: Locator;
readonly stakeAddress: Locator;
readonly walletExtraDropDown: Locator;
Expand All @@ -30,16 +33,14 @@ export class WalletActions {
readonly copyAddressButton: Locator;
readonly stakingButton: Locator;
readonly stakingCardano: Locator;
readonly transactionSummaryTitle: Locator;
readonly transactionItem: Locator;
readonly transactionAddress: Locator;

constructor(private readonly page: Page) {
this.transactionSearch = this.page.getByTestId('@wallet/accounts/search-icon');
this.accountSearch = this.page.getByTestId('@account-menu/search-input');
this.accountChevron = this.page.getByTestId('@account-menu/arrow');
this.cardanoAccountLabels = {
normal: this.page.getByTestId('@account-menu/ada/normal/0/label'),
legacy: this.page.getByTestId('@account-menu/ada/legacy/0/label'),
ledger: this.page.getByTestId('@account-menu/ada/ledger/0/label'),
};
this.walletStakingButton = this.page.getByTestId('@wallet/menu/staking');
this.stakeAddress = this.page.getByTestId('@cardano/staking/address');
this.walletExtraDropDown = this.page.getByTestId('@wallet/menu/extra-dropdown');
Expand All @@ -59,13 +60,22 @@ export class WalletActions {
this.copyAddressButton = this.page.getByTestId('@metadata/copy-address-button');
this.stakingButton = this.page.getByTestId('@wallet/menu/staking');
this.stakingCardano = this.page.getByTestId('@wallet/cardano/staking');
this.transactionSummaryTitle = this.page.getByTestId(
'@wallet/transactions/summary-card/title',
);
this.transactionItem = this.page.getByTestId('@wallet/transaction-item');
this.transactionAddress = this.page.getByTestId('@wallet/transaction/target-address');
}

accountButton = ({ symbol = 'btc', atIndex = 0 }: WalletParams = {}): Locator =>
this.page.getByTestId(`@account-menu/${symbol}/normal/${atIndex}`);
accountButton = ({
symbol = 'btc',
type = 'normal',
atIndex = 0,
}: WalletParams = {}): Locator =>
this.page.getByTestId(`@account-menu/${symbol}/${type}/${atIndex}`);

accountLabel = ({ symbol = 'btc', atIndex = 0 }: WalletParams = {}): Locator =>
this.page.getByTestId(`@account-menu/${symbol}/normal/${atIndex}/label`);
accountLabel = ({ symbol = 'btc', type = 'normal', atIndex = 0 }: WalletParams = {}): Locator =>
this.page.getByTestId(`@account-menu/${symbol}/${type}/${atIndex}/label`);

@step()
async filterTransactions(transaction: string) {
Expand All @@ -82,8 +92,13 @@ export class WalletActions {

@step()
async checkStakesOfCardanoAccounts() {
for (const type in this.cardanoAccountLabels) {
await this.cardanoAccountLabels[type].click();
const cardanoAccounts = [
this.accountButton({ symbol: 'ada' }),
this.accountButton({ symbol: 'ada', type: 'legacy' }),
this.accountButton({ symbol: 'ada', type: 'ledger' }),
];
for (const account of cardanoAccounts) {
await account.click();
await this.walletStakingButton.click();
await expect(this.stakeAddress).toBeVisible();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@ import { AccountLabelId } from '../../support/enums/accountLabelId';
// Metadata is by default disabled, this means, that application does not try to generate master key and connect to cloud.
// Hovering over fields that may be labeled shows "add label" button upon which is clicked, Suite initiates metadata flow
test.describe('Account metadata', { tag: ['@group=metadata', '@webOnly'] }, () => {
test.use({
emulatorSetupConf: { mnemonic: 'mnemonic_all' },
});

test.use({ emulatorSetupConf: { mnemonic: 'mnemonic_all' } });
test.beforeEach(async ({ metadataProviderMocks }) => {
await metadataProviderMocks.initializeProviderMocking(MetadataProvider.DROPBOX);
});

test('dropbox provider', async ({
page,
onboardingPage,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@ import { MetadataProvider } from '../../support/metadataProviderMocks';
const metadataEl = '@metadata/addressLabel/bc1q7e6qu5smalrpgqrx9k2gnf0hgjyref5p36ru2m';

test.describe('Metadata - address labeling', { tag: ['@group=metadata', '@webOnly'] }, () => {
test.use({
emulatorStartConf: { wipe: true },
emulatorSetupConf: { mnemonic: 'mnemonic_all' },
});

test.use({ emulatorSetupConf: { mnemonic: 'mnemonic_all' } });
test.beforeEach(async ({ metadataProviderMocks }) => {
await metadataProviderMocks.initializeProviderMocking(MetadataProvider.GOOGLE);
});

test('google provider', async ({ page, onboardingPage, metadataPage, dashboardPage }) => {
// Pass through onboarding and device authentication
await onboardingPage.completeOnboarding();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { test, expect } from '../../support/fixtures';

test.describe('Look up a BTC account', { tag: ['@group=wallet'] }, () => {
test.use({
emulatorStartConf: { wipe: true },
emulatorSetupConf: {
mnemonic: 'cancel solid bulb sample fury scrap whale ranch raven razor sight skin',
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import { test, expect } from '../../support/fixtures';

test.describe('Custom-blockbook-discovery', { tag: ['@group=wallet'] }, () => {
test.use({
emulatorStartConf: { wipe: true },
emulatorSetupConf: { mnemonic: 'mnemonic_all' },
});

test.use({ emulatorSetupConf: { mnemonic: 'mnemonic_all' } });
test.beforeEach(async ({ onboardingPage, dashboardPage }) => {
await onboardingPage.completeOnboarding();
await dashboardPage.discoveryShouldFinish();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@ import { test, expect } from '../../support/fixtures';

test.describe('Coin balance', { tag: ['@group=wallet'] }, () => {
const address = 'bcrt1qkvwu9g3k2pdxewfqr7syz89r3gj557l374sg5v';

test.use({
emulatorStartConf: { wipe: true },
emulatorSetupConf: { mnemonic: 'mnemonic_all' },
});

test.use({ emulatorSetupConf: { mnemonic: 'mnemonic_all' } });
test.beforeEach(async ({ dashboardPage, onboardingPage }) => {
await onboardingPage.completeOnboarding();
await dashboardPage.discoveryShouldFinish();
Expand Down
49 changes: 49 additions & 0 deletions packages/suite-desktop-core/e2e/tests/wallet/transactions.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { test, expect } from '../../support/fixtures';
import { graphRangeOptions } from '../../support/pageActions/dashboardActions';

const rangeData: { range: graphRangeOptions; label: string }[] = [
{ range: 'day', label: '1 day' },
{ range: 'week', label: '1 week' },
{ range: 'month', label: '1 month' },
{ range: 'year', label: '1 year' },
{ range: 'all', label: 'All' },
];

test.describe('Account transactions overview', { tag: ['@group=wallet'] }, () => {
test.use({ emulatorSetupConf: { mnemonic: 'mnemonic_all' } });
test.beforeEach(async ({ onboardingPage, dashboardPage }) => {
await onboardingPage.completeOnboarding();
await dashboardPage.discoveryShouldFinish();
});

test('Check graph span and search a transaction by BTC address', async ({
walletPage,
dashboardPage,
}) => {
await test.step('Cycle thru all time range filters', async () => {
await walletPage.accountButton({ symbol: 'btc' }).click();
for (const { range, label } of rangeData) {
await dashboardPage.graphRangeSelector(range).click();
const labelElement = walletPage.transactionSummaryTitle.getByText(label);
await expect(labelElement).toBeVisible();
}
});

const latestTransactionAddress = await test.step('Find the latest transaction', async () =>
await walletPage.transactionAddress.first().textContent());

if (!latestTransactionAddress) {
throw new Error('No latest transaction found');
}

await test.step('Search for latest transaction by its address', async () => {
await walletPage.transactionSearch.fill(latestTransactionAddress);
await expect(walletPage.transactionItem).toHaveCount(1);
await expect(walletPage.transactionItem).toContainText(latestTransactionAddress);
});

// go to a certain accounts page and verify you are on that page
// await page.getByTestId('@account-menu/legacy').click();
// await walletPage.accountButton({ symbol: 'btc', type: 'legacy' }).click();
});
});
48 changes: 0 additions & 48 deletions packages/suite-web/e2e/tests/wallet/look-up-an-account.test.ts

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ export const GraphRangeSelector = ({
onSelectedRange(range);
}
}}
data-testid={`@dashboard/graph/range-${range.label}`}
>
{getFormattedLabel(range.label)}
</RangeItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ export const TransactionItem = memo(
ref={anchorRef}
$isPhishingTransaction={isPhishingTransaction}
className={className}
data-testid="@wallet/transaction-item"
>
<Card variant={isPending ? 'warning' : undefined}>
<OutlineHighlight shouldHighlight={shouldHighlight}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const TargetAddressLabel = ({
}

return (
<TruncatedSpan>
<TruncatedSpan data-testid="@wallet/transaction/target-address">
{target.addresses?.map((a, i) =>
// either it may be AddressLabeling - sent to another account associated with this device, e.g: "Bitcoin #2"
// or it may show address metadata label added from receive tab e.g "My address for illegal things"
Expand Down
Loading

0 comments on commit cb71804

Please sign in to comment.