fix(ci): fix getTranslations import and clean AISearchResults orphaned syntax
All checks were successful
Build & Deploy / 🔍 Prepare (push) Successful in 24s
Build & Deploy / 🧪 QA (push) Successful in 1m9s
Build & Deploy / 🏗️ Build (push) Successful in 2m49s
Build & Deploy / 🚀 Deploy (push) Successful in 26s
Build & Deploy / 🧪 Post-Deploy Verification (push) Successful in 45s
Build & Deploy / 🔔 Notify (push) Successful in 2s
All checks were successful
Build & Deploy / 🔍 Prepare (push) Successful in 24s
Build & Deploy / 🧪 QA (push) Successful in 1m9s
Build & Deploy / 🏗️ Build (push) Successful in 2m49s
Build & Deploy / 🚀 Deploy (push) Successful in 26s
Build & Deploy / 🧪 Post-Deploy Verification (push) Successful in 45s
Build & Deploy / 🔔 Notify (push) Successful in 2s
This commit is contained in:
38
app/[locale]/referenzen/[slug]/page.test.tsx
Normal file
38
app/[locale]/referenzen/[slug]/page.test.tsx
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
import { describe, it, expect, vi } from 'vitest';
|
||||||
|
import ReferenceDetail from './page';
|
||||||
|
|
||||||
|
// Mock next/navigation
|
||||||
|
vi.mock('next/navigation', () => ({
|
||||||
|
notFound: vi.fn(),
|
||||||
|
}));
|
||||||
|
|
||||||
|
// Mock next-intl/server
|
||||||
|
vi.mock('next-intl/server', () => ({
|
||||||
|
setRequestLocale: vi.fn(),
|
||||||
|
getTranslations: vi.fn().mockResolvedValue(() => 'translated text'),
|
||||||
|
}));
|
||||||
|
|
||||||
|
// Mock @/lib/references
|
||||||
|
vi.mock('@/lib/references', () => ({
|
||||||
|
getReferenceBySlug: vi.fn().mockResolvedValue({
|
||||||
|
slug: 'test-slug',
|
||||||
|
frontmatter: {
|
||||||
|
title: 'Test Title',
|
||||||
|
location: 'Test Location',
|
||||||
|
category: 'Test Category',
|
||||||
|
},
|
||||||
|
content: 'Test content',
|
||||||
|
}),
|
||||||
|
}));
|
||||||
|
|
||||||
|
describe('ReferenceDetail Page TDD', () => {
|
||||||
|
it('renders reference detail correctly', async () => {
|
||||||
|
const props = {
|
||||||
|
params: Promise.resolve({ locale: 'de', slug: 'test-slug' })
|
||||||
|
};
|
||||||
|
|
||||||
|
// We expect the execution to fail if getTranslations is not defined/imported inside page.tsx
|
||||||
|
const component = await ReferenceDetail(props);
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import { notFound } from 'next/navigation';
|
import { notFound } from 'next/navigation';
|
||||||
import { Container, Badge, Heading } from '@/components/ui';
|
import { Container, Badge, Heading } from '@/components/ui';
|
||||||
import { setRequestLocale } from 'next-intl/server';
|
import { setRequestLocale, getTranslations } from 'next-intl/server';
|
||||||
import { Metadata } from 'next';
|
import { Metadata } from 'next';
|
||||||
import { getReferenceBySlug, getAllReferences } from '@/lib/references';
|
import { getReferenceBySlug, getAllReferences } from '@/lib/references';
|
||||||
import { MDXRemote } from 'next-mdx-remote/rsc';
|
import { MDXRemote } from 'next-mdx-remote/rsc';
|
||||||
|
|||||||
61
components/search/AISearchResults.test.tsx
Normal file
61
components/search/AISearchResults.test.tsx
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
import * as React from 'react';
|
||||||
|
import { describe, it, expect, vi } from 'vitest';
|
||||||
|
import { render } from '@testing-library/react';
|
||||||
|
import { AISearchResults } from './AISearchResults';
|
||||||
|
|
||||||
|
// Mock lucide-react
|
||||||
|
vi.mock('lucide-react', () => ({
|
||||||
|
ArrowUp: () => <div data-testid="arrow-up" />,
|
||||||
|
X: () => <div data-testid="close-icon" />,
|
||||||
|
Sparkles: () => <div data-testid="sparkles" />,
|
||||||
|
ChevronRight: () => <div data-testid="chevron-right" />,
|
||||||
|
RotateCcw: () => <div data-testid="rotate-ccw" />,
|
||||||
|
Copy: () => <div data-testid="copy" />,
|
||||||
|
Check: () => <div data-testid="check" />,
|
||||||
|
}));
|
||||||
|
|
||||||
|
// Mock next/link
|
||||||
|
vi.mock('next/link', () => ({
|
||||||
|
default: ({ children, href }: any) => <a href={href}>{children}</a>,
|
||||||
|
}));
|
||||||
|
|
||||||
|
// Mock useAnalytics
|
||||||
|
vi.mock('../analytics/useAnalytics', () => ({
|
||||||
|
useAnalytics: () => ({
|
||||||
|
trackEvent: vi.fn(),
|
||||||
|
}),
|
||||||
|
}));
|
||||||
|
|
||||||
|
// Mock react-markdown
|
||||||
|
vi.mock('react-markdown', () => ({
|
||||||
|
default: ({ children }: any) => <div>{children}</div>,
|
||||||
|
}));
|
||||||
|
|
||||||
|
// Mock remark-gfm
|
||||||
|
vi.mock('remark-gfm', () => ({
|
||||||
|
default: {},
|
||||||
|
}));
|
||||||
|
|
||||||
|
// Mock next-intl
|
||||||
|
vi.mock('next-intl', () => ({
|
||||||
|
useTranslations: () => {
|
||||||
|
const translate = (key: string) => key;
|
||||||
|
translate.raw = (key: string) => {
|
||||||
|
if (key === 'loadingTexts') return ['Lade...', 'Denke nach...'];
|
||||||
|
if (key === 'prompts') return ['Prompt 1', 'Prompt 2'];
|
||||||
|
return [];
|
||||||
|
};
|
||||||
|
return translate;
|
||||||
|
},
|
||||||
|
useLocale: () => 'en',
|
||||||
|
}));
|
||||||
|
|
||||||
|
describe('AISearchResults Component Test (TDD)', () => {
|
||||||
|
it('renders correctly when open', () => {
|
||||||
|
const handleClose = vi.fn();
|
||||||
|
const { container } = render(
|
||||||
|
<AISearchResults isOpen={true} onClose={handleClose} />
|
||||||
|
);
|
||||||
|
expect(container).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -10,9 +10,6 @@ import remarkGfm from 'remark-gfm';
|
|||||||
import dynamic from 'next/dynamic';
|
import dynamic from 'next/dynamic';
|
||||||
import { useTranslations } from 'next-intl';
|
import { useTranslations } from 'next-intl';
|
||||||
const AIOrb = dynamic(() => import('./AIOrb'), { ssr: false });
|
const AIOrb = dynamic(() => import('./AIOrb'), { ssr: false });
|
||||||
'Frage den Senior-Ingenieur... 👴🔧',
|
|
||||||
'Frage ChatGPTs Cousin 2. Grades... 🤖',
|
|
||||||
];
|
|
||||||
|
|
||||||
interface ProductMatch {
|
interface ProductMatch {
|
||||||
id: string;
|
id: string;
|
||||||
|
|||||||
Reference in New Issue
Block a user