mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-06 08:37:22 +00:00
further refactor + remove auto-fix for now
This commit is contained in:
1 parent
0445b4d0c0
commit
b3d4deedc8
7 files changed
+102
-240
No files matched your search
@@ -4,67 +4,22 @@ import { AssistantContent } from './AssistantContent';
|
||||
import { TestApp } from '@/test/TestApp';
|
||||
import type { CoreToolMessage } from 'ai';
|
||||
|
||||
|
||||
describe('AssistantContent', () => {
|
||||
const mockToolResults: CoreToolMessage[] = [];
|
||||
|
||||
describe('Build Action Detection', () => {
|
||||
const testCases = [
|
||||
{
|
||||
name: 'auto-build success',
|
||||
content: '✅ Agent completed successfully. Project built and preview updated!',
|
||||
expectedTitle: 'Auto-Build Project',
|
||||
expectedStatus: 'Success'
|
||||
},
|
||||
{
|
||||
name: 'build error',
|
||||
content: '❌ Auto-build failed. Analyzing error and attempting to fix automatically...',
|
||||
expectedTitle: 'Auto-Build Project',
|
||||
expectedStatus: 'Failed'
|
||||
},
|
||||
{
|
||||
name: 'build loading',
|
||||
content: '🔄 Building project...',
|
||||
expectedTitle: 'Build Project',
|
||||
expectedStatus: 'Running'
|
||||
},
|
||||
{
|
||||
name: 'deploy success',
|
||||
content: '🎉 Deploy completed successfully!',
|
||||
expectedTitle: 'Deploy Project',
|
||||
expectedStatus: 'Success'
|
||||
},
|
||||
{
|
||||
name: 'auto-fix',
|
||||
content: '⚠️ Auto-fix attempt limit reached. Please fix the build error manually',
|
||||
expectedTitle: 'Auto-Fix Error',
|
||||
expectedStatus: 'Success'
|
||||
}
|
||||
];
|
||||
it('should render build action for auto-build success message', () => {
|
||||
const content = '✅ Agent completed successfully. Project built and preview updated!';
|
||||
|
||||
testCases.forEach(({ name, content, expectedTitle, expectedStatus }) => {
|
||||
it(`should render ${name} action for string content`, () => {
|
||||
render(
|
||||
<TestApp>
|
||||
<AssistantContent content={content} toolResults={mockToolResults} />
|
||||
</TestApp>
|
||||
);
|
||||
render(
|
||||
<TestApp>
|
||||
<AssistantContent content={content} toolResults={mockToolResults} />
|
||||
</TestApp>
|
||||
);
|
||||
|
||||
expect(screen.getByText(expectedTitle)).toBeInTheDocument();
|
||||
expect(screen.getByText(expectedStatus)).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it(`should render ${name} action for array content`, () => {
|
||||
const arrayContent = [{ type: 'text' as const, text: content }];
|
||||
|
||||
render(
|
||||
<TestApp>
|
||||
<AssistantContent content={arrayContent} toolResults={mockToolResults} />
|
||||
</TestApp>
|
||||
);
|
||||
|
||||
expect(screen.getByText(expectedTitle)).toBeInTheDocument();
|
||||
expect(screen.getByText(expectedStatus)).toBeInTheDocument();
|
||||
});
|
||||
// Check if BuildAction component is rendered
|
||||
expect(screen.queryByText(/Project/)).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should render regular markdown for non-build-action string content', () => {
|
||||
|
||||
Reference in new issue
Block a user