Update homepage routes to include language and mode
Build & Deploy / Build & Push Docker Image (push) Successful in 2m51s
Test / Type Check (all packages) (push) Successful in 52s
Build & Deploy / Deploy to VPS (push) Successful in 4s
Test / API Unit Tests (push) Successful in 49s
Test / Homepage Unit Tests (push) Successful in 44s
Test / Storefront Unit Tests (push) Successful in 39s
Test / Admin Unit Tests (push) Successful in 40s
Test / Dashboard Unit Tests (push) Successful in 40s
Test / API Integration Tests (push) Successful in 1m0s

This commit is contained in:
root
2026-07-02 14:10:17 -04:00
parent 56c3bcf666
commit 781512399b
51 changed files with 792 additions and 344 deletions
@@ -19,9 +19,9 @@ describe('destination registry', () => {
expect(
resolveDestination('privacy', 'fr', { demoSubmissionEnabled: false, demoMode: 'blocked' })
.href,
).toBe('/fr/confidentialite');
).toBe('/fr/system/confidentialite');
expect(
resolveDestination('sign-in', 'en', { demoSubmissionEnabled: false, demoMode: 'blocked' }).href,
).toBe('/en/sign-in');
).toBe('/en/system/sign-in');
});
});
+11 -11
View File
@@ -27,33 +27,33 @@ describe('localization foundations', () => {
});
it('generates and resolves localized stable route paths', () => {
expect(localizedPath('home', 'ar')).toBe('/ar');
expect(localizedPath('privacy', 'fr')).toBe('/fr/confidentialite');
expect(localizedPath('sign-in', 'ar')).toBe('/ar/تسجيل-الدخول');
expect(localizedPath('home', 'ar')).toBe('/ar/system');
expect(localizedPath('privacy', 'fr')).toBe('/fr/system/confidentialite');
expect(localizedPath('sign-in', 'ar')).toBe('/ar/system/تسجيل-الدخول');
expect(routeIdFromSlug('fr', 'confidentialite')).toBe('privacy');
expect(routeIdFromSlug('fr', 'privacy')).toBeNull();
expect(routeIdFromAnyLocaleSlug('privacy')).toBe('privacy');
expect(routeIdFromAnyLocaleSlug('confidentialite')).toBe('privacy');
expect(routeIdFromAnyLocaleSlug('unknown')).toBeNull();
expect(routeIdFromPathname('/ar/%D8%A7%D9%84%D8%AE%D8%B5%D9%88%D8%B5%D9%8A%D8%A9')).toBe(
'privacy',
);
expect(
routeIdFromPathname('/ar/system/%D8%A7%D9%84%D8%AE%D8%B5%D9%88%D8%B5%D9%8A%D8%A9'),
).toBe('privacy');
expect(routeIdFromPathname('/de')).toBeNull();
});
it('generates reciprocal hreflang values', () => {
const links = hreflangMap(new URL('https://approved.test'), 'home');
expect(links.en).toBe('https://approved.test/en');
expect(links.ar).toBe('https://approved.test/ar');
expect(links['x-default']).toBe('https://approved.test/en');
expect(links.en).toBe('https://approved.test/en/system');
expect(links.ar).toBe('https://approved.test/ar/system');
expect(links['x-default']).toBe('https://approved.test/en/system');
});
it('preserves only approved campaign query values and valid hashes', () => {
const current = new URL(
'https://approved.test/en?utm_source=campaign&email=private%40approved.test#gibberish',
'https://approved.test/en/system?utm_source=campaign&email=private%40approved.test#gibberish',
);
const switched = localeSwitchUrl(current, 'fr', 'home');
expect(switched.pathname).toBe('/fr');
expect(switched.pathname).toBe('/fr/system');
expect(switched.search).toBe('?utm_source=campaign');
expect(switched.hash).toBe('');
@@ -15,7 +15,7 @@ describe('PricingSection', () => {
const user = userEvent.setup();
const content = buildHomepageContent(enHomepage, enShell).pricing;
const { container } = render(
<PricingSection content={content} locale="en" homePath="/en" demoSubmissionEnabled />,
<PricingSection content={content} locale="en" homePath="/en/system" demoSubmissionEnabled />,
);
expect(container.querySelector('[data-plan="launch"]')).toHaveAttribute(
@@ -34,7 +34,9 @@ describe('PricingSection', () => {
it('keeps unapproved public prices out of the rendered section', () => {
const content = buildHomepageContent(enHomepage, enShell).pricing;
render(<PricingSection content={content} locale="en" homePath="/en" demoSubmissionEnabled />);
render(
<PricingSection content={content} locale="en" homePath="/en/system" demoSubmissionEnabled />,
);
expect(screen.getAllByText('Starting price pending approval')).toHaveLength(2);
expect(screen.getByText('Custom pricing')).toBeInTheDocument();
+49 -2
View File
@@ -43,6 +43,15 @@ function request(input: string) {
};
}
type ProxyTestResponse = {
kind: 'next' | 'redirect';
url?: string;
};
function runProxy(proxy: (request: never) => unknown, input: ReturnType<typeof request>) {
return proxy(input as never) as ProxyTestResponse;
}
beforeEach(() => {
nextServer.next.mockClear();
nextServer.redirect.mockClear();
@@ -52,7 +61,7 @@ describe('homepage proxy app boundaries', () => {
it('does not localize storefront proxy paths', async () => {
const { proxy } = await import('@/proxy');
const response = proxy(request('https://rentaldrivego.ma/storefront/en') as never) as any;
const response = runProxy(proxy, request('https://rentaldrivego.ma/storefront/en'));
expect(response.kind).toBe('next');
expect(nextServer.redirect).not.toHaveBeenCalled();
@@ -61,7 +70,45 @@ describe('homepage proxy app boundaries', () => {
it('redirects locale-prefixed storefront paths back to the storefront proxy mount', async () => {
const { proxy } = await import('@/proxy');
const response = proxy(request('https://rentaldrivego.ma/en/storefront/en') as never) as any;
const response = runProxy(proxy, request('https://rentaldrivego.ma/en/storefront/en'));
expect(response).toMatchObject({
kind: 'redirect',
url: 'https://rentaldrivego.ma/storefront/en',
});
});
it('redirects the root path to locale and mode segments', async () => {
const { proxy } = await import('@/proxy');
const input = request('https://rentaldrivego.ma/');
input.headers.set('accept-language', 'fr;q=1,en;q=0.8');
const response = runProxy(proxy, input);
expect(response).toMatchObject({
kind: 'redirect',
url: 'https://rentaldrivego.ma/fr/system',
});
});
it('redirects legacy localized slugs to mode-aware localized slugs', async () => {
const { proxy } = await import('@/proxy');
const response = runProxy(proxy, request('https://rentaldrivego.ma/en/privacy'));
expect(response).toMatchObject({
kind: 'redirect',
url: 'https://rentaldrivego.ma/en/system/privacy',
});
});
it('redirects locale-and-mode storefront paths back to the storefront proxy mount', async () => {
const { proxy } = await import('@/proxy');
const response = runProxy(
proxy,
request('https://rentaldrivego.ma/en/dark/storefront/en'),
);
expect(response).toMatchObject({
kind: 'redirect',