ui: migrate the extension pages and Configs; five components they needed

Phase 2, part 1.  Three files leave Semantic UI (baseline 75 -> 72), and the
components they needed join the library and the gallery:

  Header       Semantic's shape (as/icon/subheader/dividing).  47 files use
               <Header>, and the level now picks the size, so the type scale
               stays a scale instead of each call site choosing a font size.
  Message      gains an icon and a dismiss button.
  ActionInput  input and button sharing one outline, for <Input action={...}/>.
  Loading      centered loader with a caption, replacing the
               <Loader active inline='centered'> + wrapper div in 19 places.
  Modal        becomes compound - Modal.Header/.Content/.Actions, plus
               Semantic's open, closeIcon, and size names - because 34 files
               are written against that shape.

test-utils mounts MantineProvider with ThemeProvider's exact configuration:
migrated components render Mantine internals and every one of their test files
would otherwise need its own provider.

One Semantic bleed found and fixed: semantic.min.css sets
`h1,h2,h3,h4,h5 { font-family: Lato }` and loads after Mantine's element rule,
so headings ignored the theme's body face.  Only visible in amber, where the
body is mono and the headings were not.  A class-level restatement outranks it;
the rule comes out when Semantic does.

Verified: 925 jest tests, clean production build, and a night-mode audit of
every painted pixel in the gallery (red-only, one known false positive).  The
Configs backup and restore flow was exercised against the real API.
This commit is contained in:
Roland 2026-07-29 20:25:34 -06:00
parent 6ffc5b57c8
commit 00c52872fa
No known key found for this signature in database
GPG key ID: 1BA620CE6C9A4680
12 changed files with 621 additions and 202 deletions

View file

@ -7,8 +7,10 @@ import {ThemeContext} from '../../contexts/contexts';
import {cssVariablesResolver, mantineTheme, semanticColorNames} from '../../themes/mantine';
import {themeChoices} from '../../themes/names';
import {
ActionInput,
Button,
Confirm,
Header,
Icon,
IconButton,
Label,
@ -129,6 +131,78 @@ describe('Message', () => {
expect(screen.getByRole('alert')).toHaveClass('wrolpi-message-error');
});
it('dismisses when asked', async () => {
const onDismiss = jest.fn();
renderUI(<Message title='Install the extension' onDismiss={onDismiss}/>);
await userEvent.click(screen.getByRole('button', {name: 'Dismiss'}));
expect(onDismiss).toHaveBeenCalled();
});
it('offers no dismiss button when the message cannot be cleared', () => {
renderUI(<Message title='Refresh running'/>);
expect(screen.queryByRole('button', {name: 'Dismiss'})).not.toBeInTheDocument();
});
it('renders a leading icon when given one', () => {
const {container} = renderUI(<Message icon='puzzle piece' title='Extension'/>);
expect(container.querySelector('.wrolpi-message-icon svg')).toBeInTheDocument();
});
});
describe('Header', () => {
it('renders the requested heading level', () => {
renderUI(<Header as='h1'>Browser Extension</Header>);
expect(screen.getByRole('heading', {level: 1, name: 'Browser Extension'})).toBeInTheDocument();
});
it('defaults to h3 so a call site that omits the level still nests sanely', () => {
renderUI(<Header>Firefox</Header>);
expect(screen.getByRole('heading', {level: 3, name: 'Firefox'})).toBeInTheDocument();
});
it('takes its size from the level, not from the call site', () => {
// The class is what ui.css keys the type scale on; a call site passing its own
// font-size is the thing this component exists to prevent.
const {container} = renderUI(<Header as='h4'>Install steps</Header>);
expect(container.querySelector('.wrolpi-header-h4')).toBeInTheDocument();
});
it('renders an icon and a subheader', () => {
const {container} = renderUI(<Header icon='globe' subheader='Paste this into the extension'>
This WROLPi's URL
</Header>);
expect(container.querySelector('svg')).toBeInTheDocument();
expect(screen.getByText('Paste this into the extension')).toBeInTheDocument();
});
});
describe('ActionInput', () => {
it('joins the input and its action into one control', () => {
const {container} = renderUI(
<ActionInput label='URL' value='https://wrolpi.local' readOnly
action={<Button role='cancel'>Copy</Button>}/>
);
expect(container.querySelector('.wrolpi-action-input')).toBeInTheDocument();
expect(screen.getByRole('textbox', {name: 'URL'})).toHaveValue('https://wrolpi.local');
expect(screen.getByRole('button', {name: 'Copy'})).toBeInTheDocument();
});
it('is a plain input when no action is given', () => {
const {container} = renderUI(<ActionInput label='URL'/>);
expect(container.querySelector('.wrolpi-action-input')).not.toBeInTheDocument();
expect(screen.getByRole('textbox', {name: 'URL'})).toBeInTheDocument();
});
});
describe('Progress', () => {