Inline Comment 0.2.0 - initial public release
Thunderbird/Betterbird add-on (Manifest V3): typing inside a quote splits the quote and inserts your own text with a marker such as [OH]:. - English and German user interface - Licensed under the Mozilla Public License 2.0 - English documentation, JSDoc lint gate, 87 tests (node:test + jsdom)
This commit is contained in:
commit
9053327486
57 files changed
+9849
No files matched your search
@@ -0,0 +1,108 @@
|
||||
/*
|
||||
* Copyright 2026 Oliver Herb
|
||||
* SPDX-License-Identifier: MPL-2.0
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
/*
|
||||
* Static checks of src/manifest.json: manifest version, add-on ID and
|
||||
* minimum application version, localized fields, permissions, the version
|
||||
* number shared with package.json and CHANGELOG.md, and that every file the
|
||||
* manifest or the options page refers to exists. The JSON and HTML files are
|
||||
* read from disk; no browser or DOM is involved.
|
||||
*/
|
||||
|
||||
const { test } = require("node:test");
|
||||
const assert = require("node:assert/strict");
|
||||
const fs = require("node:fs");
|
||||
const path = require("node:path");
|
||||
const manifest = require("../src/manifest.json");
|
||||
const pkg = require("../package.json");
|
||||
const { COMPOSE_SCRIPT_FILES } = require("../src/lib/settings.js");
|
||||
|
||||
const ROOT = path.join(__dirname, "..");
|
||||
const SRC = path.join(ROOT, "src");
|
||||
|
||||
/**
|
||||
* Tells whether a file exists in the add-on source.
|
||||
* @param {string} relative Path relative to src/.
|
||||
* @returns {boolean} True if the file exists.
|
||||
*/
|
||||
function exists(relative) {
|
||||
return fs.existsSync(path.join(SRC, relative));
|
||||
}
|
||||
|
||||
test("Manifest V3 with a fixed add-on ID and minimum version 128", () => {
|
||||
assert.equal(manifest.manifest_version, 3);
|
||||
assert.equal(
|
||||
manifest.browser_specific_settings.gecko.id,
|
||||
"inline-comment@ih-engineering.de",
|
||||
);
|
||||
assert.equal(
|
||||
manifest.browser_specific_settings.gecko.strict_min_version,
|
||||
"128.0",
|
||||
);
|
||||
});
|
||||
|
||||
test("default locale is en and translations exist for en and de", () => {
|
||||
assert.equal(manifest.default_locale, "en");
|
||||
for (const locale of [manifest.default_locale, "de"]) {
|
||||
const file = `_locales/${locale}/messages.json`;
|
||||
assert.ok(exists(file), `missing: src/${file}`);
|
||||
}
|
||||
});
|
||||
|
||||
test("name, description and button title come from _locales", () => {
|
||||
assert.equal(manifest.name, "__MSG_extensionName__");
|
||||
assert.equal(manifest.description, "__MSG_extensionDescription__");
|
||||
assert.equal(manifest.compose_action.default_title, "__MSG_actionTitle__");
|
||||
});
|
||||
|
||||
test("version is the same in manifest.json, package.json and CHANGELOG.md", () => {
|
||||
assert.equal(manifest.version, pkg.version);
|
||||
const changelog = fs.readFileSync(path.join(ROOT, "CHANGELOG.md"), "utf8");
|
||||
assert.match(
|
||||
changelog,
|
||||
new RegExp(`^## \\[${pkg.version.replace(/\./g, "\\.")}\\]`, "m"),
|
||||
);
|
||||
});
|
||||
|
||||
test("the required permissions are declared", () => {
|
||||
for (const permission of [
|
||||
"compose",
|
||||
"scripting",
|
||||
"storage",
|
||||
"accountsRead",
|
||||
]) {
|
||||
assert.ok(manifest.permissions.includes(permission), permission);
|
||||
}
|
||||
});
|
||||
|
||||
test("all referenced files exist", () => {
|
||||
const files = [
|
||||
...manifest.background.scripts,
|
||||
...COMPOSE_SCRIPT_FILES,
|
||||
manifest.options_ui.page,
|
||||
manifest.compose_action.default_icon,
|
||||
...Object.values(manifest.icons),
|
||||
];
|
||||
for (const file of files) {
|
||||
assert.ok(exists(file), `missing: src/${file}`);
|
||||
}
|
||||
});
|
||||
|
||||
test("the options page loads only existing scripts", () => {
|
||||
const html = fs.readFileSync(
|
||||
path.join(SRC, manifest.options_ui.page),
|
||||
"utf8",
|
||||
);
|
||||
const dir = path.dirname(manifest.options_ui.page);
|
||||
for (const [, src] of html.matchAll(/<script src="([^"]+)"/g)) {
|
||||
assert.ok(exists(path.join(dir, src)), `missing: ${src}`);
|
||||
}
|
||||
});
|
||||
Reference in new issue
Block a user