Files
deepseek-harness/packages/experimental/webworker-runtime/tests/client/text-viewer.spec.ts
T
Turtle 805cb207be fix(webworker): open config files and load plugin manager in the preview (#5375)
* fix(webworker): load plugin manager and HMR in the preview Worker

The Worker disabled both rows, which left Creator mode's
tool-plugin-manager waiting for its service and the Plugins page without
a manageable profile. Only package commands are unavailable; the
services load. The Worker provides appReady from its own readiness
promise, resolved once the tunnel serves, and its process shim reports
no entry script, so HMR keeps only its profile configuration watches.

Fixes #5372

* fix(webworker): show xdg-open text files in a preview viewer

The Worker implements xdg-open as a platform executable that sends one
VFS text file to the page, which shows it in a read-only modal dialog.
Settings' "Open configuration file" now opens the profile patch in the
preview instead of failing on a missing desktop opener.

Fixes #5371
2026-09-28 19:29:45 +08:00

39 lines
1.6 KiB
TypeScript

// @vitest-environment jsdom
import { beforeAll, expect, it } from 'vitest'
import { showTextViewer } from '../../src/client/text-viewer.ts'
beforeAll(() => {
// jsdom lacks the modal dialog methods.
HTMLDialogElement.prototype.showModal = function showModal(this: HTMLDialogElement) { this.open = true }
HTMLDialogElement.prototype.close = function close(this: HTMLDialogElement) { this.open = false }
})
function viewer(): HTMLDialogElement {
return document.querySelector('dialog[data-preview-text-viewer]') as HTMLDialogElement
}
it('shows the file as plain text, replaces it on reuse, and closes from its button', () => {
showTextViewer('/dsh/home/a.yml', '<b>first</b>')
expect(viewer().open).toBe(true)
expect(viewer().querySelector('h2')?.textContent).toBe('/dsh/home/a.yml')
expect(viewer().querySelector('pre')?.innerHTML).toBe('&lt;b&gt;first&lt;/b&gt;')
showTextViewer('/dsh/home/b.yml', 'second')
expect(document.querySelectorAll('dialog[data-preview-text-viewer]')).toHaveLength(1)
expect(viewer().querySelector('pre')?.textContent).toBe('second')
viewer().querySelector('button')?.click()
expect(viewer().open).toBe(false)
})
it('keeps keys pressed in the viewer from reaching document-level modal layers', () => {
showTextViewer('/dsh/home/a.yml', 'text')
let reached = false
const listener = (): void => { reached = true }
document.addEventListener('keydown', listener)
viewer().querySelector('button')?.dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape', bubbles: true }))
document.removeEventListener('keydown', listener)
expect(reached).toBe(false)
})