From aa06d765a7b84adb9f6436a867db32365bb3f0e5 Mon Sep 17 00:00:00 2001 From: vinayaktorus Date: Sat, 31 Aug 2024 16:43:40 +0530 Subject: [PATCH 1/2] refactored with login state from openlogin --- .../AuthServicePage.ts | 1 - .../demo-wallet-service/index.test.ts | 24 +++++++++++-------- walletservices/wallet-service/index.test.ts | 5 +++- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/authservice/login-with-passwordless/AuthServicePage.ts b/authservice/login-with-passwordless/AuthServicePage.ts index e78f650..b4d944e 100644 --- a/authservice/login-with-passwordless/AuthServicePage.ts +++ b/authservice/login-with-passwordless/AuthServicePage.ts @@ -1,6 +1,5 @@ // playwright-dev-page.ts import { Page } from "@playwright/test"; -// eslint-disable-next-line import/no-extraneous-dependencies import * as speakeasy from "speakeasy"; import { delay } from "../utils"; diff --git a/walletservices/demo-wallet-service/index.test.ts b/walletservices/demo-wallet-service/index.test.ts index ba2ea08..11c336e 100644 --- a/walletservices/demo-wallet-service/index.test.ts +++ b/walletservices/demo-wallet-service/index.test.ts @@ -1,7 +1,7 @@ import { test } from "@playwright/test"; -import { SessionManager } from "@toruslabs/session-manager"; -import * as fs from "fs"; +import { AccountsPage } from "../../authservice/openlogin-account-page/AccountsPage"; +import { signInWithEmailWithTestEmailOnDemoApp } from "../../authservice/utils"; import { signInWithEmailWithTestEmailAppInDemoApp } from "../utils"; import { DemoWalletServicesPage } from "./DemoWalletServicesPage"; @@ -39,18 +39,22 @@ test.describe.serial("Demo Wallet Services Scenarios @demo", () => { await demoWalletServicesPage.clickLogOut(); }); - test(`Verify user is able to login into wallet services using session id from auth service`, async ({ page }) => { + test(`Verify user is able to login into wallet services using session id from auth service`, async ({ page, browser }) => { test.slow(); + let sessionId; + test.setTimeout(3 * 60000); + await page.goto("https://demo-openlogin.web3auth.io/"); + await signInWithEmailWithTestEmailOnDemoApp(page, testEmail, browser, testEmail.split("@")[0].split(".")[1], "production", "mainnet"); + const accountsPage = new AccountsPage(page); + const keys: string | null = await accountsPage.getOpenLoginState(); + if (keys !== null) { + const jsonObject = JSON.parse(keys); + sessionId = jsonObject.sessionId; + } const demoWalletServicesPage = new DemoWalletServicesPage(page); - const sessionId = SessionManager.generateRandomSessionKey(); - const sessionManagerInstance = new SessionManager({ sessionId }); - const content = fs.readFileSync("walletservices/demo-wallet-service/openloginstate.json", "utf-8"); - const data = JSON.parse(content); - data.sessionId = sessionId; - await sessionManagerInstance.createSession(data); await page.goto(demoWalletServiceLoginURL); await page.waitForLoadState(); - await page.locator(`xpath=.//input[@aria-placeholder='Enter Session Id...']`).fill(data.sessionId); + await page.locator(`xpath=.//input[@aria-placeholder='Enter Session Id...']`).fill(sessionId); await page.locator(`xpath=.//button[text()='Login with Session Id']`).click(); await page.waitForLoadState(); await demoWalletServicesPage.verifyUserInfoInDemoApp(testEmail); diff --git a/walletservices/wallet-service/index.test.ts b/walletservices/wallet-service/index.test.ts index e12dcc6..499e368 100644 --- a/walletservices/wallet-service/index.test.ts +++ b/walletservices/wallet-service/index.test.ts @@ -39,7 +39,7 @@ test.describe.serial("Core Wallet Services Scenarios @smoke", () => { await accountsPage.selectCurrency("USD"); await accountsPage.clickHome(); await accountsPage.verifyNetworkName("Sepolia Test Network"); - await accountsPage.verifyBalanceAndAddress("0x0dBa...4e49F", "1600"); + await accountsPage.verifyBalanceAndAddress("0x0dBa...4e49F", "1500"); }); test(`Verify validations on send transaction screen`, async () => { @@ -87,6 +87,9 @@ test.describe.serial("Core Wallet Services Scenarios @smoke", () => { test(`Verify user is able to view the sent transaction activity`, async () => { const accountsPage = new WalletServicesPage(page); await page.goto(`${walletServiceLoginURL}/wallet/home`); + await accountsPage.navigateToSettingsWithOption("General"); + await accountsPage.selectNetwork("Main Ethereum Network", "Sepolia Test Network"); + await accountsPage.clickHome(); await accountsPage.clickLink(" Activity"); await page.waitForURL(`${walletServiceLoginURL}/wallet/activity`, { waitUntil: "load", From aa43079b4bfccf538d5e36903ab6db3cf89666a2 Mon Sep 17 00:00:00 2001 From: vinayaktorus Date: Mon, 9 Sep 2024 21:49:26 +0530 Subject: [PATCH 2/2] modified cases for demo wallet --- .../openlogin-account-page/AccountsPage.ts | 3 ++- .../DemoWalletServicesPage.ts | 4 ++-- .../demo-wallet-service/index.test.ts | 19 +++++++++---------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/authservice/openlogin-account-page/AccountsPage.ts b/authservice/openlogin-account-page/AccountsPage.ts index f6d1cdb..c7587d3 100644 --- a/authservice/openlogin-account-page/AccountsPage.ts +++ b/authservice/openlogin-account-page/AccountsPage.ts @@ -1,6 +1,7 @@ // playwright-dev-page.ts import { expect, Page } from "@playwright/test"; import axios from "axios"; + const testEmailAppApiKey = process.env.TESTMAIL_APP_APIKEY; export class AccountsPage { readonly page: Page; @@ -224,7 +225,7 @@ export class AccountsPage { async getOpenLoginState() { await this.page.waitForSelector(`xpath=.//p[text()='User info']`); - await this.page.locator("button").filter({ hasText: "Get openlogin state" }).click(); + await this.page.locator("button").filter({ hasText: " Get web3auth state " }).click(); const keys = await this.page.locator("xpath=.//div[@id='console']//pre").first().textContent(); return keys; } diff --git a/walletservices/demo-wallet-service/DemoWalletServicesPage.ts b/walletservices/demo-wallet-service/DemoWalletServicesPage.ts index 39b6614..5d07812 100644 --- a/walletservices/demo-wallet-service/DemoWalletServicesPage.ts +++ b/walletservices/demo-wallet-service/DemoWalletServicesPage.ts @@ -297,9 +297,9 @@ export class DemoWalletServicesPage { return this.page.locator(`xpath=.//h1[text()='Current Network']/parent::div//pre`).first().textContent(); } - async switchChain(browser: Browser) { + async switchChain(browser: Browser, chain: string) { const currentNetworkBeforeSwitch = await this.getCurrentNetwork(); - await this.page.locator(`xpath=.//button[text()='Switch Chain 0xaa36a7']`).click(); + await this.page.locator(`xpath=.//button[text()='${chain}']`).click(); await delay(5000); const pages = await browser.contexts()[0].pages(); await pages[1].bringToFront(); diff --git a/walletservices/demo-wallet-service/index.test.ts b/walletservices/demo-wallet-service/index.test.ts index 11c336e..eb0f347 100644 --- a/walletservices/demo-wallet-service/index.test.ts +++ b/walletservices/demo-wallet-service/index.test.ts @@ -1,8 +1,7 @@ import { test } from "@playwright/test"; import { AccountsPage } from "../../authservice/openlogin-account-page/AccountsPage"; -import { signInWithEmailWithTestEmailOnDemoApp } from "../../authservice/utils"; -import { signInWithEmailWithTestEmailAppInDemoApp } from "../utils"; +import { signInWithEmailWithTestEmailApp, signInWithEmailWithTestEmailAppInDemoApp } from "../utils"; import { DemoWalletServicesPage } from "./DemoWalletServicesPage"; const demoWalletServiceLoginURL = "https://demo-wallet.web3auth.io"; @@ -12,9 +11,9 @@ const address = "0x0dB...d4e49F"; const walletAddress = "0x0dBa...4e49F"; const signAddress = "0x0dBa2cE4784849FA4e42936cA0c5d8bC1Cd4e49F"; const expectedBalance = "0.635632785708915"; - +let sessionId: string = ""; test.describe.serial("Demo Wallet Services Scenarios @demo", () => { - test(`Verify demo wallet services functionalities using passwordless login`, async ({ page, browser }) => { + test.skip(`Verify demo wallet services functionalities using passwordless login`, async ({ page, browser }) => { test.setTimeout(3 * 60000); // adding more time to compensate high loading time test.slow() does not help in this case const demoWalletServicesPage = new DemoWalletServicesPage(page); await page.goto(demoWalletServiceLoginURL); @@ -28,23 +27,23 @@ test.describe.serial("Demo Wallet Services Scenarios @demo", () => { waitUntil: "load", }); await demoWalletServicesPage.verifyUserInfoInDemoApp(testEmail); - await demoWalletServicesPage.switchChain(browser); + await demoWalletServicesPage.switchChain(browser, "Switch Chain 0x13882"); + await demoWalletServicesPage.switchChain(browser, "Switch Chain 0xaa36a7"); await demoWalletServicesPage.verifyAddressInDemoApp(address); await demoWalletServicesPage.verifyBalanceInDemoApp(expectedBalance); await demoWalletServicesPage.verifyWalletInDemoApp(walletAddress); - await demoWalletServicesPage.verifySignedMessages("Personal Sign", browser, signAddress.toLowerCase()); - await demoWalletServicesPage.verifySignedMessages("ETH Sign", browser, "0x0dBa2cE4784849FA4e42936cA0c5d8bC1Cd4e49F"); - await demoWalletServicesPage.verifySignedMessages("Typed data v1", browser, signAddress.toLowerCase()); + await demoWalletServicesPage.verifySignedMessages("Personal Sign", browser, signAddress); + await demoWalletServicesPage.verifySignedMessages("ETH Sign", browser, signAddress); + await demoWalletServicesPage.verifySignedMessages("Typed data v4", browser, signAddress); await demoWalletServicesPage.verifyWalletConnect(); await demoWalletServicesPage.clickLogOut(); }); test(`Verify user is able to login into wallet services using session id from auth service`, async ({ page, browser }) => { test.slow(); - let sessionId; test.setTimeout(3 * 60000); await page.goto("https://demo-openlogin.web3auth.io/"); - await signInWithEmailWithTestEmailOnDemoApp(page, testEmail, browser, testEmail.split("@")[0].split(".")[1], "production", "mainnet"); + await signInWithEmailWithTestEmailApp(page, testEmail, browser, testEmail.split("@")[0].split(".")[1], currentTimestamp); const accountsPage = new AccountsPage(page); const keys: string | null = await accountsPage.getOpenLoginState(); if (keys !== null) {