Skip to content

Commit

Permalink
Merge pull request #566 from chatch/fulfill-smoke-test
Browse files Browse the repository at this point in the history
fulfill smoke test
  • Loading branch information
chatch authored Dec 20, 2023
2 parents d0153a2 + 14e3c1a commit 947d4e8
Show file tree
Hide file tree
Showing 3 changed files with 227 additions and 21 deletions.
182 changes: 170 additions & 12 deletions e2e/production.spec.ts
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')
})
48 changes: 48 additions & 0 deletions e2e/utils.ts
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()
}
18 changes: 9 additions & 9 deletions playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ export default defineConfig({
use: { ...devices['Desktop Chrome'] },
},

{
name: 'firefox',
use: { ...devices['Desktop Firefox'] },
},
// {
// name: 'firefox',
// use: { ...devices['Desktop Firefox'] },
// },

{
name: 'webkit',
use: { ...devices['Desktop Safari'] },
},
// {
// name: 'webkit',
// use: { ...devices['Desktop Safari'] },
// },

/* Test against mobile viewports. */
// {
Expand Down Expand Up @@ -74,5 +74,5 @@ export default defineConfig({
// url: 'http://127.0.0.1:3000',
// reuseExistingServer: !process.env.CI,
// },
timeout: 5 * 1000,
timeout: 30 * 1000,
})

0 comments on commit 947d4e8

Please sign in to comment.