// FILE: _St/IG_StYellow/test_ext_download_restore_v279aa.js | ROLE: v279aa 수동 다운로드 복구·안내 우선순위 회귀 검사
const fs = require('fs');
const path = require('path');
const assert = require('assert');
const root = __dirname;
const read = (f) => fs.readFileSync(path.join(root,f),'utf8');
const manifest = JSON.parse(read('manifest.json'));
const bg = read('background.js');
const content = read('content_instagram.js');
const side = read('side.js');
const html = read('side.html');
const inject = read(path.join('js','instagram_inject.js'));
assert.strictEqual(manifest.version_name,'2.3.8.280');
assert.ok((manifest.permissions||[]).includes('downloads'));
assert.ok(bg.includes('function igblueDownloadWithChromeFallback'));
assert.ok(bg.includes('WS8771 미실행: 확장 수동 다운로드로 전환합니다.'));
assert.ok(bg.includes('if(msg && msg.auto_direct_download)'));
assert.ok(content.includes('ndy_content_down_background_redirect'));
assert.ok(!content.includes('new CustomEvent("ndy_ig_down"'));
for (const token of ['page_downloader','URL.createObjectURL','document.addEventListener("ndy_ig_down"','Download triggered']) assert.ok(!inject.includes(token), token);
assert.ok(side.includes('startBtn.disabled = !teAutoPyLastPyOk'));
assert.ok(!side.includes('startBtn.disabled = !teAutoPyCdpReady'));
assert.ok(!side.includes('if (!teAutoPyCdpReady) { teAutoPyApplyCdpNotice();'));
assert.ok(side.includes('teAiwkSetupNotice(true, "Auto8700/WS8771 미실행")'));
assert.ok(side.includes('Auto8700 미실행'));
assert.ok(html.includes('_St.zip 다운로드'));
assert.ok(html.includes('_St\\Auto8700\\run_auto_service8700_manager.bat'));
assert.ok(html.includes('CDP는 자동예약에만 필요합니다.'));
console.log('test_ext_download_restore_v279aa: OK');
