同步移动端源码并修复小程序嵌入标题
Some checks failed
CI / verify (push) Has been cancelled

This commit is contained in:
lyf
2026-07-28 18:37:40 +08:00
parent 06ad609e1f
commit 540bb8627f
62 changed files with 4196 additions and 1410 deletions

View File

@@ -0,0 +1,52 @@
import { describe, expect, it } from 'vitest'
import {
OUTDOOR_BUILDING_EXIT_ZOOM,
OUTDOOR_BUILDING_ENTRY_ZOOM,
canEnterBuildingSemanticMap,
distanceBetweenCoordinatesMeters,
hasReachedOutdoorExitBoundary
} from '@/domain/guideSemanticZoom'
const museum = { latitude: 22.692763, longitude: 114.363572 }
describe('guide semantic zoom', () => {
it('uses a stable outdoor extent below the building-entry threshold', () => {
expect(OUTDOOR_BUILDING_EXIT_ZOOM).toBeLessThan(OUTDOOR_BUILDING_ENTRY_ZOOM)
})
it('starts the outdoor handoff before the 3D camera reaches its hard zoom clamp', () => {
expect(hasReachedOutdoorExitBoundary(92, 100)).toBe(true)
expect(hasReachedOutdoorExitBoundary(91.9, 100)).toBe(false)
expect(hasReachedOutdoorExitBoundary(0, 0)).toBe(false)
})
it('enters the building only when the museum is centered at the entry zoom', () => {
expect(canEnterBuildingSemanticMap({
...museum,
zoom: OUTDOOR_BUILDING_ENTRY_ZOOM
}, museum)).toBe(true)
})
it('does not enter the building when the outdoor map has not been zoomed in enough', () => {
expect(canEnterBuildingSemanticMap({
...museum,
zoom: OUTDOOR_BUILDING_ENTRY_ZOOM - 0.1
}, museum)).toBe(false)
})
it('does not switch for a similarly zoomed but unrelated outdoor location', () => {
expect(canEnterBuildingSemanticMap({
latitude: 22.698,
longitude: 114.37,
zoom: OUTDOOR_BUILDING_ENTRY_ZOOM + 1
}, museum)).toBe(false)
})
it('calculates a usable geographic distance for the focus guard', () => {
expect(distanceBetweenCoordinatesMeters(museum, museum)).toBe(0)
expect(distanceBetweenCoordinatesMeters(museum, {
latitude: 22.693763,
longitude: 114.363572
})).toBeGreaterThan(100)
})
})