Files
BoosAPI/desktop/libs/markstream-vue/test/react-link-node-loading-state.test.tsx
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

70 lines
2.0 KiB
TypeScript

/**
* @vitest-environment jsdom
*/
/* eslint-disable antfu/no-import-node-modules-by-path */
import { afterEach, describe, expect, it } from 'vitest'
import React, { act } from '../packages/markstream-react/node_modules/react'
import { createRoot } from '../packages/markstream-react/node_modules/react-dom/client'
import { LinkNode } from '../packages/markstream-react/src/components/LinkNode/LinkNode'
async function flushReact() {
await act(async () => {
await Promise.resolve()
await Promise.resolve()
})
}
afterEach(() => {
document.body.innerHTML = ''
;(globalThis as any).IS_REACT_ACT_ENVIRONMENT = false
})
describe('markstream-react link loading state', () => {
it('renders a subtle loading hint instead of an anchor', async () => {
;(globalThis as any).IS_REACT_ACT_ENVIRONMENT = true
const host = document.createElement('div')
document.body.appendChild(host)
const root = createRoot(host)
await act(async () => {
root.render(React.createElement(LinkNode as any, {
node: {
type: 'link',
href: 'https://example.com',
title: null,
text: 'Example',
raw: '[Example](https://example.com',
loading: true,
children: [],
},
indexKey: 'react-link-loading',
ctx: {
typewriter: false,
codeBlockProps: {},
mermaidProps: {},
d2Props: {},
infographicProps: {},
showTooltips: true,
codeBlockStream: true,
renderCodeBlocksAsPre: false,
events: {},
},
}))
})
await flushReact()
expect(host.querySelector('a.link-node')).toBeNull()
const loading = host.querySelector('.link-loading') as HTMLElement | null
expect(loading).toBeTruthy()
expect(loading?.textContent).toContain('Example')
expect(host.querySelector('.link-loading-indicator')).toBeTruthy()
expect(loading?.getAttribute('style')).toContain('--underline-duration: 1.6s')
await act(async () => {
root.unmount()
})
})
})