// FILE: _St/Analyze8780/test_analyze8780_ui.js | ROLE: Analyze8780 LIKE 검색·DB 번호·미디어·차트·페이징 UI 회귀 테스트
const assert = require('assert');
const fs = require('fs');
const path = require('path');

const html = fs.readFileSync(path.join(__dirname, 'web', 'index.html'), 'utf8');

assert.ok(!html.includes('id="accountPager"'));
assert.ok(!html.includes('id="refreshAccounts"'));
assert.ok(!html.includes('0/200'));
assert.ok(html.includes('const ACCOUNT_PAGE_SIZE=10000'));
assert.ok(html.includes('<option value="10000">10000</option>'));
assert.ok(html.includes('page_size=${ACCOUNT_PAGE_SIZE}&search=${encodeURIComponent(pattern)}'));
assert.ok(html.includes('/api/accounts/check?search=${encodeURIComponent(currentSearchPattern())}'));
assert.ok(html.includes('입력값을 SQLite <b>LIKE</b> 조건에 그대로 사용합니다.'));
assert.ok(html.includes('<code>%단어%</code>'));
assert.ok(html.includes('<code>_</code> 임의의 한 글자'));
assert.ok(!html.includes('matchAccountQuery'));
assert.ok(html.includes('id="databaseButtons"'));
assert.ok(html.includes('button.onclick=()=>switchDatabase(filename)'));
assert.ok(html.includes('/api/database/open'));
assert.ok(html.includes('/api/open-folder'));
assert.ok(html.includes('virtual_path'));
assert.ok(!html.includes('/api/posts/${post.id}/media/${asset.id}'));
assert.ok(html.includes('media_files'));
assert.ok(html.includes('absolute_path'));
assert.ok(html.includes('📋 경로 복사'));
assert.ok(html.includes('copyLocalPath'));
assert.ok(html.includes('DB 통계와 저장된 미디어 ${fileCount}개를 함께 삭제합니다.'));
assert.ok(html.includes('https://cdn.jsdelivr.net/npm/apexcharts'));
assert.ok(html.includes('stats?limit=${uiSettings.chartLimit}'));
assert.ok(html.includes("const SETTINGS_KEY='analyze8780.settings.v290'"));
assert.ok(html.includes('id="settingsButton"'));
assert.ok(html.includes('id="settingMediaWidth" type="text"'));
assert.ok(html.includes('function validCssSize(value)'));
assert.ok(html.includes("typeof value==='number'&&Number.isFinite(value)?value:null"));
assert.ok(html.includes('id="settingChartDays"'));
assert.ok(html.includes('id="settingYAuto"'));
assert.ok(html.includes('function chartValue(value)'));
assert.ok(html.includes('connectNulls:false'));
assert.ok(html.includes('function mediaViewHtml(post)'));
assert.ok(html.includes('webp|avif'));
assert.ok(html.includes("kinds.push(ext||'IMG')"));
assert.ok(html.includes('class=\"media-view media-video\"'));
assert.ok(html.includes('🖼 이미지 열기'));
assert.ok(html.includes('▶ 동영상 열기'));
assert.ok(html.includes('📁 폴더 열기'));
assert.ok(html.includes('shared:true,intersect:false,followCursor:true'));
assert.ok(html.includes('object-fit:contain'));
console.log('OK test_analyze8780_ui');
