From 0ae424ff42a5ce2371d8923bd48d66d59644e7dc Mon Sep 17 00:00:00 2001 From: Paul Nothaft Date: Wed, 2 Sep 2026 09:43:02 +0200 Subject: [PATCH] test(migrations): pin migration 194's per-field guard The per-field fix landed without a test for the case it exists for: an admin-translated subject over a still-English body, and the reverse. --- ...german_gallery_created_translation.test.js | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/backend/__tests__/migrations/194_german_gallery_created_translation.test.js b/backend/__tests__/migrations/194_german_gallery_created_translation.test.js index 972c9b24..3fb75d46 100644 --- a/backend/__tests__/migrations/194_german_gallery_created_translation.test.js +++ b/backend/__tests__/migrations/194_german_gallery_created_translation.test.js @@ -183,6 +183,35 @@ describe('migration 194 — German gallery_created translation (QA J.04)', () => expect((await rowFor(id, 'de')).body_html).toContain('Galerie erfolgreich erstellt'); }); + it('keeps a subject the admin translated while repairing the still-English body', async () => { + // Each field is judged on its own. Gating on body_html alone would have + // thrown this subject away — and down() is a no-op, so for good. + const adminSubject = 'Ihre Galerie steht bereit'; + const id = await seedFreshInstall({ deSubject: adminSubject }); + + await migration.up(knex); + + const de = await rowFor(id, 'de'); + expect(de.subject).toBe(adminSubject); + expect(de.body_html).toContain('Galerie erfolgreich erstellt'); + expect(de.body_text).toContain('Passwort'); + const master = await knex('email_templates').where({ id }).first(); + expect(master.subject_de).toBe(adminSubject); + expect(master.body_html_de).toContain('Galerie erfolgreich erstellt'); + }); + + it('keeps an admin-translated body while repairing a still-English subject', async () => { + const adminHtml = '

Hallo {{host_name}}, „{{event_name}}“ ist online: {{gallery_link}} / {{gallery_password}} bis {{expiry_date}} ({{event_date}})

'; + const id = await seedFreshInstall({ deHtml: adminHtml }); + + await migration.up(knex); + + const de = await rowFor(id, 'de'); + expect(de.body_html).toBe(adminHtml); + expect(de.subject).toBe('Ihre Fotogalerie ist bereit!'); + expect((await knex('email_templates').where({ id }).first()).body_html_de).toBe(adminHtml); + }); + it('is idempotent', async () => { const id = await seedFreshInstall();