be370cc615
Project CI / AI game creator shell Rust shard 1/4 (push) Successful in 7m12s
Project CI / AI game creator shell Rust shard 2/4 (push) Successful in 7m17s
Project CI / AI game creator shell Rust shard 3/4 (push) Successful in 7m26s
Project CI / AI game creator shell Rust shard 4/4 (push) Successful in 7m37s
Project CI / AI game creator shell Rust smoke (push) Successful in 1m57s
Project CI / AI game creator shell Rust crates (push) Successful in 2m10s
Project CI / Frontend tests (push) Successful in 6m4s
Project CI / Native shell tests (push) Successful in 8m58s
Project CI / Backend tests (push) Has been cancelled
Project CI / AI game creator shell web tests (push) Has been cancelled
Project CI / Repository checks (push) Has been cancelled
- 新增设置「工作区」分类,承载「项目创建目录」的选择与恢复默认入口 - 自动建项命令新增可选 projectsRoot,未指定时沿用 AppData projects 默认目录 - 新增项目创建目录校验与解析:只接受目录选择器返回且通过私有路径门禁的既有目录 - 目录选择器新增可选 title 参数,用于「选择项目创建目录」文案 - 首页自动建项与模板建项在建项时携带用户选定的项目创建目录 - 客户端本地保存项目创建目录偏好,建项时重新校验,不作为授权凭据 - 补充设置页工作区、首页建项与目录偏好单测 - 修复项目开发视图缺失的 Shapes 图标导入,恢复 agc:typecheck 通过 - 同步实施计划、决策日志与排障记忆文档
54 lines
1.9 KiB
TypeScript
54 lines
1.9 KiB
TypeScript
/** @vitest-environment jsdom */
|
|
import { beforeEach, describe, expect, it } from 'vitest';
|
|
|
|
import {
|
|
normalizeProjectCreationDirectory,
|
|
readProjectCreationDirectory,
|
|
writeProjectCreationDirectory,
|
|
} from '../src/features/app-shell/model';
|
|
|
|
const STORAGE_KEY = 'genarrative-ai-game-creator.project-creation-directory.v1';
|
|
|
|
describe('项目创建目录偏好', () => {
|
|
beforeEach(() => {
|
|
window.localStorage.clear();
|
|
});
|
|
|
|
it('去掉首尾空白与多余分隔符,并保留盘根', () => {
|
|
expect(normalizeProjectCreationDirectory(' ')).toBe('');
|
|
expect(normalizeProjectCreationDirectory(' F:\\Projects\\游戏\\ ')).toBe(
|
|
'F:\\Projects\\游戏',
|
|
);
|
|
expect(normalizeProjectCreationDirectory('F:/Projects/游戏/')).toBe(
|
|
'F:/Projects/游戏',
|
|
);
|
|
expect(normalizeProjectCreationDirectory('C:\\')).toBe('C:\\');
|
|
// 首尾空白按 trim 处理;目录中间的控制字符必须整条拒绝。
|
|
expect(normalizeProjectCreationDirectory('F:\\游戏\n')).toBe('F:\\游戏');
|
|
expect(normalizeProjectCreationDirectory('F:\\游\n戏')).toBe('');
|
|
});
|
|
|
|
it('保存选中的目录,并在恢复默认位置时清空', () => {
|
|
expect(readProjectCreationDirectory()).toBe('');
|
|
|
|
expect(writeProjectCreationDirectory(' F:\\Projects\\游戏 ')).toBe(
|
|
'F:\\Projects\\游戏',
|
|
);
|
|
expect(readProjectCreationDirectory()).toBe('F:\\Projects\\游戏');
|
|
|
|
expect(writeProjectCreationDirectory(' ')).toBe('');
|
|
expect(readProjectCreationDirectory()).toBe('');
|
|
});
|
|
|
|
it('忽略存储里不可用的值,退回默认位置', () => {
|
|
window.localStorage.setItem(STORAGE_KEY, JSON.stringify('relative/games'));
|
|
expect(readProjectCreationDirectory()).toBe('');
|
|
|
|
window.localStorage.setItem(STORAGE_KEY, JSON.stringify(42));
|
|
expect(readProjectCreationDirectory()).toBe('');
|
|
|
|
window.localStorage.setItem(STORAGE_KEY, '{not json');
|
|
expect(readProjectCreationDirectory()).toBe('');
|
|
});
|
|
});
|