diff --git a/apps/idos-data-dashboard/src/core/idos/idos-provider.tsx b/apps/idos-data-dashboard/src/core/idos/idos-provider.tsx index a63e800e1..8805d3292 100644 --- a/apps/idos-data-dashboard/src/core/idos/idos-provider.tsx +++ b/apps/idos-data-dashboard/src/core/idos/idos-provider.tsx @@ -40,7 +40,7 @@ export const Provider = ({ children }: PropsWithChildren) => { } return null; - }, [ethSigner, selector]); + }, [!!ethSigner, selector]); const initialise = useCallback(async () => { const signer = await getSigner(); @@ -55,7 +55,6 @@ export const Provider = ({ children }: PropsWithChildren) => { url: import.meta.env.VITE_IDOS_ENCLAVE_URL, }, }); - const profile = await _sdk.hasProfile(userAddress); setHasProfile(profile); @@ -66,9 +65,8 @@ export const Provider = ({ children }: PropsWithChildren) => { setPublicKey(_pk); } - setSdk(_sdk); - }, [getSigner, userAddress, sdk]); + }, [getSigner, !!sdk]); useEffect(() => { initialise() diff --git a/apps/idos-sdk-e2e/tests/01-evm-auth.spec.ts b/apps/idos-sdk-e2e/tests/01-evm-auth.spec.ts index 43172051a..7a1009ae7 100644 --- a/apps/idos-sdk-e2e/tests/01-evm-auth.spec.ts +++ b/apps/idos-sdk-e2e/tests/01-evm-auth.spec.ts @@ -19,11 +19,16 @@ test("should login successfully with an EVM wallet", async ({ }) => { const metamask = new MetaMask(context, metamaskPage, basicSetup.walletPassword, extensionId); await page.goto("/"); + await page.getByRole("button", { name: "Connect a wallet" }).click(); await page.getByRole("button", { name: "Metamask" }).first().click(); + + await metamask.switchAccount("Pristine"); await metamask.connectToDapp(["Pristine"]); await page.waitForTimeout(2000); + await metamask.confirmSignature(); + await expect(page.locator("#disconnect-wallet-btn")).toBeVisible(); }); @@ -35,10 +40,12 @@ test("should set successfully an EVM signer", async ({ }) => { const metamask = new MetaMask(context, metamaskPage, basicSetup.walletPassword, extensionId); await page.goto("/"); + await page.getByRole("button", { name: "Connect a wallet" }).click(); await page.getByRole("button", { name: "Metamask" }).first().click(); - await metamask.switchAccount("Account 1"); - await metamask.connectToDapp(["Account 1"]); + + await metamask.switchAccount("Pristine"); + await metamask.connectToDapp(["Pristine"]); await page.waitForTimeout(2000); await metamask.confirmSignature(); diff --git a/apps/idos-sdk-e2e/tests/02-data.spec.ts b/apps/idos-sdk-e2e/tests/02-data.spec.ts index 22bf5cc6f..6cf7fad84 100644 --- a/apps/idos-sdk-e2e/tests/02-data.spec.ts +++ b/apps/idos-sdk-e2e/tests/02-data.spec.ts @@ -21,29 +21,37 @@ test("should fetch credentials successfully", async ({ extensionId, }) => { const metamask = new MetaMask(context, metamaskPage, basicSetup.walletPassword, extensionId); + await page.goto("/"); await page.getByRole("button", { name: "Connect a wallet" }).click(); await page.getByRole("button", { name: "Metamask" }).first().click(); - await metamask.switchAccount("Account 1"); - await metamask.connectToDapp(["Account 1"]); + + await metamask.switchAccount("Pristine"); + await metamask.connectToDapp(["Pristine"]); await page.waitForTimeout(2000); await metamask.confirmSignature(); + const list = page.locator("#credentials-list"); - await expect(list.getByRole("listitem")).toHaveCount(3); + await expect(list.getByRole("listitem")).toHaveCount(2); }); test("should fetch wallets successfully", async ({ context, page, metamaskPage, extensionId }) => { await page.goto("/wallets"); const metamask = new MetaMask(context, metamaskPage, basicSetup.walletPassword, extensionId); + await page.getByRole("button", { name: "Connect a wallet" }).click(); await page.getByRole("button", { name: "Metamask" }).first().click(); - await metamask.switchAccount("Account 1"); - await metamask.connectToDapp(["Account 1"]); - await page.waitForTimeout(3000); + + await metamask.switchAccount("Pristine"); + await metamask.connectToDapp(["Pristine"]); + await page.waitForTimeout(2000); await metamask.confirmSignature(); + const list = page.locator("#wallets-list"); await expect(list.getByRole("listitem")).toHaveCount(1); const address = await metamask.getAccountAddress(); - await expect(list.getByRole("listitem").first().locator("p").last()).toHaveText( + + const wallet = await list.getByRole("listitem").first().locator("p").last().textContent(); + await expect(wallet?.toLocaleLowerCase()).toEqual( address.toLocaleLowerCase(), // The address is stored in lowercase format in the idOS so we need to normalize the MetaMask address. ); }); @@ -54,26 +62,33 @@ test("should add / delete a wallet successfully", async ({ metamaskPage, extensionId, }) => { - await page.goto("/wallets"); const metamask = new MetaMask(context, metamaskPage, basicSetup.walletPassword, extensionId); + await page.goto("/"); + await page.getByRole("button", { name: "Connect a wallet" }).click(); await page.getByRole("button", { name: "Metamask" }).first().click(); - await metamask.switchAccount("Account 1"); - await metamask.connectToDapp(["Account 1"]); - await page.waitForTimeout(3000); + + await metamask.switchAccount("Pristine"); + await metamask.connectToDapp(["Pristine"]); + await page.waitForTimeout(2000); await metamask.confirmSignature(); + await page.waitForTimeout(2000); + + await page.goto("/wallets"); + // Testing wallet addition const addWalletButton = page.locator("#add-wallet-button"); await addWalletButton.click(); await page.locator("#address").fill(TEST_WALLET_ADDRESS); await page.locator("#add-wallet-form-submit").click(); + await page.waitForTimeout(3000); await metamask.confirmSignature(); - await page.waitForTimeout(5000); - const list = page.locator("#wallets-list"); - await expect(list.getByRole("listitem")).toHaveCount(2); + await page.waitForTimeout(10000); + const list = await page.locator("#wallets-list"); + await expect(list.getByRole("listitem")).toHaveCount(2); // Testing wallet deletion - const deleteButton = list.locator(`#delete-wallet-${TEST_WALLET_ADDRESS}`); + const deleteButton = await list.locator(`#delete-wallet-${TEST_WALLET_ADDRESS}`); await deleteButton.click(); await page.locator(`#confirm-delete-wallet-${TEST_WALLET_ADDRESS}`).click(); await metamask.confirmSignature(); diff --git a/apps/idos-sdk-e2e/tests/03-enclave.spec.ts b/apps/idos-sdk-e2e/tests/03-enclave.spec.ts index ce4656de2..4a0fd739e 100644 --- a/apps/idos-sdk-e2e/tests/03-enclave.spec.ts +++ b/apps/idos-sdk-e2e/tests/03-enclave.spec.ts @@ -2,7 +2,7 @@ import { MetaMask, metaMaskFixtures, testWithSynpress } from "@synthetixio/synpr import basicSetup from "./wallet-setup/basic.setup"; // @todo: This should be created from the sdk instead of relying on hardcoded values. -const credentialContent = process.env.CREDENTIAL_CONTENT as string; +// const credentialContent = process.env.CREDENTIAL_CONTENT as string; const test = testWithSynpress(metaMaskFixtures(basicSetup)); const { expect } = test; @@ -23,23 +23,31 @@ test("should decrypt a credential successfully", async ({ const metamask = new MetaMask(context, metamaskPage, basicSetup.walletPassword, extensionId); await page.getByRole("button", { name: "Connect a wallet" }).click(); await page.getByRole("button", { name: "Metamask" }).first().click(); - await metamask.switchAccount("Account 1"); - await metamask.connectToDapp(["Account 1"]); + + await metamask.switchAccount("Pristine"); + await metamask.connectToDapp(["Pristine"]); await page.waitForTimeout(2000); await metamask.confirmSignature(); - const popupPromise = page.waitForEvent("popup"); + await page.waitForTimeout(2000); + await page.getByRole("button", { name: "View details" }).first().click(); - const idOSButton = page.frameLocator("#idos-enclave-iframe").locator("#unlock"); + const idOSButton = await page.frameLocator("#idos-enclave-iframe").locator("#unlock"); await idOSButton.click(); + const popupPromise = await page.waitForEvent("popup"); const idOSPopup = await popupPromise; await page.waitForTimeout(2000); - await (await idOSPopup.waitForSelector("#auth-method-password")).click(); - const passwordInput = idOSPopup.locator("#idos-password-input"); + + await idOSPopup.locator("#auth-method-password").click(); + const passwordInput = await idOSPopup.locator("#idos-password-input"); + await passwordInput.fill("qwerty"); await idOSPopup.getByRole("button", { name: "Unlock" }).click(); + await page.waitForTimeout(4000); - const code = page.locator("#credential-details"); - await expect(code).toHaveText(credentialContent); + const code = await page.locator("#credential-details").textContent(); + expect(code).toContain("uuid:087b9cf0-a968-471d-a4e8-a805a05357ed"); + // uuid:203490be-fec8-49f9-80d7-fa504a057a0c for PROD + // uuid:087b9cf0-a968-471d-a4e8-a805a05357ed for PLAYGROUND }); test("should filter credentials by country successfully", async ({ @@ -49,23 +57,27 @@ test("should filter credentials by country successfully", async ({ extensionId, }) => { const metamask = new MetaMask(context, metamaskPage, basicSetup.walletPassword, extensionId); - await page.goto("e2e/credential-filtering-by-country"); await page.getByRole("button", { name: "Connect a wallet" }).click(); await page.getByRole("button", { name: "Metamask" }).first().click(); - await metamask.switchAccount("Account 1"); - await metamask.connectToDapp(["Account 1"]); + + await metamask.switchAccount("Pristine"); + await metamask.connectToDapp(["Pristine"]); await page.waitForTimeout(2000); await metamask.confirmSignature(); + await page.waitForTimeout(2000); + await page.goto("e2e/credential-filtering-by-country"); + await page.waitForTimeout(2000); - const popupPromise = page.waitForEvent("popup"); - - const idOSButton = page.frameLocator("#idos-enclave-iframe").locator("#unlock"); + const idOSButton = await page.frameLocator("#idos-enclave-iframe").locator("#unlock"); await idOSButton.click(); + const popupPromise = await page.waitForEvent("popup"); const idOSPopup = await popupPromise; await page.waitForTimeout(2000); - await (await idOSPopup.waitForSelector("#auth-method-password")).click(); - const passwordInput = idOSPopup.locator("#idos-password-input"); + + await idOSPopup.locator("#auth-method-password").click(); + const passwordInput = await idOSPopup.locator("#idos-password-input"); + await passwordInput.fill("qwerty"); await idOSPopup.getByRole("button", { name: "Unlock" }).click();