From 64de8d2cf658d151e2d7cd6de8b1530833d870e3 Mon Sep 17 00:00:00 2001 From: Taran Vohra Date: Thu, 12 Feb 2026 15:07:27 +0530 Subject: [PATCH] Add e2e test for language variant navigation (#3992) --- packages/gitbook/e2e/internal.spec.ts | 66 +++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/packages/gitbook/e2e/internal.spec.ts b/packages/gitbook/e2e/internal.spec.ts index 64148ef18..acf1ccb5f 100644 --- a/packages/gitbook/e2e/internal.spec.ts +++ b/packages/gitbook/e2e/internal.spec.ts @@ -507,6 +507,72 @@ const testCases: TestsCase[] = [ }, ], }, + { + name: 'Language Site (Navigation when switching language variant)', + contentBaseURL: 'https://gitbook-open-e2e-sites.gitbook.io/yjs/', + tests: [ + { + name: 'Should resolve to the same page in the new language variant when switching language variant (Source English -> Target Dutch)', + url: 'ecosystem/connection-provider', + screenshot: false, + run: async (page) => { + const spaceDropdown = page + .locator('[data-testid="space-dropdown-button"]') + .locator('visible=true'); + await spaceDropdown.click(); + + const variantSelectionDropdown = page.locator( + 'css=[data-testid="dropdown-menu"]' + ); + // Click the dutch language variant in the dropdown + await variantSelectionDropdown + .getByRole('menuitem', { + name: 'Yjs (NL)', + }) + .click(); + + // It should keep the current page path, i.e "ecosysteem/connection-provider" when navigating to the NL variant + await page.waitForURL((url) => + url.pathname.includes('nl/ecosysteem/connection-provider') + ); + // Verify we are on the correct page by checking the h1 + await expect( + page.getByRole('heading', { level: 1, name: 'Connectieprovider' }) + ).toBeVisible(); + }, + }, + { + name: 'Should resolve to the same page in the new language variant when switching language variant (Source Dutch -> Target Finnish)', + url: 'nl/ecosysteem/connection-provider', + screenshot: false, + run: async (page) => { + const spaceDropdown = page + .locator('[data-testid="space-dropdown-button"]') + .locator('visible=true'); + await spaceDropdown.click(); + + const variantSelectionDropdown = page.locator( + 'css=[data-testid="dropdown-menu"]' + ); + // Click the finnish language variant in the dropdown + await variantSelectionDropdown + .getByRole('menuitem', { + name: 'Yjs (FI)', + }) + .click(); + + // It should keep the current page path, i.e "ecosysteem/connection-provider" when navigating to the FI variant + await page.waitForURL((url) => + url.pathname.includes('fi/ekosysteemi/connection-provider') + ); + // Verify we are on the correct page by checking the h1 + await expect( + page.getByRole('heading', { level: 1, name: 'Yhteysvälittäjä' }) + ).toBeVisible(); + }, + }, + ], + }, { name: 'GitBook Site (Sections and Section Groups)', contentBaseURL: 'https://gitbook-open-e2e-sites.gitbook.io/sections/',