feat: simplify code project creation

This commit is contained in:
inman
2026-09-07 10:06:37 +08:00
parent f8eee430f4
commit af13aca003
15 changed files with 351 additions and 486 deletions

View File

@@ -2,10 +2,7 @@ import { render, screen } from '@testing-library/react';
import { MemoryRouter, Route, Routes } from 'react-router-dom';
import { beforeEach, describe, expect, it, vi } from 'vitest';
import { MainLayout } from '@/components/layout/MainLayout';
import { codingWorkspaceStore } from '@/stores/coding-workspace';
import { useProjectConfigStore } from '@/stores/project-config';
import { useSettingsStore } from '@/stores/settings';
import { createCodingProjectConfigV2 } from '@electron/coding-projects/project-config';
const routeRenderMock = vi.hoisted(() => vi.fn());
@@ -46,20 +43,6 @@ function renderLayout(path: string) {
describe('MainLayout module isolation', () => {
beforeEach(() => {
routeRenderMock.mockReset();
const project = {
id: 'local-project',
path: '/tmp/local-project',
name: 'local-project',
createdAt: '',
updatedAt: '',
lastOpenedAt: '',
};
codingWorkspaceStore.setState({ activeProject: project });
useProjectConfigStore.setState({
configsByProjectId: {
[project.id]: { ...createCodingProjectConfigV2(), initialized: false },
},
});
useSettingsStore.setState({ sidebarCollapsed: false });
});
@@ -89,19 +72,17 @@ describe('MainLayout module isolation', () => {
});
it('does not overlay the local project initialization gate on AI hardware', () => {
const load = vi.fn().mockResolvedValue(undefined);
useProjectConfigStore.setState({ load });
renderLayout('/ai-hardware');
expect(screen.getByTestId('route-content')).toBeVisible();
expect(screen.queryByTestId('project-initialization-gate')).not.toBeInTheDocument();
expect(load).not.toHaveBeenCalled();
});
it('keeps the local project initialization gate for AI programming routes', () => {
it('does not restore the removed project initialization gate on AI programming routes', () => {
renderLayout('/chat');
expect(screen.getByTestId('project-initialization-gate')).toBeVisible();
expect(screen.getByTestId('route-content')).toBeVisible();
expect(screen.queryByTestId('project-initialization-gate')).not.toBeInTheDocument();
expect(screen.getByTestId('titlebar-stub')).toHaveAttribute('data-overlay', 'false');
});