@@ -39,13 +39,16 @@ describe("SEO metadata helpers", () => {
3939 test ( "omits English-only posts from localized blog navigation" , ( ) => {
4040 const englishSlugs = blogPostsForLocale ( "en" ) . map ( ( post ) => post . slug ) ;
4141 const japaneseSlugs = blogPostsForLocale ( "ja" ) . map ( ( post ) => post . slug ) ;
42+ const germanSlugs = blogPostsForLocale ( "de" ) . map ( ( post ) => post . slug ) ;
4243
4344 expect ( englishSlugs ) . toContain ( "cmux-omo" ) ;
4445 expect ( englishSlugs ) . toContain ( "gpl" ) ;
4546 expect ( englishSlugs ) . toContain ( "cmux-claude-teams" ) ;
4647 expect ( japaneseSlugs ) . not . toContain ( "cmux-omo" ) ;
4748 expect ( japaneseSlugs ) . not . toContain ( "gpl" ) ;
4849 expect ( japaneseSlugs ) . not . toContain ( "cmux-claude-teams" ) ;
50+ expect ( japaneseSlugs ) . toContain ( "cmux-ssh" ) ;
51+ expect ( germanSlugs ) . not . toContain ( "cmux-ssh" ) ;
4952 } ) ;
5053
5154 test ( "keeps canonical URLs locale-aware" , ( ) => {
@@ -794,11 +797,14 @@ describe("SEO middleware", () => {
794797 . filter (
795798 ( url ) =>
796799 url . endsWith ( "/pricing" ) ||
800+ url . endsWith ( "/blog/cmux-ssh" ) ||
797801 url . endsWith ( "/docs/agent-integrations/oh-my-pi" ) ,
798802 ) ;
799803 expect ( urls ) . toEqual ( [
800804 "https://cmux.com/pricing" ,
801805 "https://cmux.com/ja/pricing" ,
806+ "https://cmux.com/blog/cmux-ssh" ,
807+ "https://cmux.com/ja/blog/cmux-ssh" ,
802808 "https://cmux.com/docs/agent-integrations/oh-my-pi" ,
803809 "https://cmux.com/ja/docs/agent-integrations/oh-my-pi" ,
804810 ] ) ;
@@ -843,6 +849,25 @@ describe("SEO middleware", () => {
843849 "https://cmux.com/blog/gpl" ,
844850 ] ) ;
845851 } ) ;
852+
853+ test ( "limits partially translated blog posts to authored locales" , ( ) => {
854+ const german = middleware (
855+ requestFor ( "/de/blog/cmux-ssh" , { "accept-language" : "de" } ) ,
856+ ) ;
857+ expect ( german . status ) . toBe ( 301 ) ;
858+ expect ( german . headers . get ( "location" ) ) . toBe (
859+ "https://cmux.com/blog/cmux-ssh" ,
860+ ) ;
861+
862+ const japanese = middleware (
863+ requestFor ( "/ja/blog/cmux-ssh" , { "accept-language" : "ja" } ) ,
864+ ) ;
865+ expect ( japanese . status ) . toBe ( 200 ) ;
866+ expect ( japanese . headers . get ( "location" ) ) . toBeNull ( ) ;
867+ expect ( japanese . headers . get ( "Link" ) ) . toContain ( 'hreflang="en"' ) ;
868+ expect ( japanese . headers . get ( "Link" ) ) . toContain ( 'hreflang="ja"' ) ;
869+ expect ( japanese . headers . get ( "Link" ) ) . not . toContain ( 'hreflang="de"' ) ;
870+ } ) ;
846871} ) ;
847872
848873const wideSearchBaseCodePoint =
0 commit comments