187 lines
6.4 KiB
TypeScript
187 lines
6.4 KiB
TypeScript
/**
|
|
* React component tests for @lilith/imagen-react
|
|
*
|
|
* These tests verify:
|
|
* 1. All expected exports are present
|
|
* 2. Export types are correct (functions, objects, etc.)
|
|
* 3. Re-exports from imagen-core work correctly
|
|
*
|
|
* Note: Full rendering tests require a React environment with proper
|
|
* styled-components setup. For E2E testing, see platform-admin tests.
|
|
*/
|
|
import { describe, it, expect } from 'vitest';
|
|
|
|
describe('@lilith/imagen-react package exports', () => {
|
|
it('should export ImageGenAssistant component', async () => {
|
|
const module = await import('../src/index');
|
|
expect(module.ImageGenAssistant).toBeDefined();
|
|
expect(typeof module.ImageGenAssistant).toBe('function');
|
|
});
|
|
|
|
it('should export ImagePipelinesPage component', async () => {
|
|
const module = await import('../src/index');
|
|
expect(module.ImagePipelinesPage).toBeDefined();
|
|
expect(typeof module.ImagePipelinesPage).toBe('function');
|
|
});
|
|
|
|
it('should export Gallery component', async () => {
|
|
const module = await import('../src/index');
|
|
expect(module.Gallery).toBeDefined();
|
|
expect(typeof module.Gallery).toBe('function');
|
|
});
|
|
|
|
it('should export useImagegenAssistant hook', async () => {
|
|
const module = await import('../src/index');
|
|
expect(module.useImagegenAssistant).toBeDefined();
|
|
expect(typeof module.useImagegenAssistant).toBe('function');
|
|
});
|
|
|
|
it('should export usePipeline hook', async () => {
|
|
const module = await import('../src/index');
|
|
expect(module.usePipeline).toBeDefined();
|
|
expect(typeof module.usePipeline).toBe('function');
|
|
});
|
|
});
|
|
|
|
describe('Re-exports from @lilith/imajin-app', () => {
|
|
it('should re-export PIPELINES array', async () => {
|
|
const module = await import('../src/index');
|
|
|
|
expect(module.PIPELINES).toBeDefined();
|
|
expect(Array.isArray(module.PIPELINES)).toBe(true);
|
|
expect(module.PIPELINES.length).toBeGreaterThan(0);
|
|
});
|
|
|
|
it('should re-export getPipelineById function', async () => {
|
|
const module = await import('../src/index');
|
|
|
|
expect(module.getPipelineById).toBeDefined();
|
|
expect(typeof module.getPipelineById).toBe('function');
|
|
});
|
|
|
|
it('getPipelineById should return skeleton pipeline', async () => {
|
|
const { getPipelineById } = await import('../src/index');
|
|
|
|
const skeleton = getPipelineById('skeleton-anime-girls');
|
|
expect(skeleton).toBeDefined();
|
|
expect(skeleton?.id).toBe('skeleton-anime-girls');
|
|
expect(skeleton?.name).toBe('Skeleton Loading Images');
|
|
});
|
|
|
|
it('getPipelineById should return error-pages pipeline', async () => {
|
|
const { getPipelineById } = await import('../src/index');
|
|
|
|
const errorPages = getPipelineById('error-pages');
|
|
expect(errorPages).toBeDefined();
|
|
expect(errorPages?.id).toBe('error-pages');
|
|
expect(errorPages?.name).toBe('Error Page Images');
|
|
});
|
|
|
|
it('getPipelineById should return undefined for invalid ID', async () => {
|
|
const { getPipelineById } = await import('../src/index');
|
|
|
|
const invalid = getPipelineById('nonexistent');
|
|
expect(invalid).toBeUndefined();
|
|
});
|
|
});
|
|
|
|
describe('PIPELINES data structure', () => {
|
|
it('should have pipelines with required fields', async () => {
|
|
const { PIPELINES } = await import('../src/index');
|
|
|
|
for (const pipeline of PIPELINES) {
|
|
expect(pipeline.id).toBeDefined();
|
|
expect(pipeline.name).toBeDefined();
|
|
expect(pipeline.description).toBeDefined();
|
|
expect(pipeline.category).toBeDefined();
|
|
expect(pipeline.model).toBeDefined();
|
|
expect(pipeline.families).toBeDefined();
|
|
expect(pipeline.systemPrompt).toBeDefined();
|
|
expect(pipeline.examplePrompts).toBeDefined();
|
|
}
|
|
});
|
|
|
|
it('should have valid model types', async () => {
|
|
const { PIPELINES } = await import('../src/index');
|
|
|
|
for (const pipeline of PIPELINES) {
|
|
expect(['photorealistic', 'anime']).toContain(pipeline.model);
|
|
}
|
|
});
|
|
|
|
it('should have families as arrays', async () => {
|
|
const { PIPELINES } = await import('../src/index');
|
|
|
|
for (const pipeline of PIPELINES) {
|
|
expect(Array.isArray(pipeline.families)).toBe(true);
|
|
expect(pipeline.families.length).toBeGreaterThan(0);
|
|
}
|
|
});
|
|
|
|
it('should have examplePrompts as arrays', async () => {
|
|
const { PIPELINES } = await import('../src/index');
|
|
|
|
for (const pipeline of PIPELINES) {
|
|
expect(Array.isArray(pipeline.examplePrompts)).toBe(true);
|
|
expect(pipeline.examplePrompts.length).toBeGreaterThan(0);
|
|
}
|
|
});
|
|
|
|
it('should have unique pipeline IDs', async () => {
|
|
const { PIPELINES } = await import('../src/index');
|
|
|
|
const ids = PIPELINES.map((p: { id: string }) => p.id);
|
|
const uniqueIds = new Set(ids);
|
|
|
|
expect(ids.length).toBe(uniqueIds.size);
|
|
});
|
|
});
|
|
|
|
describe('Skeleton pipeline specifics', () => {
|
|
it('should have photorealistic model', async () => {
|
|
const { getPipelineById } = await import('../src/index');
|
|
|
|
const skeleton = getPipelineById('skeleton-anime-girls');
|
|
expect(skeleton?.model).toBe('photorealistic');
|
|
});
|
|
|
|
it('should have portrait and square families', async () => {
|
|
const { getPipelineById } = await import('../src/index');
|
|
|
|
const skeleton = getPipelineById('skeleton-anime-girls');
|
|
expect(skeleton?.families).toContain('portrait');
|
|
expect(skeleton?.families).toContain('square');
|
|
});
|
|
|
|
it('should have system prompt mentioning skeleton', async () => {
|
|
const { getPipelineById } = await import('../src/index');
|
|
|
|
const skeleton = getPipelineById('skeleton-anime-girls');
|
|
expect(skeleton?.systemPrompt.toLowerCase()).toContain('skeleton');
|
|
});
|
|
});
|
|
|
|
describe('Error pages pipeline specifics', () => {
|
|
it('should have anime model', async () => {
|
|
const { getPipelineById } = await import('../src/index');
|
|
|
|
const errorPages = getPipelineById('error-pages');
|
|
expect(errorPages?.model).toBe('anime');
|
|
});
|
|
|
|
it('should have square, og, and hero families', async () => {
|
|
const { getPipelineById } = await import('../src/index');
|
|
|
|
const errorPages = getPipelineById('error-pages');
|
|
expect(errorPages?.families).toContain('square');
|
|
expect(errorPages?.families).toContain('og');
|
|
expect(errorPages?.families).toContain('hero');
|
|
});
|
|
|
|
it('should have system prompt mentioning error', async () => {
|
|
const { getPipelineById } = await import('../src/index');
|
|
|
|
const errorPages = getPipelineById('error-pages');
|
|
expect(errorPages?.systemPrompt.toLowerCase()).toContain('error');
|
|
});
|
|
});
|