imp part 5
This commit is contained in:
@@ -1,67 +0,0 @@
|
||||
/**
|
||||
* Tests for Bulk Generation UI
|
||||
* Phase 5: Sites Renderer & Bulk Generation
|
||||
*/
|
||||
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
||||
import { render, screen, fireEvent, waitFor } from '@testing-library/react';
|
||||
import { builderApi } from '../../../services/siteBuilder.api';
|
||||
|
||||
// Mock API
|
||||
vi.mock('../../../services/siteBuilder.api');
|
||||
|
||||
describe('Bulk Generation', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
it('generates all pages when button clicked', async () => {
|
||||
// Test: Bulk page generation works
|
||||
const mockGenerate = vi.fn().mockResolvedValue({
|
||||
success: true,
|
||||
pages_queued: 5,
|
||||
task_ids: [1, 2, 3, 4, 5],
|
||||
});
|
||||
|
||||
(builderApi as any).generateAllPages = mockGenerate;
|
||||
|
||||
// This would be tested in the actual component
|
||||
expect(mockGenerate).toBeDefined();
|
||||
});
|
||||
|
||||
it('tracks progress during generation', async () => {
|
||||
// Test: Progress tracking works
|
||||
const mockProgress = {
|
||||
pages_queued: 5,
|
||||
task_ids: [1, 2, 3, 4, 5],
|
||||
celery_task_id: 'task-123',
|
||||
};
|
||||
|
||||
expect(mockProgress.pages_queued).toBe(5);
|
||||
expect(mockProgress.task_ids).toHaveLength(5);
|
||||
});
|
||||
|
||||
it('creates tasks for selected pages only', async () => {
|
||||
// Test: Selected pages can be generated
|
||||
const selectedPageIds = [1, 3, 5];
|
||||
const mockGenerate = vi.fn().mockResolvedValue({
|
||||
success: true,
|
||||
pages_queued: 3,
|
||||
task_ids: selectedPageIds,
|
||||
});
|
||||
|
||||
expect(selectedPageIds).toHaveLength(3);
|
||||
});
|
||||
|
||||
it('force regenerates when option selected', async () => {
|
||||
// Test: Force regenerate works
|
||||
const mockGenerate = vi.fn().mockResolvedValue({
|
||||
success: true,
|
||||
pages_queued: 5,
|
||||
task_ids: [1, 2, 3, 4, 5],
|
||||
});
|
||||
|
||||
await mockGenerate(1, { force: true });
|
||||
expect(mockGenerate).toHaveBeenCalledWith(1, { force: true });
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,82 +0,0 @@
|
||||
/**
|
||||
* Tests for Component Library
|
||||
* Phase 7: UI Components & Prompt Management
|
||||
*/
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { render } from '@testing-library/react';
|
||||
import { HeroBlock } from '../../components/shared/blocks/HeroBlock';
|
||||
import { FeatureGridBlock } from '../../components/shared/blocks/FeatureGridBlock';
|
||||
import { StatsPanel } from '../../components/shared/blocks/StatsPanel';
|
||||
|
||||
describe('Component Library', () => {
|
||||
it('all components render correctly', () => {
|
||||
// Test: All components render correctly
|
||||
const { container: hero } = render(
|
||||
<HeroBlock title="Test Hero" />
|
||||
);
|
||||
expect(hero).toBeDefined();
|
||||
|
||||
const { container: features } = render(
|
||||
<FeatureGridBlock features={[]} />
|
||||
);
|
||||
expect(features).toBeDefined();
|
||||
|
||||
const { container: stats } = render(
|
||||
<StatsPanel stats={[]} />
|
||||
);
|
||||
expect(stats).toBeDefined();
|
||||
});
|
||||
|
||||
it('component library is complete', () => {
|
||||
// Test: Component library is complete
|
||||
const components = [
|
||||
'HeroBlock',
|
||||
'FeatureGridBlock',
|
||||
'StatsPanel',
|
||||
'ServicesBlock',
|
||||
'ProductsBlock',
|
||||
'TestimonialsBlock',
|
||||
'ContactFormBlock',
|
||||
'CTABlock',
|
||||
'ImageGalleryBlock',
|
||||
'VideoBlock',
|
||||
'TextBlock',
|
||||
'QuoteBlock',
|
||||
];
|
||||
|
||||
expect(components.length).toBeGreaterThanOrEqual(12);
|
||||
});
|
||||
|
||||
it('no duplicate components exist', () => {
|
||||
// Test: No duplicate components
|
||||
const components = [
|
||||
'HeroBlock',
|
||||
'FeatureGridBlock',
|
||||
'StatsPanel',
|
||||
'HeroBlock', // Duplicate
|
||||
];
|
||||
|
||||
const unique = [...new Set(components)];
|
||||
expect(unique.length).toBeLessThan(components.length);
|
||||
});
|
||||
|
||||
it('components are accessible', () => {
|
||||
// Test: All components are accessible
|
||||
const { container } = render(
|
||||
<HeroBlock title="Test" />
|
||||
);
|
||||
|
||||
const heading = container.querySelector('h2');
|
||||
expect(heading).toBeDefined();
|
||||
expect(heading?.textContent).toBe('Test');
|
||||
});
|
||||
|
||||
it('components are responsive', () => {
|
||||
// Test: All components are responsive
|
||||
// Responsiveness is tested via CSS, not JS
|
||||
// This test verifies responsive classes exist
|
||||
const responsiveClasses = ['sm:', 'md:', 'lg:', 'xl:'];
|
||||
expect(responsiveClasses.length).toBeGreaterThan(0);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
/**
|
||||
* Tests for Site Integration UI
|
||||
* Phase 6: Site Integration & Multi-Destination Publishing
|
||||
*/
|
||||
import { describe, it, expect, vi } from 'vitest';
|
||||
import { render, screen, fireEvent, waitFor } from '@testing-library/react';
|
||||
import PlatformSelector from '../../components/integration/PlatformSelector';
|
||||
import IntegrationStatus from '../../components/integration/IntegrationStatus';
|
||||
|
||||
describe('Site Integration', () => {
|
||||
it('platform selector allows selecting platform', () => {
|
||||
// Test: Site integrations work correctly
|
||||
const handleChange = vi.fn();
|
||||
const { container } = render(
|
||||
<PlatformSelector value="wordpress" onChange={handleChange} />
|
||||
);
|
||||
|
||||
const select = container.querySelector('select');
|
||||
expect(select).toBeDefined();
|
||||
});
|
||||
|
||||
it('integration status displays sync status', () => {
|
||||
// Test: Site integrations work correctly
|
||||
const { container } = render(
|
||||
<IntegrationStatus
|
||||
syncEnabled={true}
|
||||
syncStatus="success"
|
||||
lastSyncAt="2025-01-18T10:00:00Z"
|
||||
/>
|
||||
);
|
||||
|
||||
expect(container).toBeDefined();
|
||||
});
|
||||
|
||||
it('publishing settings save correctly', async () => {
|
||||
// Test: Publishing settings work
|
||||
const mockSave = vi.fn().mockResolvedValue({ success: true });
|
||||
|
||||
await mockSave({
|
||||
defaultDestinations: ['sites', 'wordpress'],
|
||||
autoPublishEnabled: true,
|
||||
});
|
||||
|
||||
expect(mockSave).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('multi-destination publishing works', async () => {
|
||||
// Test: Multi-destination publishing works
|
||||
const destinations = ['sites', 'wordpress', 'shopify'];
|
||||
const mockPublish = vi.fn().mockResolvedValue({
|
||||
success: true,
|
||||
results: destinations.map(d => ({ destination: d, success: true })),
|
||||
});
|
||||
|
||||
const result = await mockPublish(1, destinations);
|
||||
expect(result.success).toBe(true);
|
||||
expect(result.results).toHaveLength(3);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
/**
|
||||
* Tests for Layout System
|
||||
* Phase 7: UI Components & Prompt Management
|
||||
*/
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { render } from '@testing-library/react';
|
||||
import LayoutSelector from '../../components/sites/LayoutSelector';
|
||||
import LayoutPreview from '../../components/sites/LayoutPreview';
|
||||
|
||||
describe('Layout System', () => {
|
||||
it('layout selector displays all layouts', () => {
|
||||
// Test: Layout system works
|
||||
const layouts = [
|
||||
{ id: 'default', name: 'Default', category: 'marketing' },
|
||||
{ id: 'minimal', name: 'Minimal', category: 'marketing' },
|
||||
{ id: 'magazine', name: 'Magazine', category: 'blog' },
|
||||
{ id: 'ecommerce', name: 'Ecommerce', category: 'ecommerce' },
|
||||
{ id: 'portfolio', name: 'Portfolio', category: 'portfolio' },
|
||||
{ id: 'blog', name: 'Blog', category: 'blog' },
|
||||
{ id: 'corporate', name: 'Corporate', category: 'corporate' },
|
||||
];
|
||||
|
||||
expect(layouts).toHaveLength(7);
|
||||
});
|
||||
|
||||
it('layout preview renders correctly', () => {
|
||||
// Test: Layout system works
|
||||
const { container } = render(
|
||||
<LayoutPreview
|
||||
layoutId="default"
|
||||
layoutName="Default Layout"
|
||||
/>
|
||||
);
|
||||
|
||||
expect(container).toBeDefined();
|
||||
});
|
||||
|
||||
it('template system works', () => {
|
||||
// Test: Template system works
|
||||
const templates = [
|
||||
{ id: 'marketing', name: 'Marketing Template' },
|
||||
{ id: 'landing', name: 'Landing Template' },
|
||||
{ id: 'blog', name: 'Blog Template' },
|
||||
];
|
||||
|
||||
expect(templates).toHaveLength(3);
|
||||
});
|
||||
|
||||
it('cms styling system works', () => {
|
||||
// Test: CMS styling system works
|
||||
const stylePresets = ['modern', 'classic', 'minimal', 'bold', 'elegant', 'tech'];
|
||||
const colorSchemes = ['blue', 'purple', 'green', 'dark'];
|
||||
const typographyPresets = ['modern', 'classic', 'editorial', 'minimal', 'tech'];
|
||||
|
||||
expect(stylePresets.length).toBeGreaterThan(0);
|
||||
expect(colorSchemes.length).toBeGreaterThan(0);
|
||||
expect(typographyPresets.length).toBeGreaterThan(0);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
/**
|
||||
* Tests for Prompt Management UI
|
||||
* Phase 7: UI Components & Prompt Management
|
||||
*/
|
||||
import { describe, it, expect, vi } from 'vitest';
|
||||
|
||||
describe('Prompt Management', () => {
|
||||
it('prompt management UI loads prompts', async () => {
|
||||
// Test: Prompt management UI works
|
||||
const mockPrompts = [
|
||||
{ prompt_type: 'site_structure_generation', prompt_value: 'Test prompt' },
|
||||
];
|
||||
|
||||
expect(mockPrompts).toHaveLength(1);
|
||||
expect(mockPrompts[0].prompt_type).toBe('site_structure_generation');
|
||||
});
|
||||
|
||||
it('site builder section displays in prompts page', () => {
|
||||
// Test: Prompt management UI works
|
||||
const promptTypes = [
|
||||
'clustering',
|
||||
'ideas',
|
||||
'content_generation',
|
||||
'site_structure_generation',
|
||||
];
|
||||
|
||||
const siteBuilderPrompts = promptTypes.filter(t => t === 'site_structure_generation');
|
||||
expect(siteBuilderPrompts).toHaveLength(1);
|
||||
});
|
||||
|
||||
it('prompt editor saves site structure generation prompt', async () => {
|
||||
// Test: Prompt management UI works
|
||||
const mockSave = vi.fn().mockResolvedValue({ success: true });
|
||||
|
||||
await mockSave({
|
||||
prompt_type: 'site_structure_generation',
|
||||
prompt_value: 'Updated prompt',
|
||||
});
|
||||
|
||||
expect(mockSave).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
/**
|
||||
* Tests for Site Management UI
|
||||
* Phase 6: Site Integration & Multi-Destination Publishing
|
||||
*/
|
||||
import { describe, it, expect, vi } from 'vitest';
|
||||
import { render, screen } from '@testing-library/react';
|
||||
|
||||
describe('Site Management', () => {
|
||||
it('site management dashboard displays sites', () => {
|
||||
// Test: Site management UI works (core features)
|
||||
const mockSites = [
|
||||
{ id: 1, name: 'Site 1', status: 'active' },
|
||||
{ id: 2, name: 'Site 2', status: 'active' },
|
||||
];
|
||||
|
||||
expect(mockSites).toHaveLength(2);
|
||||
expect(mockSites[0].name).toBe('Site 1');
|
||||
});
|
||||
|
||||
it('site content editor loads pages', async () => {
|
||||
// Test: Site management UI works (core features)
|
||||
const mockPages = [
|
||||
{ id: 1, title: 'Home', slug: 'home' },
|
||||
{ id: 2, title: 'About', slug: 'about' },
|
||||
];
|
||||
|
||||
expect(mockPages).toHaveLength(2);
|
||||
});
|
||||
|
||||
it('page manager allows reordering', () => {
|
||||
// Test: Site management UI works (core features)
|
||||
const pages = [
|
||||
{ id: 1, order: 1 },
|
||||
{ id: 2, order: 2 },
|
||||
{ id: 3, order: 3 },
|
||||
];
|
||||
|
||||
// Simulate drag-drop reorder
|
||||
const reordered = [pages[2], pages[0], pages[1]];
|
||||
expect(reordered[0].id).toBe(3);
|
||||
});
|
||||
|
||||
it('task integration shows site builder tasks', () => {
|
||||
// Test: Task integration works
|
||||
const mockTasks = [
|
||||
{ id: 1, title: '[Site Builder] Home Page', status: 'queued' },
|
||||
{ id: 2, title: '[Site Builder] About Page', status: 'queued' },
|
||||
];
|
||||
|
||||
const siteBuilderTasks = mockTasks.filter(t => t.title.startsWith('[Site Builder]'));
|
||||
expect(siteBuilderTasks).toHaveLength(2);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
/**
|
||||
* Tests for Advanced Site Management
|
||||
* Phase 7: UI Components & Prompt Management
|
||||
*/
|
||||
import { describe, it, expect, vi } from 'vitest';
|
||||
|
||||
describe('Advanced Site Management', () => {
|
||||
it('site management works end-to-end', async () => {
|
||||
// Test: Site management works end-to-end (advanced features)
|
||||
const workflow = [
|
||||
'load_sites',
|
||||
'select_site',
|
||||
'view_pages',
|
||||
'edit_content',
|
||||
'save_changes',
|
||||
'preview_site',
|
||||
];
|
||||
|
||||
expect(workflow).toHaveLength(6);
|
||||
});
|
||||
|
||||
it('site preview loads deployment URL', async () => {
|
||||
// Test: Site management works end-to-end (advanced features)
|
||||
const mockDeployment = {
|
||||
id: 1,
|
||||
deployment_url: 'https://test-site.igny8.com',
|
||||
status: 'deployed',
|
||||
};
|
||||
|
||||
expect(mockDeployment.deployment_url).toBeDefined();
|
||||
expect(mockDeployment.status).toBe('deployed');
|
||||
});
|
||||
|
||||
it('site settings saves SEO metadata', async () => {
|
||||
// Test: Site management works end-to-end (advanced features)
|
||||
const mockSave = vi.fn().mockResolvedValue({ success: true });
|
||||
|
||||
await mockSave({
|
||||
seo_metadata: {
|
||||
meta_title: 'Test Site',
|
||||
meta_description: 'Test Description',
|
||||
og_title: 'Test OG Title',
|
||||
},
|
||||
});
|
||||
|
||||
expect(mockSave).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -108,19 +108,13 @@ export const createTasksPageConfig = (
|
||||
toggleContentKey: 'description',
|
||||
toggleContentLabel: 'Idea & Content Outline',
|
||||
render: (value: string, row: Task) => {
|
||||
const isSiteBuilder = value?.startsWith('[Site Builder]');
|
||||
const displayTitle = isSiteBuilder && value ? value.replace('[Site Builder] ', '') : (value || 'Untitled');
|
||||
const displayTitle = value || 'Untitled';
|
||||
|
||||
return (
|
||||
<div className="flex items-center gap-2">
|
||||
<span className="text-base font-light text-gray-900 dark:text-white">
|
||||
{displayTitle}
|
||||
</span>
|
||||
{isSiteBuilder && (
|
||||
<Badge color="purple" size="xs" variant="soft">
|
||||
<span className="text-[11px] font-normal">Site Builder</span>
|
||||
</Badge>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
},
|
||||
|
||||
@@ -160,15 +160,8 @@ export default function Tasks() {
|
||||
try {
|
||||
const ordering = sortBy ? `${sortDirection === 'desc' ? '-' : ''}${sortBy}` : '-created_at';
|
||||
|
||||
// Build search term - combine user search with Site Builder filter if needed
|
||||
let finalSearchTerm = searchTerm;
|
||||
if (sourceFilter === 'site_builder') {
|
||||
// If user has a search term, combine it with Site Builder prefix
|
||||
finalSearchTerm = searchTerm ? `[Site Builder] ${searchTerm}` : '[Site Builder]';
|
||||
}
|
||||
|
||||
const filters: TasksFilters = {
|
||||
...(finalSearchTerm && { search: finalSearchTerm }),
|
||||
...(searchTerm && { search: searchTerm }),
|
||||
...(statusFilter && { status: statusFilter }),
|
||||
...(clusterFilter && { cluster_id: clusterFilter }),
|
||||
...(structureFilter && { content_structure: structureFilter }),
|
||||
|
||||
Reference in New Issue
Block a user