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 all 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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"build": "npm run locale && vue-cli-service build",
"lint": "vue-cli-service lint",
"prepare": "husky install",
"test": "npx playwright test --config=playwright.config.ts --workers=1",
"test": "npx playwright test --config=playwright.config.ts --workers=10",
"test:browserstack": "npx playwright test --config=playwright-browserstack.config.ts --workers=1",
"test:controller": "npx mocha ./tests/controller/**.ts",
"test:report": "rm -rf .nyc_output && rm -rf coverage && npx nyc --reporter=text --reporter=html npm run test:controller",
Expand Down
2 changes: 1 addition & 1 deletion src/utils/const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export const WALLET_SUPPORTED_NETWORKS = {
...SUPPORTED_NETWORKS,
mainnet: {
...SUPPORTED_NETWORKS.mainnet,
rpcTarget: "https://green-dark-sky.solana-mainnet.quiknode.pro/0b4b99540b7930cf590dc7fb0a2d1c9a906fd53c/",
rpcTarget: "https://green-dark-sky.solana-mainnet.quiknode.pro/97c87069b81ef4ec0765a267525c82153e5404fc/",
},
testnet: {
...SUPPORTED_NETWORKS.testnet,
Expand Down
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
Loading