This commit is contained in:
76
tests/e2e/guide-performance.spec.ts
Normal file
76
tests/e2e/guide-performance.spec.ts
Normal file
@@ -0,0 +1,76 @@
|
||||
import { expect, test } from '@playwright/test'
|
||||
|
||||
interface GuidePerformanceSummary {
|
||||
operationCount: number
|
||||
operations: Array<{
|
||||
kind: string
|
||||
name: string
|
||||
p50Ms?: number
|
||||
p95Ms?: number
|
||||
}>
|
||||
}
|
||||
|
||||
interface GuidePerformanceApi {
|
||||
snapshot: () => Array<{ kind: string; name: string; outcome: string }>
|
||||
summary: () => GuidePerformanceSummary
|
||||
}
|
||||
|
||||
test('publishes model and POI label performance metrics in the H5 runtime', async ({ page }) => {
|
||||
await page.goto('/')
|
||||
await page.waitForURL(/tab=guide/, { timeout: 30_000 })
|
||||
|
||||
await expect.poll(async () => page.evaluate(() => (
|
||||
(window as Window & { __GUIDE_3D_VISUAL_STABILITY__?: { isInitialModelReady: () => boolean } })
|
||||
.__GUIDE_3D_VISUAL_STABILITY__?.isInitialModelReady() || false
|
||||
)), { timeout: 180_000 }).toBe(true)
|
||||
|
||||
await expect.poll(async () => page.evaluate(() => {
|
||||
const api = (window as Window & { __SGS_GUIDE_PERFORMANCE__?: GuidePerformanceApi })
|
||||
.__SGS_GUIDE_PERFORMANCE__
|
||||
return api?.snapshot().some((record) => (
|
||||
record.kind === 'interaction' && record.name === 'poi-label-first-render' && record.outcome === 'success'
|
||||
)) || false
|
||||
}), { timeout: 30_000 }).toBe(true)
|
||||
|
||||
const summary = await page.evaluate(() => (
|
||||
(window as Window & { __SGS_GUIDE_PERFORMANCE__?: GuidePerformanceApi })
|
||||
.__SGS_GUIDE_PERFORMANCE__?.summary()
|
||||
))
|
||||
|
||||
expect(summary).toBeTruthy()
|
||||
console.log(`[guide-performance] ${JSON.stringify(summary)}`)
|
||||
expect(summary!.operationCount).toBeGreaterThan(0)
|
||||
expect(summary!.operations).toEqual(expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
kind: 'model'
|
||||
}),
|
||||
expect.objectContaining({
|
||||
kind: 'interaction',
|
||||
name: 'poi-label-first-render'
|
||||
})
|
||||
]))
|
||||
|
||||
await page.getByText('+', { exact: true }).click()
|
||||
await expect(page.locator('.floor-switcher')).toBeVisible({ timeout: 30_000 })
|
||||
const targetFloor = page.locator('.floor-item:not(.active)').first()
|
||||
await expect(targetFloor).toBeVisible({ timeout: 30_000 })
|
||||
const targetFloorLabel = await targetFloor.locator('.floor-label').innerText()
|
||||
await targetFloor.click()
|
||||
await expect(page.locator('.floor-item.active .floor-label')).toHaveText(targetFloorLabel, {
|
||||
timeout: 120_000
|
||||
})
|
||||
|
||||
await page.locator('.search-box').click()
|
||||
await expect(page.locator('[data-testid="poi-result-list"] .result-row').first())
|
||||
.toBeVisible({ timeout: 30_000 })
|
||||
|
||||
const interactionSummary = await page.evaluate(() => (
|
||||
(window as Window & { __SGS_GUIDE_PERFORMANCE__?: GuidePerformanceApi })
|
||||
.__SGS_GUIDE_PERFORMANCE__?.summary()
|
||||
))
|
||||
console.log(`[guide-performance-interactions] ${JSON.stringify(interactionSummary)}`)
|
||||
expect(interactionSummary?.operations).toEqual(expect.arrayContaining([
|
||||
expect.objectContaining({ kind: 'interaction', name: 'floor-switch', successCount: 1 }),
|
||||
expect.objectContaining({ kind: 'interaction', name: 'poi-search-data', successCount: 1 })
|
||||
]))
|
||||
})
|
||||
Reference in New Issue
Block a user