Expanded solutions (10 new industries) and products (Compliance & Data section) to cover full docs.lux.financial capability surface.
103 lines
4.3 KiB
TypeScript
103 lines
4.3 KiB
TypeScript
import { test, expect } from '@playwright/test'
|
|
import { getUrls, httpStatus, getCurrentValidators, snap } from './helpers'
|
|
|
|
const urls = getUrls()
|
|
|
|
/** Check if lux.build is reachable before running page tests */
|
|
async function skipIfUnreachable(request: any) {
|
|
const status = await httpStatus(request, urls.staking, 10_000)
|
|
if (status === 0) {
|
|
test.skip(true, 'lux.build is unreachable (connection refused/timeout)')
|
|
}
|
|
}
|
|
|
|
// ── Staking Reachability ────────────────────────────────────────────
|
|
test.describe('Staking — Reachability', () => {
|
|
test('lux.build responds', async ({ request }) => {
|
|
const status = await httpStatus(request, urls.staking, 15_000)
|
|
console.log(` lux.build HTTP: ${status}`)
|
|
expect(status).toBeGreaterThan(0)
|
|
})
|
|
})
|
|
|
|
// ── lux.build — Frontend ────────────────────────────────────────────
|
|
test.describe('Staking — lux.build Frontend', () => {
|
|
test('lux.build loads', async ({ request, page }) => {
|
|
await skipIfUnreachable(request)
|
|
const res = await page.goto(urls.staking, { timeout: 30_000, waitUntil: 'domcontentloaded' })
|
|
const status = res?.status() || 0
|
|
expect([200, 301, 302, 307]).toContain(status)
|
|
await snap(page, 'staking-home')
|
|
})
|
|
|
|
test('staking page has visible UI', async ({ request, page }) => {
|
|
await skipIfUnreachable(request)
|
|
await page.goto(urls.staking, { timeout: 30_000, waitUntil: 'domcontentloaded' })
|
|
await page.waitForTimeout(5000)
|
|
await snap(page, 'staking-ui')
|
|
})
|
|
})
|
|
|
|
// ── lux.build — Delegation UI ───────────────────────────────────────
|
|
test.describe('Staking — Delegation', () => {
|
|
test('delegation page shows validators', async ({ request, page }) => {
|
|
await skipIfUnreachable(request)
|
|
await page.goto(urls.staking, { timeout: 30_000, waitUntil: 'domcontentloaded' })
|
|
await page.waitForTimeout(5000)
|
|
const stakingUI = page.locator(
|
|
'[class*="validator"], [class*="Validator"], [class*="delegate"], [class*="Delegate"], ' +
|
|
'[class*="stake"], [class*="Stake"], ' +
|
|
'text=/validator/i, text=/delegate/i, text=/stake/i'
|
|
).first()
|
|
const visible = await stakingUI.isVisible({ timeout: 10_000 }).catch(() => false)
|
|
if (visible) {
|
|
await snap(page, 'staking-validators')
|
|
}
|
|
expect(await page.title()).toBeTruthy()
|
|
})
|
|
|
|
test('can navigate to delegation flow', async ({ request, page }) => {
|
|
await skipIfUnreachable(request)
|
|
await page.goto(urls.staking, { timeout: 30_000, waitUntil: 'domcontentloaded' })
|
|
await page.waitForTimeout(3000)
|
|
const delegateBtn = page.locator(
|
|
'a:has-text("Delegate"), a:has-text("Stake"), button:has-text("Delegate"), button:has-text("Stake")'
|
|
).first()
|
|
const visible = await delegateBtn.isVisible({ timeout: 5_000 }).catch(() => false)
|
|
if (visible) {
|
|
await delegateBtn.click()
|
|
await page.waitForTimeout(3000)
|
|
await snap(page, 'staking-delegate-flow')
|
|
}
|
|
expect(await page.title()).toBeTruthy()
|
|
})
|
|
})
|
|
|
|
// ── P-Chain Delegation Data ─────────────────────────────────────────
|
|
test.describe('Staking — P-Chain Validator Data', () => {
|
|
test('validators have staking parameters', async ({ request }) => {
|
|
const validators = await getCurrentValidators(request, urls.rpcPlatform) as {
|
|
nodeID: string
|
|
startTime: string
|
|
endTime: string
|
|
}[]
|
|
expect(validators.length).toBeGreaterThanOrEqual(5)
|
|
for (const v of validators) {
|
|
expect(v.nodeID).toBeTruthy()
|
|
expect(v.startTime).toBeTruthy()
|
|
expect(v.endTime).toBeTruthy()
|
|
}
|
|
console.log(` ${validators.length} validators with staking params`)
|
|
})
|
|
|
|
test('validators accept delegation', async ({ request }) => {
|
|
const validators = await getCurrentValidators(request, urls.rpcPlatform) as {
|
|
nodeID: string
|
|
delegationFee: string
|
|
}[]
|
|
const withDelegation = validators.filter(v => v.delegationFee !== undefined)
|
|
console.log(` ${withDelegation.length}/${validators.length} accept delegation`)
|
|
expect(withDelegation.length).toBeGreaterThan(0)
|
|
})
|
|
})
|