-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(e2e-connector-tests): unify connector tests FE-860 (#422)
Co-authored-by: Luiz Gomes <[email protected]>
- Loading branch information
1 parent
9772e7f
commit 5aac2bc
Showing
10 changed files
with
149 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,18 @@ | ||
REACT_APP_PORT= | ||
REACT_NEXT_PORT= | ||
VITE_FUEL_PROVIDER_URL="https://testnet.fuel.network/v1/graphql" | ||
VITE_WALLET_SECRET= # leave it empty to skip seed wallet | ||
VITE_MASTER_WALLET_MNEMONIC= | ||
# URLs for the provider | ||
VITE_FUEL_PROVIDER_URL="http://localhost:4000/v1/graphql" | ||
NEXT_PUBLIC_PROVIDER_URL="http://localhost:4000/v1/graphql" | ||
|
||
# Project and chain configuration | ||
NEXT_PUBLIC_WC_PROJECT_ID="your_wc_project_id" | ||
NEXT_PUBLIC_CHAIN_ID_NAME="testnet" | ||
VITE_APP_WC_PROJECT_ID="your_wc_project_id" | ||
VITE_CHAIN_ID_NAME="local" | ||
|
||
# Wallet configuration | ||
VITE_WALLET_SECRET="your_wallet_secret" | ||
VITE_MASTER_WALLET_MNEMONIC="your_wallet_mnemonic" | ||
|
||
# Port settings | ||
REACT_APP_PORT=5173 | ||
REACT_NEXT_PORT=3002 | ||
PORT=5173 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
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 skipBridgeFunds(page); | ||
|
||
await page.click('text=Disconnect'); | ||
await page.waitForSelector('text=/Connect Wallet/'); | ||
|
||
await connect(page); | ||
await skipBridgeFunds(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(); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.