fix bug#7
Build & Push / Build & Push Docker Image (push) Failing after 2m50s
Test / Type Check (all packages) (push) Failing after 55s
Test / API Unit Tests (push) Has been skipped
Test / Homepage Unit Tests (push) Has been skipped
Test / Carplace Unit Tests (push) Has been skipped
Test / Admin Unit Tests (push) Has been skipped
Test / Dashboard Unit Tests (push) Has been skipped
Test / API Integration Tests (push) Has been skipped
Build & Push / Build & Push Docker Image (push) Failing after 2m50s
Test / Type Check (all packages) (push) Failing after 55s
Test / API Unit Tests (push) Has been skipped
Test / Homepage Unit Tests (push) Has been skipped
Test / Carplace Unit Tests (push) Has been skipped
Test / Admin Unit Tests (push) Has been skipped
Test / Dashboard Unit Tests (push) Has been skipped
Test / API Integration Tests (push) Has been skipped
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
import { HeaderNavigation } from '@/components/app-shell/HeaderNavigation';
|
||||
import { ThemedAccountCreateLink } from '@/components/app-shell/ThemedAccountCreateLink';
|
||||
import { act, render, screen } from '@testing-library/react';
|
||||
import { describe, expect, it, vi } from 'vitest';
|
||||
|
||||
vi.mock('next/navigation', () => ({
|
||||
usePathname: () => '/en/light',
|
||||
}));
|
||||
|
||||
const labels = {
|
||||
product: 'Product',
|
||||
workflow: 'Workflow',
|
||||
modules: 'Modules',
|
||||
pricing: 'Pricing',
|
||||
faq: 'FAQ',
|
||||
};
|
||||
|
||||
describe('HeaderNavigation', () => {
|
||||
it('updates destinations when the client theme preference changes', async () => {
|
||||
document.documentElement.dataset.themePreference = 'light';
|
||||
|
||||
render(
|
||||
<HeaderNavigation
|
||||
locale="en"
|
||||
mode="light"
|
||||
label="Primary navigation"
|
||||
labels={labels}
|
||||
/>,
|
||||
);
|
||||
|
||||
const product = screen.getByRole('link', { name: 'Product' });
|
||||
expect(product).toHaveAttribute('href', '/en/light#product');
|
||||
|
||||
await act(async () => {
|
||||
document.documentElement.dataset.themePreference = 'dark';
|
||||
window.dispatchEvent(
|
||||
new CustomEvent('rentaldrivego:theme-preference', { detail: 'dark' }),
|
||||
);
|
||||
});
|
||||
|
||||
expect(product).toHaveAttribute('href', '/en/dark#product');
|
||||
});
|
||||
|
||||
it('updates account creation destinations when the client theme preference changes', async () => {
|
||||
document.documentElement.dataset.themePreference = 'light';
|
||||
|
||||
render(
|
||||
<ThemedAccountCreateLink locale="en" initialPreference="light">
|
||||
Create account
|
||||
</ThemedAccountCreateLink>,
|
||||
);
|
||||
|
||||
const link = screen.getByRole('link', { name: 'Create account' });
|
||||
expect(link).toHaveAttribute('href', '/dashboard/sign-up?lang=en&theme=light');
|
||||
|
||||
await act(async () => {
|
||||
document.documentElement.dataset.themePreference = 'dark';
|
||||
window.dispatchEvent(
|
||||
new CustomEvent('rentaldrivego:theme-preference', { detail: 'dark' }),
|
||||
);
|
||||
});
|
||||
|
||||
expect(link).toHaveAttribute('href', '/dashboard/sign-up?lang=en&theme=dark');
|
||||
});
|
||||
});
|
||||
@@ -5,6 +5,7 @@ import enShell from '@/content/locales/en/shell.json';
|
||||
import frHomepage from '@/content/locales/fr/homepage.json';
|
||||
import frShell from '@/content/locales/fr/shell.json';
|
||||
import { buildHomepageContent } from '@/content/homepage-model';
|
||||
import { accountCreateUrl } from '@/lib/account-urls';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
|
||||
describe('homepage content model', () => {
|
||||
@@ -28,14 +29,19 @@ describe('homepage content model', () => {
|
||||
it('keeps unresolved conversion destinations disabled', () => {
|
||||
const content = buildHomepageContent(enHomepage, enShell);
|
||||
|
||||
expect(content.hero.primary.href).toBe('/dashboard/sign-up?lang=en');
|
||||
expect(content.hero.primary.href).toBe('/dashboard/sign-up?lang=en&theme=dark');
|
||||
expect(content.hero.primary.disabledReason).toBeUndefined();
|
||||
expect(content.final.primary.href).toBe('/dashboard/sign-up?lang=en');
|
||||
expect(content.final.primary.href).toBe('/dashboard/sign-up?lang=en&theme=dark');
|
||||
expect(content.final.primary.disabledReason).toBeUndefined();
|
||||
expect(content.pricing.actionDisabledReason).toBe(enShell.states.pendingBody);
|
||||
expect(content.final.secondary.disabledReason).toBe(enShell.states.pendingBody);
|
||||
});
|
||||
|
||||
it('includes explicit theme handoff in account creation URLs', () => {
|
||||
expect(accountCreateUrl('en', 'light')).toBe('/dashboard/sign-up?lang=en&theme=light');
|
||||
expect(accountCreateUrl('en', 'dark')).toBe('/dashboard/sign-up?lang=en&theme=dark');
|
||||
});
|
||||
|
||||
it('keeps preview identifiers isolated from translated prose', () => {
|
||||
const content = buildHomepageContent(arHomepage, arShell);
|
||||
|
||||
|
||||
@@ -19,9 +19,9 @@ describe('destination registry', () => {
|
||||
expect(
|
||||
resolveDestination('privacy', 'fr', { demoSubmissionEnabled: false, demoMode: 'blocked' })
|
||||
.href,
|
||||
).toBe('/fr/system/confidentialite');
|
||||
).toBe('/fr/dark/confidentialite');
|
||||
expect(
|
||||
resolveDestination('sign-in', 'en', { demoSubmissionEnabled: false, demoMode: 'blocked' }).href,
|
||||
).toBe('/en/system/sign-in');
|
||||
).toBe('/en/dark/sign-in');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -27,9 +27,9 @@ describe('localization foundations', () => {
|
||||
});
|
||||
|
||||
it('generates and resolves localized stable route paths', () => {
|
||||
expect(localizedPath('home', 'ar')).toBe('/ar/system');
|
||||
expect(localizedPath('privacy', 'fr')).toBe('/fr/system/confidentialite');
|
||||
expect(localizedPath('sign-in', 'ar')).toBe('/ar/system/تسجيل-الدخول');
|
||||
expect(localizedPath('home', 'ar')).toBe('/ar/dark');
|
||||
expect(localizedPath('privacy', 'fr')).toBe('/fr/dark/confidentialite');
|
||||
expect(localizedPath('sign-in', 'ar')).toBe('/ar/dark/تسجيل-الدخول');
|
||||
expect(routeIdFromSlug('fr', 'confidentialite')).toBe('privacy');
|
||||
expect(routeIdFromSlug('fr', 'privacy')).toBeNull();
|
||||
expect(routeIdFromAnyLocaleSlug('privacy')).toBe('privacy');
|
||||
@@ -43,17 +43,17 @@ describe('localization foundations', () => {
|
||||
|
||||
it('generates reciprocal hreflang values', () => {
|
||||
const links = hreflangMap(new URL('https://approved.test'), 'home');
|
||||
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');
|
||||
expect(links.en).toBe('https://approved.test/en/dark');
|
||||
expect(links.ar).toBe('https://approved.test/ar/dark');
|
||||
expect(links['x-default']).toBe('https://approved.test/en/dark');
|
||||
});
|
||||
|
||||
it('preserves only approved campaign query values and valid hashes', () => {
|
||||
const current = new URL(
|
||||
'https://approved.test/en/system?utm_source=campaign&email=private%40approved.test#gibberish',
|
||||
'https://approved.test/en/dark?utm_source=campaign&email=private%40approved.test#gibberish',
|
||||
);
|
||||
const switched = localeSwitchUrl(current, 'fr', 'home');
|
||||
expect(switched.pathname).toBe('/fr/system');
|
||||
expect(switched.pathname).toBe('/fr/dark');
|
||||
expect(switched.search).toBe('?utm_source=campaign');
|
||||
expect(switched.hash).toBe('');
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ describe('homepage proxy app boundaries', () => {
|
||||
|
||||
expect(response).toMatchObject({
|
||||
kind: 'redirect',
|
||||
url: 'https://rentaldrivego.ma/fr/system',
|
||||
url: 'https://rentaldrivego.ma/fr/dark',
|
||||
});
|
||||
});
|
||||
|
||||
@@ -87,7 +87,7 @@ describe('homepage proxy app boundaries', () => {
|
||||
|
||||
expect(response).toMatchObject({
|
||||
kind: 'redirect',
|
||||
url: 'https://rentaldrivego.ma/en/system/privacy',
|
||||
url: 'https://rentaldrivego.ma/en/dark/privacy',
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { currentThemePreference } from '@/lib/theme/client';
|
||||
import { isThemePreference, resolveTheme, serverResolvedTheme } from '@/lib/theme/config';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
|
||||
@@ -15,4 +16,9 @@ describe('theme foundations', () => {
|
||||
expect(resolveTheme('light', true)).toBe('light');
|
||||
expect(serverResolvedTheme('system')).toBe('light');
|
||||
});
|
||||
|
||||
it('defaults client theme preference to dark when no choice exists', () => {
|
||||
delete document.documentElement.dataset.themePreference;
|
||||
expect(currentThemePreference()).toBe('dark');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user