// 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.319');
assert.ok((manifest.permissions||[]).includes('downloads'));
assert.ok(bg.includes('function igblueDownloadWithChromeFallback'));
assert.ok(bg.includes('WS8771 미실행: 원래 인젝션 수동 다운로드로 전환합니다.'));
assert.ok(bg.includes('IGBLUE_MANUAL_USE_MAIN_DOWNLOADER'));
assert.ok(content.includes('igblue_manual_original_download'));
assert.ok(inject.includes('function teMainOriginalManualDownload('));
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"'));
assert.ok(!inject.includes('document.addEventListener("ndy_ig_down"'));
assert.ok(inject.includes('window.URL.createObjectURL(e)'));
assert.ok(inject.includes('n.download=`${stem}.${ext}`'));
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');
