Admin panel in English and Polish, reworded per docs/dev/admin-ux.md
- admin-i18n module: AdminText { en, pl }, component texts under the ipal
namespace (project translations win), en + pl admin languages when the
project sets none (project's supportedLanguages wins)
- every plugin label, description, option, tab and group as { en, pl };
explicit labels instead of auto-labels; sentence case; glossary terms
- visible renames (slugs, names, data unchanged): Cookie banner, Form
messages, Privacy group, Search engines, Maintenance, Spam protection,
E-mail sending, stats nav link Overview (hidden without access)
- Polish visitor defaults by page locale: cookie banner, form messages,
validators, lightbox, accessibility widget; {field} uses the label
- fixes: e-mail status banner used Turnstile wording; developer words and
env var names out of editor messages; stats numbers/dates in the admin
language; test e-mail no longer says ipal-kit
- test/adminUx.test.ts: length limits, en + pl present, no developer words
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
eeac33ed2f
commit
6b46bc0c14
+24
-2
@@ -1,6 +1,9 @@
|
||||
import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest'
|
||||
|
||||
import { submitForm } from '../src/modules/forms/submitForm.js'
|
||||
import { localizedRules, minLength, required } from '../src/modules/forms/validators.js'
|
||||
import { notificationFallback } from '../src/modules/notifications/defaults.js'
|
||||
import { resolveFormMessage } from '../src/modules/notifications/resolveFormMessage.js'
|
||||
import { UNKNOWN_IP_FACTOR } from '../src/modules/shared/rateLimit.js'
|
||||
import { fakePayload } from './helpers.js'
|
||||
|
||||
@@ -171,6 +174,25 @@ describe('submitForm — other gates', () => {
|
||||
})
|
||||
})
|
||||
|
||||
test('a validation message names the field by its label, in the page language', async () => {
|
||||
const { payload } = fakePayload({ forms: { f: { fields: [{ name: 'email', blockType: 'email', label: 'Adres e-mail', required: true }] } } })
|
||||
const result = await submitForm({ data: { email: 'nope' }, formId: 'f', ip: nextIp(), locale: 'pl', maxPerMinute: 0, payload })
|
||||
expect(result).toEqual({ field: 'email', kind: 'invalid_format', label: 'Adres e-mail', reason: 'validation', success: false })
|
||||
expect(resolveFormMessage(result, notificationFallback('pl').form)).toBe('Sprawdź pole „Adres e-mail”.')
|
||||
// no single field at fault → the generic error, never an empty {field}
|
||||
expect(resolveFormMessage({ kind: 'unknown_fields', reason: 'validation', success: false }, notificationFallback('en').form)).toBe(notificationFallback('en').form.error)
|
||||
})
|
||||
|
||||
test('validator messages: full sentences, Polish via localizedRules, own message wins', () => {
|
||||
expect(required()('')).toBe('Fill in this field.')
|
||||
expect(minLength(10)('abc')).toBe('Enter at least 10 characters.')
|
||||
const pl = localizedRules('pl-PL')
|
||||
expect(pl.required()('')).toBe('Uzupełnij to pole.')
|
||||
expect(pl.minLength(2)('a')).toBe('Wpisz co najmniej 2 znaki.')
|
||||
expect(pl.minLength(5)('a')).toBe('Wpisz co najmniej 5 znaków.')
|
||||
expect(pl.email('Mój tekst')('x')).toBe('Mój tekst')
|
||||
})
|
||||
|
||||
test('the captcha field injected by the widget is not an unknown key', async () => {
|
||||
const { create, payload } = fakePayload({ forms })
|
||||
const result = await submitForm({
|
||||
@@ -200,8 +222,8 @@ describe('turnstileKeyProblem', () => {
|
||||
const { turnstileKeyProblem } = await import('../src/modules/turnstile/config.js')
|
||||
expect(turnstileKeyProblem({})).toBeNull()
|
||||
expect(turnstileKeyProblem({ turnstileSecretKey: 's', turnstileSiteKey: 'k' })).toBeNull()
|
||||
expect(turnstileKeyProblem({ turnstileSiteKey: 'k' })).toMatch(/Secret key is missing/)
|
||||
expect(turnstileKeyProblem({ turnstileSecretKey: 's' })).toMatch(/Site key is missing/)
|
||||
expect(turnstileKeyProblem({ turnstileSiteKey: 'k' })).toMatch(/secret key is missing/)
|
||||
expect(turnstileKeyProblem({ turnstileSecretKey: 's' })).toMatch(/site key is missing/)
|
||||
vi.stubEnv('TURNSTILE_SECRET_KEY', 's')
|
||||
expect(turnstileKeyProblem({ turnstileSiteKey: 'k' })).toBeNull()
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user