Files
inbuxa-admin/src/help/help.test.ts
T
jcoffey-dev 824427ef46 Help on every option and every page
- Each option's explanation moves from a line of text under its label to
  a small tooltip on an ⓘ beside it, so forms read calmer and the help is
  still one hover away.
- Help text is ours where written (src/help/texts.ts: domains, people,
  DNS providers, blocked addresses, and the main pages), and the schema's
  description elsewhere.
- A "?" on every list and form opens a side panel: what the page is for,
  what people usually do there, and every option explained.
- Every tooltip and panel carries a stable help id (x:Domain.dnsManagement,
  x:Domain), and manual.ts turns an id into a link to the admin manual
  once one is configured (VITE_MANUAL_URL, or <meta name="manual-url">).
  Until then no link shows.
2026-09-19 01:59:14 -07:00

39 lines
1.5 KiB
TypeScript

/*
* SPDX-FileCopyrightText: 2026 Coffey Labs
*
* SPDX-License-Identifier: AGPL-3.0-only
*/
import { afterEach, describe, expect, it } from 'vitest';
import { manualUrl } from './manual';
import { fieldHelp, FIELD_HELP } from './texts';
describe('manualUrl', () => {
afterEach(() => document.querySelector('meta[name="manual-url"]')?.remove());
it('shows no link until a manual is configured', () => {
expect(manualUrl('x:Domain.dnsManagement')).toBeNull();
});
it('maps help ids to stable manual pages and anchors', () => {
const meta = document.createElement('meta');
meta.name = 'manual-url';
meta.content = 'https://docs.example.org/admin/';
document.head.appendChild(meta);
expect(manualUrl('x:Domain')).toBe('https://docs.example.org/admin/reference/domain/');
expect(manualUrl('x:Domain.dnsManagement')).toBe('https://docs.example.org/admin/reference/domain/#dnsmanagement');
expect(manualUrl('x:DnsServerCloudflare.secret')).toBe(
'https://docs.example.org/admin/reference/dns-server-cloudflare/#secret',
);
expect(manualUrl('x:Account/User')).toBe('https://docs.example.org/admin/reference/account-user/');
});
});
describe('fieldHelp', () => {
it('prefers our words, then the schema description', () => {
expect(fieldHelp('x:Domain.catchAllAddress', 'schema text')).toBe(FIELD_HELP['x:Domain.catchAllAddress']);
expect(fieldHelp('x:Domain.unknownField', 'schema text')).toBe('schema text');
expect(fieldHelp(undefined, null)).toBeNull();
});
});