42 lines
1.9 KiB
TypeScript
42 lines
1.9 KiB
TypeScript
import type { RewriteRun } from './rewriteRun'
|
|
import { renderToStaticMarkup } from 'react-dom/server'
|
|
import { describe, expect, it } from 'vitest'
|
|
import { RewriteThread } from './AskThread'
|
|
|
|
const QUESTION = '/ecc:writing-code-comments\n\n只按这个技能重写这一段注释。'
|
|
|
|
function render(run: RewriteRun): string {
|
|
return renderToStaticMarkup(<RewriteThread run={run} onStop={() => {}} />)
|
|
}
|
|
|
|
const text = (html: string): string => html.replace(/<[^>]*>/g, '')
|
|
|
|
describe('按注释规范重写的过程', () => {
|
|
const running: RewriteRun = { question: QUESTION, text: '新的**注释**', activity: '读取 routes.py', status: 'running' }
|
|
|
|
it('进行中画出固定的要求、流出来的回答和正在读的文件,能停;没有输入框、没有「问过 N 次」', () => {
|
|
const html = render(running)
|
|
expect(html).toContain('aria-label="按注释规范重写"')
|
|
expect(html).toContain('class="cr-qa"')
|
|
expect(text(html)).toContain('/ecc:writing-code-comments')
|
|
expect(html).toContain('data-streaming=""')
|
|
expect(text(html)).toContain('新的注释')
|
|
expect(text(html)).toContain('读取 routes.py')
|
|
expect(html).toContain('aria-label="停止"')
|
|
expect(html).not.toContain('<textarea')
|
|
expect(html).not.toContain('问过')
|
|
expect(html).not.toContain('继续问')
|
|
expect(html).not.toContain('cr-qa-profile')
|
|
})
|
|
|
|
it('没写成时原因留在这块上,不收成「问过 N 次」', () => {
|
|
const html = render({ ...running, text: '一半', status: 'failed', error: '模型没有给出注释正文,没有改文件。' })
|
|
expect(html).toContain('role="alert"')
|
|
expect(text(html)).toContain('模型没有给出注释正文,没有改文件。')
|
|
expect(text(html)).toContain('/ecc:writing-code-comments')
|
|
expect(html).not.toContain('问过')
|
|
expect(html).not.toContain('<textarea')
|
|
expect(html).not.toContain('aria-label="停止"')
|
|
})
|
|
})
|