{[0, 1, 2].map((item) => (
@@ -159,7 +159,7 @@ export function ImageCanvas() {
{
await page.addInitScript(() => {
const now = Date.now();
+ localStorage.setItem('niancode-settings', JSON.stringify({
+ state: { sidebarCollapsed: true },
+ version: 0,
+ }));
localStorage.setItem('niancode-auth', JSON.stringify({
state: {
authBase: 'https://biz.nianxx.cn/auth/',
@@ -355,6 +359,7 @@ test.describe('AI Design V2 workspace', () => {
await expect(page.getByTestId('sidebar-image-workspace')).toBeVisible();
await expect(page.getByTestId('image-workspace-history-rail')).toBeVisible();
await expect(page.getByTestId('image-workspace-works-rail')).toHaveCount(0);
+ await expect(page.getByTestId('titlebar-sidebar-toggle')).toHaveCount(0);
await expect(page.getByRole('heading', { name: '和 AI 一起完善创作' })).toHaveCount(0);
await expect(page.getByText('当前设计项目的制作记录')).toHaveCount(0);
await expect(page.getByText('实时同步')).toHaveCount(0);
@@ -402,13 +407,14 @@ test.describe('AI Design V2 workspace', () => {
expect(layout!.conversationHeight).toBeGreaterThan(300);
expect(layout!.sidebarWidth).toBe(256);
expect(layout!.horizontalGap).toBeLessThanOrEqual(1);
- expect(layout!.historyRailWidth).toBeGreaterThanOrEqual(320);
+ expect(layout!.historyRailWidth).toBe(256);
+ expect(layout!.historyRailWidth).toBe(layout!.sidebarWidth);
expect(layout!.historyRailHeight).toBeGreaterThan(500);
expect(layout!.historyTopGap).toBeLessThanOrEqual(1);
expect(layout!.historyBottomGap).toBeLessThanOrEqual(1);
expect(layout!.historyHorizontalGap).toBeLessThanOrEqual(1);
- expect(layout!.workspaceHeaderHeight).toBe(48);
- expect(layout!.historyHeaderHeight).toBe(48);
+ expect(layout!.workspaceHeaderHeight).toBe(40);
+ expect(layout!.historyHeaderHeight).toBe(40);
expect(layout!.headerTopGap).toBeLessThanOrEqual(1);
expect(layout!.headerBottomGap).toBeLessThanOrEqual(1);
expect(layout!.conversationWidth).toBeGreaterThan(600);
diff --git a/tests/unit/image-canvas-page.test.tsx b/tests/unit/image-canvas-page.test.tsx
index 1397f78..43978c9 100644
--- a/tests/unit/image-canvas-page.test.tsx
+++ b/tests/unit/image-canvas-page.test.tsx
@@ -131,9 +131,9 @@ describe('AI Design Canvas page', () => {
render();
const historyRail = screen.getByTestId('image-workspace-history-rail');
- expect(historyRail).toHaveClass('h-full', 'border-l');
- expect(screen.getByTestId('image-workspace-header')).toHaveClass('h-12');
- expect(screen.getByTestId('image-workspace-history-header')).toHaveClass('h-12');
+ expect(historyRail).toHaveClass('h-full', 'w-64', 'border-l');
+ expect(screen.getByTestId('image-workspace-header')).toHaveClass('h-10');
+ expect(screen.getByTestId('image-workspace-history-header')).toHaveClass('h-10');
expect(within(historyRail).getByRole('heading', { name: '历史作品' })).toBeInTheDocument();
expect(within(historyRail).queryByText('当前设计项目的制作记录')).not.toBeInTheDocument();
expect(within(historyRail).getByText('还没有历史作品')).toBeInTheDocument();
diff --git a/tests/unit/main-layout-module-gate.test.tsx b/tests/unit/main-layout-module-gate.test.tsx
index ac2b456..2f97e5b 100644
--- a/tests/unit/main-layout-module-gate.test.tsx
+++ b/tests/unit/main-layout-module-gate.test.tsx
@@ -7,18 +7,38 @@ import { useSettingsStore } from '@/stores/settings';
const routeRenderMock = vi.hoisted(() => vi.fn());
vi.mock('@/components/layout/Sidebar', () => ({
- Sidebar: ({ hideOnCompact = false }: { hideOnCompact?: boolean }) => (
-
+ Sidebar: ({ hideOnCompact = false, forceExpanded = false, sidebarPeekOpen = false, onSidebarPeekChange }: {
+ hideOnCompact?: boolean;
+ forceExpanded?: boolean;
+ sidebarPeekOpen?: boolean;
+ onSidebarPeekChange?: (open: boolean, source: 'toggle' | 'focus' | 'sidebar' | 'titlebar') => void;
+ }) => (
+
),
}));
vi.mock('@/components/layout/TitleBar', () => ({
- TitleBar: ({ integrated = false, overlay = false, showSidebarControls = true, pageTitle }: { integrated?: boolean; overlay?: boolean; showSidebarControls?: boolean; pageTitle?: string }) => (
+ TitleBar: ({ integrated = false, overlay = false, showSidebarControls = true, pageTitle, sidebarPeekOpen = false, onSidebarPeekChange }: {
+ integrated?: boolean;
+ overlay?: boolean;
+ showSidebarControls?: boolean;
+ pageTitle?: string;
+ sidebarPeekOpen?: boolean;
+ onSidebarPeekChange?: (open: boolean, source: 'toggle' | 'focus' | 'sidebar' | 'titlebar') => void;
+ }) => (
),
}));
@@ -54,13 +74,19 @@ describe('MainLayout module isolation', () => {
});
it('uses the full-height workspace shell with the shared left project sidebar for AI painting', () => {
+ useSettingsStore.setState({ sidebarCollapsed: true });
renderLayout('/image-canvas');
expect(screen.getByTestId('main-content')).toHaveClass('basis-0', 'h-full', 'overflow-hidden', 'p-0');
expect(screen.getByTestId('main-content')).not.toHaveClass('p-5', 'sm:p-6');
expect(screen.getByTestId('titlebar-stub')).toHaveAttribute('data-overlay', 'true');
- expect(screen.getByTestId('titlebar-stub')).toHaveAttribute('data-sidebar-controls', 'true');
+ expect(screen.getByTestId('titlebar-stub')).toHaveAttribute('data-sidebar-controls', 'false');
+ expect(screen.getByTestId('titlebar-stub')).toHaveAttribute('data-peek-open', 'false');
+ expect(screen.getByTestId('titlebar-stub')).toHaveAttribute('data-has-peek-handler', 'false');
expect(screen.getByTestId('sidebar-stub')).toHaveAttribute('data-hide-on-compact', 'true');
+ expect(screen.getByTestId('sidebar-stub')).toHaveAttribute('data-force-expanded', 'true');
+ expect(screen.getByTestId('sidebar-stub')).toHaveAttribute('data-peek-open', 'false');
+ expect(screen.getByTestId('sidebar-stub')).toHaveAttribute('data-has-peek-handler', 'false');
});
it('does not overlay the local project initialization gate on AI hardware', () => {
diff --git a/tests/unit/title-bar.test.tsx b/tests/unit/title-bar.test.tsx
index 1533c67..c1d949e 100644
--- a/tests/unit/title-bar.test.tsx
+++ b/tests/unit/title-bar.test.tsx
@@ -132,6 +132,18 @@ describe('TitleBar platform behavior', () => {
expect(screen.getByTestId('titlebar-logo')).toBeInTheDocument();
});
+ it('leaves the narrow Windows Canvas rail to the native window controls', () => {
+ window.electron.platform = 'win32';
+
+ render();
+
+ expect(screen.queryByTestId('titlebar-sidebar-toggle')).not.toBeInTheDocument();
+ expect(screen.queryByTestId('titlebar-logo')).not.toBeInTheDocument();
+ expect(screen.getByTitle('Minimize')).toBeInTheDocument();
+ expect(screen.getByTitle('Maximize')).toBeInTheDocument();
+ expect(screen.getByTitle('Close')).toBeInTheDocument();
+ });
+
it('keeps an optional page title after the macOS traffic-light safe area', () => {
window.electron.platform = 'darwin';
useSettingsStore.setState({ sidebarCollapsed: true });