Files
BoosAPI/desktop/libs/markstream-vue/test/mermaid-block-node-tooltip.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 { afterEach, describe, expect, it } from 'vitest'
import { nextTick } from 'vue'
import MermaidBlockNode from '../src/components/MermaidBlockNode/MermaidBlockNode.vue'
import { hideTooltip } from '../src/composables/useSingletonTooltip'
function makeNode() {
return {
type: 'code_block',
language: 'mermaid',
code: `graph TD
A[Start] --> B{Is it working?}
B -->|Yes| C[Great!]`,
raw: '',
}
}
function wait(ms: number) {
return new Promise(resolve => setTimeout(resolve, ms))
}
async function waitTooltipShow() {
await wait(100)
await nextTick()
}
describe('mermaidBlockNode tooltip toggles', () => {
afterEach(async () => {
hideTooltip(true)
await nextTick()
})
it('renders action buttons with default tooltip settings', async () => {
const wrapper = mount(MermaidBlockNode, {
props: {
loading: false,
node: makeNode(),
},
})
const firstActionBtn = wrapper.find('button.mermaid-action-btn')
expect(firstActionBtn.exists()).toBe(true)
wrapper.unmount()
})
it('disables tooltips when showTooltips is false', async () => {
const wrapper = mount(MermaidBlockNode, {
props: {
loading: false,
node: makeNode(),
showTooltips: false,
},
})
const firstActionBtn = wrapper.find('button.mermaid-action-btn')
await firstActionBtn.trigger('focus')
await waitTooltipShow()
expect(firstActionBtn.attributes('aria-describedby')).toBeUndefined()
wrapper.unmount()
})
it('normalizes streamed language labels in the header', async () => {
const mermaidWrapper = mount(MermaidBlockNode, {
props: {
loading: false,
node: {
...makeNode(),
language: 'mermaid',
},
},
})
expect(mermaidWrapper.text()).toContain('Mermaid')
mermaidWrapper.unmount()
})
})