release: v0.20.0
This commit is contained in:
@@ -249,11 +249,11 @@ describe('PageBuilder: edits made while a save is in flight', () => {
|
||||
</ConfirmProvider>
|
||||
</NotificationProvider>,
|
||||
);
|
||||
fireEvent.click(await screen.findByRole('button', { name: /New subpage/ }));
|
||||
fireEvent.click(await screen.findByRole('button', { name: 'New subpage' }));
|
||||
fireEvent.click(screen.getByRole('button', { name: 'Save Changes' }));
|
||||
await waitFor(() => expect(releasePut).not.toBeNull());
|
||||
|
||||
fireEvent.click(screen.getByRole('button', { name: /New subpage/ }));
|
||||
fireEvent.click(screen.getByRole('button', { name: 'New subpage' }));
|
||||
await act(async () => releasePut!());
|
||||
|
||||
await screen.findByText('Saved successfully!');
|
||||
|
||||
@@ -146,6 +146,26 @@ describe('journal editor: text blocks as markdown (A-5)', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('journal editor: mode toggles (A-18)', () => {
|
||||
// Rendered as admin-btn-xs, the active mode carried admin-btn-primary, whose
|
||||
// background the size class overrode: both modes looked the same.
|
||||
it('mark the active mode, starting on Visual Blocks and Desktop', async () => {
|
||||
await renderJournal();
|
||||
const pressed = (name: string) =>
|
||||
screen.getByRole('button', { name }).getAttribute('aria-pressed');
|
||||
|
||||
expect(pressed('Visual Blocks')).toBe('true');
|
||||
expect(pressed('Raw Markdown')).toBe('false');
|
||||
expect(pressed('Desktop')).toBe('true');
|
||||
expect(pressed('Mobile')).toBe('false');
|
||||
|
||||
fireEvent.click(screen.getByRole('button', { name: 'Raw Markdown' }));
|
||||
expect(pressed('Visual Blocks')).toBe('false');
|
||||
expect(pressed('Raw Markdown')).toBe('true');
|
||||
expect(screen.getByRole('button', { name: 'Raw Markdown' }).className).toContain('active');
|
||||
});
|
||||
});
|
||||
|
||||
describe('InlineMarkdownField', () => {
|
||||
function Harness({ initial }: { initial: string }) {
|
||||
const [html, setHtml] = useState(initial);
|
||||
|
||||
67
app/admin/components/__tests__/zoom-settings.test.tsx
Normal file
67
app/admin/components/__tests__/zoom-settings.test.tsx
Normal file
@@ -0,0 +1,67 @@
|
||||
// @vitest-environment jsdom
|
||||
import { describe, it, expect, vi, afterEach } from 'vitest';
|
||||
import { render, screen, cleanup, fireEvent } from '@testing-library/react';
|
||||
import GeneralSection from '../settings/GeneralSection';
|
||||
import ZoomOverrideField from '../fields/ZoomOverrideField';
|
||||
|
||||
/**
|
||||
* The admin switches for the lightbox zoom (#467): one site-wide toggle in
|
||||
* Settings › General, and an inherit / on / off choice per page and album.
|
||||
* The YAML they produce is covered by the page builder round-trip tests.
|
||||
*/
|
||||
|
||||
afterEach(cleanup);
|
||||
|
||||
describe('Settings › General › Photo zoom', () => {
|
||||
const renderWith = (settings: Record<string, unknown>) => {
|
||||
const update = vi.fn();
|
||||
render(<GeneralSection settings={settings} update={update} updateMany={vi.fn()} />);
|
||||
return { update, row: screen.getByRole('button', { name: /Photo zoom/ }) };
|
||||
};
|
||||
|
||||
it('is shown off when settings.yaml says nothing, and switches it on', () => {
|
||||
const { update, row } = renderWith({});
|
||||
expect(row.getAttribute('aria-pressed')).toBe('false');
|
||||
fireEvent.click(row);
|
||||
expect(update).toHaveBeenCalledWith('zoom', true);
|
||||
});
|
||||
|
||||
it('switches it off again', () => {
|
||||
const { update, row } = renderWith({ zoom: true });
|
||||
expect(row.getAttribute('aria-pressed')).toBe('true');
|
||||
fireEvent.click(row);
|
||||
expect(update).toHaveBeenCalledWith('zoom', false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('ZoomOverrideField', () => {
|
||||
const renderField = (value: boolean | undefined) => {
|
||||
const onChange = vi.fn();
|
||||
render(
|
||||
<ZoomOverrideField
|
||||
id="z"
|
||||
value={value}
|
||||
onChange={onChange}
|
||||
inheritLabel="Inherit"
|
||||
hint="hint"
|
||||
/>,
|
||||
);
|
||||
return { onChange, select: screen.getByLabelText('Photo zoom') as HTMLSelectElement };
|
||||
};
|
||||
|
||||
it('shows the three states', () => {
|
||||
expect(renderField(undefined).select.value).toBe('');
|
||||
cleanup();
|
||||
expect(renderField(true).select.value).toBe('on');
|
||||
cleanup();
|
||||
expect(renderField(false).select.value).toBe('off');
|
||||
});
|
||||
|
||||
it('reports true, false, and undefined for inherit', () => {
|
||||
const { onChange, select } = renderField(undefined);
|
||||
fireEvent.change(select, { target: { value: 'on' } });
|
||||
fireEvent.change(select, { target: { value: 'off' } });
|
||||
fireEvent.change(select, { target: { value: '' } });
|
||||
expect(onChange.mock.calls).toEqual([[true], [false], [undefined]]);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user