Skip to content

Commit

Permalink
feat: adding tests for blog articles (#1356)
Browse files Browse the repository at this point in the history
  • Loading branch information
bojank93 authored Oct 1, 2024
1 parent a03e944 commit 176753a
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 8 deletions.
35 changes: 28 additions & 7 deletions tests/e2e.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import {
itemInSettingsMenuToBeVisible,
openMainMenu,
tabInHeader,
sectionOnTheBlogPage,
checkSocialNetworkIcons,
} from './testData/commonFunctions';

test.describe('Jumper full e2e flow', () => {
Expand Down Expand Up @@ -92,34 +94,53 @@ test.describe('Jumper full e2e flow', () => {
await expect(page.getByRole('menu')).not.toBeVisible();
});

test('Should be able to navigate to profile and open Explore Filament Mission', async ({
test('Should be able to navigate to profile and open Explore WoodSwap Mission', async ({
page,
}) => {
let profileUrl = `${await page.url()}profile`;
const whatIsFilamentTitle = page.locator(
'xpath=//p[normalize-space(text())="Explore Filament"]',
const whatIsWoodSwapTitle = page.locator(
'xpath=//p[normalize-space(text())="Explore WoodSwap"]',
);
await openMainMenu(page);
await expectMenuToBeVisible(page);
await itemInMenu(page, 'Jumper Profile');
expect(await page.url()).toBe(profileUrl);
await page.locator('.profile-page').isVisible();
await page
.locator('xpath=//p[normalize-space(text())="Explore Filament"]')
.locator('xpath=//p[normalize-space(text())="Explore WoodSwap"]')
.click();

await expect(whatIsFilamentTitle).toBeInViewport({ timeout: 15000 });
await expect(whatIsWoodSwapTitle).toBeInViewport({ timeout: 15000 });
});

test('Should be able to navigate to jumper learn', async ({ page }) => {
test('Should be able to navigate to the Jumper Learn', async ({ page }) => {
const sectionName = [
'Announcement',
'Partner',
'Bridge',
'Swap',
'Tutorial',
'Knowledge',
];
const socialNetworks = ['LinkedIn', 'Facebook', 'X'];
const jumperIsLiveOnSolanaArticlet = await page.locator(
'xpath=//h2[normalize-space(text())="Jumper is Live on Solana!"]',
);
const articleTitle = await page.locator(
'xpath=//h2[normalize-space(text())="The most awaited release is here, Jumper is live on Solana!"]',
);
let learnUrl = `${await page.url()}learn`;
// await closeWelcomeScreen(page);
await openMainMenu(page);
await expectMenuToBeVisible(page);
await itemInMenu(page, 'Jumper Learn');
expect(await page.url()).toBe(learnUrl);
await page.waitForLoadState('load');
await page.locator('.learn-page').isVisible();
sectionOnTheBlogPage(page, sectionName);
await jumperIsLiveOnSolanaArticlet.click();
await page.waitForLoadState('load');
await expect(articleTitle).toBeVisible();
checkSocialNetworkIcons(page, socialNetworks);
});

test('Should be able to navigate to LI.FI Scan', async ({ page }) => {
Expand Down
22 changes: 21 additions & 1 deletion tests/testData/commonFunctions.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { Page } from '@playwright/test';
import { expect } from '@playwright/test';
import exp from 'constants';

export async function findTheBestRoute(page) {
await page.getByRole('heading', { name: 'Find the best route' });
Expand All @@ -9,10 +10,10 @@ export async function openMainMenu(page) {
await page.locator('#main-burger-menu-button').click();
}


export async function itemInMenu(page, option: string) {
await page.getByRole('menuitem', { name: option }).click({ timeout: 20000 });
}

export async function closeWelcomeScreen(page: Page) {
return page.locator('#get-started-button').click();
}
Expand All @@ -24,18 +25,37 @@ export async function tabInHeader(page, name: string) {
export async function expectMenuToBeVisible(page) {
await expect(page.getByRole('menu')).toBeVisible();
}

export async function expectBackgroundColorToHaveCss(page, rgb: string) {
const backgroundColor = await page.locator('xpath=/html/body/div[1]');
expect(backgroundColor).toHaveCSS(`background-color`, rgb);
}

export async function itemInSettingsMenu(page, selector: string) {
await page
.locator(`xpath=//p[normalize-space(text())="${selector}"]`)
.click();
}

export async function itemInSettingsMenuToBeVisible(page, selector: string) {
const itemName = await page.locator(
`xpath=//button[normalize-space(text())="${selector}"]`,
);
expect(itemName).toBeVisible();
}

export async function sectionOnTheBlogPage(page, selectors: string[]) {
for (const selector of selectors) {
const sectionName = await page.locator(`#${selector}`);
expect(sectionName).toBeVisible();
}
}

export async function checkSocialNetworkIcons(page, networks: string[]) {
for (const network of networks) {
const socialNetworkIcon = await page.locator(
`xpath=//button[@aria-label='Share article on ${network}']`,
);
await expect(socialNetworkIcon).toBeEnabled();
}
}

0 comments on commit 176753a

Please sign in to comment.