feat: hide header View link in standalone mode
The "View" link opens the read-only live view of the canvas. In frontend-only standalone mode the editor already renders the only (localStorage) copy, so the live view adds nothing — hide the link. Kept in full mode. ha-relevant: no
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { describe, it, expect, beforeEach, vi } from 'vitest'
|
||||
import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest'
|
||||
import { render, screen, fireEvent } from '@testing-library/react'
|
||||
import { Toolbar } from '../Toolbar'
|
||||
import { useCanvasStore } from '@/stores/canvasStore'
|
||||
@@ -56,4 +56,33 @@ describe('Toolbar', () => {
|
||||
fireEvent.click(screen.getByText('Save'))
|
||||
expect(defaultProps.onSave).toHaveBeenCalledWith()
|
||||
})
|
||||
|
||||
it('shows the View (live view) link in full mode', () => {
|
||||
render(<Toolbar {...defaultProps} />)
|
||||
expect(screen.getByText('View')).toBeInTheDocument()
|
||||
})
|
||||
})
|
||||
|
||||
// ── Standalone mode ────────────────────────────────────────────────────────────
|
||||
// VITE_STANDALONE is read at module load, so re-import Toolbar after stubbing it.
|
||||
describe('Toolbar (standalone)', () => {
|
||||
afterEach(() => {
|
||||
vi.unstubAllEnvs()
|
||||
})
|
||||
|
||||
it('hides the View link (live view is pointless without a backend)', async () => {
|
||||
vi.stubEnv('VITE_STANDALONE', 'true')
|
||||
vi.resetModules()
|
||||
const { useCanvasStore: cs } = await import('@/stores/canvasStore')
|
||||
vi.mocked(cs).mockReturnValue({
|
||||
hasUnsavedChanges: false, past: [], future: [],
|
||||
} as ReturnType<typeof useCanvasStore>)
|
||||
const { Toolbar: TB } = await import('../Toolbar')
|
||||
|
||||
render(<TB {...defaultProps} />)
|
||||
expect(screen.queryByText('View')).not.toBeInTheDocument()
|
||||
// Other actions remain.
|
||||
expect(screen.getByText('Save')).toBeInTheDocument()
|
||||
expect(screen.getByText('MD')).toBeInTheDocument()
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user