⚡ perf(vscode): 代码阅读预览差异到了不再给每张卡片外面包一层:改动色条画在卡片里、挪到卡片外侧,卡片不拆掉重建
This commit is contained in:
1 parent
0ad4748cc6
commit
b2e998665e
3 files changed
+93
-63
No files matched your search
@@ -277,6 +277,37 @@ describe('一条消息只重画受影响的卡片', () => {
|
||||
expect(container.querySelector('[data-offset="30"]')?.getAttribute('data-occurrence')).toBe('normal')
|
||||
})
|
||||
|
||||
it('差异到了:卡片还是原来那个元素(不拆掉重建),改了的那块标上改动色条,删掉的块放回原处', async () => {
|
||||
await load()
|
||||
await deliver(copy(DOC))
|
||||
const cards = [...container.querySelectorAll('.cr-block')]
|
||||
const removed = { ...block('9', 'gone'), translation: [{ text: 'gone', role: 'plain' as const }] }
|
||||
renders.start()
|
||||
await deliver({
|
||||
type: 'diff',
|
||||
diff: {
|
||||
base: 'HEAD',
|
||||
version: 3,
|
||||
blocks: { save: { change: 'mod', own: true } },
|
||||
removed: [{ parent: '', after: 'save', block: removed, line: 9, kindName: '函数' }],
|
||||
stats: { add: 0, mod: 1, del: 1 },
|
||||
lineCount: 20,
|
||||
},
|
||||
})
|
||||
const counts = renders.stop()
|
||||
expect(counts.SegmentText).toBeUndefined()
|
||||
const after = [...container.querySelectorAll('.cr-block:not(.cr-removed)')]
|
||||
expect(after).toHaveLength(3)
|
||||
after.forEach((card, index) => expect(card).toBe(cards[index]))
|
||||
expect(container.querySelector('[data-id="1"] > .cr-change-bar')?.getAttribute('data-change')).toBe('mod')
|
||||
expect(container.querySelector('[data-id="0"] > .cr-change-bar')?.hasAttribute('data-change')).toBe(false)
|
||||
expect(container.querySelector('.cr-level')?.hasAttribute('data-diff')).toBe(true)
|
||||
const gone = container.querySelector('.cr-removed')!
|
||||
expect(gone.querySelector('.cr-change-bar')?.getAttribute('data-change')).toBe('del')
|
||||
expect(cards[1].compareDocumentPosition(gone) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy()
|
||||
expect(gone.compareDocumentPosition(cards[2]) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy()
|
||||
})
|
||||
|
||||
it('没展开、没说过的块下面不画问答区;展开一块只重画那一块', async () => {
|
||||
await load()
|
||||
await deliver({ type: 'qa', available: true, threads: [], path: [], subject: 'file', current: [], rewrites: [], rewriteCurrent: [] })
|
||||
|
||||
Reference in new issue
Block a user