-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix send flow * add playwright test for send & receive flow * cleaning * increase playwrigth timeout * regenerate lockfile * reinstall web-ext * nigiri in playwright.yml CI * Update src/domain/pset.ts Co-authored-by: João Bordalo <[email protected]> * dynamic address placeholder & fix switch cases in pset.ts * add with: cache: 'yarn' in CI * confirmation page deduct fee from amount --------- Co-authored-by: João Bordalo <[email protected]>
- Loading branch information
1 parent
0f07b1e
commit 8e6c90c
Showing
21 changed files
with
567 additions
and
290 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
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,25 @@ | ||
import type { MarinaProvider } from 'marina-provider'; | ||
import Marina from '../src/inject/marina/provider'; | ||
import { test as pwTest, expect as pwExpect, makeOnboardingRestore } from './utils'; | ||
|
||
const vulpemFaucetURL = 'https://faucet.vulpem.com/'; | ||
|
||
pwTest('should set up a window.marina object', async ({ page }) => { | ||
await page.goto(vulpemFaucetURL); | ||
// test if the window.marina object is set up | ||
// use isEnabled() to check if the functions are available | ||
const isEnableViaProvider = await page.evaluate( | ||
(name: string) => (window[name as any] as unknown as MarinaProvider).isEnabled(), | ||
Marina.PROVIDER_NAME | ||
); | ||
pwExpect(isEnableViaProvider).toBe(false); | ||
}); | ||
|
||
pwTest('should be able to connect to a web app (faucet.vulpem.com)', async ({ page, extensionId, context }) => { | ||
await makeOnboardingRestore(page, extensionId); | ||
await page.goto(vulpemFaucetURL); | ||
await page.getByRole('button', { name: 'Connect with Marina' }).click(); | ||
const popup = await context.waitForEvent('page'); | ||
await popup.getByRole('button', { name: 'Connect' }).click(); | ||
pwExpect(page.getByText('Wrong network, switch to the Testnet')).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,9 @@ | ||
import { test as pwTest, makeOnboardingRestore, marinaURL, PASSWORD } from "./utils"; | ||
|
||
pwTest('should be able to create a new Marina wallet & Log in', async ({ page, extensionId }) => { | ||
await makeOnboardingRestore(page, extensionId); | ||
await page.goto(marinaURL(extensionId, 'popup.html')); | ||
await page.getByPlaceholder('Enter your password').fill(PASSWORD); | ||
await page.getByRole('button', { name: 'Log in' }).click(); | ||
await page.waitForSelector('text=Assets'); | ||
}); |
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,75 @@ | ||
import { address } from 'liquidjs-lib'; | ||
import { faucet } from '../test/_regtest'; | ||
import { | ||
test as pwTest, | ||
expect as pwExpect, | ||
makeOnboardingRestore, | ||
marinaURL, | ||
PASSWORD, | ||
} from './utils'; | ||
|
||
pwTest( | ||
'should be able to generate a new address via wallet/receive popup UI', | ||
async ({ page, extensionId }) => { | ||
// onboard a new wallet | ||
await makeOnboardingRestore(page, extensionId); | ||
// login page | ||
await page.goto(marinaURL(extensionId, 'popup.html')); | ||
await page.getByPlaceholder('Enter your password').fill(PASSWORD); | ||
await page.getByRole('button', { name: 'Log in' }).click(); | ||
await page.waitForSelector('text=Assets'); | ||
// go to receive page and generate a new address | ||
await page.getByRole('button', { name: 'Receive' }).click(); | ||
await page.getByRole('button', { name: 'New Asset' }).click(); | ||
await page.getByRole('button', { name: 'Copy' }).click(); | ||
await page.waitForSelector('text=Copied'); | ||
const clipboard = await page.evaluate('navigator.clipboard.readText()'); | ||
pwExpect(typeof clipboard).toBe('string'); | ||
pwExpect(clipboard).toContain('lq1'); | ||
pwExpect(address.isConfidential(clipboard as string)).toBe(true); | ||
} | ||
); | ||
|
||
pwTest( | ||
'should be able to send some funds via wallet/send popup UI', | ||
async ({ page, extensionId }) => { | ||
await makeOnboardingRestore(page, extensionId); // create a new wallet | ||
// go to networks page and switch to regtest | ||
await page.goto(marinaURL(extensionId, 'popup.html')); | ||
await page.getByPlaceholder('Enter your password').fill(PASSWORD); | ||
await page.getByRole('button', { name: 'Log in' }).click(); | ||
await page.waitForSelector('text=Assets'); | ||
await page.getByAltText('menu icon').click(); // hamburger menu | ||
await page.getByText('Settings').click(); | ||
await page.getByRole('button', { name: 'Networks' }).click(); | ||
await page.getByRole('button', { name: 'Liquid' }).click(); // by default on Liquid, so the button contains the network name | ||
await page.getByText('Regtest').click(); | ||
// wait some time for the network to switch | ||
await page.waitForTimeout(2000); | ||
|
||
// go to receive page and generate a new address, we'll use it to faucet some funds | ||
await page.goto(marinaURL(extensionId, 'popup.html')); | ||
await page.getByRole('button', { name: 'Receive' }).click(); | ||
await page.getByRole('button', { name: 'New Asset' }).click(); | ||
await page.getByRole('button', { name: 'Copy' }).click(); | ||
await page.waitForSelector('text=Copied'); | ||
const address = await page.evaluate("navigator.clipboard.readText()"); | ||
pwExpect(address as string).toContain('el1'); | ||
await faucet(address as string, 1); // send 1 L-BTC to the address | ||
await page.goto(marinaURL(extensionId, 'popup.html')); | ||
await page.waitForSelector('text=1 L-BTC'); | ||
await page.getByRole('button', { name: 'Send' }).click(); // go to send | ||
await page.getByText('Liquid Bitcoin').click(); // select L-BTC | ||
await page.getByPlaceholder('el1...').fill(address as string); // fill the address | ||
await page.getByPlaceholder('0').fill('0.9'); // fill the amount | ||
await page.getByRole('button', { name: 'Verify' }).click(); | ||
await page.getByRole('button', { name: 'L-BTC' }).click(); | ||
await page.waitForSelector('text=Fee:'); | ||
await page.getByRole('button', { name: 'Confirm' }).click(); // send | ||
await page.getByRole('button', { name: 'Send' }).click(); // confirm | ||
await page.waitForSelector('text=Unlock'); | ||
await page.getByPlaceholder('Password').fill(PASSWORD); | ||
await page.getByRole('button', { name: 'Unlock' }).click(); | ||
await page.waitForSelector('text=Payment successful !'); | ||
} | ||
); |
This file was deleted.
Oops, something went wrong.
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,8 @@ | ||
export class CoinSelectionError extends Error { | ||
constructor(public target: { amount: number; asset: string }, public selectedAmount: number) { | ||
super( | ||
`Coin selection failed for ${target.amount} with ${selectedAmount} selected (asset: ${target.asset}))` | ||
); | ||
this.name = 'CoinSelectionError'; | ||
} | ||
} |
Oops, something went wrong.