Skip to content

Commit 5e8ff28

Browse files
authored
Merge pull request #44 from objectstack-ai/copilot/design-plugin-test-cases
2 parents 91b2183 + 10ec2d3 commit 5e8ff28

File tree

9 files changed

+371
-17
lines changed

9 files changed

+371
-17
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
"prototype": "pnpm --filter prototype dev",
2121
"playground": "pnpm --filter @apps/playground dev",
2222
"build": "pnpm -r build",
23-
"test": "pnpm -r test",
23+
"pretest": "pnpm --filter @object-ui/types build && pnpm --filter @object-ui/core build && pnpm --filter @object-ui/react build && pnpm --filter @object-ui/components build",
24+
"test": "vitest run",
2425
"docs:dev": "pnpm --filter object-ui-docs dev",
2526
"docs:build": "pnpm --filter object-ui-docs build",
2627
"docs:preview": "pnpm --filter object-ui-docs preview",

packages/plugin-charts/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"scripts": {
1717
"build": "vite build",
1818
"test": "vitest run",
19+
"test:watch": "vitest",
1920
"type-check": "tsc --noEmit",
2021
"lint": "eslint ."
2122
},
Lines changed: 125 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,128 @@
1-
import { describe, it, expect } from 'vitest';
1+
import { describe, it, expect, beforeAll } from 'vitest';
2+
import { ComponentRegistry } from '@object-ui/core';
23

3-
describe('@object-ui/plugin-charts', () => {
4-
it('should pass', () => {
5-
expect(true).toBe(true);
4+
describe('Plugin Charts', () => {
5+
// Import all renderers to register them
6+
beforeAll(async () => {
7+
await import('./index');
8+
});
9+
10+
describe('chart-bar component', () => {
11+
it('should be registered in ComponentRegistry', () => {
12+
const chartBarRenderer = ComponentRegistry.get('chart-bar');
13+
expect(chartBarRenderer).toBeDefined();
14+
});
15+
16+
it('should have proper metadata', () => {
17+
const config = ComponentRegistry.getConfig('chart-bar');
18+
expect(config).toBeDefined();
19+
expect(config?.label).toBe('Bar Chart');
20+
expect(config?.category).toBe('plugin');
21+
expect(config?.inputs).toBeDefined();
22+
expect(config?.defaultProps).toBeDefined();
23+
});
24+
25+
it('should have expected inputs', () => {
26+
const config = ComponentRegistry.getConfig('chart-bar');
27+
const inputNames = config?.inputs?.map((input: any) => input.name) || [];
28+
29+
expect(inputNames).toContain('data');
30+
expect(inputNames).toContain('dataKey');
31+
expect(inputNames).toContain('xAxisKey');
32+
expect(inputNames).toContain('height');
33+
expect(inputNames).toContain('color');
34+
});
35+
36+
it('should have data as required input', () => {
37+
const config = ComponentRegistry.getConfig('chart-bar');
38+
const dataInput = config?.inputs?.find((input: any) => input.name === 'data');
39+
40+
expect(dataInput).toBeDefined();
41+
expect(dataInput?.required).toBe(true);
42+
expect(dataInput?.type).toBe('array');
43+
});
44+
45+
it('should have sensible default props', () => {
46+
const config = ComponentRegistry.getConfig('chart-bar');
47+
const defaults = config?.defaultProps;
48+
49+
expect(defaults).toBeDefined();
50+
expect(defaults?.dataKey).toBe('value');
51+
expect(defaults?.xAxisKey).toBe('name');
52+
expect(defaults?.height).toBe(400);
53+
expect(defaults?.color).toBe('#8884d8');
54+
expect(defaults?.data).toBeDefined();
55+
expect(Array.isArray(defaults?.data)).toBe(true);
56+
expect(defaults?.data.length).toBeGreaterThan(0);
57+
});
58+
});
59+
60+
describe('chart (advanced) component', () => {
61+
it('should be registered in ComponentRegistry', () => {
62+
const chartRenderer = ComponentRegistry.get('chart');
63+
expect(chartRenderer).toBeDefined();
64+
});
65+
66+
it('should have proper metadata', () => {
67+
const config = ComponentRegistry.getConfig('chart');
68+
expect(config).toBeDefined();
69+
expect(config?.label).toBe('Chart');
70+
expect(config?.category).toBe('plugin');
71+
expect(config?.inputs).toBeDefined();
72+
expect(config?.defaultProps).toBeDefined();
73+
});
74+
75+
it('should have expected inputs', () => {
76+
const config = ComponentRegistry.getConfig('chart');
77+
const inputNames = config?.inputs?.map((input: any) => input.name) || [];
78+
79+
expect(inputNames).toContain('chartType');
80+
expect(inputNames).toContain('data');
81+
expect(inputNames).toContain('config');
82+
expect(inputNames).toContain('xAxisKey');
83+
expect(inputNames).toContain('series');
84+
expect(inputNames).toContain('className');
85+
});
86+
87+
it('should have chartType as enum input', () => {
88+
const config = ComponentRegistry.getConfig('chart');
89+
const chartTypeInput = config?.inputs?.find((input: any) => input.name === 'chartType');
90+
91+
expect(chartTypeInput).toBeDefined();
92+
expect(chartTypeInput?.type).toBe('enum');
93+
expect(chartTypeInput?.enum).toBeDefined();
94+
expect(Array.isArray(chartTypeInput?.enum)).toBe(true);
95+
96+
const enumValues = chartTypeInput?.enum?.map((e: any) => e.value) || [];
97+
expect(enumValues).toContain('bar');
98+
expect(enumValues).toContain('line');
99+
expect(enumValues).toContain('area');
100+
});
101+
102+
it('should have data and series as required inputs', () => {
103+
const config = ComponentRegistry.getConfig('chart');
104+
const dataInput = config?.inputs?.find((input: any) => input.name === 'data');
105+
const seriesInput = config?.inputs?.find((input: any) => input.name === 'series');
106+
107+
expect(dataInput?.required).toBe(true);
108+
expect(seriesInput?.required).toBe(true);
109+
});
110+
111+
it('should have sensible default props', () => {
112+
const config = ComponentRegistry.getConfig('chart');
113+
const defaults = config?.defaultProps;
114+
115+
expect(defaults).toBeDefined();
116+
expect(defaults?.chartType).toBe('bar');
117+
expect(defaults?.xAxisKey).toBe('name');
118+
expect(defaults?.data).toBeDefined();
119+
expect(Array.isArray(defaults?.data)).toBe(true);
120+
expect(defaults?.data.length).toBeGreaterThan(0);
121+
expect(defaults?.config).toBeDefined();
122+
expect(typeof defaults?.config).toBe('object');
123+
expect(defaults?.series).toBeDefined();
124+
expect(Array.isArray(defaults?.series)).toBe(true);
125+
expect(defaults?.series.length).toBeGreaterThan(0);
126+
});
6127
});
7128
});

packages/plugin-editor/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"scripts": {
1717
"build": "vite build",
1818
"test": "vitest run",
19+
"test:watch": "vitest",
1920
"type-check": "tsc --noEmit",
2021
"lint": "eslint ."
2122
},
Lines changed: 87 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,90 @@
1-
import { describe, it, expect } from 'vitest';
1+
import { describe, it, expect, beforeAll } from 'vitest';
2+
import { ComponentRegistry } from '@object-ui/core';
23

3-
describe('@object-ui/plugin-editor', () => {
4-
it('should pass', () => {
5-
expect(true).toBe(true);
4+
describe('Plugin Editor', () => {
5+
// Import all renderers to register them
6+
beforeAll(async () => {
7+
await import('./index');
8+
});
9+
10+
describe('code-editor component', () => {
11+
it('should be registered in ComponentRegistry', () => {
12+
const editorRenderer = ComponentRegistry.get('code-editor');
13+
expect(editorRenderer).toBeDefined();
14+
});
15+
16+
it('should have proper metadata', () => {
17+
const config = ComponentRegistry.getConfig('code-editor');
18+
expect(config).toBeDefined();
19+
expect(config?.label).toBe('Code Editor');
20+
expect(config?.category).toBe('plugin');
21+
expect(config?.inputs).toBeDefined();
22+
expect(config?.defaultProps).toBeDefined();
23+
});
24+
25+
it('should have expected inputs', () => {
26+
const config = ComponentRegistry.getConfig('code-editor');
27+
const inputNames = config?.inputs?.map((input: any) => input.name) || [];
28+
29+
expect(inputNames).toContain('value');
30+
expect(inputNames).toContain('language');
31+
expect(inputNames).toContain('theme');
32+
expect(inputNames).toContain('height');
33+
expect(inputNames).toContain('readOnly');
34+
});
35+
36+
it('should have language as enum input', () => {
37+
const config = ComponentRegistry.getConfig('code-editor');
38+
const languageInput = config?.inputs?.find((input: any) => input.name === 'language');
39+
40+
expect(languageInput).toBeDefined();
41+
expect(languageInput?.type).toBe('enum');
42+
expect(languageInput?.enum).toBeDefined();
43+
expect(Array.isArray(languageInput?.enum)).toBe(true);
44+
45+
const enumValues = languageInput?.enum || [];
46+
expect(enumValues).toContain('javascript');
47+
expect(enumValues).toContain('typescript');
48+
expect(enumValues).toContain('python');
49+
expect(enumValues).toContain('json');
50+
expect(enumValues).toContain('html');
51+
expect(enumValues).toContain('css');
52+
});
53+
54+
it('should have theme as enum input', () => {
55+
const config = ComponentRegistry.getConfig('code-editor');
56+
const themeInput = config?.inputs?.find((input: any) => input.name === 'theme');
57+
58+
expect(themeInput).toBeDefined();
59+
expect(themeInput?.type).toBe('enum');
60+
expect(themeInput?.enum).toBeDefined();
61+
expect(Array.isArray(themeInput?.enum)).toBe(true);
62+
63+
const enumValues = themeInput?.enum || [];
64+
expect(enumValues).toContain('vs-dark');
65+
expect(enumValues).toContain('light');
66+
});
67+
68+
it('should have sensible default props', () => {
69+
const config = ComponentRegistry.getConfig('code-editor');
70+
const defaults = config?.defaultProps;
71+
72+
expect(defaults).toBeDefined();
73+
expect(defaults?.value).toBeDefined();
74+
expect(typeof defaults?.value).toBe('string');
75+
expect(defaults?.language).toBe('javascript');
76+
expect(defaults?.theme).toBe('vs-dark');
77+
expect(defaults?.height).toBe('400px');
78+
expect(defaults?.readOnly).toBe(false);
79+
});
80+
81+
it('should have readOnly as boolean input', () => {
82+
const config = ComponentRegistry.getConfig('code-editor');
83+
const readOnlyInput = config?.inputs?.find((input: any) => input.name === 'readOnly');
84+
85+
expect(readOnlyInput).toBeDefined();
86+
expect(readOnlyInput?.type).toBe('boolean');
87+
expect(readOnlyInput?.defaultValue).toBe(false);
88+
});
689
});
790
});

packages/plugin-kanban/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"scripts": {
1717
"build": "vite build",
1818
"test": "vitest run",
19+
"test:watch": "vitest",
1920
"type-check": "tsc --noEmit",
2021
"lint": "eslint ."
2122
},
Lines changed: 101 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,104 @@
1-
import { describe, it, expect } from 'vitest';
1+
import { describe, it, expect, beforeAll } from 'vitest';
2+
import { ComponentRegistry } from '@object-ui/core';
23

3-
describe('@object-ui/plugin-kanban', () => {
4-
it('should pass', () => {
5-
expect(true).toBe(true);
4+
describe('Plugin Kanban', () => {
5+
// Import all renderers to register them
6+
beforeAll(async () => {
7+
await import('./index');
8+
});
9+
10+
describe('kanban component', () => {
11+
it('should be registered in ComponentRegistry', () => {
12+
const kanbanRenderer = ComponentRegistry.get('kanban');
13+
expect(kanbanRenderer).toBeDefined();
14+
});
15+
16+
it('should have proper metadata', () => {
17+
const config = ComponentRegistry.getConfig('kanban');
18+
expect(config).toBeDefined();
19+
expect(config?.label).toBe('Kanban Board');
20+
expect(config?.icon).toBe('LayoutDashboard');
21+
expect(config?.category).toBe('plugin');
22+
expect(config?.inputs).toBeDefined();
23+
expect(config?.defaultProps).toBeDefined();
24+
});
25+
26+
it('should have expected inputs', () => {
27+
const config = ComponentRegistry.getConfig('kanban');
28+
const inputNames = config?.inputs?.map((input: any) => input.name) || [];
29+
30+
expect(inputNames).toContain('columns');
31+
expect(inputNames).toContain('onCardMove');
32+
expect(inputNames).toContain('className');
33+
});
34+
35+
it('should have columns as required input', () => {
36+
const config = ComponentRegistry.getConfig('kanban');
37+
const columnsInput = config?.inputs?.find((input: any) => input.name === 'columns');
38+
39+
expect(columnsInput).toBeDefined();
40+
expect(columnsInput?.required).toBe(true);
41+
expect(columnsInput?.type).toBe('array');
42+
expect(columnsInput?.description).toBeDefined();
43+
});
44+
45+
it('should have onCardMove as code input', () => {
46+
const config = ComponentRegistry.getConfig('kanban');
47+
const onCardMoveInput = config?.inputs?.find((input: any) => input.name === 'onCardMove');
48+
49+
expect(onCardMoveInput).toBeDefined();
50+
expect(onCardMoveInput?.type).toBe('code');
51+
expect(onCardMoveInput?.advanced).toBe(true);
52+
expect(onCardMoveInput?.description).toBeDefined();
53+
});
54+
55+
it('should have sensible default props', () => {
56+
const config = ComponentRegistry.getConfig('kanban');
57+
const defaults = config?.defaultProps;
58+
59+
expect(defaults).toBeDefined();
60+
expect(defaults?.columns).toBeDefined();
61+
expect(Array.isArray(defaults?.columns)).toBe(true);
62+
expect(defaults?.columns.length).toBeGreaterThan(0);
63+
expect(defaults?.className).toBe('w-full');
64+
});
65+
66+
it('should have default columns with proper structure', () => {
67+
const config = ComponentRegistry.getConfig('kanban');
68+
const defaults = config?.defaultProps;
69+
const columns = defaults?.columns || [];
70+
71+
// Verify at least 3 columns exist (todo, in-progress, done)
72+
expect(columns.length).toBeGreaterThanOrEqual(3);
73+
74+
// Verify each column has required properties
75+
columns.forEach((column: any) => {
76+
expect(column.id).toBeDefined();
77+
expect(column.title).toBeDefined();
78+
expect(column.cards).toBeDefined();
79+
expect(Array.isArray(column.cards)).toBe(true);
80+
});
81+
82+
// Verify at least one column has cards
83+
const hasCards = columns.some((column: any) => column.cards.length > 0);
84+
expect(hasCards).toBe(true);
85+
});
86+
87+
it('should have cards with proper structure', () => {
88+
const config = ComponentRegistry.getConfig('kanban');
89+
const defaults = config?.defaultProps;
90+
const columns = defaults?.columns || [];
91+
92+
// Find a column with cards
93+
const columnWithCards = columns.find((column: any) => column.cards.length > 0);
94+
expect(columnWithCards).toBeDefined();
95+
96+
const card = columnWithCards.cards[0];
97+
expect(card.id).toBeDefined();
98+
expect(card.title).toBeDefined();
99+
expect(card.description).toBeDefined();
100+
expect(card.badges).toBeDefined();
101+
expect(Array.isArray(card.badges)).toBe(true);
102+
});
6103
});
7104
});

packages/plugin-markdown/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"scripts": {
1717
"build": "vite build",
1818
"test": "vitest run",
19+
"test:watch": "vitest",
1920
"type-check": "tsc --noEmit",
2021
"lint": "eslint ."
2122
},

0 commit comments

Comments
 (0)