49 lines
1.5 KiB
TypeScript
49 lines
1.5 KiB
TypeScript
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
|
|
import { generateMetadata } from './page';
|
|
|
|
vi.mock('../../lib/seo', async (importOriginal) => {
|
|
const actual = await importOriginal<typeof import('../../lib/seo')>();
|
|
return {
|
|
...actual,
|
|
getSeoConfig: vi.fn().mockResolvedValue({
|
|
texts: {},
|
|
brandNameFa: 'کنینا ایران',
|
|
titleSeparator: '|',
|
|
titlePosition: 'suffix',
|
|
canonicalBaseUrl: 'https://canina.ir',
|
|
ogImageUrl: 'https://canina.ir/assets/og.jpg',
|
|
defaultMetaTitle: 'کنینا ایران',
|
|
defaultMetaDescription: 'فروشگاه رسمی کنینا',
|
|
keywords: ['canina'],
|
|
}),
|
|
};
|
|
});
|
|
|
|
describe('/login metadata', () => {
|
|
beforeEach(() => {
|
|
vi.stubEnv('NEXT_PUBLIC_APP_ENV', 'production');
|
|
vi.stubEnv('NODE_ENV', 'production');
|
|
vi.stubEnv('NEXT_PUBLIC_SITE_URL', 'https://canina.ir');
|
|
});
|
|
|
|
afterEach(() => {
|
|
vi.unstubAllGlobals();
|
|
vi.unstubAllEnvs();
|
|
});
|
|
|
|
it('provides explicit noindex and self-canonical without pointing canonical to home', async () => {
|
|
const meta = await generateMetadata();
|
|
|
|
// Must be noindex
|
|
expect(meta.robots).toMatchObject({
|
|
index: false,
|
|
follow: false,
|
|
});
|
|
|
|
// Canonical must be self-referential /login, NOT home '/'
|
|
expect(meta.alternates?.canonical).toBe('https://canina.ir/login');
|
|
expect(meta.alternates?.canonical).not.toBe('https://canina.ir/');
|
|
expect(meta.alternates?.canonical).not.toBe('https://canina.ir');
|
|
});
|
|
});
|