feat: prefill the mairie form from the picked event

Wire the seam end to end: the background mirrors config.local.json into
storage (a content script would need web_accessible_resources, which would
expose the email to the mairie page), and the content script lays the computed
values into the form.

The layer is deliberately thin and untested: all the logic lives in
formulaire-valeurs.js. It never writes an empty value, never touches the image,
the honeypots or the CSRF tokens, and never submits: a human reads and sends.
A banner states what is left to do, and warns when a field could not be filled,
so that a silent failure stays diagnosable.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Pierre Martin
2026-07-17 14:30:47 +02:00
co-authored by Claude Opus 4.8
parent 78153557dd
commit 2e60bd08d8
5 changed files with 363 additions and 1 deletions
+42
View File
@@ -14,6 +14,12 @@ describe("manifest.json", () => {
expect(manifest.background.scripts).toContain("background.js");
});
// Scripts classiques : pas d'import, l'ordre du tableau EST la dépendance.
// config.js pose globalThis.EchoConfig, que background.js lit.
test("charge config.js avant background.js", () => {
expect(manifest.background.scripts).toEqual(["config.js", "background.js"]);
});
test("demande les host_permissions des deux sources", () => {
expect(manifest.host_permissions).toEqual([
"https://atelier-huit.frama.space/*",
@@ -34,11 +40,47 @@ describe("manifest.json", () => {
});
});
describe("content_scripts (pré-remplissage du formulaire mairie)", () => {
const contentScript = manifest.content_scripts?.[0];
// URL exacte du formulaire, pas tout ville-cugnaux.fr : on n'injecte pas de
// code sur les pages d'un tiers sans raison.
test("ne s'injecte que sur le formulaire de la mairie", () => {
expect(contentScript.matches).toEqual([
"https://www.ville-cugnaux.fr/mes-loisirs/associations/proposer-un-evenement-dans-lagenda/*",
]);
});
test("charge config, valeurs puis poseur (l'ordre EST la dépendance)", () => {
expect(contentScript.js).toEqual([
"config.js",
"formulaire-valeurs.js",
"formulaire-mairie.js",
]);
});
test("porte le style du bandeau", () => {
expect(contentScript.css).toEqual(["formulaire-mairie.css"]);
});
test("chaque fichier déclaré existe sur le disque", () => {
for (const fichier of [...contentScript.js, ...contentScript.css]) {
expect(existsSync(join(extensionDir, fichier))).toBe(true);
}
});
});
describe("ressources référencées", () => {
test("background.js existe", () => {
expect(existsSync(join(extensionDir, "background.js"))).toBe(true);
});
test("chaque script d'arrière-plan existe", () => {
for (const fichier of manifest.background.scripts) {
expect(existsSync(join(extensionDir, fichier))).toBe(true);
}
});
test("liste.html existe", () => {
expect(existsSync(join(extensionDir, "liste.html"))).toBe(true);
});