Skip to content

Commit 2a01064

Browse files
committed
Add Redeem view test class
Signed-off-by: Emre Bogazliyanlioglu <emre@wormholelabs.xyz>
1 parent 4a889f3 commit 2a01064

File tree

4 files changed

+47
-31
lines changed

4 files changed

+47
-31
lines changed

wormhole-connect/src/views/v2/Redeem/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ const Redeem = () => {
392392
const statusHeader = useMemo(() => {
393393
let statusText = 'Transaction submitted';
394394
if (isTxCompleted) {
395-
statusText = 'Transaction complete';
395+
statusText = 'Transaction completed';
396396
} else if (isTxRefunded) {
397397
statusText = 'Transaction was refunded';
398398
} else if (isTxFailed) {

wormhole-connect/tests/e2e/specs/mayan-swift.spec.ts

+12-22
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { test, expect, Page } from '@playwright/test';
22
import dotenv from 'dotenv';
33
import path from 'path';
44
import { BridgeView } from '../views/bridge';
5+
import { RedeemView } from '../views/redeem';
56

67
// Read from .env* files
78
// This is only for local testing overrides
@@ -31,28 +32,27 @@ const ARB_USDC_CONTRACT = '0xaf88d065e77c8cC2239327C5EDb3A432268e5831';
3132
const BASE_USDC_CONTRACT = '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913';
3233

3334
let page: Page;
35+
let bridgeView: BridgeView;
36+
let redeemView: RedeemView;
3437

3538
// Annotate entire file as serial.
3639
test.describe.configure({ mode: 'serial' });
3740

3841
test.beforeAll(async ({ browser }) => {
3942
page = await browser.newPage();
43+
bridgeView = new BridgeView(page);
44+
redeemView = new RedeemView(page);
4045
});
4146

4247
test.afterAll(async () => {
4348
await page.close();
4449
});
4550

4651
test('should configure transaction', async () => {
47-
// Navigate to the root page
52+
// Navigate to brige view
4853
await page.goto(`http://localhost:5173/?config=${DEFAULT_CONFIG}`);
4954

50-
// Wait for the main container to be visible
51-
await page.waitForSelector('#sample-app', {
52-
state: 'visible',
53-
});
54-
55-
const bridgeView = new BridgeView(page);
55+
// Verify key elements are present in bridge view
5656
await bridgeView.verifyElements();
5757

5858
// Set source wallet
@@ -78,28 +78,18 @@ test('should configure transaction', async () => {
7878

7979
// Mayan Swift route should be visible and selected by default
8080
await expect(page.getByTestId('route-MayanSwapSWIFT-selected')).toBeVisible();
81-
82-
// Verify Confirm transaction button and start transaction
83-
const confirmButton = page.getByTestId('confirm-transaction-button');
84-
await expect(confirmButton).toHaveText('Confirm transaction');
85-
await expect(confirmButton).toBeEnabled();
8681
});
8782

8883
test('should initiate transaction', async () => {
8984
// Start transaction
90-
const confirmButton = page.getByTestId('confirm-transaction-button');
91-
await confirmButton.click();
92-
// Wait for Confirm transaction button to be in Preparing state
93-
await expect(confirmButton).toHaveText('Preparing transaction');
85+
await bridgeView.startTransaction();
9486

9587
// Wait for Redeem view
96-
await expect(page.getByTestId('redeem-view')).toBeVisible({ timeout: 30000 });
88+
await redeemView.verifyElements();
9789

9890
// Verify transaction status as submitted
99-
const statusHeader = page.getByTestId('redeem-view-status-header');
100-
await expect(statusHeader).toHaveText('Transaction submitted');
91+
await redeemView.confirmTransactionState('Transaction submitted');
92+
10193
// Wait for transaction completion
102-
await expect(statusHeader).toHaveText('Transaction complete', {
103-
timeout: 30000,
104-
});
94+
await redeemView.confirmTransactionState('Transaction completed');
10595
});

wormhole-connect/tests/e2e/views/bridge.ts

+13-8
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,16 @@ export class BridgeView {
44
private readonly srcAssetPicker: Locator;
55
private readonly destAssetPicker: Locator;
66
private readonly amountInput: Locator;
7+
private readonly confirmButton: Locator;
78

89
constructor(public readonly page: Page) {
9-
this.srcAssetPicker = this.page.getByTestId('source-asset-picker');
10-
this.destAssetPicker = this.page.getByTestId('dest-asset-picker');
11-
this.amountInput = this.page.getByTestId('amount-input');
10+
this.srcAssetPicker = page.getByTestId('source-asset-picker');
11+
this.destAssetPicker = page.getByTestId('dest-asset-picker');
12+
this.amountInput = page.getByTestId('amount-input');
13+
this.confirmButton = page.getByTestId('confirm-transaction-button');
1214
}
1315

14-
async goto(config: string) {
15-
await this.page.goto(`http://localhost:5173/?config=${config}`);
16-
}
17-
18-
// Verify key elements are present in bridge view
16+
// Verify key elements are present in Bridge view
1917
async verifyElements() {
2018
await expect(this.srcAssetPicker).toBeVisible();
2119
await expect(this.destAssetPicker).toBeVisible();
@@ -73,4 +71,11 @@ export class BridgeView {
7371
async enterAmount(amount: string) {
7472
await this.amountInput.getByPlaceholder('0').fill(amount);
7573
}
74+
75+
async startTransaction() {
76+
await expect(this.confirmButton).toHaveText('Confirm transaction');
77+
await expect(this.confirmButton).toBeEnabled();
78+
await this.confirmButton.click();
79+
await expect(this.confirmButton).toHaveText('Preparing transaction');
80+
}
7681
}
+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { expect, Locator, Page } from '@playwright/test';
2+
3+
export class RedeemView {
4+
private readonly mainContainer: Locator;
5+
private readonly statusHeader: Locator;
6+
7+
constructor(public readonly page: Page) {
8+
this.mainContainer = page.getByTestId('redeem-view');
9+
this.statusHeader = page.getByTestId('redeem-view-status-header');
10+
}
11+
12+
// Verify key elements are present in Redeem view
13+
async verifyElements(timeout = 30000) {
14+
await expect(this.mainContainer).toBeVisible({ timeout });
15+
await expect(this.statusHeader).toBeVisible({ timeout });
16+
}
17+
18+
async confirmTransactionState(status: string, timeout = 30000) {
19+
await expect(this.statusHeader).toHaveText(status, { timeout });
20+
}
21+
}

0 commit comments

Comments
 (0)