From e48a8bb626bf12c7b58c25570d5c146f37ee70b8 Mon Sep 17 00:00:00 2001 From: lyf <2514544224@qq.com> Date: Mon, 13 Jul 2026 19:34:26 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E4=B8=89=E7=BB=B4=E5=88=87?= =?UTF-8?q?=E6=8D=A2=E6=B5=8F=E8=A7=88=E5=99=A8=E9=AA=8C=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- playwright.config.ts | 2 +- src/components/map/ThreeMap.vue | 6 ++- tests/e2e/three-map-camera-stability.spec.ts | 51 +++++++++++++++----- 3 files changed, 45 insertions(+), 14 deletions(-) diff --git a/playwright.config.ts b/playwright.config.ts index d091aa9..5aacf0d 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -4,7 +4,7 @@ const baseURL = process.env.PLAYWRIGHT_BASE_URL || 'http://127.0.0.1:5173' export default defineConfig({ testDir: './tests/e2e', - timeout: 180_000, + timeout: 600_000, fullyParallel: false, use: { baseURL, diff --git a/src/components/map/ThreeMap.vue b/src/components/map/ThreeMap.vue index a159adb..fa9467d 100644 --- a/src/components/map/ThreeMap.vue +++ b/src/components/map/ThreeMap.vue @@ -3607,7 +3607,11 @@ const installVisualStabilityDiagnostics = () => { } diagnosticsWindow.__GUIDE_3D_VISUAL_STABILITY__ = { 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, showOverview, resetCamera diff --git a/tests/e2e/three-map-camera-stability.spec.ts b/tests/e2e/three-map-camera-stability.spec.ts index 4556f01..0433047 100644 --- a/tests/e2e/three-map-camera-stability.spec.ts +++ b/tests/e2e/three-map-camera-stability.spec.ts @@ -32,9 +32,15 @@ interface VisualReport { isCameraTweening: boolean } +interface FloorReport { + floorId: string + label: string + modelMatchKeys: string[] +} + interface VisualStabilityApi { getReport: () => VisualReport - getFloorIds: () => string[] + getFloors: () => FloorReport[] switchFloor: (floorId: string) => Promise showOverview: () => Promise } @@ -47,7 +53,7 @@ const getApiState = async (page: Page) => { } const api = windowWithDiagnostics.__GUIDE_3D_VISUAL_STABILITY__ return api - ? { floorIds: api.getFloorIds(), report: api.getReport() } + ? { floors: api.getFloors(), report: api.getReport() } : null }) } catch (error) { @@ -162,28 +168,49 @@ const showOverview = async (page: Page, testInfo: TestInfo, name: string) => { 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) => { 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))?.report.anchors.length ?? 0, { timeout: 180_000 }).toBe(3) 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, 'L2', 'l1-l2') - await switchFloor(page, testInfo, 'L3', 'l2-l3') - await switchFloor(page, testInfo, 'L1', 'l3-l1') + await switchFloor(page, testInfo, l1, 'exterior-l1') + await switchFloor(page, testInfo, l2, 'l1-l2') + await switchFloor(page, testInfo, l3, 'l2-l3') + await switchFloor(page, testInfo, l1, 'l3-l1') await showOverview(page, testInfo, 'l1-exterior') - await switchFloor(page, testInfo, 'L-2', 'exterior-lminus2') - await switchFloor(page, testInfo, 'L5', 'lminus2-l5') - await switchFloor(page, testInfo, 'L-2', 'l5-lminus2') + await switchFloor(page, testInfo, lMinus2, 'exterior-lminus2') + await switchFloor(page, testInfo, l5, 'lminus2-l5') + await switchFloor(page, testInfo, lMinus2, 'l5-lminus2') 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') })