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..21ae4cb88 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,14 @@ 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.connectToDapp(["Pristine"]); await page.waitForTimeout(2000); + await metamask.confirmSignature(); + await expect(page.locator("#disconnect-wallet-btn")).toBeVisible(); }); @@ -35,10 +38,11 @@ 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.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..a22e40fb4 100644 --- a/apps/idos-sdk-e2e/tests/02-data.spec.ts +++ b/apps/idos-sdk-e2e/tests/02-data.spec.ts @@ -21,25 +21,28 @@ 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.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.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(); @@ -54,26 +57,32 @@ 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.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..5b060ce5d 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,29 @@ 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.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 +55,25 @@ 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.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();