const test = require('node:test'); const assert = require('node:assert/strict'); const fs = require('node:fs'); const path = require('node:path'); const root = path.resolve(__dirname, '..'); const styles = fs.readFileSync(path.join(root, 'styles.css'), 'utf8'); const mailUi = fs.readFileSync(path.join(root, 'mail-ui.js'), 'utf8'); const app = fs.readFileSync(path.join(root, 'app.js'), 'utf8'); const transport = fs.readFileSync(path.join(root, 'android', 'app', 'src', 'main', 'java', 'studio', 'daybreak', 'mail', 'AndroidMailTransport.kt'), 'utf8'); const mainActivity = fs.readFileSync(path.join(root, 'android', 'app', 'src', 'main', 'java', 'studio', 'daybreak', 'mail', 'MainActivity.java'), 'utf8'); const packageJson = JSON.parse(fs.readFileSync(path.join(root, 'package.json'), 'utf8')); const packageLock = JSON.parse(fs.readFileSync(path.join(root, 'package-lock.json'), 'utf8')); test('mobile layout removes desktop minimum width and provides a compact reader flow', () => { assert.match(styles, /min-width:320px/); assert.match(styles, /@media\(max-width:1000px\),\(max-height:500px\) and \(orientation:landscape\)/); assert.match(styles, /@media\(max-height:500px\) and \(orientation:landscape\)/); assert.match(styles, /overflow-wrap:anywhere;word-break:break-word/); assert.match(styles, /\.hidden,\[hidden\]\{display:none!important\}/); assert.match(styles, /body\.reader-open \.mail-layout \.list-pane/); assert.match(app, /id="reader-back"/); assert.match(app, /classList\.add\('reader-open'\)/); assert.match(app, /\$\$\('\.folder'\)\.forEach/); assert.match(app, /if\(!m\)\{state\.activeMessage=null;document\.body\.classList\.remove\('reader-open'\);return;\}/); }); test('mailbox setup exposes ports and TLS modes and submits them to Android', () => { for (const id of ['mail-account-imap-port', 'mail-account-imap-secure', 'mail-account-smtp-port', 'mail-account-smtp-secure']) { assert.ok(mailUi.includes(`id="${id}"`), `missing account field ${id}`); } assert.match(mailUi, /imapPort,/); assert.match(mailUi, /imapSecure:/); assert.match(mailUi, /smtpPort,/); assert.match(mailUi, /smtpSecure:/); }); test('Android mail transport supports verified implicit TLS and required STARTTLS modes', () => { assert.match(transport, /"imaps" else "imap"/); assert.match(transport, /mail\.\$protocol\.starttls\.required/); assert.match(transport, /mail\.smtp\.ssl\.enable/); assert.match(transport, /mail\.smtp\.starttls\.required/); assert.match(transport, /ssl\.checkserveridentity/); }); test('Capacitor mail plugin is registered before BridgeActivity creates the bridge', () => { assert.ok(mainActivity.indexOf('registerPlugin(EpMailPlugin.class)') < mainActivity.indexOf('super.onCreate(savedInstanceState)')); }); test('OpenPGP.js is pinned to the exact version in the lockfile pending security review', () => { assert.equal(packageJson.dependencies.openpgp, packageLock.packages['node_modules/openpgp'].version); assert.match(packageJson.dependencies.openpgp, /^\d+\.\d+\.\d+$/); });