e0a5f57793
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.
57 lines
2.0 KiB
TypeScript
57 lines
2.0 KiB
TypeScript
import { mount } from '@vue/test-utils'
|
|
import { describe, expect, it, vi } from 'vitest'
|
|
import { nextTick } from 'vue'
|
|
import Demo from '../../playground/src/pages/mermaid-export-demo.vue'
|
|
import MermaidBlockNode from '../../src/components/MermaidBlockNode/MermaidBlockNode.vue'
|
|
|
|
describe('playground mermaid-export demo', () => {
|
|
it('intercepts export and displays uploaded URL', async () => {
|
|
vi.useFakeTimers()
|
|
|
|
const wrapper = mount(Demo as any, { attachTo: document.body })
|
|
|
|
// Wait for mounted lifecycle
|
|
await nextTick()
|
|
|
|
// Find the rendered MermaidBlockNode instance
|
|
const m = wrapper.findComponent(MermaidBlockNode as any)
|
|
expect(m.exists()).toBeTruthy()
|
|
|
|
// Ensure the export button will be shown by setting mermaidAvailable
|
|
;(m.vm as any).mermaidAvailable = true
|
|
;(m.vm as any).showSource = false
|
|
await nextTick()
|
|
|
|
// Inject a fake SVG into the mermaid content area so export handler has something
|
|
const content = m.find('div._mermaid')
|
|
expect(content.exists()).toBeTruthy()
|
|
content.element.innerHTML = '<svg xmlns="http://www.w3.org/2000/svg"><g></g></svg>'
|
|
|
|
await nextTick()
|
|
|
|
// Instead of relying on DOM click wiring, emit the `export` event directly on the child
|
|
const ev = {
|
|
payload: { type: 'export' },
|
|
defaultPrevented: false,
|
|
preventDefault() { this.defaultPrevented = true },
|
|
svgElement: content.element.querySelector('svg'),
|
|
svgString: '<svg></svg>',
|
|
}
|
|
;(m.vm as any).$emit('export', ev)
|
|
|
|
// Advance timers to resolve the component's fake upload (700ms)
|
|
vi.runAllTimers()
|
|
// allow microtasks scheduled by async handlers to run
|
|
await Promise.resolve()
|
|
await nextTick()
|
|
|
|
// The uploaded URL should be displayed by the demo
|
|
expect(wrapper.html()).toContain('Uploaded')
|
|
const link = wrapper.find('a')
|
|
expect(link.exists()).toBeTruthy()
|
|
expect(link.attributes('href') || '').toMatch(/^https:\/\/example\.com\/uploads/)
|
|
|
|
vi.useRealTimers()
|
|
})
|
|
})
|