test(ui): verify the template download button saves the file in Chrome
- scripts/verify-template-download.cjs clicks 입력 템플릿 다운로드 and reports the saved file - result: 교각입력템플릿.xlsx (19,391 bytes), sheets 교각 · IP · 받침 - verify/template-download-2026-10-21.xlsx keeps the saved copy as evidence Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
6319cccb8e
commit
def1e1b9fc
2 files changed
+43
No files matched your search
@@ -0,0 +1,43 @@
|
||||
// Clicks the template download button in the import dialog through Chrome DevTools
|
||||
// and reports the saved file. Run with Windows Node (same machine as Chrome):
|
||||
// node verify-template-download.cjs "C:\\Users\\...\\Temp\\verify-downloads"
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const DL_DIR = process.argv[2];
|
||||
const CDP = 'http://127.0.0.1:9444';
|
||||
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
||||
|
||||
async function main() {
|
||||
fs.mkdirSync(DL_DIR, { recursive: true });
|
||||
const page = (await (await fetch(`${CDP}/json`)).json()).find((t) => t.type === 'page');
|
||||
const ws = new WebSocket(page.webSocketDebuggerUrl);
|
||||
await new Promise((res, rej) => { ws.onopen = res; ws.onerror = rej; });
|
||||
let seq = 0;
|
||||
const waiting = new Map();
|
||||
ws.onmessage = (ev) => {
|
||||
const m = JSON.parse(ev.data);
|
||||
if (m.id && waiting.has(m.id)) { waiting.get(m.id)(m); waiting.delete(m.id); }
|
||||
};
|
||||
const send = (method, params = {}) => new Promise((res) => {
|
||||
const id = ++seq; waiting.set(id, res); ws.send(JSON.stringify({ id, method, params }));
|
||||
});
|
||||
const evalJs = async (expression) => {
|
||||
const r = await send('Runtime.evaluate', { expression, awaitPromise: true, returnByValue: true });
|
||||
if (r.result.exceptionDetails) throw new Error(JSON.stringify(r.result.exceptionDetails).slice(0, 300));
|
||||
return r.result.result.value;
|
||||
};
|
||||
await send('Page.enable');
|
||||
await send('Runtime.enable');
|
||||
await send('Browser.setDownloadBehavior', { behavior: 'allow', downloadPath: DL_DIR, eventsEnabled: false });
|
||||
await send('Page.navigate', { url: 'http://127.0.0.1:5173/' });
|
||||
await sleep(4000);
|
||||
await evalJs(`document.getElementById('open-import').click()`);
|
||||
await sleep(500);
|
||||
await evalJs(`document.getElementById('download-template').click()`);
|
||||
await sleep(4000);
|
||||
const files = fs.readdirSync(DL_DIR);
|
||||
console.log('DOWNLOADED', JSON.stringify(files));
|
||||
for (const f of files) console.log('SIZE', f, fs.statSync(path.join(DL_DIR, f)).size);
|
||||
ws.close();
|
||||
}
|
||||
main().catch((e) => { console.error('FAILED', e); process.exit(1); });
|
||||
Reference in new issue
Block a user