Files
BoosAPI/desktop/libs/markstream-vue/test/node-renderer-measurement-performance.test.ts
boos e0a5f57793 feat(desktop): embed BoosAPI Desktop client as a subproject
Vendor the rebranded BoosAPI Desktop client (Tauri + Vue) into metapi as
a monorepo subdirectory under desktop/. Source only — node_modules,
dist, Cargo target and the upstream .git history are excluded.

desktop/ keeps its own independent Cargo workspace (desktop/src-tauri
with crates/*); it is not part of the backend boosapi crate, so a
`cargo check` at the metapi root still compiles only the backend. Build
the desktop app from desktop/src-tauri per desktop/README.md.

Note: app icons are still placeholder assets pending the final BoosAPI
logo. The updater signing keys live outside the repo and are not
included.
2026-06-22 11:32:57 +08:00

79 lines
1.9 KiB
TypeScript

import { mount } from '@vue/test-utils'
import { describe, expect, it, vi } from 'vitest'
import { flushAll } from './setup/flush-all'
class CountingResizeObserver {
static observeCalls = 0
observe() {
CountingResizeObserver.observeCalls += 1
}
unobserve() {}
disconnect() {}
}
function createParagraph(index: number) {
return {
type: 'paragraph',
raw: `Paragraph ${index}`,
children: [
{
type: 'text',
content: `Paragraph ${index}`,
raw: `Paragraph ${index}`,
},
],
}
}
function createCodeBlock(index: number) {
return {
type: 'code_block',
language: 'js',
code: `console.log(${index})`,
raw: `\`\`\`js\nconsole.log(${index})\n\`\`\``,
loading: false,
}
}
describe('node renderer measurement performance', () => {
it('skips node height observers when virtualization is off', async () => {
CountingResizeObserver.observeCalls = 0
vi.stubGlobal('ResizeObserver', CountingResizeObserver as any)
const NodeRenderer = (await import('../src/components/NodeRenderer')).default
const wrapper = mount(NodeRenderer, {
props: {
nodes: [createParagraph(1), createCodeBlock(1)],
viewportPriority: false,
},
})
await flushAll()
expect(CountingResizeObserver.observeCalls).toBe(0)
wrapper.unmount()
})
it('still measures node heights when virtualization is on', async () => {
CountingResizeObserver.observeCalls = 0
vi.stubGlobal('ResizeObserver', CountingResizeObserver as any)
const NodeRenderer = (await import('../src/components/NodeRenderer')).default
const nodes = Array.from({ length: 4 }, (_, index) => createParagraph(index + 1))
const wrapper = mount(NodeRenderer, {
props: {
nodes,
maxLiveNodes: 1,
viewportPriority: false,
},
})
await flushAll()
expect(CountingResizeObserver.observeCalls).toBeGreaterThan(0)
wrapper.unmount()
})
})