Files
Genarrative/src/routing/activeAppPageRoutes.test.ts
T
kdletters 39aed2e486
Project CI / AI game creator shell Rust shard 1/4 (push) Failing after 18s
Project CI / AI game creator shell Rust shard 4/4 (push) Failing after 18s
Project CI / AI game creator shell Rust shard 2/4 (push) Failing after 19s
Project CI / AI game creator shell Rust shard 3/4 (push) Failing after 19s
Project CI / AI game creator shell Rust crates (push) Failing after 18s
Project CI / Native shell tests (push) Failing after 18s
Project CI / Backend tests (push) Failing after 18s
Project CI / AI game creator shell Rust smoke (push) Failing after 19s
Project CI / Frontend tests (push) Failing after 7s
Project CI / AI game creator shell web tests (push) Failing after 11s
Project CI / Repository checks (push) Failing after 11s
OSS 写入显式使用 v1 签名
ossutil v2 默认 v4 签名,缺 region 会直接失败\n总号写入与回读统一走 buildOssutilArgs,默认 --sign-version v1,可切 v4 并配合 AGC_OSS_REGION\n补充参数构造单测
2026-09-20 18:33:02 +08:00

79 lines
3.2 KiB
TypeScript

/* @vitest-environment jsdom */
import { describe, expect, it } from 'vitest';
import {
isAppHistoryState,
isKnownMainAppPagePath,
pushAppHistoryPath,
readEditorCanvasProjectIdFromLocationSearch,
replaceAppHistoryPath,
resolvePathForSelectionStage,
resolveSelectionStageFromPath,
shouldRedirectEditorCanvasWithoutProject,
} from './activeAppPageRoutes';
describe('appPageRoutes', () => {
it('resolves the active creation, project, and editor stages', () => {
expect(resolveSelectionStageFromPath('/')).toBe('platform');
expect(resolveSelectionStageFromPath('/creation')).toBe('creation-home');
expect(resolveSelectionStageFromPath('/project')).toBe('project');
expect(resolveSelectionStageFromPath('/PROFILE/')).toBe('profile');
expect(resolveSelectionStageFromPath('/EDITOR/CANVAS/')).toBe(
'image-editor',
);
expect(resolveSelectionStageFromPath('/games')).toBe('games');
expect(resolveSelectionStageFromPath('/games/detail/')).toBe('game-detail');
expect(resolveSelectionStageFromPath('/games/play')).toBe('game-play');
expect(resolveSelectionStageFromPath('/games/mine')).toBe('game-mine');
expect(resolveSelectionStageFromPath('/games/publish')).toBe(
'game-publish',
);
expect(resolveSelectionStageFromPath('/creation/rpg')).toBe('platform');
expect(resolveSelectionStageFromPath('/runtime/puzzle')).toBe('platform');
expect(isKnownMainAppPagePath('/creation')).toBe(true);
expect(isKnownMainAppPagePath('/profile')).toBe(true);
expect(isKnownMainAppPagePath('/creation/rpg')).toBe(false);
expect(isKnownMainAppPagePath('/runtime/puzzle')).toBe(false);
expect(resolvePathForSelectionStage('creation-home')).toBe('/creation');
expect(resolvePathForSelectionStage('project')).toBe('/project');
expect(resolvePathForSelectionStage('profile')).toBe('/profile');
expect(resolvePathForSelectionStage('games')).toBe('/games');
expect(resolvePathForSelectionStage('game-mine')).toBe('/games/mine');
expect(resolvePathForSelectionStage('game-publish')).toBe('/games/publish');
});
it('requires a project id for direct editor navigation', () => {
expect(readEditorCanvasProjectIdFromLocationSearch('?projectid=abc')).toBe(
'abc',
);
expect(shouldRedirectEditorCanvasWithoutProject('/editor/canvas', '')).toBe(
true,
);
expect(
shouldRedirectEditorCanvasWithoutProject(
'/editor/canvas',
'?projectid=project-1',
),
).toBe(false);
});
it('preserves host context while navigating public pages', () => {
window.history.replaceState(
null,
'',
'/?clientRuntime=native_app&hostShell=tauri_desktop',
);
pushAppHistoryPath('/editor/canvas?projectid=project-1');
expect(window.location.pathname).toBe('/editor/canvas');
expect(window.location.search).toContain('projectid=project-1');
expect(window.location.search).toContain('clientRuntime=native_app');
expect(isAppHistoryState(window.history.state)).toBe(true);
replaceAppHistoryPath('/project');
expect(window.location.pathname).toBe('/project');
expect(window.location.search).toContain('hostShell=tauri_desktop');
});
});