const test = require('node:test'); const assert = require('node:assert/strict'); const { readFileSync } = require('node:fs'); const { join } = require('node:path'); const projectRoot = join(__dirname, '..'); const destructiveModules = [ 'album-pages.js', 'article-pages.js', 'ceremony-admin-pages.js', 'earning-pages.js', 'feed-pages.js', 'genealogy-lifecycle-pages.js', 'generation-pages.js', 'growth-pages.js', 'join-pages.js', 'lineage-pages.js', 'memo-pages.js', 'member-admin-pages.js', 'merit-pages.js', 'person-document-pages.js', 'relative-pages.js', 'security-pages.js', 'video-pages.js', 'vip-pages.js' ]; test('destructive business actions use the shared in-page confirmation dialog', () => { const profileCommon = readFileSync(join(projectRoot, 'public', 'js', 'profile-common.js'), 'utf8'); assert.match(profileCommon, /confirmAction:\s*confirmAction/); destructiveModules.forEach((fileName) => { const source = readFileSync(join(projectRoot, 'public', 'js', fileName), 'utf8'); assert.doesNotMatch(source, /root\.confirm\s*\(/, `${fileName} should not open a native browser confirm`); assert.match(source, /ProfileUI\.confirmAction/, `${fileName} should use the shared confirmation dialog`); }); }); test('password-protected document actions use the shared masked prompt dialog', () => { const profileCommon = readFileSync(join(projectRoot, 'public', 'js', 'profile-common.js'), 'utf8'); const documentSource = readFileSync(join(projectRoot, 'public', 'js', 'person-document-pages.js'), 'utf8'); assert.match(profileCommon, /promptAction:\s*promptAction/); assert.doesNotMatch(documentSource, /root\.prompt\s*\(/); assert.match(documentSource, /ProfileUI\.promptAction/); }); test('legacy logout dialog stays out of the focus order until opened', () => { const page = readFileSync(join(projectRoot, 'profile.html'), 'utf8'); const profileCommon = readFileSync(join(projectRoot, 'public', 'js', 'profile-common.js'), 'utf8'); const styles = readFileSync(join(projectRoot, 'public', 'css', 'profile.css'), 'utf8'); assert.match(page, /id="logoutModal"[^>]*\shidden/); assert.match(profileCommon, /prop\('hidden', false\).*addClass\('show'\)/); assert.match(profileCommon, /removeClass\('show'\).*prop\('hidden', true\)/); assert.match(styles, /\.logout-modal\[hidden\]\s*\{\s*display:\s*none;/); });