feat: capture clipboard links in inbox gui

This commit is contained in:
2026-06-05 01:55:38 +08:00
parent 44d0be2649
commit 326f6f283d
9 changed files with 96 additions and 8 deletions
+29 -1
View File
@@ -140,8 +140,12 @@ async function runReadyScenario(cdp, url) {
await assertText(cdp, 'Текст', 'inbox: capture kind visible')
await assertText(cdp, 'Буфер обмена', 'inbox: capture source visible')
await assertEval(cdp, `!document.querySelector('.inbox-screen')?.innerText.includes('Manual Root Item')`, 'inbox: manual root is hidden')
await setClipboardText(cdp, 'https://example.test/from-clipboard')
await clickText(cdp, '.inbox-header .btn', 'Вставить из буфера')
await assertText(cdp, 'https://example.test/from-clipboard', 'inbox: clipboard URL captured')
await assertText(cdp, 'Ссылка', 'inbox: clipboard URL kind visible')
await screenshot(cdp, 'inbox.png')
await clickText(cdp, '.inbox-item-actions .btn', 'Открыть')
await clickText(cdp, '.inbox-item', 'Inbox Smoke Item')
await assertText(cdp, 'Inbox Smoke Item', 'inbox: item opens from list')
await clickText(cdp, '.nav-item', 'Корзина')
@@ -335,6 +339,13 @@ async function setInputValue(cdp, selector, value) {
await sleep(100)
}
async function setClipboardText(cdp, value) {
await cdp.send('Runtime.evaluate', {
expression: `window.__VERSTAK_GUI_SMOKE_CLIPBOARD__ = ${JSON.stringify(value)}`,
returnByValue: true,
})
}
async function clickFolderOpenButton(cdp, name) {
const ok = await evalValue(cdp, `
(() => {
@@ -559,6 +570,13 @@ function wailsMockSource() {
const clone = (value) => JSON.parse(JSON.stringify(value));
const mode = new URL(location.href).searchParams.get('smokeMode') || 'ready';
Object.defineProperty(navigator, 'clipboard', {
configurable: true,
value: {
readText: async () => window.__VERSTAK_GUI_SMOKE_CLIPBOARD__ || '',
},
});
const templates = [
{ id: 'folder.default', title: 'template.folder.default', icon: 'folder', enabled: true },
{ id: 'project.default', title: 'template.project.default', icon: 'project', enabled: true },
@@ -691,6 +709,16 @@ function wailsMockSource() {
ListWorkspaceTree: async () => clone(state.nodes.filter((node) => node.captureInbox !== true)),
ListWorkspaceChildren: async (id) => clone(childrenOf(id)),
ListInboxNodes: async () => clone(state.nodes.filter((node) => !node.parent_id && node.captureInbox === true).map((node) => ({ ...node, captureKind: node.captureKind || '', captureSource: node.captureSource || '' }))),
CaptureText: async (text) => {
const node = { id: 'node-capture-text-' + Date.now(), title: String(text || '').trim().split('\\n').find(Boolean) || 'Captured text', type: 'note', section: '', captureInbox: true, captureKind: 'text', captureSource: 'clipboard', createdAt: now, has_children: false, children: [] };
state.nodes.push(node);
return clone({ ...node, captureKind: node.captureKind, captureSource: node.captureSource });
},
CaptureURL: async (url, title) => {
const node = { id: 'node-capture-url-' + Date.now(), title: title || url, type: 'note', section: '', captureInbox: true, captureKind: 'url', captureSource: 'clipboard', createdAt: now, has_children: false, children: [] };
state.nodes.push(node);
return clone({ ...node, captureKind: node.captureKind, captureSource: node.captureSource });
},
ListTrash: async () => clone({
trashPath: '/tmp/verstak-smoke-vault/.verstak/trash',
nodes: [{ id: 'node-trash', title: 'Trash Smoke Folder', type: 'folder', fsPath: 'Trash Smoke Folder', deletedAt: now }],