mirror of
https://github.com/bookorbit/bookorbit.git
synced 2026-11-03 00:11:37 -06:00
test(settings): cover fill-crop preference sync payload
Guard against the display preference mismatch reported in #1290 by checking author fields in cover-mode saves and verifying server acceptance of the complete payload. Ref #1290
This commit is contained in:
@@ -150,9 +150,18 @@ describe('useDisplaySettingsSync', () => {
|
||||
'/api/v1/user-preferences/display',
|
||||
expect.objectContaining({
|
||||
method: 'PUT',
|
||||
body: expect.stringContaining('"bookCoverDisplayMode":"fill-crop"'),
|
||||
body: expect.any(String),
|
||||
}),
|
||||
)
|
||||
|
||||
const request = apiMock.mock.calls[0]?.[1] as RequestInit
|
||||
expect(JSON.parse(request.body as string)).toMatchObject({
|
||||
settings: {
|
||||
authorRowDensity: 'comfortable',
|
||||
authorCoverFallback: false,
|
||||
bookCoverDisplayMode: 'fill-crop',
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
it('cancels a pending debounced save', async () => {
|
||||
|
||||
@@ -483,6 +483,19 @@ describe('UserPreferencesService', () => {
|
||||
expect(repo.upsert).toHaveBeenCalledWith(11, 'display', preferences);
|
||||
});
|
||||
|
||||
it('upsertDisplayPreferences accepts the complete client payload for fill-crop covers', async () => {
|
||||
const preferences = {
|
||||
...validDisplayPreferences,
|
||||
authorRowDensity: 'comfortable',
|
||||
authorCoverFallback: false,
|
||||
bookCoverDisplayMode: 'fill-crop',
|
||||
} satisfies DisplayPreferences;
|
||||
|
||||
await expect(service.upsertDisplayPreferences(11, preferences)).resolves.toBeUndefined();
|
||||
|
||||
expect(repo.upsert).toHaveBeenCalledWith(11, 'display', preferences);
|
||||
});
|
||||
|
||||
it('upsertDisplayPreferences defaults author display preferences omitted by older clients', async () => {
|
||||
const { authorRowDensity, authorCoverFallback, ...olderPreferences } = validDisplayPreferences;
|
||||
void authorRowDensity;
|
||||
|
||||
Reference in New Issue
Block a user