test: unit and end-to-end suites
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
27fafa0bcd
commit
9b00e21c44
49 files changed
+6694
-1
No files matched your search
@@ -0,0 +1,45 @@
|
||||
const { app, BrowserWindow } = require('electron');
|
||||
const path = require('path');
|
||||
const os = require('os');
|
||||
const fs = require('fs');
|
||||
|
||||
const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'ink-test-rename-'));
|
||||
const vault = path.join(tmp, 'Vault');
|
||||
fs.mkdirSync(vault);
|
||||
|
||||
fs.writeFileSync(path.join(vault, 'A.md'), '# Target\n');
|
||||
fs.writeFileSync(path.join(vault, 'B.md'), 'Go to [[A#Target]]\n');
|
||||
|
||||
app.setPath('userData', tmp);
|
||||
fs.writeFileSync(path.join(tmp, 'settings.json'), JSON.stringify({ vault, lastPage: 'A', bounds: { width: 1280, height: 860 } }));
|
||||
require('../electron/main.cjs');
|
||||
|
||||
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
||||
|
||||
app.whenReady().then(async () => {
|
||||
let win;
|
||||
for (let i = 0; i < 80 && !(win = BrowserWindow.getAllWindows()[0]); i++) await sleep(100);
|
||||
const wc = win.webContents;
|
||||
if (wc.isLoading()) await new Promise((r) => wc.once('did-finish-load', r));
|
||||
const js = (code) => wc.executeJavaScript(`(async () => { ${code} })()`);
|
||||
|
||||
await sleep(1000);
|
||||
// Change heading in A
|
||||
await js(`
|
||||
const el = document.querySelector('.b-h1 .c');
|
||||
el.textContent = 'New Target';
|
||||
const evt = new Event('input', { bubbles: true });
|
||||
el.dispatchEvent(evt);
|
||||
`);
|
||||
// Trigger blur to save
|
||||
await js(`
|
||||
const el = document.querySelector('.b-h1 .c');
|
||||
el.blur();
|
||||
`);
|
||||
await sleep(3000); // Wait for heading renames to commit (2000ms delay)
|
||||
|
||||
// Read B
|
||||
const b = fs.readFileSync(path.join(vault, 'B.md'), 'utf8');
|
||||
console.log("B content:", b);
|
||||
app.exit();
|
||||
});
|
||||
Reference in new issue
Block a user