Files
webmail/lib/__tests__/product-name.test.ts
T
ghoztyandClaude Opus 5.5 30f51e5ca4 feat: name the app with the configured APP_NAME in user-facing strings
Some user-facing strings still said "Bulwark" on a deployment with its own
APP_NAME: Settings > General > Default apps (protocol handlers), the "Open
Bulwark" notification, the rate-limit banner and toast, the plugin connect
dialog, one plugin permission text and the connector page.

These strings now take an {appName} placeholder, filled by productName():
the configured APP_NAME, or "Bulwark" when it is unset or the default
"Webmail" (the same rule as the TOTP issuer and the About card, #1160).
A stock install reads as before.

The settings search (the settings page and api.app.searchSettings) indexes
these texts with the name filled in, so "bulwark" or the configured name
finds Default apps and no result carries the raw placeholder.

Locales: the 13 keys in every locale that has "Bulwark" in them. Languages
that inflect the name (cs, et, hu, ko, ro, sk, tr) use a neutral form such
as "{appName} uygulamasında" instead of a declined "Bulwark'ta"; a native
check of those is welcome.

Not changed on purpose: the mobile app, push relay, Lite, demo and admin
texts, which speak about Bulwark itself.

Closes #1314

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-22 04:14:54 +03:00

60 lines
2.3 KiB
TypeScript

// @vitest-environment node
import fs from 'fs';
import path from 'path';
import { describe, expect, it } from 'vitest';
import { productName } from '../product-name';
describe('productName', () => {
it('uses the configured app name', () => {
expect(productName('Acme Mail')).toBe('Acme Mail');
expect(productName(' Acme Mail ')).toBe('Acme Mail');
});
it('keeps Bulwark on a stock install', () => {
expect(productName('Webmail')).toBe('Bulwark');
expect(productName('')).toBe('Bulwark');
expect(productName(' ')).toBe('Bulwark');
expect(productName(undefined)).toBe('Bulwark');
expect(productName(null)).toBe('Bulwark');
});
});
// Strings that speak about this deployment name it through {appName}, so a
// branded install does not tell its users about "Bulwark".
const APP_NAME_KEYS = [
'protocol_handlers.description',
'protocol_handlers.mailto_description',
'protocol_handlers.protocol_open_mode_description',
'protocol_handlers.focus_notification_title',
'protocol_handlers.focus_notification_body',
'protocol_handlers.webcal_description',
'protocol_handlers.browser_note',
'common.rate_limited_detail',
'common.rate_limited_action_detail',
'plugins.permissions.http_proxy.body',
'plugins.connect.intro_password',
'plugins.connect.intro_password_any',
'plugins.connect.intro_signin',
];
const localesDir = path.resolve(__dirname, '../../locales');
const locales = fs.readdirSync(localesDir).filter((l) => fs.statSync(path.join(localesDir, l)).isDirectory());
function lookup(obj: unknown, key: string): unknown {
return key.split('.').reduce<unknown>((o, p) => (o && typeof o === 'object' ? (o as Record<string, unknown>)[p] : undefined), obj);
}
describe('app name in locale strings', () => {
it.each(locales)('%s does not hardcode Bulwark where {appName} belongs', (locale) => {
const data = JSON.parse(fs.readFileSync(path.join(localesDir, locale, 'common.json'), 'utf-8'));
const hardcoded = APP_NAME_KEYS.filter((key) => String(lookup(data, key)).includes('Bulwark'));
expect(hardcoded).toEqual([]);
});
it('en names the app in every listed string', () => {
const data = JSON.parse(fs.readFileSync(path.join(localesDir, 'en', 'common.json'), 'utf-8'));
const missing = APP_NAME_KEYS.filter((key) => !String(lookup(data, key)).includes('{appName}'));
expect(missing).toEqual([]);
});
});