()
| 166 | } |
| 167 | |
| 168 | async function main() { |
| 169 | await prepareBuild() |
| 170 | const tempRoot = await mkdtemp(join(tmpdir(), 'zennotes-sidebar-vim-')) |
| 171 | const vaultRoot = join(tempRoot, 'vault') |
| 172 | const userDataRoot = join(tempRoot, 'user-data') |
| 173 | await seedVault(vaultRoot) |
| 174 | await seedUserData(userDataRoot, vaultRoot) |
| 175 | const port = await getFreePort() |
| 176 | |
| 177 | const child = spawn(electronPath, [`--remote-debugging-port=${port}`, desktopOutMain], { |
| 178 | cwd: repoRoot, |
| 179 | env: { ...process.env, ELECTRON_DISABLE_SECURITY_WARNINGS: '1', ZENNOTES_USER_DATA_PATH: userDataRoot }, |
| 180 | stdio: ['ignore', 'pipe', 'pipe'] |
| 181 | }) |
| 182 | let log = '' |
| 183 | child.stdout.on('data', (c) => (log += c)); child.stderr.on('data', (c) => (log += c)) |
| 184 | |
| 185 | const errors = [] |
| 186 | const failures = [] |
| 187 | const check = (name, ok, detail) => { |
| 188 | if (ok) console.log(` PASS ${name}`) |
| 189 | else { failures.push(name); console.error(` FAIL ${name}${detail ? ` — ${detail}` : ''}`) } |
| 190 | } |
| 191 | |
| 192 | let client |
| 193 | try { |
| 194 | client = await connectPage(port) |
| 195 | client.on('Runtime.consoleAPICalled', (e) => { |
| 196 | if (e.type === 'error') errors.push(e.args?.map((a) => a.value ?? a.description ?? '').join(' ')) |
| 197 | }) |
| 198 | await Promise.all([client.send('Page.enable'), client.send('Runtime.enable')]) |
| 199 | |
| 200 | console.log(`\nSidebar vim smoke test — ${NOTE_COUNT} notes\n`) |
| 201 | |
| 202 | // Wait for the seeded notes to render; expand inbox if it loads collapsed. |
| 203 | const ready = await until(client, `(() => { |
| 204 | const notes = document.querySelectorAll('[data-sidebar-type="note"]').length; |
| 205 | if (notes === 0) { |
| 206 | const f = document.querySelector('[data-sidebar-type="folder"][data-sidebar-folder="inbox"][data-sidebar-subpath=""]'); |
| 207 | if (f && f.getAttribute('data-sidebar-collapsed') === 'true') f.click(); |
| 208 | } |
| 209 | return notes >= ${NOTE_COUNT - 5}; |
| 210 | })()`, 35000, 200) |
| 211 | check('vault loads and notes render in the sidebar', !!ready, |
| 212 | ready ? '' : `log tail: ${JSON.stringify(log.slice(-300))}`) |
| 213 | if (!ready) throw new Error('notes never rendered — aborting') |
| 214 | await sleep(300) |
| 215 | |
| 216 | // 1. Windowing is active: every row present, but most are cheap placeholders. |
| 217 | const counts = await evaluate(client, `(() => ({ |
| 218 | all: document.querySelectorAll('[data-sidebar-type="note"]').length, |
| 219 | full: document.querySelectorAll('button[data-sidebar-type="note"]').length, |
| 220 | placeholders: document.querySelectorAll('div[data-sidebar-type="note"]').length, |
| 221 | }))()`) |
| 222 | check('windowing active — all rows present, most are placeholders', |
| 223 | counts.all >= NOTE_COUNT - 5 && counts.placeholders > counts.full && counts.full < 200, JSON.stringify(counts)) |
| 224 | |
| 225 | // 2. Placeholders occupy real vertical space → list has full scroll height. |
no test coverage detected