Skip to content

Commit

Permalink
feat: Add tests for BurnerWalletConnector FE-411 (#400)
Browse files Browse the repository at this point in the history
Co-authored-by: Luiz Gomes <[email protected]>
  • Loading branch information
nelitow and LuizAsFight authored Oct 21, 2024
1 parent 9945f18 commit fe8ba63
Show file tree
Hide file tree
Showing 7 changed files with 132 additions and 18 deletions.
17 changes: 6 additions & 11 deletions e2e-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,18 @@
"homepage": "https://github.com/FuelLabs/fuel-connectors",
"type": "module",
"scripts": {
"test:react-app": "pnpm test:react-app:ci -- --ui",
"test:react-app:ci": "playwright test e2e-tests/react-app --project=react-app"
"test:e2e": "playwright test"
},
"devDependencies": {
"@fuels/connectors": "workspace:*",
"@fuels/playwright-utils": "0.23.0",
"@fuels/ts-config": "0.20.0",
"@playwright/test": "1.46.1",
"@types/node": "20.12.11",
"@playwright/test": "1.48.1",
"dotenv": "16.4.5",
"fuels": "0.96.1"
},
"engines": {
"node": ">=18",
"pnpm": ">=9"
"node": ">=20.11.0",
"pnpm": "9.x"
},
"packageManager": "[email protected]",
"dependencies": {
"playwright": "1.46.1"
}
"packageManager": "[email protected]"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { getButtonByText, getByAriaLabel, test } from '@fuels/playwright-utils';
import { type Page, expect } from '@playwright/test';

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

test.describe('BurnerWalletConnector', async () => {
test.beforeEach(async ({ page }) => {
await page.goto('/');
await page.bringToFront();
});

test('should connect and show fuel address', 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 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 page.reload();
await page.waitForSelector('text=/Connect Wallet/');
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ import { type WalletUnlocked, bn } from 'fuels';
import { testSetup, transferMaxBalance } from '../setup';
dotenv.config();

const fuelPathToExtension = await downloadFuel('0.27.0');
test.use({ pathToExtension: fuelPathToExtension });

const connect = async (
page: Page,
fuelWalletTestHelper: FuelWalletTestHelper,
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"ts:check": "turbo run ts:check",
"test": "vitest",
"test:ci": "turbo run test -- --run --coverage.enabled --coverage.reporter=json-summary --coverage.reporter=json",
"test:e2e": "turbo run test:e2e",
"lint:check": "biome check --apply-unsafe .",
"lint:ci": "biome lint --max-diagnostics=1000 --diagnostic-level=error .",
"format": "biome format --write .",
Expand All @@ -40,8 +41,8 @@
"vitest": "2.0.2"
},
"engines": {
"node": ">=18",
"pnpm": ">=9"
"node": ">=20.11.0",
"pnpm": "9.x"
},
"pnpm": {
"overrides": {
Expand Down
76 changes: 74 additions & 2 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pnpm-workspace.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
packages:
- 'examples/*'
- 'packages/*'
- 'e2e-tests'
3 changes: 3 additions & 0 deletions turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
},
"test": {
"dependsOn": ["^build"]
},
"test:e2e": {
"cache": false
}
}
}

0 comments on commit fe8ba63

Please sign in to comment.