File tree Expand file tree Collapse file tree
packages/ui/src/components Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -174,6 +174,28 @@ describe('SettingsModal', () => {
174174 expect ( onClose ) . toHaveBeenCalled ( ) ;
175175 } ) ;
176176
177+ it ( 'shows export/import space buttons on settings tab when handlers provided' , ( ) => {
178+ const onExportSpace = vi . fn ( ) ;
179+ const onImportSpace = vi . fn ( ) ;
180+ const onClose = vi . fn ( ) ;
181+ render (
182+ < SettingsModal
183+ { ...defaultProps }
184+ initialTab = "settings"
185+ onExportSpace = { onExportSpace }
186+ onImportSpace = { onImportSpace }
187+ onClose = { onClose }
188+ /> ,
189+ ) ;
190+ const exportBtn = screen . getByTestId ( 'settings-export-space-btn' ) ;
191+ const importBtn = screen . getByTestId ( 'settings-import-space-btn' ) ;
192+ expect ( exportBtn ) . toBeDefined ( ) ;
193+ expect ( importBtn ) . toBeDefined ( ) ;
194+ exportBtn . click ( ) ;
195+ expect ( onExportSpace ) . toHaveBeenCalled ( ) ;
196+ expect ( onClose ) . toHaveBeenCalled ( ) ;
197+ } ) ;
198+
177199 it ( 'shows data tab with clear all data button' , ( ) => {
178200 render ( < SettingsModal { ...defaultProps } initialTab = "data" /> ) ;
179201 expect ( screen . getByTestId ( 'settings-panel-data' ) ) . toBeDefined ( ) ;
Original file line number Diff line number Diff line change @@ -260,6 +260,39 @@ export function SettingsModal({
260260 </ button >
261261 </ label >
262262
263+ { ( onExportSpace || onImportSpace ) && (
264+ < >
265+ < div className = "cept-settings-section-divider" />
266+ < h3 className = "cept-settings-section-title" > Import / Export</ h3 >
267+ < div className = "cept-settings-actions" >
268+ { onExportSpace && (
269+ < button
270+ className = "cept-settings-action-btn"
271+ onClick = { ( ) => { onExportSpace ( ) ; onClose ( ) ; } }
272+ data-testid = "settings-export-space-btn"
273+ >
274+ < svg width = "14" height = "14" viewBox = "0 0 16 16" fill = "none" stroke = "currentColor" strokeWidth = "1.5" >
275+ < path d = "M8 2v8M5 5l3-3 3 3M3 11v2h10v-2" />
276+ </ svg >
277+ Export space as ZIP
278+ </ button >
279+ ) }
280+ { onImportSpace && (
281+ < button
282+ className = "cept-settings-action-btn"
283+ onClick = { ( ) => { onImportSpace ( ) ; onClose ( ) ; } }
284+ data-testid = "settings-import-space-btn"
285+ >
286+ < svg width = "14" height = "14" viewBox = "0 0 16 16" fill = "none" stroke = "currentColor" strokeWidth = "1.5" >
287+ < path d = "M8 10V2M5 7l3 3 3-3M3 11v2h10v-2" />
288+ </ svg >
289+ Import space from ZIP
290+ </ button >
291+ ) }
292+ </ div >
293+ </ >
294+ ) }
295+
263296 < div className = "cept-settings-section-divider" />
264297 < button
265298 className = "cept-settings-danger-btn"
Original file line number Diff line number Diff line change @@ -212,6 +212,14 @@ describe('Sidebar', () => {
212212 expect ( screen . getByText ( 'My Workspace' ) ) . toBeDefined ( ) ;
213213 } ) ;
214214
215+ it ( 'updates displayed space name when spaceName prop changes' , ( ) => {
216+ const { rerender } = render ( < Sidebar pages = { mockPages } spaceName = "Demo Space" /> ) ;
217+ expect ( screen . getByText ( 'Demo Space' ) ) . toBeDefined ( ) ;
218+ rerender ( < Sidebar pages = { mockPages } spaceName = "New Project" /> ) ;
219+ expect ( screen . getByText ( 'New Project' ) ) . toBeDefined ( ) ;
220+ expect ( screen . queryByText ( 'Demo Space' ) ) . toBeNull ( ) ;
221+ } ) ;
222+
215223 it ( 'renders back button when onBackToSpace is provided' , ( ) => {
216224 const onBackToSpace = vi . fn ( ) ;
217225 render ( < Sidebar pages = { mockPages } onBackToSpace = { onBackToSpace } /> ) ;
Original file line number Diff line number Diff line change @@ -80,6 +80,11 @@ export function Sidebar({
8080 position : { x : number ; y : number } ;
8181 } | null > ( null ) ;
8282
83+ // Sync editSpaceNameValue when spaceName prop changes (e.g., after creating or switching spaces)
84+ useEffect ( ( ) => {
85+ setEditSpaceNameValue ( spaceName ?? 'Space' ) ;
86+ } , [ spaceName ] ) ;
87+
8388 const handleContextMenu = useCallback (
8489 ( id : string , title : string , position : { x : number ; y : number } ) => {
8590 setContextMenu ( { pageId : id , pageTitle : title , position } ) ;
You can’t perform that action at this time.
0 commit comments