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
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:
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user