-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #566 from chatch/fulfill-smoke-test
fulfill smoke test
- Loading branch information
Showing
3 changed files
with
227 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,209 @@ | ||
import { test, expect } from '@playwright/test' | ||
import { clickLinkAndVerify, getFirstLink, verifyOpeningNewPage } from './utils' | ||
|
||
const baseUrl = 'https://steexp.com' | ||
|
||
test('top page', async ({ page }) => { | ||
await page.goto('https://steexp.com/') | ||
await page.goto(`${baseUrl}/`) | ||
await expect(page).toHaveTitle('Stellar Explorer | Home') | ||
|
||
// Click account link | ||
const accountLink = await getFirstLink(page, 0) | ||
await clickLinkAndVerify( | ||
baseUrl, | ||
page, | ||
accountLink, | ||
'Stellar Explorer | Account Balances', | ||
) | ||
}) | ||
|
||
test('operations', async ({ page }) => { | ||
await page.goto('https://steexp.com/operations') | ||
const targetUrl = `${baseUrl}/operations` | ||
|
||
await page.goto(targetUrl) | ||
await expect(page).toHaveTitle('Stellar Explorer | Operations') | ||
|
||
// Click account link | ||
const accountLink = await getFirstLink(page, 0) | ||
await clickLinkAndVerify( | ||
baseUrl, | ||
page, | ||
accountLink, | ||
'Stellar Explorer | Account Balances', | ||
) | ||
|
||
// Click transaction link | ||
await page.goto(targetUrl) | ||
const transactionLink = await getFirstLink(page, 2) | ||
await clickLinkAndVerify( | ||
baseUrl, | ||
page, | ||
transactionLink, | ||
'Stellar Explorer | Transaction', | ||
) | ||
}) | ||
|
||
test('transactions', async ({ page }) => { | ||
await page.goto('https://steexp.com/txs') | ||
const targetUrl = `${baseUrl}/txs` | ||
|
||
await page.goto(targetUrl) | ||
await expect(page).toHaveTitle('Stellar Explorer | Transactions') | ||
|
||
// Click transaction link | ||
const transactionLink = await getFirstLink(page, 0) | ||
await clickLinkAndVerify( | ||
baseUrl, | ||
page, | ||
transactionLink, | ||
'Stellar Explorer | Transaction', | ||
) | ||
|
||
// Click account link | ||
await page.goto(targetUrl) | ||
const accountLink = await getFirstLink(page, 1) | ||
await clickLinkAndVerify( | ||
baseUrl, | ||
page, | ||
accountLink, | ||
'Stellar Explorer | Account Balances', | ||
) | ||
|
||
// Click ledger link | ||
await page.goto(targetUrl) | ||
const ledgerLink = await getFirstLink(page, 2) | ||
await clickLinkAndVerify( | ||
baseUrl, | ||
page, | ||
ledgerLink, | ||
'Stellar Explorer | Ledger', | ||
) | ||
}) | ||
|
||
test('ledgers', async ({ page }) => { | ||
await page.goto('https://steexp.com/ledgers') | ||
const targetUrl = `${baseUrl}/ledgers` | ||
|
||
await page.goto(targetUrl) | ||
await expect(page).toHaveTitle('Stellar Explorer | Ledgers') | ||
|
||
// Click ledger link | ||
const ledgerLink = await getFirstLink(page, 0) | ||
await clickLinkAndVerify( | ||
baseUrl, | ||
page, | ||
ledgerLink, | ||
'Stellar Explorer | Ledger', | ||
) | ||
}) | ||
|
||
test('assets', async ({ page }) => { | ||
await page.goto('https://steexp.com/assets') | ||
test('assets', async ({ page, context }) => { | ||
const targetUrl = `${baseUrl}/assets` | ||
|
||
await page.goto(targetUrl) | ||
await expect(page).toHaveTitle('Stellar Explorer | Assets') | ||
|
||
// Click asset link | ||
const assetLink = await getFirstLink(page, 0) | ||
await verifyOpeningNewPage(page, context, assetLink) | ||
}) | ||
|
||
test('anchors', async ({ page }) => { | ||
await page.goto('https://steexp.com/anchors') | ||
const targetUrl = `${baseUrl}/anchors` | ||
|
||
await page.goto(targetUrl) | ||
await expect(page).toHaveTitle('Stellar Explorer | Anchors') | ||
|
||
// Click anchors link | ||
const anchorLink = await getFirstLink(page, 0) | ||
await clickLinkAndVerify( | ||
baseUrl, | ||
page, | ||
anchorLink, | ||
'Stellar Explorer | Anchor', | ||
) | ||
}) | ||
|
||
test('exchanges', async ({ page }) => { | ||
await page.goto('https://steexp.com/exchanges') | ||
test('exchanges', async ({ page, context }) => { | ||
const targetUrl = `${baseUrl}/exchanges` | ||
|
||
await page.goto(targetUrl) | ||
await expect(page).toHaveTitle('Stellar Explorer | Exchanges') | ||
|
||
// Click asset link | ||
const exchangeLink = await getFirstLink(page, 0) | ||
await verifyOpeningNewPage(page, context, exchangeLink) | ||
}) | ||
|
||
test('effects', async ({ page }) => { | ||
await page.goto('https://steexp.com/effects') | ||
const targetUrl = `${baseUrl}/effects` | ||
|
||
await page.goto(targetUrl) | ||
await expect(page).toHaveTitle('Stellar Explorer | Effects') | ||
|
||
// Click account link | ||
const accountLink = await getFirstLink(page, 0) | ||
await clickLinkAndVerify( | ||
baseUrl, | ||
page, | ||
accountLink, | ||
'Stellar Explorer | Account Balances', | ||
) | ||
}) | ||
|
||
test('payments', async ({ page }) => { | ||
await page.goto('https://steexp.com/payments') | ||
const targetUrl = `${baseUrl}/payments` | ||
|
||
await page.goto(targetUrl) | ||
await expect(page).toHaveTitle('Stellar Explorer | Payments') | ||
|
||
// Click account link | ||
const accountLink = await getFirstLink(page, 0) | ||
await clickLinkAndVerify( | ||
baseUrl, | ||
page, | ||
accountLink, | ||
'Stellar Explorer | Account Balances', | ||
) | ||
|
||
// Click transaction link | ||
await page.goto(targetUrl) | ||
const transactionLink = await getFirstLink(page, 2) | ||
await clickLinkAndVerify( | ||
baseUrl, | ||
page, | ||
transactionLink, | ||
'Stellar Explorer | Transaction', | ||
) | ||
}) | ||
|
||
test('trades', async ({ page }) => { | ||
await page.goto('https://steexp.com/trades') | ||
const targetUrl = `${baseUrl}/trades` | ||
|
||
await page.goto(targetUrl) | ||
await expect(page).toHaveTitle('Stellar Explorer | Trades') | ||
|
||
// Click account 1 link | ||
const account1Link = await getFirstLink(page, 0) | ||
await clickLinkAndVerify( | ||
baseUrl, | ||
page, | ||
account1Link, | ||
'Stellar Explorer | Account Balances', | ||
) | ||
|
||
// Click account 2 link | ||
await page.goto(targetUrl) | ||
const account2Link = await getFirstLink(page, 2) | ||
await clickLinkAndVerify( | ||
baseUrl, | ||
page, | ||
account2Link, | ||
'Stellar Explorer | Account Balances', | ||
) | ||
}) | ||
|
||
test('pools', async ({ page }) => { | ||
const targetUrl = `${baseUrl}/pools` | ||
|
||
await page.goto(targetUrl) | ||
await expect(page).toHaveTitle('Stellar Explorer | Liquidity Pools') | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import type { BrowserContext, Locator, Page } from '@playwright/test' | ||
import { expect } from '@playwright/test' | ||
|
||
export const getFirstLink = async ( | ||
page: Page, | ||
columnNum: number, | ||
): Promise<Locator> => { | ||
let rowNum = 0 | ||
let row = page.locator('tbody tr').nth(rowNum) | ||
while (await row.locator('td').nth(columnNum).locator('a').isHidden()) { | ||
rowNum++ | ||
row = page.locator('tbody tr').nth(rowNum) | ||
} | ||
|
||
return row.locator('td').nth(columnNum).locator('a') | ||
} | ||
|
||
export const clickLinkAndVerify = async ( | ||
baseUrl: string, | ||
page: Page, | ||
linkLocator: Locator, | ||
title: string, | ||
): Promise<void> => { | ||
const linkUrl = (await linkLocator.getAttribute('href')) || '' | ||
const expectedText = linkUrl?.split('/').pop() | ||
const expectedTitle = `${title} ${expectedText}` | ||
await linkLocator.click() | ||
await page.waitForTimeout(3000) | ||
const expectedUrl = new URL(linkUrl, baseUrl).toString() | ||
expect(page.url()).toBe(expectedUrl) | ||
|
||
await expect(page).toHaveTitle(expectedTitle) | ||
expect(await page.textContent('body')).toContain(expectedText) | ||
} | ||
|
||
export const verifyOpeningNewPage = async ( | ||
page: Page, | ||
context: BrowserContext, | ||
linkLocator: Locator, | ||
): Promise<void> => { | ||
const linkUrl = await linkLocator.getAttribute('href') | ||
|
||
await linkLocator.click() | ||
await page.waitForTimeout(3000) | ||
const allPages = context.pages() | ||
const allPageUrls = allPages.map((p: Page) => p.url()) | ||
expect(allPageUrls.includes(`${linkUrl}/`)).toBeTruthy() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters