Files
tamagotchi-paradise-ko/test/ui_keept18_test.js
T
syskiller 2d48091205 줄바꿈을 LF로 통일
서버에서 바로 빌드하고 고칠 수 있게 저장소 줄바꿈을 LF로 맞췄습니다.
CRLF로 들어가 있던 sh 빌드 스크립트도 이제 리눅스에서 그대로 돌아갑니다.
내용은 바뀌지 않았습니다.
2026-11-24 07:13:54 +09:00

43 lines
3.3 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// 1.6.10 test5: start device with a further T18Emu: removing the main program (and others) keeps all of T18Emu's
// blocks, spares, program and save. node test/ui_keept18_test.js <start device ROM with T18Emu in the menu> <out_dir>
const { chromium } = require('playwright');
const fs = require('fs'), path = require('path');
const E = require('../src/emu.js'), F = require('../src/feld.js');
(async () => {
const [rom, out, broken] = process.argv.slice(2);
fs.mkdirSync(out, { recursive: true });
let bad = 0; const ok = (c, m) => { console.log((c ? 'ok ' : 'FAIL ') + m); if (!c) bad++; };
const st = new Uint8Array(fs.readFileSync(__dirname + '/../feld/stub_feld_tpl.bin'));
const a = new Uint8Array(fs.readFileSync(rom));
const t18 = E.appsRead(a, F.feldApps(a, st).apps).find((x) => x.kind === 't18');
ok(!!t18, 'T18Emu in the menu');
const b = await chromium.launch(); const p = await b.newPage({ viewport: { width: 1280, height: 900 }, acceptDownloads: true });
const errors = []; p.on('pageerror', (e) => errors.push(e.message));
await p.addInitScript(() => { try { localStorage.setItem('paramix-lang', 'de'); } catch (e) {} });
await p.goto('file://' + path.resolve(__dirname, '../dist/ParamixStudio.html'));
await p.setInputFiles('#fileRom', rom); await p.waitForSelector('#work.on', { timeout: 60000 }); await p.waitForTimeout(1500);
ok(!(await p.evaluate(() => !!document.querySelector('#plan .rule.warn'))), 'no damage note for an intact T18Emu');
if (broken) {
await p.setInputFiles('#fileRom', broken); await p.waitForTimeout(3000);
ok(/Tama Meets ist beschädigt/.test(await p.evaluate(() => (document.querySelector('#plan .rule.warn') || {}).textContent || '')), 'damage note for emptied T18Emu blocks');
await p.setInputFiles('#fileRom', rom); await p.waitForTimeout(3000);
}
await p.click('.tab[data-tab="emu"]'); await p.waitForTimeout(300);
// the main program (first row) out, and every further one that is not T18Emu
const n = await p.evaluate(() => { let k = 0; for (const r of [...document.querySelectorAll('#appsList .prow')]) { const nm = r.querySelector('.pname').textContent.trim(); if (/TAMA MEETS|WOLFENSTEIN/.test(nm)) continue; const d = [...r.querySelectorAll('button')].find((x) => x.textContent.trim() === '×'); if (d) { d.click(); k++; break; } } return k; });
ok(n === 1, 'main program removed');
await p.waitForTimeout(1500);
const dlp = p.waitForEvent('download', { timeout: 180000 }); await p.click('#btnSave');
const dl = await dlp; const r1 = out + '/' + dl.suggestedFilename(); await dl.saveAs(r1);
const o = new Uint8Array(fs.readFileSync(r1));
const c = E.t18Cfg(a, t18.off); let ch = 0;
for (const blk of c.map.concat(c.spare)) { if (blk === 0xFFFF) continue; const s = blk << 16; if (!a.subarray(s, s + 0x10000).every((v, k) => v === o[s + k])) ch++; }
ok(ch === 0, 'all T18Emu blocks unchanged (' + ch + ' changed)');
ok(a.subarray(c.saveOff, c.saveOff + 0x24000).every((v, k) => v === o[c.saveOff + k]), 'T18Emu save unchanged');
ok(!!E.appsRead(o, F.feldApps(o, st).apps).find((x) => x.kind === 't18' && x.off === t18.off), 'T18Emu still in the menu at its place');
ok(!errors.length, 'no page errors ' + errors.join('; '));
await b.close();
fs.unlinkSync(r1);
console.log(bad ? 'FAIL ' + bad : 'all good');
})();