// "Report a problem" (frame/reportModel.ts): the summary says versions and what is switched on, and // cannot say anything about the person: it has no field for an account, an address or a path, and // every value is reduced to id characters before it is written. import assert from 'node:assert/strict'; import { readFileSync } from 'node:fs'; import { dirname, join } from 'node:path'; import test from 'node:test'; import { fileURLToPath } from 'node:url'; import { FRAMEWORK_VERSION, buildReport, reportFileName, reportValue, systemFromUserAgent, webviewFromUserAgent, type ReportInfo } from '../src/frame/reportModel.ts'; const here = dirname(fileURLToPath(import.meta.url)); const INFO: ReportInfo = { product: 'wayBetter for X', appVersion: '1.3.2', system: 'Windows 11 (x64)', webview: 'WebView2 141.0.3537.71', language: 'tr', languageChoice: 'site', mode: 'advanced', theme: 'night-ink', iconPack: 'phosphor', plugins: ['reply-guard.plugin.js', 'mute-words.plugin.js'], details: [{ label: 'Paused features', values: ['composeCounter'] }], safeMode: false, }; test('the summary is one fact per line, in English', () => { assert.equal(buildReport(INFO), [ 'wayBetter for X 1.3.2', `Framework: wayBetter ${FRAMEWORK_VERSION}`, 'System: Windows 11 (x64)', 'Webview: WebView2 141.0.3537.71', 'Language: tr (chosen: site)', 'Mode: advanced', 'Theme: night-ink', 'Icon pack: phosphor', 'Plugins on: reply-guard.plugin.js, mute-words.plugin.js', 'Paused features: composeCounter', 'Safe mode: no', ].join('\n')); }); test('an app without modes, themes or plugins says less, never something made up', () => { const text = buildReport({ product: 'App', appVersion: '', system: '', webview: '', language: '', languageChoice: '', plugins: null, safeMode: true }); assert.equal(text, ['App unknown version', `Framework: wayBetter ${FRAMEWORK_VERSION}`, 'System: unknown', 'Webview: unknown', 'Language: unknown (chosen: unknown)', 'Plugins on: unknown', 'Safe mode: yes'].join('\n')); assert.match(buildReport({ ...INFO, mode: null, plugins: [], iconPack: '', details: [{ label: 'Paused features', values: [] }] }), /Mode: none chosen\n[\s\S]*Icon pack: the site's own\nPlugins on: none\nPaused features: none\n/); }); test('nothing about the person can ride along in a value', () => { const hostile: ReportInfo = { product: 'wayBetter for X