From 44fd7199b8f538bd15896ace94a0c31614428998 Mon Sep 17 00:00:00 2001 From: David Pine Date: Mon, 6 Apr 2026 06:54:33 -0500 Subject: [PATCH 1/4] Fix PR 672 follow-up regressions --- src/frontend/src/components/FooterLinks.astro | 4 +- src/frontend/src/components/OsAwareTabs.astro | 2 +- .../unit/custom-components.vitest.test.ts | 37 +++++++++++++++++++ 3 files changed, 41 insertions(+), 2 deletions(-) diff --git a/src/frontend/src/components/FooterLinks.astro b/src/frontend/src/components/FooterLinks.astro index 0c6879d75..279596495 100644 --- a/src/frontend/src/components/FooterLinks.astro +++ b/src/frontend/src/components/FooterLinks.astro @@ -5,7 +5,9 @@ import config from 'virtual:starlight/user-config'; const links = config.social || []; const gitHubLink = links.find((link) => link.label === 'GitHub')?.href ?? null; const discordLink = links.find((link) => link.label === 'Discord')?.href ?? null; -const is404 = Astro.url.pathname === '/404' || Astro.url.pathname === '/404/'; +const is404 = + Astro.locals.starlightRoute?.entry?.slug === '404' || + /^\/(?:[^/]+\/)?404\/?$/.test(Astro.url.pathname); --- { diff --git a/src/frontend/src/components/OsAwareTabs.astro b/src/frontend/src/components/OsAwareTabs.astro index 1b509c020..966d904f7 100644 --- a/src/frontend/src/components/OsAwareTabs.astro +++ b/src/frontend/src/components/OsAwareTabs.astro @@ -25,7 +25,7 @@ const { syncKey = 'terminal' } = Astro.props; function activateTabByLabel(starlightTabs, label) { const tabs = Array.from(starlightTabs.querySelectorAll('[role="tab"]')); const panels = Array.from(starlightTabs.querySelectorAll(':scope > [role="tabpanel"]')); - const tabIndex = tabs.findIndex((tab) => tab instanceof HTMLAnchorElement && tab.textContent?.trim() === label); + const tabIndex = tabs.findIndex((tab) => tab.textContent?.trim() === label); if (tabIndex < 0) return; diff --git a/src/frontend/tests/unit/custom-components.vitest.test.ts b/src/frontend/tests/unit/custom-components.vitest.test.ts index b00b889c0..1d7f579a0 100644 --- a/src/frontend/tests/unit/custom-components.vitest.test.ts +++ b/src/frontend/tests/unit/custom-components.vitest.test.ts @@ -10,6 +10,7 @@ import CTABanner from '@components/CTABanner.astro'; import CapabilityGrid from '@components/CapabilityGrid.astro'; import CodespacesButton from '@components/CodespacesButton.astro'; import Expand from '@components/Expand.astro'; +import FooterLinks from '@components/FooterLinks.astro'; import FeatureShowcase from '@components/FeatureShowcase.astro'; import FluidGrid from '@components/FluidGrid.astro'; import FooterPreferences from '@components/FooterPreferences.astro'; @@ -754,4 +755,40 @@ describe('custom Astro component render coverage', () => { expect(html).toContain(`origHeight%3D${heroImage.height}`); expect(html).not.toContain('h=1000'); }); + + it('hides footer community links on localized 404 pages', async () => { + const html = normalizeHtml( + await renderComponent(FooterLinks, { + requestUrl: 'https://aspire.dev/ja/404/', + locals: { + starlightRoute: { + editUrl: + 'https://github.com/microsoft/aspire.dev/edit/main/src/frontend/src/content/docs/404.mdx', + entry: { + id: '404', + slug: '404', + filePath: 'src/content/docs/404.mdx', + data: {}, + }, + }, + }, + }) + ); + + expect(html).not.toContain('footer.community'); + expect(html).not.toContain('https://x.com/aspiredotdev'); + }); + + it('renders OsAwareTabs activation logic without anchor-only tab assumptions', async () => { + const html = normalizeHtml( + await renderComponent(OsAwareTabs, { + props: { syncKey: 'terminal' }, + slots: { unix: 'echo unix', windows: 'Write-Host windows' }, + }) + ); + const inlineScript = html.split('