Verify (Gitea) / gate (build · unit · facts) (push) Failing after 1m42s
- 窗口固定 860×620;右下角拖拽调整、双击复位、尺寸持久化;切换分类不再改窗口高度 - 面板加载 effect 只依赖 open+源库路径(actions 用 ref),复制不再触发重新读库 - 批量复制:延迟 setWorkspaces(deferState),结束后一次 commitList(一次渲染+一次写索引) - 修复 268 接线:app 端 createBoard(b, opts) 之前只传 b,silent/defer 未生效 - 记住上次分类/排序
70 lines
3.1 KiB
JavaScript
70 lines
3.1 KiB
JavaScript
'use strict'
|
||
const test = require('node:test')
|
||
const assert = require('node:assert')
|
||
const fs = require('node:fs')
|
||
const path = require('node:path')
|
||
|
||
const SRC_DIR = path.join(__dirname, '..', 'src')
|
||
const loadSrc = (g, file) => new Function('window', 'globalThis', fs.readFileSync(path.join(SRC_DIR, file), 'utf8'))(g, g)
|
||
|
||
function makeEnv() {
|
||
const g = { console, setTimeout, btoa: (s) => Buffer.from(s, 'binary').toString('base64'), atob: (s) => Buffer.from(s, 'base64').toString('binary') }
|
||
;['vault-browse.js', 'board-transfer.js', 'vault-browse-actions.js'].forEach((f) => loadSrc(g, f))
|
||
const vault = '/fake/vault'
|
||
const files = {
|
||
[vault + '/data.json']: JSON.stringify({ keys: {}, assets: {} }),
|
||
[vault + '/canvases/a.json']: JSON.stringify({ id: 'a', name: 'A', nodes: [{ id: 'n1', type: 'prompt', data: { text: 'hi' } }], edges: [], groups: [] }),
|
||
[vault + '/canvases/b.json']: JSON.stringify({ id: 'b', name: 'B', nodes: [{ id: 'n2', type: 'prompt', data: { text: 'yo' } }], edges: [], groups: [] }),
|
||
}
|
||
const tauri = {
|
||
fs: {
|
||
readTextFile: async (p) => { if (!(p in files)) throw new Error('ENOENT'); return files[p] },
|
||
readDir: async (p) => Object.keys(files).filter((k) => k.indexOf(p + '/') === 0 && k.slice(p.length + 1).indexOf('/') < 0).map((k) => ({ name: k.split('/').pop(), isDirectory: false })),
|
||
readFile: async () => new Uint8Array([1, 2, 3]),
|
||
},
|
||
core: {
|
||
invoke: async (cmd, args) => {
|
||
if (cmd === 'read_text_many') return (args.rels || []).map((rel) => ({ rel, text: files[vault + '/' + rel] }))
|
||
if (cmd === 'stat_many') return (args.rels || []).map((rel) => ({ rel, exists: true, size: 1, mtime: 1000 }))
|
||
if (cmd === 'read_files_b64') return []
|
||
return true
|
||
},
|
||
},
|
||
}
|
||
const calls = { create: [], persist: 0 }
|
||
let n = 0
|
||
const actions = g.IWBStorageFile.vaultBrowseActions.create({
|
||
tauri,
|
||
grantDir: async () => true,
|
||
writeImage: async () => ({ __blob: 'imgblob_x' }),
|
||
createBoard: (b, opts) => { calls.create.push({ name: b.name, opts }); return { id: 'ws' + (++n), list: [{ id: 'ws' + n }] } },
|
||
commitList: async () => { calls.persist++ },
|
||
flush: async () => {},
|
||
uid: (p) => p + (++n),
|
||
currentBoardNames: () => [],
|
||
})
|
||
return { g, actions, calls, vault }
|
||
}
|
||
|
||
test('copyMany:逐个 silent 建板 + 只 persist 一次', async () => {
|
||
const { actions, calls, vault } = makeEnv()
|
||
const r = await actions.copyMany(vault, [{ id: 'a', name: 'A' }, { id: 'b', name: 'B' }])
|
||
assert.equal(r.length, 2)
|
||
assert.equal(r.every((x) => x.ok), true)
|
||
assert.equal(calls.create.length, 2)
|
||
assert.equal(calls.create[0].opts.silent, true)
|
||
assert.equal(calls.create[0].opts.deferState, true)
|
||
assert.equal(calls.create[1].opts.silent, true)
|
||
assert.equal(calls.create[1].opts.deferState, true)
|
||
assert.equal(calls.persist, 1)
|
||
})
|
||
|
||
test('copyOne(单个):走切换路径(silent=false)', async () => {
|
||
const { actions, calls, vault } = makeEnv()
|
||
const r = await actions.copyOne(vault, 'a', 'A')
|
||
assert.equal(r.ok, true)
|
||
assert.equal(calls.create.length, 1)
|
||
assert.equal(calls.create[0].opts.silent, false)
|
||
})
|
||
|