Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(e2e-connector-tests): unify connector tests FE-860 #422

Merged
merged 75 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from 65 commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
3a6a7b5
chore: add test:react-app command for running e2e tests in the React app
nelitow Oct 14, 2024
cc20d11
chore: add e2e tests for connectors app
nelitow Oct 14, 2024
84f75a7
chore: remove e2e-tests package.json
nelitow Oct 14, 2024
153e94a
chore: update playwright.config.ts to load environment variables from…
nelitow Oct 14, 2024
ca7ee16
chore: Update lock file
nelitow Oct 14, 2024
59e78d1
feat: replicate the react app in next
nelitow Oct 15, 2024
b81e0ed
build: default env to null
nelitow Oct 16, 2024
b71b527
add react-next-e2e
nelitow Oct 17, 2024
ffb3e11
test: next e2e
nelitow Oct 17, 2024
de9e881
reset: next
nelitow Oct 17, 2024
68f8251
chore: update lockfile
nelitow Oct 17, 2024
2cf8290
Merge branch 'main' into nj/feat/e2e-ci
LuizAsFight Oct 19, 2024
3df96bc
chore: Update VITE_MASTER_WALLET_MNEMONIC in pr-tests.yml
nelitow Oct 19, 2024
371b58c
Merge branch 'main' into nj/feat/e2e-ci
nelitow Oct 21, 2024
d5fcafd
chore: Update devDependencies in package.json
nelitow Oct 21, 2024
f24605a
chore: Add e2e-tests package.json
nelitow Oct 22, 2024
3eeac51
chore: Remove unused dependencies in package.json
nelitow Oct 22, 2024
61ece6c
chore: Update e2e-tests package.json
nelitow Oct 22, 2024
68a395a
chore: Remove redundant dotenv configuration
nelitow Oct 22, 2024
fa9b34b
refactor: Update e2e-tests setup.ts
nelitow Oct 22, 2024
0952020
refactor: Update BurnerWalletConnector test description
nelitow Oct 22, 2024
c477db5
refactor: Update FuelWalletConnector test description and setup
nelitow Oct 22, 2024
6d85564
refactor: Update test descriptions and setup for FuelWalletConnector …
nelitow Oct 22, 2024
b5b901e
refactor: Comment out Playwright Browsers installation step in PR tes…
nelitow Oct 22, 2024
1cc488d
refactor: Add skipBridgeFunds function to BurnerWalletConnector test
nelitow Oct 22, 2024
fa0c6b6
refactor: Update PR tests workflow and Docker setup
nelitow Oct 22, 2024
8b5c9b4
refactor: Add docker environment file for fuels-wallet project
nelitow Oct 22, 2024
383b4dd
Update pr-tests.yml
nelitow Oct 22, 2024
a2a564f
refactor: Update PR tests workflow to use npx playwright for E2E tests
nelitow Oct 22, 2024
68c70dc
refactor: Update fuel provider URL in config.ts and .env.example
nelitow Oct 23, 2024
0766e60
Update pr-tests.yml
nelitow Oct 23, 2024
70508a4
tests: make tests usable in current local node
nelitow Oct 23, 2024
f0a8783
refactor: Remove unused import in playwright.config.ts
nelitow Oct 23, 2024
5883cfe
refactor: Remove console.log statement in FuelWalletConnector.test.ts
nelitow Oct 23, 2024
916b3a3
refactor: Update fuel provider URL and add wallet secret and mnemonic…
nelitow Oct 23, 2024
c803774
refactor: Update pr-tests.yml to make tests also run in testnet
nelitow Oct 23, 2024
34ca48f
Revert "refactor: Update pr-tests.yml to make tests also run in testnet"
nelitow Oct 23, 2024
189c9be
refactor: Update pr-tests.yml to include main branch in push event
nelitow Oct 23, 2024
d697ca4
Merge branch 'main' into nj/feat/next-sample-app-full-
nelitow Oct 24, 2024
d717214
chore: update lock
nelitow Oct 24, 2024
8b5f48a
Merge branch 'nj/feat/e2e-ci' into nj/feat/next-sample-app-full-
nelitow Oct 24, 2024
77dda8b
chore: update lock
nelitow Oct 25, 2024
5b8f7cb
refactor: Update environment variables for local development
nelitow Oct 28, 2024
de8ce39
refactor: Update package.json scripts for e2e testing
nelitow Oct 28, 2024
9317c72
refactor: Update environment variables for local development
nelitow Oct 28, 2024
2fd9ccc
test: move folders and unify test config
nelitow Oct 28, 2024
9624f70
refactor: Update environment variables for local development and e2e …
nelitow Oct 28, 2024
636ef3f
refactor: Update environment variables for local development and e2e …
nelitow Oct 28, 2024
e7e7bfa
fix: next e2e tailwind and assets
nelitow Oct 28, 2024
8b4b6cc
Merge branch 'main' into nj/feat/next-sample-app-full-
nelitow Oct 29, 2024
f62f0ff
fix; e2e-next Toast
nelitow Oct 29, 2024
6e89095
chore: update counter component for es5 build
nelitow Oct 29, 2024
3c21ad4
fix: next build issues
nelitow Oct 29, 2024
8a99da7
fix: next import warnings
nelitow Oct 29, 2024
7c3a9be
debug info
nelitow Oct 29, 2024
bc0d578
fix: test pr release env
nelitow Oct 29, 2024
f49ce8a
fix: changeset to ignore e2e next
nelitow Oct 29, 2024
ef1f48e
fix; update command package name
nelitow Oct 29, 2024
df47f22
Update pr-release.yaml
nelitow Oct 29, 2024
0142e41
feat: Add common utility functions for e2e tests
nelitow Oct 30, 2024
8096853
Merge branch 'main' into nj/feat/unify-connector-tests
nelitow Nov 8, 2024
e99df6a
chore: clean merge
nelitow Nov 8, 2024
22addcb
undo biome change
nelitow Nov 8, 2024
a90c420
chore: remove unused file
nelitow Nov 8, 2024
b00abf6
chore: remove duplicate lines
nelitow Nov 8, 2024
d70970d
chore: update fuel
nelitow Nov 8, 2024
c2b487c
ci: try to fail
nelitow Nov 8, 2024
703a046
ci: filter back
nelitow Nov 9, 2024
7df17ed
ci: update .gitignore to exclude Playwright report directories
nelitow Nov 9, 2024
1d89ee4
ci: update Dockerfile to use fuel-core version v0.41.1
nelitow Nov 9, 2024
b966917
ci: add skipBridgeFunds calls to session tests for improved connectio…
nelitow Nov 9, 2024
917e2ba
ci: refactor walletSetup parameters for improved clarity and structure
nelitow Nov 9, 2024
a2a78b1
Revert "ci: update Dockerfile to use fuel-core version v0.41.1"
nelitow Nov 9, 2024
c3acbbc
ci: disable headless mode in Playwright configuration for better debu…
nelitow Nov 9, 2024
70173bf
ci: update .env.example with local configuration settings for develop…
nelitow Nov 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions e2e-tests/runner/common/common.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import { test } from '@fuels/playwright-utils';
import { type Page, expect } from '@playwright/test';
import type { ApproveTransferFunction, ConnectorFunctions } from './types';

// biome-ignore lint/suspicious/noExportsInTest: <explanation>
export const skipBridgeFunds = async (page: Page) => {
if (await page.isVisible('text=Bridge Funds')) {
await page.click('text=Continue to application');
}
};

// biome-ignore lint/suspicious/noExportsInTest: <explanation>
export const sessionTests = async (
page: Page,
{ connect }: ConnectorFunctions,
) => {
await connect(page);

await test.step('should connect, disconnect, and reconnect', async () => {
await page.click('text=Disconnect');
await page.waitForSelector('text=/Connect Wallet/');

await connect(page);
expect(await page.waitForSelector('text=/Your Fuel Address/')).toBeTruthy();
});

await test.step('should connect, refresh and stay connected', async () => {
await page.reload();
await skipBridgeFunds(page);
await page.waitForSelector('text=/Your Fuel Address/');
});

await test.step('should connect, disconnect, refresh and stay disconnected', async () => {
await skipBridgeFunds(page);
await page.click('text=Disconnect');
await page.waitForSelector('text=/Connect Wallet/');

await page.reload();
await page.waitForSelector('text=/Connect Wallet/');
});
};

// biome-ignore lint/suspicious/noExportsInTest: <explanation>
export const transferTests = async (
page: Page,
{ connect, approveTransfer }: ConnectorFunctions,
) => {
await connect(page);

await page.click('text=Transfer 0.0001 ETH');
await approveTransfer(page);

expect(
await page.waitForSelector('text=Transferred successfully!'),
).toBeTruthy();
};

// biome-ignore lint/suspicious/noExportsInTest: <explanation>
export const incrementTests = async (
page: Page,
{ approveTransfer }: ConnectorFunctions,
) => {
await test.step('should connect and increment', async () => {
await page.click('text=Increment');
await approveTransfer(page);

expect(await page.waitForSelector('text=Success')).toBeTruthy();
expect(
await page.waitForSelector('text=Counter Incremented!'),
).toBeTruthy();
});
};
14 changes: 14 additions & 0 deletions e2e-tests/runner/common/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// types.ts
import type { Page } from '@playwright/test';

export type ConnectFunction = (page: Page) => Promise<void>;
export type ApproveTransferFunction = (page: Page) => Promise<void>;

/**
* Connector interface, where each wallet connector implements
* its own connect and approveTransfer functions.
*/
export interface ConnectorFunctions {
connect: ConnectFunction;
approveTransfer: ApproveTransferFunction;
}
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
import { getButtonByText, getByAriaLabel, test } from '@fuels/playwright-utils';
import { type Page, expect } from '@playwright/test';
import { sessionTests, skipBridgeFunds } from '../../../common/common';
import type { ConnectFunction } from '../../../common/types';

const connectBurner = async (page: Page, walletName = 'Burner Wallet') => {
const connect: ConnectFunction = async (page: Page) => {
await page.bringToFront();
const connectButton = getButtonByText(page, 'Connect');
await connectButton.click();
await getByAriaLabel(page, `Connect to ${walletName}`, true).click();
await getByAriaLabel(page, 'Connect to Burner Wallet', true).click();

await skipBridgeFunds(page);
};

const skipBridgeFunds = async (page: Page) => {
if (await page.isVisible('text=Bridge Funds')) {
await page.click('text=Continue to application');
}
expect(await page.waitForSelector('text=/Your Fuel Address/')).toBeTruthy();
};

test.describe('BurnerWalletConnector', async () => {
Expand All @@ -23,33 +21,6 @@ test.describe('BurnerWalletConnector', async () => {
});

test('BurnerWallet Tests', async ({ page }) => {
await connectBurner(page);

expect(await page.waitForSelector('text=/Your Fuel Address/')).toBeTruthy();

await test.step('should connect, disconnect, and reconnect', async () => {
await page.click('text=Disconnect');
await page.waitForSelector('text=/Connect Wallet/');

await connectBurner(page);
expect(
await page.waitForSelector('text=/Your Fuel Address/'),
).toBeTruthy();
});

await test.step('should connect, refresh and stay connected', async () => {
await page.reload();
await skipBridgeFunds(page);
await page.waitForSelector('text=/Your Fuel Address/');
});

await test.step('should connect, disconnect, refresh and stay disconnected', async () => {
await skipBridgeFunds(page);
await page.click('text=Disconnect');
await page.waitForSelector('text=/Connect Wallet/');

await page.reload();
await page.waitForSelector('text=/Connect Wallet/');
});
await sessionTests(page, { connect, approveTransfer: async () => {} });
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,13 @@ import {
} from '@fuels/playwright-utils';
import type { FuelWalletTestHelper } from '@fuels/playwright-utils';
import { test } from '@fuels/playwright-utils';
import { type Page, expect } from '@playwright/test';
import dotenv from 'dotenv';
import { type WalletUnlocked, bn } from 'fuels';
import { sessionTests, transferTests } from '../../../common/common';
import type { ConnectorFunctions } from '../../../common/types';
import { testSetup, transferMaxBalance } from '../setup';
dotenv.config();

const connect = async (
page: Page,
fuelWalletTestHelper: FuelWalletTestHelper,
) => {
const connectButton = getButtonByText(page, 'Connect');
await connectButton.click();
await getByAriaLabel(page, 'Connect to Fuel Wallet', true).click();
await fuelWalletTestHelper.walletConnect();
};

const fuelPathToExtension = await downloadFuel('0.40.1');
nelitow marked this conversation as resolved.
Show resolved Hide resolved

test.use({
Expand All @@ -34,6 +25,17 @@ test.describe('FuelWalletConnector', () => {

const depositAmount = '0.0003'; // Should be enough to cover the increment and transfer

const connect: ConnectorFunctions['connect'] = async (page) => {
const connectButton = getButtonByText(page, 'Connect Wallet', true);
await connectButton.click();
await getByAriaLabel(page, 'Connect to Fuel Wallet', true).click();
await fuelWalletTestHelper.walletConnect();
};

const approveTransfer: ConnectorFunctions['approveTransfer'] = async () => {
await fuelWalletTestHelper.walletApprove();
};

test.beforeEach(async ({ context, extensionId, page }) => {
({ fuelWalletTestHelper, fuelWallet, masterWallet } = await testSetup({
context,
Expand All @@ -43,7 +45,6 @@ test.describe('FuelWalletConnector', () => {
}));

await page.goto('/');
await connect(page, fuelWalletTestHelper);
});

test.afterEach(async () => {
Expand All @@ -63,48 +64,8 @@ test.describe('FuelWalletConnector', () => {
await switchButton.click();
}

expect(await page.waitForSelector('text=Your Fuel Address')).toBeTruthy();

// await test.step('should connect and increment', async () => {
// await page.click('text=Increment');
// await fuelWalletTestHelper.walletApprove();

// expect(await page.waitForSelector('text=Success')).toBeTruthy();
// expect(
// await page.waitForSelector('text=Counter Incremented!'),
// ).toBeTruthy();
// });

await test.step('should connect and transfer', async () => {
await page.click('text=Transfer 0.0001 ETH');
await fuelWalletTestHelper.walletApprove();

expect(await page.waitForSelector('text=Success')).toBeTruthy();
expect(
await page.waitForSelector('text=Transferred successfully!'),
).toBeTruthy();
});

await test.step('should connect, disconnect, and reconnect', async () => {
await page.click('text=Disconnect');
await page.waitForSelector('text=Connect Wallet');

await connect(page, fuelWalletTestHelper);

expect(await page.waitForSelector('text=Your Fuel Address')).toBeTruthy();
});

await test.step('should connect, refresh and stay connected', async () => {
await page.reload();
await page.waitForSelector('text=Your Fuel Address');
});

await test.step('should connect, disconnect, refresh and stay disconnected', async () => {
await page.click('text=Disconnect');
await page.waitForSelector('text=Connect Wallet');
await sessionTests(page, { connect, approveTransfer });

await page.reload();
await page.waitForSelector('text=Connect Wallet');
});
await transferTests(page, { connect, approveTransfer });
});
});
Loading