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 read = file => fs.readFileSync(path.join(root, file), 'utf8');
test('renderer bootstrap loads shared state and mail security before the application', () => {
const html = read('index.html');
const state = html.indexOf('');
const contentSecurity = html.indexOf('');
const app = html.indexOf('');
assert.ok(state >= 0 && contentSecurity > state && app > contentSecurity);
});
test('desktop, Android web generation, and offline cache include renderer support modules', () => {
const buildFiles = require(path.join(root, 'package.json')).build.files;
const androidAssets = read('scripts/prepare-android-web.cjs');
const worker = read('service-worker.js');
for (const file of ['renderer-state.js', 'mail-content-security.js']) {
assert.ok(buildFiles.includes(file), `Electron package is missing ${file}`);
assert.ok(androidAssets.includes(`'${file}'`), `Android web generator is missing ${file}`);
assert.ok(worker.includes(`'./${file}'`), `service worker is missing ${file}`);
}
});