完善活动运营域与联调标准化
This commit is contained in:
@@ -7,7 +7,9 @@ import { getGameModeDefaults } from '../miniprogram/game/core/gameModeDefaults'
|
||||
import { GameRuntime } from '../miniprogram/game/core/gameRuntime'
|
||||
import { ScoreORule } from '../miniprogram/game/rules/scoreORule'
|
||||
import { resolveSystemSettingsState } from '../miniprogram/game/core/systemSettingsState'
|
||||
import { adaptBackendLaunchResultToEnvelope } from '../miniprogram/utils/backendLaunchAdapter'
|
||||
import { type GameDefinition } from '../miniprogram/game/core/gameDefinition'
|
||||
import { type BackendLaunchResult } from '../miniprogram/utils/backendApi'
|
||||
import { type OrienteeringCourseData } from '../miniprogram/utils/orienteeringCourse'
|
||||
|
||||
type StorageMap = Record<string, unknown>
|
||||
@@ -297,6 +299,70 @@ function testRuntimeRestoreDefinition(): void {
|
||||
assert(restoreResult.presentation.hud.punchButtonText === runtime.presentation.hud.punchButtonText, '恢复后 HUD 关键按钮文案应可重建')
|
||||
}
|
||||
|
||||
function testLaunchRuntimeAdapter(): void {
|
||||
const launchResult: BackendLaunchResult = {
|
||||
event: {
|
||||
id: 'evt_demo_variant_manual_001',
|
||||
displayName: 'Manual Variant Demo',
|
||||
},
|
||||
launch: {
|
||||
source: 'event',
|
||||
config: {
|
||||
configUrl: 'https://example.com/runtime.json',
|
||||
configLabel: 'runtime demo',
|
||||
releaseId: 'rel_runtime_001',
|
||||
routeCode: 'route-variant-b',
|
||||
},
|
||||
business: {
|
||||
source: 'direct-event',
|
||||
eventId: 'evt_demo_variant_manual_001',
|
||||
sessionId: 'sess_001',
|
||||
sessionToken: 'token_001',
|
||||
sessionTokenExpiresAt: '2026-04-03T16:00:00+08:00',
|
||||
routeCode: 'route-variant-b',
|
||||
},
|
||||
variant: {
|
||||
id: 'variant_b',
|
||||
name: 'B 线',
|
||||
routeCode: 'route-variant-b',
|
||||
assignmentMode: 'manual',
|
||||
},
|
||||
runtime: {
|
||||
runtimeBindingId: 'rtb_001',
|
||||
placeId: 'place_campus',
|
||||
placeName: '示范校园',
|
||||
mapId: 'map_main',
|
||||
mapName: '主图',
|
||||
tileReleaseId: 'tile_rel_001',
|
||||
courseSetId: 'course_set_001',
|
||||
courseVariantId: 'variant_b',
|
||||
routeCode: 'route-variant-b',
|
||||
},
|
||||
presentation: {
|
||||
presentationId: 'pres_001',
|
||||
templateKey: 'campus-v1',
|
||||
version: 'v3',
|
||||
},
|
||||
contentBundle: {
|
||||
bundleId: 'bundle_001',
|
||||
bundleType: 'quiz-pack',
|
||||
version: 'v7',
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
const envelope = adaptBackendLaunchResultToEnvelope(launchResult)
|
||||
assert(!!envelope.runtime, 'launch.runtime 应映射到 GameLaunchEnvelope.runtime')
|
||||
assert(envelope.runtime!.runtimeBindingId === 'rtb_001', 'runtimeBindingId 应正确适配')
|
||||
assert(envelope.runtime!.placeName === '示范校园', 'placeName 应正确适配')
|
||||
assert(envelope.runtime!.mapName === '主图', 'mapName 应正确适配')
|
||||
assert(envelope.runtime!.courseVariantId === 'variant_b', 'courseVariantId 应正确适配')
|
||||
assert(envelope.runtime!.routeCode === 'route-variant-b', 'runtime routeCode 应优先保留后端透出值')
|
||||
assert(!!envelope.variant && envelope.variant.variantName === 'B 线', 'variant 摘要应继续保持兼容')
|
||||
assert(!!envelope.presentation && envelope.presentation.presentationId === 'pres_001', 'launch.presentation 应映射到 GameLaunchEnvelope.presentation')
|
||||
assert(!!envelope.contentBundle && envelope.contentBundle.bundleId === 'bundle_001', 'launch.contentBundle 应映射到 GameLaunchEnvelope.contentBundle')
|
||||
}
|
||||
|
||||
function run(): void {
|
||||
createWxStorage({})
|
||||
testControlInheritance()
|
||||
@@ -305,6 +371,7 @@ function run(): void {
|
||||
testTimeoutEndReason()
|
||||
testClassicSequentialSkipConfirmDefault()
|
||||
testRuntimeRestoreDefinition()
|
||||
testLaunchRuntimeAdapter()
|
||||
console.log('runtime smoke tests passed')
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user