Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/vtx: fixing e2e tests #409

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions tests/auth-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { memoize } from "lodash-es";
import type { OpenLoginBackendState } from "@/utils/enums";
import TorusStorageLayer from "@/utils/tkey/storageLayer";

import { getBackendDomain, getDomain, getStateDomain, wait } from "./utils";
import { getBackendDomain, getDomain, getStateDomain } from "./utils";

const ec = new EC("secp256k1");
export const EPHEMERAL_KEYPAIR = ec.genKeyPair({ entropy: "ad1238470128347018934701983470183478sfa" });
Expand Down Expand Up @@ -75,7 +75,6 @@ export const createRedisKey = memoize(async () => {

export async function login(context: BrowserContext, browserName: "chromium" | "webkit" | "firefox"): Promise<Page> {
await createRedisKey();

const keyFunction = `window.localStorage.setItem(
"controllerModule-ephemeral",
JSON.stringify({
Expand Down Expand Up @@ -142,8 +141,5 @@ export async function login(context: BrowserContext, browserName: "chromium" | "
await context.addInitScript({ content: stateFunction });
const page = await context.newPage();
await page.goto(getDomain());
// await changeLanguage(page, "english");
await wait(500);
// await page.locator("text=Account Balance").waitFor();
return page;
}
20 changes: 1 addition & 19 deletions tests/e2e/activity/activity.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
selectTransactionTypeFilter,
} from "../../activity.utils";
import { IMPORT_ACC_SECRET_KEY, login } from "../../auth-helper";
import { ensureTextualElementExists, getLastWeeksDate, getOlderDate, importAccount, switchNetwork, switchTab, wait } from "../../utils";
import { ensureTextualElementExists, getLastWeeksDate, getOlderDate, importAccount, switchNetwork, switchTab } from "../../utils";
import test, { markResult, setBrowserStackTestTitle } from "../fixtures";

test.describe("Activity Page", async () => {
Expand All @@ -34,7 +34,6 @@ test.describe("Activity Page", async () => {
test("Activities should work with network=mainnet", async () => {
// see navigation works correctly
await switchTab(page, "activity");
await wait(1000);
// getting list of activities on activity page
const activities = await getActivities(page);

Expand All @@ -49,7 +48,6 @@ test.describe("Activity Page", async () => {
// see navigation works correctly
await switchTab(page, "activity");
await switchNetwork(page, "testnet");
await wait(1000);
// getting list of activities on activity page
const activities = await getActivities(page);

Expand All @@ -64,7 +62,6 @@ test.describe("Activity Page", async () => {
// see navigation works correctly
await switchTab(page, "activity");
await switchNetwork(page, "devnet");
await wait(1000);
// getting list of activities on activity page
const activities = await getActivities(page);

Expand All @@ -80,7 +77,6 @@ test.describe("Activity Page", async () => {
await switchTab(page, "activity");
// Last 1 week filter
await selectTimeFilter(page, "Last 1 week");
await wait(1000);
// getting list of dates on activity page
let activityDates = await getDateOfActivities(page);
let elements = await activityDates.elementHandles();
Expand All @@ -96,7 +92,6 @@ test.describe("Activity Page", async () => {

// Last 1 month filter
await selectTimeFilter(page, "Last 1 month");
await wait(1000);
// getting list of dates on activity page
activityDates = await getDateOfActivities(page);
elements = await activityDates.elementHandles();
Expand All @@ -112,7 +107,6 @@ test.describe("Activity Page", async () => {

// Last 6 months filter
await selectTimeFilter(page, "Last 6 months");
await wait(1000);
// getting list of dates on activity page
activityDates = await getDateOfActivities(page);
elements = await activityDates.elementHandles();
Expand All @@ -134,7 +128,6 @@ test.describe("Activity Page", async () => {

// Send filter
await selectTransactionTypeFilter(page, "Send");
await wait(1000);
// getting list on activities
let activitiesList = await getActivities(page);
let elements = await activitiesList.elementHandles();
Expand All @@ -148,7 +141,6 @@ test.describe("Activity Page", async () => {

// Receive filter
await selectTransactionTypeFilter(page, "Receive");
await wait(1000);
// getting list on activities
activitiesList = await getActivities(page);
elements = await activitiesList.elementHandles();
Expand All @@ -162,7 +154,6 @@ test.describe("Activity Page", async () => {

// Topup filter
await selectTransactionTypeFilter(page, "Topup");
await wait(1000);
// getting list on activities
activitiesList = await getActivities(page);
elements = await activitiesList.elementHandles();
Expand Down Expand Up @@ -233,7 +224,6 @@ test.skip("Activity Page with Imported Account", async () => {
test("Activities should work with network=mainnet", async () => {
// see navigation works correctly
await switchTab(page, "activity");
await wait(1000);
// getting list of activities on activity page
const activities = await getActivities(page);

Expand All @@ -248,7 +238,6 @@ test.skip("Activity Page with Imported Account", async () => {
// see navigation works correctly
await switchTab(page, "activity");
await switchNetwork(page, "testnet");
await wait(1000);
// getting list of activities on activity page
const activities = await getActivities(page);

Expand All @@ -263,7 +252,6 @@ test.skip("Activity Page with Imported Account", async () => {
// see navigation works correctly
await switchTab(page, "activity");
await switchNetwork(page, "devnet");
await wait(1000);
// getting list of activities on activity page
const activities = await getActivities(page);

Expand All @@ -279,7 +267,6 @@ test.skip("Activity Page with Imported Account", async () => {
await switchTab(page, "activity");
// Last 1 week filter
await selectTimeFilter(page, "Last 1 week");
await wait(1000);
// getting list of dates on activity page
let activityDates = await getDateOfActivities(page);
let elements = await activityDates.elementHandles();
Expand All @@ -295,7 +282,6 @@ test.skip("Activity Page with Imported Account", async () => {

// Last 1 month filter
await selectTimeFilter(page, "Last 1 month");
await wait(1000);
// getting list of dates on activity page
activityDates = await getDateOfActivities(page);
elements = await activityDates.elementHandles();
Expand All @@ -311,7 +297,6 @@ test.skip("Activity Page with Imported Account", async () => {

// Last 6 months filter
await selectTimeFilter(page, "Last 6 months");
await wait(1000);
// getting list of dates on activity page
activityDates = await getDateOfActivities(page);
elements = await activityDates.elementHandles();
Expand All @@ -333,7 +318,6 @@ test.skip("Activity Page with Imported Account", async () => {

// Send filter
await selectTransactionTypeFilter(page, "Send");
await wait(1000);
// getting list on activities
let activitiesList = await getActivities(page);
let elements = await activitiesList.elementHandles();
Expand All @@ -347,7 +331,6 @@ test.skip("Activity Page with Imported Account", async () => {

// Receive filter
await selectTransactionTypeFilter(page, "Receive");
await wait(1000);
// getting list on activities
activitiesList = await getActivities(page);
elements = await activitiesList.elementHandles();
Expand All @@ -361,7 +344,6 @@ test.skip("Activity Page with Imported Account", async () => {

// Topup filter
await selectTransactionTypeFilter(page, "Topup");
await wait(1000);
// getting list on activities
activitiesList = await getActivities(page);
elements = await activitiesList.elementHandles();
Expand Down
9 changes: 3 additions & 6 deletions tests/e2e/home/home.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import test, { markResult, setBrowserStackTestTitle } from "../fixtures";

test.describe("Home Page", async () => {
let page: Page;
test.beforeAll(async ({ browser, browserName }) => {
test.beforeEach(async ({ browser, browserName }) => {
page = await login(await browser.newContext(), browserName);
});
test.afterAll(async () => {
Expand All @@ -37,7 +37,8 @@ test.describe("Home Page", async () => {
await switchTab(page, "home");

// ENSURE TopUp button click should take to topup page
await clickTopupButton(page);
// await clickTopupButton(page);
await page.click("button >> text=Top up");
await wait(1000);
await ensureTextualElementExists(page, "Select a Provider");
});
Expand All @@ -55,20 +56,17 @@ test.describe("Home Page", async () => {
test("Currency Change should work correctly", async () => {
// see navigation works correctly
await switchTab(page, "home");
await wait(1000);
// Switching to testnet as it has > 0 balance
await switchNetwork(page, "testnet");
expect(await getInnerText(page, "#selected_network")).toContain("Solana Testnet");

// ENSURE On selecting EUR as currency, conversion rate has a positive value
await selectCurrency(page, "EUR");
await wait(1000);
const eurRate = Number(await getInnerText(page, "#conversionRate"));
expect(eurRate).toBeGreaterThan(0);

// ENSURE On selecting USD as currency, conversion rate has a positive value
await selectCurrency(page, "USD");
await wait(1000);
const usdRate = Number(await getInnerText(page, "#conversionRate"));
expect(usdRate).toBeGreaterThan(0);

Expand All @@ -83,7 +81,6 @@ test.describe("Home Page", async () => {
await switchNetwork(page, "testnet");
// Ensure Tokens are displayed
await ensureTextualElementExists(page, "Tokens");
await wait(1000);
await clickTokenIfAvailable(page);
});

Expand Down
10 changes: 5 additions & 5 deletions tests/e2e/login/login.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,24 @@ test("Should Login successfully", async ({ context, browserName }) => {
const page = await login(context, browserName);

await page.click("text=Home");
await wait(1000);
await wait(500);
expect(page.url().includes("/wallet/home")).toBeTruthy();

await page.click("text=NFTs");
await wait(1000);
await wait(500);
expect(page.url().includes("/wallet/nfts")).toBeTruthy();

await page.click("text=Activity");
await wait(1000);
await wait(500);
expect(page.url().includes("/wallet/activity")).toBeTruthy();

// Click text=Settings
await page.click("text=Settings");
await wait(1000);
await wait(500);
expect(page.url().includes("/wallet/settings")).toBeTruthy();

await page.click("text=Discover");
await wait(1000);
await wait(500);
expect(page.url().includes("/wallet/discover")).toBeTruthy();
await page.close();
});
3 changes: 2 additions & 1 deletion tests/e2e/mobile-screen/mobile-screen.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ test.describe("Mobile screens", async () => {
test("Should have all the tabs", async () => {
// eslint-disable-next-line no-restricted-syntax
for (const key of tabs) {
await wait(200);
await wait(1000);
expect(await page.locator(`#${key}_link`).count()).toBeGreaterThan(0);
await wait(200);
}
});

Expand Down
5 changes: 2 additions & 3 deletions tests/e2e/nfts/nfts.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ test.describe("Nfts Page", async () => {
});
test.beforeEach(async () => {
await switchTab(page, "nfts");
await wait(2000);
});

test.afterAll(() => {
Expand All @@ -27,7 +26,6 @@ test.describe("Nfts Page", async () => {
});

test("If no NFTs project eventually load popular NFTs project", async () => {
await wait(1000);
await ensureTextualElementExists(page, "You might be keen to check out some of the popular NFT projects");
expect(await page.locator(".popular-nft").count()).toBeGreaterThan(0);
});
Expand All @@ -43,8 +41,9 @@ test.describe("Nfts Page", async () => {
});

test("Click on NFT should open page with correct information, clicking on Send should take on transfer page", async () => {
test.slow();
await switchNetwork(page, "testnet");
await page.locator(".nft-item").first().click();
await wait(5000);
await page.locator(".send-nft").first().click();
await wait(1000);
await ensureTextualElementExists(page, "Transfer Details");
Expand Down
7 changes: 3 additions & 4 deletions tests/e2e/settings/settings.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import test, { markResult, setBrowserStackTestTitle } from "../fixtures";

test.describe("Settings Page", async () => {
let page: Page;
test.beforeAll(async ({ browser, browserName }) => {
test.beforeEach(async ({ browser, browserName }) => {
page = await login(await browser.newContext(), browserName);
});
test.afterAll(async () => {
Expand Down Expand Up @@ -47,13 +47,13 @@ test.describe("Settings Page", async () => {
test("Theme Change should work", async () => {
// // see navigation works correctly
await switchTab(page, "settings");
await wait(1000);

// **************DISPLAY CHANGES********
// CHOOSE LIGHT
await page.click("text=Light");
await wait(1000);
await expect(await page.locator(".light").elementHandles()).toHaveLength(0);

await wait(1000);
// CHOOSE DARK
await page.click("text=Dark");
await wait(1000);
Expand Down Expand Up @@ -152,7 +152,6 @@ test.describe("Settings Page", async () => {
test("Language change should work", async () => {
// see navigation works correctly
await switchTab(page, "settings");

await changeLanguage(page, "german");
await wait(500);
await ensureTextualElementExists(page, "die Einstellungen");
Expand Down
14 changes: 3 additions & 11 deletions tests/e2e/topup/topup.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ import test, { markResult, setBrowserStackTestTitle } from "../fixtures";

test.describe("Topup page", async () => {
let page: Page;
test.beforeAll(async ({ browser, browserName }) => {
test.beforeEach(async ({ browser, browserName }) => {
page = await login(await browser.newContext(), browserName);
await wait(3000);
});
test.afterAll(() => {
page.close();
Expand All @@ -22,53 +21,46 @@ test.describe("Topup page", async () => {
test("Topup Page Should render", async () => {
// // see navigation works correctly
await page.click("button:has-text('Top up')");
await wait(1000);
// ENSURE UI IS INTACT
await wait(500);
await ensureTextualElementExists(page, "Select a Provider");
});

test("Changing amount changes received value", async () => {
// // see navigation works correctly
await page.click("button:has-text('Top up')");
await wait(1000);
// MoonPay SHOULD WORK AS EXPECTED
// set amount to be transferred as 100 US Dollars, expect a positive value for expected SOL
await page.click("img[alt=moonpay]");
await page.fill("input[type='number']", "100");
await wait(2000);
const usdToSol100 = Number(await getInnerText(page, "#resCryptoAmt"));
expect(usdToSol100).toBeGreaterThan(0);

// set amount to be transferred as 200 US Dollars, expect a positive value for expected SOL
await page.fill("input[type='number']", "200");
await wait(1000);
const usdToSol200 = Number(await getInnerText(page, "#resCryptoAmt"));
await wait(2000);
expect(usdToSol200).toBeGreaterThan(usdToSol100);
});

test("Pop up page should show for top up", async () => {
// // see navigation works correctly
await page.click("button:has-text('Top up')");
await wait(1000);
// MoonPay SHOULD WORK AS EXPECTED
// set amount to be transferred as 100 US Dollars, expect a positive value for expected SOL
await page.click("img[alt=moonpay]");
await page.fill("input[type='number']", "100");
await wait(2000);

// ensure that on clicking Top up, it is redirected to MoonPay Payment page
const [page2] = await Promise.all([page.waitForEvent("popup"), page.click("button:has-text('Top up')")]);
// closing moonpay page, will show an error on top up page
page2.close();
await wait(500);
await wait(1000);
await ensureTextualElementExists(page, "Transaction could not complete.");
});

test("Changing of crypto/fiat currency changes the value you receive correctly", async () => {
// see navigation works correctly
await page.click("button:has-text('Top up')");
await wait(1000);
// change crypto currency to SOL
await switchCryptoCurrency(page, "SOL");
// change fiat currency EUR
Expand Down
Loading