✨ feat(vscode): 重写注释时在卡片下展示模型过程
This commit is contained in:
1 parent
08fb04e3fd
commit
5e8e7b65ee
15 files changed
+369
-83
No files matched your search
@@ -0,0 +1,38 @@
|
||||
import type { RewriteRuns } from './rewriteRun'
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { rewriteEnd, rewriteProgress, startRewrite } from './rewriteRun'
|
||||
|
||||
const ANCHOR = 'c1'
|
||||
const QUESTION = '/ecc:writing-code-comments\n\n只按这个技能重写这一段注释。'
|
||||
|
||||
describe('重写过程只留在页面上', () => {
|
||||
it('进行中换上全文和正在读的文件;新的一段正文来了就不再标着上一个文件', () => {
|
||||
const started = startRewrite(new Map(), ANCHOR)
|
||||
const reading = rewriteProgress(started, ANCHOR, QUESTION, '', '读取 routes.py')
|
||||
expect(reading.get(ANCHOR)).toEqual({ question: QUESTION, text: '', status: 'running', activity: '读取 routes.py' })
|
||||
const writing = rewriteProgress(reading, ANCHOR, QUESTION, '新的注释', undefined)
|
||||
expect(writing.get(ANCHOR)).toEqual({ question: QUESTION, text: '新的注释', status: 'running' })
|
||||
})
|
||||
|
||||
it('写进文件就拿掉;没写成把原因留在这块上;叫停也留着,不再进行', () => {
|
||||
const running = rewriteProgress(startRewrite(new Map(), ANCHOR), ANCHOR, QUESTION, '一半', '读取 a.py')
|
||||
expect(rewriteEnd(running, ANCHOR, 'done').has(ANCHOR)).toBe(false)
|
||||
const failed = rewriteEnd(running, ANCHOR, 'failed', '模型没有给出注释正文,没有改文件。')
|
||||
expect(failed.get(ANCHOR)).toMatchObject({ question: QUESTION, text: '一半', status: 'failed', error: '模型没有给出注释正文,没有改文件。' })
|
||||
expect(rewriteEnd(running, ANCHOR, 'stopped').get(ANCHOR)?.status).toBe('stopped')
|
||||
})
|
||||
|
||||
it('已经结束的,迟到的字不再把过程画出来;正在进行时再点一次也不重开', () => {
|
||||
const running = startRewrite(new Map(), ANCHOR)
|
||||
const done = rewriteEnd(running, ANCHOR, 'done')
|
||||
expect(rewriteProgress(done, ANCHOR, QUESTION, '迟到了').has(ANCHOR)).toBe(false)
|
||||
expect(startRewrite(running, ANCHOR)).toBe(running)
|
||||
const failed = rewriteEnd(running, ANCHOR, 'failed', '没写成')
|
||||
expect(startRewrite(failed, ANCHOR).get(ANCHOR)?.status).toBe('running')
|
||||
})
|
||||
|
||||
it('这一页上没有的结束消息不动原来的', () => {
|
||||
const runs: RewriteRuns = new Map()
|
||||
expect(rewriteEnd(runs, ANCHOR, 'failed', '没有')).toBe(runs)
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user