完善三维切换浏览器验证
Some checks failed
CI / verify (push) Has been cancelled

This commit is contained in:
lyf
2026-07-13 19:34:26 +08:00
parent 9f642ca6ed
commit e48a8bb626
3 changed files with 45 additions and 14 deletions

View File

@@ -4,7 +4,7 @@ const baseURL = process.env.PLAYWRIGHT_BASE_URL || 'http://127.0.0.1:5173'
export default defineConfig({ export default defineConfig({
testDir: './tests/e2e', testDir: './tests/e2e',
timeout: 180_000, timeout: 600_000,
fullyParallel: false, fullyParallel: false,
use: { use: {
baseURL, baseURL,

View File

@@ -3607,7 +3607,11 @@ const installVisualStabilityDiagnostics = () => {
} }
diagnosticsWindow.__GUIDE_3D_VISUAL_STABILITY__ = { diagnosticsWindow.__GUIDE_3D_VISUAL_STABILITY__ = {
getReport: getVisualStabilityReport, getReport: getVisualStabilityReport,
getFloorIds: () => floorIndex.value.map((floor) => floor.floorId), getFloors: () => floorIndex.value.map((floor) => ({
floorId: floor.floorId,
label: floor.label,
modelMatchKeys: floor.modelMatchKeys || []
})),
switchFloor: handleFloorChange, switchFloor: handleFloorChange,
showOverview, showOverview,
resetCamera resetCamera

View File

@@ -32,9 +32,15 @@ interface VisualReport {
isCameraTweening: boolean isCameraTweening: boolean
} }
interface FloorReport {
floorId: string
label: string
modelMatchKeys: string[]
}
interface VisualStabilityApi { interface VisualStabilityApi {
getReport: () => VisualReport getReport: () => VisualReport
getFloorIds: () => string[] getFloors: () => FloorReport[]
switchFloor: (floorId: string) => Promise<void> switchFloor: (floorId: string) => Promise<void>
showOverview: () => Promise<void> showOverview: () => Promise<void>
} }
@@ -47,7 +53,7 @@ const getApiState = async (page: Page) => {
} }
const api = windowWithDiagnostics.__GUIDE_3D_VISUAL_STABILITY__ const api = windowWithDiagnostics.__GUIDE_3D_VISUAL_STABILITY__
return api return api
? { floorIds: api.getFloorIds(), report: api.getReport() } ? { floors: api.getFloors(), report: api.getReport() }
: null : null
}) })
} catch (error) { } catch (error) {
@@ -162,28 +168,49 @@ const showOverview = async (page: Page, testInfo: TestInfo, name: string) => {
assertStableTransition(before, after) assertStableTransition(before, after)
} }
const normalizeFloorKey = (value: string) => value.trim().toLowerCase().replace(/[^a-z0-9.-]/g, '')
const resolveRequiredFloorId = (floors: FloorReport[], requested: string) => {
const normalizedRequested = normalizeFloorKey(requested)
const floor = floors.find((candidate) => (
[candidate.floorId, candidate.label, ...candidate.modelMatchKeys]
.some((value) => normalizeFloorKey(value) === normalizedRequested)
))
expect(floor, `missing requested floor ${requested}`).toBeDefined()
return floor!.floorId
}
test('ordinary exterior and floor switches preserve the GLB_METER camera projection', async ({ page }, testInfo) => { test('ordinary exterior and floor switches preserve the GLB_METER camera projection', async ({ page }, testInfo) => {
await page.goto('/') await page.goto('/')
await page.getByText('馆内', { exact: true }).click() await Promise.all([
page.waitForURL(/tab=guide/, { timeout: 30_000 }),
page.getByText('馆内', { exact: true }).click()
])
await expect.poll(async () => (await getApiState(page)) !== null, { timeout: 180_000 }).toBe(true) await expect.poll(async () => (await getApiState(page)) !== null, { timeout: 180_000 }).toBe(true)
await expect.poll(async () => (await getApiState(page))?.report.anchors.length ?? 0, { await expect.poll(async () => (await getApiState(page))?.report.anchors.length ?? 0, {
timeout: 180_000 timeout: 180_000
}).toBe(3) }).toBe(3)
const state = await getApiState(page) const state = await getApiState(page)
expect(state?.floorIds).toEqual(expect.arrayContaining(['L-2', 'L1', 'L1.5', 'L2', 'L3', 'L5'])) expect(state).not.toBeNull()
const lMinus2 = resolveRequiredFloorId(state!.floors, 'L-2')
const l1 = resolveRequiredFloorId(state!.floors, 'L1')
const l1Point5 = resolveRequiredFloorId(state!.floors, 'L1.5')
const l2 = resolveRequiredFloorId(state!.floors, 'L2')
const l3 = resolveRequiredFloorId(state!.floors, 'L3')
const l5 = resolveRequiredFloorId(state!.floors, 'L5')
await switchFloor(page, testInfo, 'L1', 'exterior-l1') await switchFloor(page, testInfo, l1, 'exterior-l1')
await switchFloor(page, testInfo, 'L2', 'l1-l2') await switchFloor(page, testInfo, l2, 'l1-l2')
await switchFloor(page, testInfo, 'L3', 'l2-l3') await switchFloor(page, testInfo, l3, 'l2-l3')
await switchFloor(page, testInfo, 'L1', 'l3-l1') await switchFloor(page, testInfo, l1, 'l3-l1')
await showOverview(page, testInfo, 'l1-exterior') await showOverview(page, testInfo, 'l1-exterior')
await switchFloor(page, testInfo, 'L-2', 'exterior-lminus2') await switchFloor(page, testInfo, lMinus2, 'exterior-lminus2')
await switchFloor(page, testInfo, 'L5', 'lminus2-l5') await switchFloor(page, testInfo, l5, 'lminus2-l5')
await switchFloor(page, testInfo, 'L-2', 'l5-lminus2') await switchFloor(page, testInfo, lMinus2, 'l5-lminus2')
await showOverview(page, testInfo, 'lminus2-exterior') await showOverview(page, testInfo, 'lminus2-exterior')
await switchFloor(page, testInfo, 'L1.5', 'exterior-l1point5') await switchFloor(page, testInfo, l1Point5, 'exterior-l1point5')
await showOverview(page, testInfo, 'l1point5-exterior') await showOverview(page, testInfo, 'l1point5-exterior')
}) })