@@ -214,6 +214,42 @@ 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+
244+ it ( "should resolve tidb-data-migration nested _index with folders" , ( ) => {
245+ const absolutePath = path . join (
246+ sourceBasePath ,
247+ "zh/tidb-data-migration/release-2.0/releases/_index.md"
248+ ) ;
249+ const url = calculateFileUrlWithConfig ( absolutePath , testConfig ) ;
250+ expect ( url ) . toBe ( "/zh/tidb-data-migration/v2.0/releases" ) ;
251+ } ) ;
252+
217253 it ( "should resolve api folder" , ( ) => {
218254 const absolutePath = path . join (
219255 sourceBasePath ,
@@ -469,6 +505,61 @@ describe("calculateFileUrl with defaultLanguage: 'en'", () => {
469505 // release-8.5 -> stable via branch-alias-tidb (exact match takes precedence)
470506 expect ( url ) . toBe ( "/tidb/stable/alert-rules" ) ;
471507 } ) ;
508+
509+ it ( "should omit /en/ prefix for English tidb-data-migration files" , ( ) => {
510+ const absolutePath = path . join (
511+ sourceBasePath ,
512+ "en/tidb-data-migration/release-5.3/dm-overview.md"
513+ ) ;
514+ const url = calculateFileUrlWithConfig (
515+ absolutePath ,
516+ configWithDefaultLang ,
517+ true
518+ ) ;
519+ expect ( url ) . toBe ( "/tidb-data-migration/v5.3/dm-overview" ) ;
520+ } ) ;
521+
522+ it ( "should omit /en/ prefix for English tidb-data-migration release indexes" , ( ) => {
523+ const cases = [
524+ [ "release-5.3" , "/tidb-data-migration/v5.3" ] ,
525+ [ "release-2.0" , "/tidb-data-migration/v2.0" ] ,
526+ [ "release-1.0" , "/tidb-data-migration/v1.0" ] ,
527+ ] ;
528+
529+ for ( const [ branch , expected ] of cases ) {
530+ const absolutePath = path . join (
531+ sourceBasePath ,
532+ `en/tidb-data-migration/${ branch } /_index.md`
533+ ) ;
534+ const url = calculateFileUrlWithConfig (
535+ absolutePath ,
536+ configWithDefaultLang ,
537+ true
538+ ) ;
539+ expect ( url ) . toBe ( expected ) ;
540+ }
541+ } ) ;
542+
543+ it ( "should keep /zh/ prefix for Chinese tidb-data-migration release indexes" , ( ) => {
544+ const cases = [
545+ [ "release-5.3" , "/zh/tidb-data-migration/v5.3" ] ,
546+ [ "release-2.0" , "/zh/tidb-data-migration/v2.0" ] ,
547+ [ "release-1.0" , "/zh/tidb-data-migration/v1.0" ] ,
548+ ] ;
549+
550+ for ( const [ branch , expected ] of cases ) {
551+ const absolutePath = path . join (
552+ sourceBasePath ,
553+ `zh/tidb-data-migration/${ branch } /_index.md`
554+ ) ;
555+ const url = calculateFileUrlWithConfig (
556+ absolutePath ,
557+ configWithDefaultLang ,
558+ true
559+ ) ;
560+ expect ( url ) . toBe ( expected ) ;
561+ }
562+ } ) ;
472563} ) ;
473564
474565describe ( "calculateFileUrl with slug format (relative path)" , ( ) => {
0 commit comments