From 02a12ce918ad5d1e0ee78ef35c049fd27e0d0ade Mon Sep 17 00:00:00 2001 From: Maurice Date: Fri, 23 Oct 2026 20:11:03 +0200 Subject: [PATCH] test(studio): a Studio save carries its revision, and the layers foot is drawn with its selection --- client/src/components/Studio/StudioLayersPanel.test.tsx | 2 +- client/tests/unit/studio/useBookStore.test.tsx | 7 +++++-- server/tests/unit/nest/journey-book.service.test.ts | 7 ++++++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/client/src/components/Studio/StudioLayersPanel.test.tsx b/client/src/components/Studio/StudioLayersPanel.test.tsx index b16319c33..2d55463ce 100644 --- a/client/src/components/Studio/StudioLayersPanel.test.tsx +++ b/client/src/components/Studio/StudioLayersPanel.test.tsx @@ -141,8 +141,8 @@ describe('the layers panel', () => { }); it('groups and ungroups the selection from its foot, and says when the page is empty', () => { - render(); store().select(['a', 't']); + render(); fireEvent.click(screen.getByText('journey.studio.layers.groupAction')); expect(el('a').group).toBeDefined(); fireEvent.click(screen.getByText('journey.studio.layers.ungroup')); diff --git a/client/tests/unit/studio/useBookStore.test.tsx b/client/tests/unit/studio/useBookStore.test.tsx index bb6d4947b..1a7e87a98 100644 --- a/client/tests/unit/studio/useBookStore.test.tsx +++ b/client/tests/unit/studio/useBookStore.test.tsx @@ -1,6 +1,7 @@ import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest' import { act, renderHook } from '@testing-library/react' import type { BookDocument, BookRecord } from '@trek/shared' +import { BOOK_SCHEMA_REV } from '@trek/shared' /** * Autosaving a Studio book (#1973). @@ -852,12 +853,14 @@ describe('a book a newer Studio saved', () => { }) /* A book of today goes out exactly as it went out before the revision existed. */ - it('FE-STUDIO-REV-006: sends a book of today without a revision in it', async () => { + it('FE-STUDIO-REV-006: stamps a book with the revision this Studio writes, and none while that is 1', async () => { const { result } = await mount() act(() => { result.current.queueSave(doc('a'), 'T') }) await tick() - expect(api.saveBook.mock.calls[0][1].document).not.toHaveProperty('schemaRev') + const sent = api.saveBook.mock.calls[0][1].document + if (BOOK_SCHEMA_REV > 1) expect(sent.schemaRev).toBe(BOOK_SCHEMA_REV) + else expect(sent).not.toHaveProperty('schemaRev') }) }) diff --git a/server/tests/unit/nest/journey-book.service.test.ts b/server/tests/unit/nest/journey-book.service.test.ts index 6fb03b81b..0aaff3580 100644 --- a/server/tests/unit/nest/journey-book.service.test.ts +++ b/server/tests/unit/nest/journey-book.service.test.ts @@ -566,7 +566,12 @@ describe('editBook', () => { const [tool, studio] = await Promise.all([ catchDomainError(() => books.editBook(journey.id, user.id, edited('tool'), { expectedVersion: 1 })), - books.saveBook(journey.id, user.id, { title: 'T', document: doc('studio'), baseVersion: 1 }), + // The Studio stamps what it saves with its revision, as the book tools do (useBookStore). + books.saveBook(journey.id, user.id, { + title: 'T', + document: { ...doc('studio'), schemaRev: BOOK_SCHEMA_REV }, + baseVersion: 1, + }), ]); const toolLost = tool instanceof DomainError && tool.getStatus() === 409;