Hero-admin: tabbladen Inhoud en Afbeeldingen (toegankelijk, onthouden, fout- en wijzigingsmarkering, sprong naar eerste fout) en strakke opslaanbalk over de volle breedte
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -13,6 +13,7 @@ const T = { timeout: 10000 };
|
||||
beforeEach(() => {
|
||||
_resetSetupStatusCache();
|
||||
resetMockHero();
|
||||
window.sessionStorage.clear();
|
||||
});
|
||||
|
||||
async function openPage() {
|
||||
@@ -632,6 +633,7 @@ describe('Order by dragging, wording and calm waiting', () => {
|
||||
});
|
||||
|
||||
it('speaks plain language: a plain Description field inside a titled slide, no alt text, and a short guide per part', async () => {
|
||||
window.sessionStorage.setItem('cms-hero-tab', 'images');
|
||||
setMockHero({ ...emptyHero(), id: 'h1', title: 'T', slides: [slide(1), slide(2)] });
|
||||
await openPage();
|
||||
|
||||
@@ -648,6 +650,7 @@ describe('Order by dragging, wording and calm waiting', () => {
|
||||
});
|
||||
|
||||
it('numbers the slides by their current order, also after the order changed', async () => {
|
||||
window.sessionStorage.setItem('cms-hero-tab', 'images');
|
||||
setMockHero({ ...emptyHero(), id: 'h1', title: 'T', slides: [slide(1), slide(2)] });
|
||||
await openPage();
|
||||
|
||||
@@ -1068,3 +1071,103 @@ describe('The Save button', () => {
|
||||
expect(screen.getByTestId('hero-save')).toBeEnabled();
|
||||
});
|
||||
});
|
||||
|
||||
describe('Tabs Content and Images', () => {
|
||||
beforeEach(() => {
|
||||
resetMockHero();
|
||||
});
|
||||
|
||||
it('has accessible tabs: tablist, tab, tabpanel, the arrow keys, Home and End', async () => {
|
||||
await openPage();
|
||||
|
||||
const tablist = screen.getByRole('tablist');
|
||||
const [content, images] = within(tablist).getAllByRole('tab');
|
||||
expect(content).toHaveAttribute('aria-selected', 'true');
|
||||
expect(content).toHaveAttribute('tabindex', '0');
|
||||
expect(images).toHaveAttribute('aria-selected', 'false');
|
||||
expect(images).toHaveAttribute('tabindex', '-1');
|
||||
expect(screen.getByRole('tabpanel')).toHaveAttribute('aria-labelledby', content.id);
|
||||
expect(screen.getByTestId('hero-title-input')).toBeVisible();
|
||||
|
||||
content.focus();
|
||||
await userEvent.keyboard('{ArrowRight}');
|
||||
expect(images).toHaveAttribute('aria-selected', 'true');
|
||||
expect(images).toHaveFocus();
|
||||
expect(screen.getByRole('tabpanel')).toHaveAttribute('aria-labelledby', images.id);
|
||||
expect(screen.getByTestId('hero-slides-empty')).toBeVisible();
|
||||
expect(screen.getByTestId('hero-title-input')).not.toBeVisible();
|
||||
|
||||
await userEvent.keyboard('{ArrowRight}');
|
||||
expect(content).toHaveAttribute('aria-selected', 'true');
|
||||
await userEvent.keyboard('{End}');
|
||||
expect(images).toHaveAttribute('aria-selected', 'true');
|
||||
await userEvent.keyboard('{Home}');
|
||||
expect(content).toHaveAttribute('aria-selected', 'true');
|
||||
});
|
||||
|
||||
it('keeps a change when switching tabs, shows a dot on the tab with changes, and saves both tabs with one button', async () => {
|
||||
setMockHero({ ...emptyHero(), id: 'h1', title: 'T', slides: [slide(1)] });
|
||||
await openPage();
|
||||
await userEvent.type(screen.getByTestId('hero-title-input'), 'x');
|
||||
expect(screen.getByTestId('hero-tab-content-changed')).toBeInTheDocument();
|
||||
expect(screen.queryByTestId('hero-tab-images-changed')).not.toBeInTheDocument();
|
||||
|
||||
await userEvent.click(screen.getByTestId('hero-tab-images'));
|
||||
expect(screen.getByTestId('hero-unsaved')).toBeInTheDocument();
|
||||
await userEvent.type(screen.getByTestId('hero-slide-0-alt'), '!');
|
||||
expect(screen.getByTestId('hero-tab-images-changed')).toBeInTheDocument();
|
||||
await userEvent.click(screen.getByTestId('hero-tab-content'));
|
||||
expect(screen.getByTestId('hero-title-input')).toHaveValue('Tx');
|
||||
|
||||
await userEvent.click(screen.getByTestId('hero-save'));
|
||||
|
||||
await waitFor(() => expect(getSavedHeroRequests()).toHaveLength(1));
|
||||
expect(getSavedHeroRequests()[0].title).toBe('Tx');
|
||||
expect(getSavedHeroRequests()[0].slides[0].alt).toBe('Foto 1!');
|
||||
});
|
||||
|
||||
it('remembers the chosen tab for the session', async () => {
|
||||
const first = await openPage();
|
||||
expect(first).toBeInTheDocument();
|
||||
await userEvent.click(screen.getByTestId('hero-tab-images'));
|
||||
|
||||
expect(window.sessionStorage.getItem('cms-hero-tab')).toBe('images');
|
||||
});
|
||||
|
||||
it('opens on the remembered tab', async () => {
|
||||
window.sessionStorage.setItem('cms-hero-tab', 'images');
|
||||
|
||||
await openPage();
|
||||
|
||||
expect(screen.getByTestId('hero-tab-images')).toHaveAttribute('aria-selected', 'true');
|
||||
});
|
||||
|
||||
it('shows how many photos are busy on the Images tab', async () => {
|
||||
const waiting = { ...slide(1), image: { ...slide(1).image, variants: [], src: '', processing: true } };
|
||||
setMockHero({ ...emptyHero(), id: 'h1', title: 'T', slides: [waiting, slide(2)] });
|
||||
|
||||
await openPage();
|
||||
|
||||
expect(await screen.findByTestId('hero-tab-images', {}, T)).toHaveTextContent(/1 bezig|1 busy/);
|
||||
});
|
||||
|
||||
it('jumps to the tab of the first error, marks it, and puts the cursor in that field', async () => {
|
||||
setMockHero({ ...emptyHero(), id: 'h1', title: 'T', slides: [slide(1, { alt: '' })] });
|
||||
await openPage();
|
||||
await userEvent.type(screen.getByTestId('hero-lead'), 'x');
|
||||
|
||||
await userEvent.click(screen.getByTestId('hero-save'));
|
||||
|
||||
await waitFor(() => expect(screen.getByTestId('hero-tab-images')).toHaveAttribute('aria-selected', 'true'));
|
||||
expect(screen.getByTestId('hero-tab-images-invalid')).toBeInTheDocument();
|
||||
await waitFor(() => expect(screen.getByTestId('hero-slide-0-alt')).toHaveFocus());
|
||||
});
|
||||
|
||||
it('has a full-width, opaque save bar', async () => {
|
||||
await openPage();
|
||||
|
||||
const bar = screen.getByTestId('hero-save-bar');
|
||||
expect(bar).toHaveClass('-mx-6', 'bg-background', 'border-t');
|
||||
expect(bar.className).not.toMatch(/bg-background\//);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user