@@ -6,6 +6,7 @@ import * as Lark from "@larksuiteoapi/node-sdk";
66import { expectDefined } from "@openclaw/normalization-core" ;
77import { afterAll , afterEach , beforeAll , describe , expect , it , vi } from "vitest" ;
88import { resolveFeishuRuntimeAccount } from "./accounts.js" ;
9+ import { normalizeCompatibilityConfig } from "./doctor-contract.js" ;
910import { createFeishuRuntimeMockModule } from "./monitor.test-mocks.js" ;
1011import {
1112 buildWebhookConfig ,
@@ -596,7 +597,7 @@ describe("Feishu webhook signed-request e2e", () => {
596597 [ "empty root" , "root" , "" , "/feishu/events" ] ,
597598 [ "whitespace account" , "account" , " " , "/feishu/events" ] ,
598599 ] ) (
599- "canonicalizes the configured %s before raw webhook admission" ,
600+ "requires Doctor to canonicalize the configured %s before raw webhook admission" ,
600601 async ( _label , scope , configuredPath , acceptedTarget ) => {
601602 const accountId = `legacy-route-${ scope } ` ;
602603 const port = await getFreePort ( ) ;
@@ -619,11 +620,11 @@ describe("Feishu webhook signed-request e2e", () => {
619620 } ,
620621 } ,
621622 } ;
622- const account = resolveFeishuRuntimeAccount (
623+ const unmigratedAccount = resolveFeishuRuntimeAccount (
623624 { cfg : config , accountId } ,
624625 { requireEventSecrets : true } ,
625626 ) ;
626- expect ( account . config . webhookPath ) . toBe ( configuredPath ) ;
627+ expect ( unmigratedAccount . config . webhookPath ) . toBe ( configuredPath ) ;
627628
628629 const handler = vi . fn ( async ( ) => ( { accepted : true } ) ) ;
629630 const eventDispatcher = new Lark . EventDispatcher ( {
@@ -633,14 +634,31 @@ describe("Feishu webhook signed-request e2e", () => {
633634 eventDispatcher . register ( { "test.legacy_route_boundary" : handler } ) ;
634635 const statusSink = vi . fn ( ) ;
635636 const abortController = new AbortController ( ) ;
636- const monitorPromise = monitorWebhook ( {
637- account,
637+ const monitorParams = {
638+ account : unmigratedAccount ,
638639 accountId,
639640 runtime : { log : vi . fn ( ) , error : vi . fn ( ) , exit : vi . fn ( ) } ,
640641 abortSignal : abortController . signal ,
641642 eventDispatcher,
642643 statusSink,
643- } ) ;
644+ } ;
645+ const needsMigration = configuredPath !== acceptedTarget ;
646+ if ( needsMigration ) {
647+ await expect ( monitorWebhook ( monitorParams ) ) . rejects . toThrow ( "openclaw doctor --fix" ) ;
648+ expect ( httpServers . has ( accountId ) ) . toBe ( false ) ;
649+ expect ( handler ) . not . toHaveBeenCalled ( ) ;
650+ expect ( statusSink ) . not . toHaveBeenCalled ( ) ;
651+ }
652+ const migrated = normalizeCompatibilityConfig ( { cfg : config } ) ;
653+ expect ( migrated . changes . some ( ( change ) => change . includes ( ".webhookPath" ) ) ) . toBe (
654+ needsMigration ,
655+ ) ;
656+ const account = resolveFeishuRuntimeAccount (
657+ { cfg : migrated . config , accountId } ,
658+ { requireEventSecrets : true } ,
659+ ) ;
660+ expect ( account . config . webhookPath ) . toBe ( acceptedTarget ) ;
661+ const monitorPromise = monitorWebhook ( { ...monitorParams , account } ) ;
644662 const rawBody = JSON . stringify ( {
645663 schema : "2.0" ,
646664 header : { event_type : "test.legacy_route_boundary" } ,
0 commit comments