Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/frontend/eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,16 @@ export default [
...tseslint.configs.disableTypeChecked,
},
{
files: ['tests/**/*.ts'],
files: ['tests/e2e/**/*.ts'],
...tseslint.configs.disableTypeChecked,
},
{
files: ['tests/unit/**/*.ts', 'tests/typecheck/**/*.ts'],
rules: {
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-argument': 'off',
},
},

// Disable all formatting rules.
prettierConfig,
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/scripts/fetch-with-proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ export function fetchWithProxy(url: string | URL, options: RequestInit = {}): Pr

const parsedUrl = url instanceof URL ? url : new URL(url);
return fetch(url, { ...options, agent: selectAgent(parsedUrl) });
}
}
4 changes: 3 additions & 1 deletion src/frontend/src/components/FooterLinks.astro
Original file line number Diff line number Diff line change
Expand Up @@ -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);
---

{
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/src/components/OsAwareTabs.astro
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
64 changes: 64 additions & 0 deletions src/frontend/tests/unit/custom-components.vitest.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -754,4 +755,67 @@ 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('hides footer community links when the pathname fallback matches 404 routes', async () => {
const fallbackRoute: StarlightRoute = {
editUrl:
'https://github.com/microsoft/aspire.dev/edit/main/src/frontend/src/content/docs/test.mdx',
entry: {
id: 'docs/test',
slug: '',
filePath: 'src/content/docs/test.mdx',
data: {},
},
};

for (const requestUrl of ['https://aspire.dev/404/', 'https://aspire.dev/ja/404/']) {
const html = normalizeHtml(
await renderComponent(FooterLinks, {
requestUrl,
locals: {
starlightRoute: fallbackRoute,
},
})
);

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('<script>').at(-1) ?? '';

expect(inlineScript).toContain('tab.textContent?.trim() === label');
expect(inlineScript).not.toContain('HTMLAnchorElement');
});
});
Loading