Skip to content

Commit

Permalink
test: login and connect
Browse files Browse the repository at this point in the history
  • Loading branch information
peterpeterparker committed Jul 23, 2024
1 parent c19c84a commit 3d76911
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 6 deletions.
1 change: 1 addition & 0 deletions demo/src/relying_party_frontend/src/app.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Relying Party</title>
<link rel="icon" href="%sveltekit.assets%/favicon.png" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
%sveltekit.head%
Expand Down
2 changes: 1 addition & 1 deletion demo/src/relying_party_frontend/src/routes/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</script>

{#if isNullish(wallet)}
<Button {onclick} testId="connect-wallet">Connect Wallet</Button>
<Button {onclick} testId="connect-wallet-button">Connect Wallet</Button>
{:else}
<div in:fade>
<p>Connected</p>
Expand Down
1 change: 1 addition & 0 deletions demo/src/wallet_frontend/src/app.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Wallet</title>
<link rel="icon" href="%sveltekit.assets%/favicon.png" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
%sveltekit.head%
Expand Down
33 changes: 28 additions & 5 deletions e2e/connect.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {testWithII} from '@dfinity/internet-identity-playwright';
import {InternetIdentityPage, testWithII} from '@dfinity/internet-identity-playwright';
import {expect} from '@playwright/test';

testWithII.beforeEach(async ({iiPage, browser}) => {
const REPLICA_URL = 'http://localhost:4943';
Expand All @@ -9,8 +10,30 @@ testWithII.beforeEach(async ({iiPage, browser}) => {

const RELYING_PARTY_URL = 'http://localhost:5173';

testWithII('should sign-in relying-party with a new user', async ({page, iiPage}) => {
await page.goto(RELYING_PARTY_URL);
testWithII(
'should sign-in relying-party with a new user',
async ({page: partyPage, iiPage: partyIIPage, context, browser}) => {
await partyPage.goto(RELYING_PARTY_URL);

await iiPage.signInWithNewIdentity();
});
const identity = await partyIIPage.signInWithNewIdentity();

await expect(partyPage.getByTestId('connect-wallet-button')).toBeVisible();

const walletPagePromise = context.waitForEvent('page');

await partyPage.getByTestId('connect-wallet-button').click();

const walletPage = await walletPagePromise;
await expect(walletPage).toHaveTitle('Wallet');

await expect(walletPage.getByTestId('login-button')).toBeVisible();

const walletIIPage = new InternetIdentityPage({
page: walletPage,
context,
browser
});

await walletIIPage.signInWithIdentity({identity});
}
);

0 comments on commit 3d76911

Please sign in to comment.