Skip to content

Commit

Permalink
Merge branch 'fix/e2e-pipline' of github.com:idos-network/idos-sdk-js…
Browse files Browse the repository at this point in the history
… into playground
  • Loading branch information
Mohammed-Mamoun98 committed Dec 10, 2024
2 parents d92879f + a740846 commit 7fb4da8
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 37 deletions.
6 changes: 2 additions & 4 deletions apps/idos-data-dashboard/src/core/idos/idos-provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const Provider = ({ children }: PropsWithChildren) => {
}

return null;
}, [ethSigner, selector]);
}, [!!ethSigner, selector]);

const initialise = useCallback(async () => {
const signer = await getSigner();
Expand All @@ -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);

Expand All @@ -66,9 +65,8 @@ export const Provider = ({ children }: PropsWithChildren) => {

setPublicKey(_pk);
}

setSdk(_sdk);
}, [getSigner, userAddress, sdk]);
}, [getSigner, !!sdk]);

useEffect(() => {
initialise()
Expand Down
8 changes: 6 additions & 2 deletions apps/idos-sdk-e2e/tests/01-evm-auth.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});

Expand All @@ -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();

Expand Down
37 changes: 23 additions & 14 deletions apps/idos-sdk-e2e/tests/02-data.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
Expand Down
42 changes: 25 additions & 17 deletions apps/idos-sdk-e2e/tests/03-enclave.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 ({
Expand All @@ -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();

Expand Down

0 comments on commit 7fb4da8

Please sign in to comment.