-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: WalletConnect tests FE-443 (#427)
- Loading branch information
Showing
13 changed files
with
1,397 additions
and
51 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
68 changes: 68 additions & 0 deletions
68
e2e-tests/runner/examples/connectors/WalletConnectConnector/WalletConnectConnector.test.ts
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,68 @@ | ||
import { getButtonByText, getByAriaLabel } from '@fuels/playwright-utils'; | ||
import { testWithSynpress } from '@synthetixio/synpress'; | ||
import { MetaMask, metaMaskFixtures } from '@synthetixio/synpress/playwright'; | ||
import { sessionTests, transferTests } from '../../../common/common'; | ||
import type { ConnectorFunctions } from '../../../common/types'; | ||
import basicSetup from '../../../wallet-setup/basic.setup'; | ||
import { fundWallet } from '../setup'; | ||
|
||
const test = testWithSynpress(metaMaskFixtures(basicSetup)); | ||
|
||
test.describe('WalletConnectConnector', () => { | ||
let metamask: MetaMask; | ||
|
||
test.beforeEach(async ({ context, extensionId, metamaskPage, page }) => { | ||
metamask = new MetaMask( | ||
context, | ||
metamaskPage, | ||
basicSetup.walletPassword, | ||
extensionId, | ||
); | ||
await page.goto('/', { waitUntil: 'domcontentloaded' }); | ||
}); | ||
|
||
const connect: ConnectorFunctions['connect'] = async (page) => { | ||
await page.goto('/'); | ||
const connectButton = getButtonByText(page, 'Connect Wallet', true); | ||
await connectButton.click(); | ||
await getByAriaLabel(page, 'Connect to Ethereum Wallets', true).click(); | ||
|
||
await page.getByText('Proceed anyway').click(); | ||
await getButtonByText(page, 'MetaMask', true).click(); | ||
|
||
await metamask.connectToDapp(); | ||
// wait 3 seconds for the connection to be established | ||
await page.waitForTimeout(3000); | ||
|
||
await metamask.confirmSignature(); | ||
}; | ||
|
||
const approveTransfer: ConnectorFunctions['approveTransfer'] = async () => { | ||
await metamask.confirmTransaction(); | ||
}; | ||
|
||
test('Fuel tests', async ({ page }) => { | ||
await sessionTests(page, { connect, approveTransfer }); | ||
|
||
await connect(page); | ||
|
||
const addressElement = await page.locator('#address'); | ||
let address: string | null = null; | ||
if (addressElement) { | ||
address = await addressElement.getAttribute('data-address'); | ||
} | ||
|
||
if (address) { | ||
await fundWallet({ publicKey: address }); | ||
} else { | ||
throw new Error('Address is null'); | ||
} | ||
|
||
await page.click('text=Disconnect'); | ||
await page.waitForSelector('text=/Connect Wallet/'); | ||
|
||
await transferTests(page, { connect, approveTransfer }); | ||
|
||
// await incrementTests(page, { connect, approveTransfer }); | ||
}); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"compilerOptions": { | ||
"moduleResolution": "bundler", | ||
"strict": true | ||
} | ||
} |
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,12 @@ | ||
import { defineWalletSetup } from '@synthetixio/synpress'; | ||
import { MetaMask } from '@synthetixio/synpress/playwright'; | ||
|
||
const SEED_PHRASE = | ||
'test test test test test test test test test test test junk'; | ||
const PASSWORD = 'SynpressIsAwesomeNow!!!'; | ||
|
||
export default defineWalletSetup(PASSWORD, async (context, walletPage) => { | ||
const metamask = new MetaMask(context, walletPage, PASSWORD); | ||
|
||
await metamask.importWallet(SEED_PHRASE); | ||
}); |
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 |
---|---|---|
|
@@ -57,5 +57,8 @@ | |
"fast-xml-parser@<4.4.1": ">=4.4.1" | ||
} | ||
}, | ||
"packageManager": "[email protected]" | ||
"packageManager": "[email protected]", | ||
"dependencies": { | ||
"@synthetixio/synpress": "4.0.3" | ||
} | ||
} |
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,10 +1,11 @@ | ||
import { createConfig } from 'fuels'; | ||
|
||
export default createConfig({ | ||
providerUrl: 'https://testnet.fuel.network/v1/graphql', | ||
providerUrl: 'http://localhost:4000/v1/graphql', | ||
predicates: ['./predicate'], | ||
output: './src/generated/tmp', | ||
forcBuildFlags: ['--release'], | ||
// needs the private key to deploy the predicate | ||
privateKey: '0x', | ||
privateKey: | ||
'0xa449b1ffee0e2205fa924c6740cc48b3b473aa28587df6dab12abc245d1f5298', // genesis private key | ||
}); |
Oops, something went wrong.