@@ -214,6 +214,33 @@ describe("calculateFileUrl", () => {
214214 expect ( url ) . toBe ( "/en/tidb/dev/page/" ) ;
215215 } ) ;
216216
217+ it ( "should resolve tidb-data-migration _index with release branch alias" , ( ) => {
218+ const absolutePath = path . join (
219+ sourceBasePath ,
220+ "zh/tidb-data-migration/release-2.0/_index.md"
221+ ) ;
222+ const url = calculateFileUrlWithConfig ( absolutePath , testConfig ) ;
223+ expect ( url ) . toBe ( "/zh/tidb-data-migration/v2.0" ) ;
224+ } ) ;
225+
226+ it ( "should resolve tidb-data-migration pages with release branch alias" , ( ) => {
227+ const absolutePath = path . join (
228+ sourceBasePath ,
229+ "zh/tidb-data-migration/release-2.0/overview.md"
230+ ) ;
231+ const url = calculateFileUrlWithConfig ( absolutePath , testConfig ) ;
232+ expect ( url ) . toBe ( "/zh/tidb-data-migration/v2.0/overview/" ) ;
233+ } ) ;
234+
235+ it ( "should resolve tidb-data-migration v1.0 pages with release branch alias" , ( ) => {
236+ const absolutePath = path . join (
237+ sourceBasePath ,
238+ "zh/tidb-data-migration/release-1.0/overview.md"
239+ ) ;
240+ const url = calculateFileUrlWithConfig ( absolutePath , testConfig ) ;
241+ expect ( url ) . toBe ( "/zh/tidb-data-migration/v1.0/overview/" ) ;
242+ } ) ;
243+
217244 it ( "should resolve api folder" , ( ) => {
218245 const absolutePath = path . join (
219246 sourceBasePath ,
@@ -469,6 +496,61 @@ describe("calculateFileUrl with defaultLanguage: 'en'", () => {
469496 // release-8.5 -> stable via branch-alias-tidb (exact match takes precedence)
470497 expect ( url ) . toBe ( "/tidb/stable/alert-rules" ) ;
471498 } ) ;
499+
500+ it ( "should omit /en/ prefix for English tidb-data-migration files" , ( ) => {
501+ const absolutePath = path . join (
502+ sourceBasePath ,
503+ "en/tidb-data-migration/release-5.3/dm-overview.md"
504+ ) ;
505+ const url = calculateFileUrlWithConfig (
506+ absolutePath ,
507+ configWithDefaultLang ,
508+ true
509+ ) ;
510+ expect ( url ) . toBe ( "/tidb-data-migration/v5.3/dm-overview" ) ;
511+ } ) ;
512+
513+ it ( "should omit /en/ prefix for English tidb-data-migration release indexes" , ( ) => {
514+ const cases = [
515+ [ "release-5.3" , "/tidb-data-migration/v5.3" ] ,
516+ [ "release-2.0" , "/tidb-data-migration/v2.0" ] ,
517+ [ "release-1.0" , "/tidb-data-migration/v1.0" ] ,
518+ ] ;
519+
520+ for ( const [ branch , expected ] of cases ) {
521+ const absolutePath = path . join (
522+ sourceBasePath ,
523+ `en/tidb-data-migration/${ branch } /_index.md`
524+ ) ;
525+ const url = calculateFileUrlWithConfig (
526+ absolutePath ,
527+ configWithDefaultLang ,
528+ true
529+ ) ;
530+ expect ( url ) . toBe ( expected ) ;
531+ }
532+ } ) ;
533+
534+ it ( "should keep /zh/ prefix for Chinese tidb-data-migration release indexes" , ( ) => {
535+ const cases = [
536+ [ "release-5.3" , "/zh/tidb-data-migration/v5.3" ] ,
537+ [ "release-2.0" , "/zh/tidb-data-migration/v2.0" ] ,
538+ [ "release-1.0" , "/zh/tidb-data-migration/v1.0" ] ,
539+ ] ;
540+
541+ for ( const [ branch , expected ] of cases ) {
542+ const absolutePath = path . join (
543+ sourceBasePath ,
544+ `zh/tidb-data-migration/${ branch } /_index.md`
545+ ) ;
546+ const url = calculateFileUrlWithConfig (
547+ absolutePath ,
548+ configWithDefaultLang ,
549+ true
550+ ) ;
551+ expect ( url ) . toBe ( expected ) ;
552+ }
553+ } ) ;
472554} ) ;
473555
474556describe ( "calculateFileUrl with slug format (relative path)" , ( ) => {
0 commit comments