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 9, 2024
2 parents 94f5367 + 34a12cd commit d4184f7
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 29 deletions.
11 changes: 8 additions & 3 deletions apps/idos-sdk-e2e/tests/01-evm-auth.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +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 metamask.connectToDapp();
await page.waitForTimeout(2000);
await metamask.confirmSignature();

await expect(page.locator("#disconnect-wallet-btn")).toBeVisible();
});

Expand All @@ -34,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();
await page.waitForTimeout(2000);
await metamask.confirmSignature();

Expand Down
30 changes: 19 additions & 11 deletions apps/idos-sdk-e2e/tests/02-data.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,31 @@ 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();
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();
await page.waitForTimeout(2000);
await metamask.confirmSignature();
const list = page.locator("#wallets-list");

const list = await 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(
Expand All @@ -56,20 +61,23 @@ test("should add / delete a wallet successfully", async ({
}) => {
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();
await page.waitForTimeout(2000);
await metamask.confirmSignature();

const list = await page.locator("#wallets-list");

// 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 metamask.confirmSignature();
await page.waitForTimeout(5000);
const list = page.locator("#wallets-list");
await expect(list.getByRole("listitem")).toHaveCount(2);

// Testing wallet deletion
Expand Down
36 changes: 21 additions & 15 deletions apps/idos-sdk-e2e/tests/03-enclave.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,27 @@ 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();
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();

const code = page.locator("#credential-details");
await expect(code).toHaveText(credentialContent);
const code = await page.locator("#credential-details");
expect(code).toHaveText(credentialContent);
});

test("should filter credentials by country successfully", async ({
Expand All @@ -53,19 +57,21 @@ test("should filter credentials by country successfully", async ({

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();
await page.waitForTimeout(2000);
await metamask.confirmSignature();
await page.waitForTimeout(2000);

const popupPromise = page.waitForEvent("popup");

const idOSButton = page.frameLocator("#idos-enclave-iframe").locator("#unlock");
await page.getByRole("button", { name: "View details" }).first().click();
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 d4184f7

Please sign in to comment.