Add Linker and Optimizer modules with API integration and frontend components
- Added Linker and Optimizer apps to `INSTALLED_APPS` in `settings.py`. - Configured API endpoints for Linker and Optimizer in `urls.py`. - Implemented `OptimizeContentFunction` for content optimization in the AI module. - Created prompts for content optimization and site structure generation. - Updated `OptimizerService` to utilize the new AI function for content optimization. - Developed frontend components including dashboards and content lists for Linker and Optimizer. - Integrated new routes and sidebar navigation for Linker and Optimizer in the frontend. - Enhanced content management with source and sync status filters in the Writer module. - Comprehensive test coverage added for new features and components.
This commit is contained in:
82
frontend/src/pages/Linker/__tests__/Dashboard.test.tsx
Normal file
82
frontend/src/pages/Linker/__tests__/Dashboard.test.tsx
Normal file
@@ -0,0 +1,82 @@
|
||||
/**
|
||||
* Tests for Linker Dashboard
|
||||
*/
|
||||
import { render, screen, waitFor } from '@testing-library/react';
|
||||
import { BrowserRouter } from 'react-router';
|
||||
import LinkerDashboard from '../Dashboard';
|
||||
import { fetchContent } from '../../../services/api';
|
||||
|
||||
vi.mock('../../../services/api');
|
||||
vi.mock('../../../store/siteStore', () => ({
|
||||
useSiteStore: () => ({ activeSite: { id: 1, name: 'Test Site' } }),
|
||||
}));
|
||||
vi.mock('../../../store/sectorStore', () => ({
|
||||
useSectorStore: () => ({ activeSector: { id: 1, name: 'Test Sector' } }),
|
||||
}));
|
||||
|
||||
describe('LinkerDashboard', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
it('renders dashboard title', () => {
|
||||
(fetchContent as any).mockResolvedValue({ results: [], count: 0 });
|
||||
|
||||
render(
|
||||
<BrowserRouter>
|
||||
<LinkerDashboard />
|
||||
</BrowserRouter>
|
||||
);
|
||||
|
||||
expect(screen.getByText('Linker Dashboard')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('displays stats cards when data is loaded', async () => {
|
||||
(fetchContent as any).mockResolvedValue({
|
||||
results: [
|
||||
{ id: 1, internal_links: [{ id: 1 }] },
|
||||
{ id: 2, internal_links: [] },
|
||||
],
|
||||
count: 2,
|
||||
});
|
||||
|
||||
render(
|
||||
<BrowserRouter>
|
||||
<LinkerDashboard />
|
||||
</BrowserRouter>
|
||||
);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(screen.getByText('Total Linked')).toBeInTheDocument();
|
||||
expect(screen.getByText('Total Links')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
it('shows loading state initially', () => {
|
||||
(fetchContent as any).mockImplementation(() => new Promise(() => {}));
|
||||
|
||||
render(
|
||||
<BrowserRouter>
|
||||
<LinkerDashboard />
|
||||
</BrowserRouter>
|
||||
);
|
||||
|
||||
expect(screen.getByText('Loading stats...')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('renders quick actions', async () => {
|
||||
(fetchContent as any).mockResolvedValue({ results: [], count: 0 });
|
||||
|
||||
render(
|
||||
<BrowserRouter>
|
||||
<LinkerDashboard />
|
||||
</BrowserRouter>
|
||||
);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(screen.getByText('Link Content')).toBeInTheDocument();
|
||||
expect(screen.getByText('View Content')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user