Hero: een gewijzigd focuspunt geldt pas bij het opslaan van de hero (Bryan); het focus-venster houdt de wijziging lokaal
Het eindpunt PUT /hero/images/{id}/focus is vervallen; de focus gaat mee in de opslag (imageFocus) en de varianten worden dan in nieuwe bestanden opnieuw gesneden.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -214,13 +214,14 @@ describe('Focus dialog', () => {
|
||||
return screen.findByTestId('focus-dialog');
|
||||
};
|
||||
|
||||
it('starts with the stored point and shows both previews', async () => {
|
||||
it('starts with the stored point, shows both previews and says the change needs a save', async () => {
|
||||
await open();
|
||||
|
||||
expect(screen.getByTestId('focus-x')).toHaveValue(50);
|
||||
expect(screen.getByTestId('focus-y')).toHaveValue(50);
|
||||
expect(screen.getByTestId('focus-preview-wide')).toBeInTheDocument();
|
||||
expect(screen.getByTestId('focus-preview-tall')).toBeInTheDocument();
|
||||
expect(screen.getByTestId('focus-apply-hint')).toHaveTextContent(/pas nadat je de hero opslaat|only takes effect when you save the hero/);
|
||||
});
|
||||
|
||||
it('moves the point with the keyboard', async () => {
|
||||
@@ -234,7 +235,7 @@ describe('Focus dialog', () => {
|
||||
expect(screen.getByTestId('focus-y')).toHaveValue(55);
|
||||
});
|
||||
|
||||
it('saves a general point and an own setting for the tall display', async () => {
|
||||
it('keeps a change locally until the hero is saved, then sends it with the save', async () => {
|
||||
await open();
|
||||
|
||||
fireEvent.change(screen.getByTestId('focus-x'), { target: { value: '30' } });
|
||||
@@ -246,13 +247,40 @@ describe('Focus dialog', () => {
|
||||
await userEvent.click(screen.getByTestId('focus-save'));
|
||||
|
||||
await waitFor(() => expect(screen.queryByTestId('focus-dialog')).not.toBeInTheDocument());
|
||||
// The dialog closed after the server accepted it; reopening shows the stored values.
|
||||
expect(getSavedHeroRequests()).toHaveLength(0);
|
||||
expect(screen.getByTestId('hero-slide-0-focus-pending')).toBeInTheDocument();
|
||||
|
||||
// Reopening shows the pending values.
|
||||
await userEvent.click(screen.getByTestId('hero-slide-0-focus'));
|
||||
expect(screen.getByTestId('focus-x')).toHaveValue(30);
|
||||
await userEvent.click(screen.getByTestId('focus-target-tall'));
|
||||
expect(screen.getByTestId('focus-override-tall')).toBeChecked();
|
||||
expect(screen.getByTestId('focus-x')).toHaveValue(80);
|
||||
expect(screen.getByTestId('focus-zoom')).toHaveValue('2');
|
||||
await userEvent.click(screen.getByTestId('focus-cancel'));
|
||||
|
||||
await userEvent.click(screen.getByTestId('hero-save'));
|
||||
|
||||
await waitFor(() => expect(getSavedHeroRequests()).toHaveLength(1));
|
||||
expect(getSavedHeroRequests()[0].imageFocus).toEqual([
|
||||
{
|
||||
imageId: '10000000-0000-0000-0000-000000000001',
|
||||
focus: { x: 0.3, y: 0.5, zoom: 1 },
|
||||
wide: null,
|
||||
tall: { x: 0.8, y: 0.5, zoom: 2 },
|
||||
},
|
||||
]);
|
||||
await waitFor(() => expect(screen.queryByTestId('hero-slide-0-focus-pending')).not.toBeInTheDocument());
|
||||
});
|
||||
|
||||
it('sends no focus edits when nothing was changed', async () => {
|
||||
await open();
|
||||
await userEvent.click(screen.getByTestId('focus-cancel'));
|
||||
|
||||
await userEvent.click(screen.getByTestId('hero-save'));
|
||||
|
||||
await waitFor(() => expect(getSavedHeroRequests()).toHaveLength(1));
|
||||
expect(getSavedHeroRequests()[0].imageFocus).toEqual([]);
|
||||
});
|
||||
|
||||
it('goes back to the general point when the own setting is switched off', async () => {
|
||||
@@ -266,12 +294,14 @@ describe('Focus dialog', () => {
|
||||
expect(screen.getByTestId('focus-x')).toBeDisabled();
|
||||
});
|
||||
|
||||
it('closes without saving', async () => {
|
||||
it('drops a change when the dialog is cancelled', async () => {
|
||||
await open();
|
||||
fireEvent.change(screen.getByTestId('focus-x'), { target: { value: '10' } });
|
||||
|
||||
await userEvent.click(screen.getByTestId('focus-cancel'));
|
||||
|
||||
await waitFor(() => expect(screen.queryByTestId('focus-dialog')).not.toBeInTheDocument());
|
||||
expect(screen.queryByTestId('hero-slide-0-focus-pending')).not.toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user