// FILE: _St/IG_StYellow/test_ext_single_tab_navigation_v284.js | ROLE: v285 고정 탭 검색 계정 순회·v283 다운로드 보존 검사
const assert=require('assert');
const fs=require('fs');
const path=require('path');
const root=__dirname;
const bg=fs.readFileSync(path.join(root,'background.js'),'utf8');
const side=fs.readFileSync(path.join(root,'side.js'),'utf8');
const content=fs.readFileSync(path.join(root,'content_instagram.js'),'utf8');
const manifest=JSON.parse(fs.readFileSync(path.join(root,'manifest.json'),'utf8'));
assert.strictEqual(manifest.version,'2.3.8.2850');
assert.strictEqual(manifest.version_name,'2.3.8.285');
const nav=bg.slice(bg.indexOf('function igblueSearchAccountInActiveTab'),bg.indexOf('function igblueEnsureContentScripts',bg.indexOf('function igblueSearchAccountInActiveTab')));
assert.ok(nav.includes('same_tab:true'));
assert.ok(nav.includes('type:"igblue_search_account_in_tab"'));
assert.ok(!nav.includes('chrome.tabs.update('));
assert.ok(!nav.includes('chrome.tabs.create('));
assert.ok(!nav.includes('chrome.tabs.remove('));
assert.ok(!nav.includes('handoff'));
assert.ok(side.includes('action: "instagram_search_exact_click"'));
assert.ok(side.includes('type: "IGBLUE_SEARCH_ACCOUNT_IN_TAB"'));
assert.ok(side.includes('account_context_mismatch'));
assert.ok(side.includes('["profile_loaded", "private"]'));
assert.ok(content.includes('svg[aria-label="검색"],svg[aria-label="Search"]'));
assert.ok(content.includes('exact_search_result_not_found'));
assert.ok(content.includes('igblueResetAccountContextForSearch'));
assert.ok(!side.includes('S00_ACCOUNT_HANDOFF_FAILED'));
const dl=bg.slice(bg.indexOf('function igblueDownloadWithApi(msg, sendResponse)'),bg.indexOf('function igblueIsInstagramUrl(url)',bg.indexOf('function igblueDownloadWithApi(msg, sendResponse)')));
for(const token of ['YELLOW_TEMP/','chrome.downloads.download','ig_media_downloaded','Chrome session download · WS8771 move complete']) assert.ok(dl.includes(token),`v283 download regression: ${token}`);
console.log('OK test_ext_single_tab_navigation_v284 v285 search');
