test(08-01): migrate data-layer tests into __test__ dirs

Move 65 *.test.ts + 6 *.perf.ts across data-{common,base,system,state} into sibling __test__/ (data-state/test -> data-state/__test__), incl. fixtures/floors.json and non-test helpers; rewrite Rule A relative specifiers (+1 depth), keep Rule B unchanged; sync script/test-data-node.ts require paths. Gates: test:ci=66 files, test:perf=6 files, eslint clean, zero config/production changes.
This commit is contained in:
AncTe committed 2026-10-04 17:34:09 +08:00
1 parent 109fad3b29
commit 36d8b4fb3c
75 files changed
+201 -201

No files matched your search

@@ -1,6 +1,6 @@
// 测试 Enemy 数据模型:属性单元、特殊属性增删查、克隆与复制行为
import { afterAll, beforeAll, describe, expect, it, vi } from 'vitest';
import { type IEnemy, type ISpecial } from './types';
import { type IEnemy, type ISpecial } from '../types';
vi.hoisted(() => {
vi.stubGlobal('main', { replayChecking: true });
@@ -19,8 +19,8 @@ vi.hoisted(() => {
});
interface TestModules {
Enemy: typeof import('./enemy').Enemy;
CommonSerializableSpecial: typeof import('./special').CommonSerializableSpecial;
Enemy: typeof import('../enemy').Enemy;
CommonSerializableSpecial: typeof import('../special').CommonSerializableSpecial;
logger: typeof import('@motajs/common').logger;
}
@@ -29,8 +29,8 @@ let modules: TestModules;
beforeAll(async () => {
vi.stubGlobal('main', { replayChecking: true });
vi.stubGlobal('location', { origin: 'http://localhost' });
const enemyModule = await import('./enemy');
const specialModule = await import('./special');
const enemyModule = await import('../enemy');
const specialModule = await import('../special');
const commonModule = await import('@motajs/common');
modules = {
Enemy: enemyModule.Enemy,
@@ -5,7 +5,7 @@ import {
type IEnemyComparer,
type IEnemyLegacyBridge,
type IEnemyManager
} from './types';
} from '../types';
vi.hoisted(() => {
vi.stubGlobal('main', { replayChecking: true });
@@ -24,8 +24,8 @@ vi.hoisted(() => {
});
interface TestModules {
Enemy: typeof import('./enemy').Enemy;
EnemyManager: typeof import('./manager').EnemyManager;
Enemy: typeof import('../enemy').Enemy;
EnemyManager: typeof import('../manager').EnemyManager;
logger: typeof import('@motajs/common').logger;
}
@@ -34,8 +34,8 @@ let modules: TestModules;
beforeAll(async () => {
vi.stubGlobal('main', { replayChecking: true });
vi.stubGlobal('location', { origin: 'http://localhost' });
const enemyModule = await import('./enemy');
const managerModule = await import('./manager');
const enemyModule = await import('../enemy');
const managerModule = await import('../manager');
const commonModule = await import('@motajs/common');
modules = {
Enemy: enemyModule.Enemy,
@@ -6,7 +6,7 @@ import {
type IEnemyLegacyBridge,
type IEnemyManager,
type ISpecial
} from './types';
} from '../types';
vi.hoisted(() => {
vi.stubGlobal('main', { replayChecking: true });
@@ -25,10 +25,10 @@ vi.hoisted(() => {
});
interface TestModules {
Enemy: typeof import('./enemy').Enemy;
CommonSerializableSpecial: typeof import('./special').CommonSerializableSpecial;
NonePropertySpecial: typeof import('./special').NonePropertySpecial;
EnemyManager: typeof import('./manager').EnemyManager;
Enemy: typeof import('../enemy').Enemy;
CommonSerializableSpecial: typeof import('../special').CommonSerializableSpecial;
NonePropertySpecial: typeof import('../special').NonePropertySpecial;
EnemyManager: typeof import('../manager').EnemyManager;
logger: typeof import('@motajs/common').logger;
}
@@ -37,9 +37,9 @@ let modules: TestModules;
beforeAll(async () => {
vi.stubGlobal('main', { replayChecking: true });
vi.stubGlobal('location', { origin: 'http://localhost' });
const enemyModule = await import('./enemy');
const specialModule = await import('./special');
const managerModule = await import('./manager');
const enemyModule = await import('../enemy');
const specialModule = await import('../special');
const managerModule = await import('../manager');
const commonModule = await import('@motajs/common');
modules = {
Enemy: enemyModule.Enemy,
@@ -1,7 +1,7 @@
// 测试 special 数据模型:可序列化特殊属性的数值/名称/描述单元,以及无属性特殊属性
import { afterAll, beforeAll, describe, expect, it, vi } from 'vitest';
import { type ICommonSpecialConfig } from './special';
import { type ISpecial } from './types';
import { type ICommonSpecialConfig } from '../special';
import { type ISpecial } from '../types';
vi.hoisted(() => {
vi.stubGlobal('main', { replayChecking: true });
@@ -20,8 +20,8 @@ vi.hoisted(() => {
});
interface TestModules {
defineCommonSerializableSpecial: typeof import('./special').defineCommonSerializableSpecial;
defineNonePropertySpecial: typeof import('./special').defineNonePropertySpecial;
defineCommonSerializableSpecial: typeof import('../special').defineCommonSerializableSpecial;
defineNonePropertySpecial: typeof import('../special').defineNonePropertySpecial;
}
let modules: TestModules;
@@ -29,7 +29,7 @@ let modules: TestModules;
beforeAll(async () => {
vi.stubGlobal('main', { replayChecking: true });
vi.stubGlobal('location', { origin: 'http://localhost' });
const specialModule = await import('./special');
const specialModule = await import('../special');
modules = {
defineCommonSerializableSpecial:
specialModule.defineCommonSerializableSpecial,
@@ -1,6 +1,6 @@
// 测试全局 Flag 系统存读档:同实例往返、占用状态与存档克隆
import { afterAll, describe, expect, it, vi } from 'vitest';
import { FlagSystem } from './system';
import { FlagSystem } from '../system';
vi.hoisted(() => {
vi.stubGlobal('main', { replayChecking: true });
@@ -28,7 +28,7 @@ vi.hoisted(() => {
});
interface TestModules {
FlagSystem: typeof import('./system').FlagSystem;
FlagSystem: typeof import('../system').FlagSystem;
logger: typeof import('@motajs/common').logger;
}
@@ -37,7 +37,7 @@ let modules: TestModules;
beforeAll(async () => {
vi.stubGlobal('main', { replayChecking: true });
vi.stubGlobal('location', { origin: 'http://localhost' });
const systemModule = await import('./system');
const systemModule = await import('../system');
const commonModule = await import('@motajs/common');
modules = {
FlagSystem: systemModule.FlagSystem,
@@ -1,7 +1,7 @@
// 性能测量:勇士属性修饰器重算随修饰器数量的耗时,只记录不断言
import { afterAll, describe, it, vi } from 'vitest';
import { BaseHeroModifier, HeroAttribute } from './attribute';
import { type IHeroModifier } from './types';
import { BaseHeroModifier, HeroAttribute } from '../attribute';
import { type IHeroModifier } from '../types';
vi.hoisted(() => {
vi.stubGlobal('main', { replayChecking: true });
@@ -1,9 +1,9 @@
// 测试 HeroAttribute 构件:基础/最终属性、修饰器增删排序、存盘开关、克隆、自身存读档与告警码 108/109、克隆体修饰器簿记与存档开关
import { afterAll, describe, expect, it, vi } from 'vitest';
import { BaseHeroModifier, HeroAttribute } from './attribute';
import { BaseHeroModifier, HeroAttribute } from '../attribute';
import { logger } from '@motajs/common';
import { SaveCompression } from '@user/data-common';
import { type IHeroModifier } from './types';
import { type IHeroModifier } from '../types';
/** 存读档测试覆盖的三档压缩级别 */
const SAVE_COMPRESSIONS = [
@@ -10,13 +10,13 @@ import {
TileStore,
TileType
} from '@user/data-common';
import { HeroEquipsStore } from './equipStore';
import { PercentageModifier, ValueModifier } from './modifier';
import { HeroEquipsStore } from '../equipStore';
import { PercentageModifier, ValueModifier } from '../modifier';
import {
type IEquipmentSortHandler,
type IEquipmentSorter,
type IEquipmentStateSave
} from './types';
} from '../types';
vi.hoisted(() => {
vi.stubGlobal('main', { replayChecking: true });
@@ -12,11 +12,11 @@ import {
TileType
} from '@user/data-common';
import { logger } from '@motajs/common';
import { HeroAttribute } from './attribute';
import { ValueModifier } from './modifier';
import { HeroEquipsStore } from './equipStore';
import { HeroEquipment } from './equipment';
import { EquipStatus } from './types';
import { HeroAttribute } from '../attribute';
import { ValueModifier } from '../modifier';
import { HeroEquipsStore } from '../equipStore';
import { HeroEquipment } from '../equipment';
import { EquipStatus } from '../types';
vi.hoisted(() => {
vi.stubGlobal('main', { replayChecking: true });
@@ -10,10 +10,10 @@ import {
TileType
} from '@user/data-common';
import { logger } from '@motajs/common';
import { type IPassPredicate } from '../map';
import { HeroFollowersController } from './follower';
import { HeroLocation } from './location';
import { type IHeroMoveTopImpl } from './types';
import { type IPassPredicate } from '../../map';
import { HeroFollowersController } from '../follower';
import { HeroLocation } from '../location';
import { type IHeroMoveTopImpl } from '../types';
vi.hoisted(() => {
vi.stubGlobal('main', { replayChecking: true });
@@ -9,7 +9,7 @@ import {
TileStore,
TileType
} from '@user/data-common';
import { HeroItems } from './items';
import { HeroItems } from '../items';
vi.hoisted(() => {
vi.stubGlobal('main', { replayChecking: true });
@@ -7,7 +7,7 @@ import {
ItemStore,
TileStore
} from '@user/data-common';
import { HeroLocation } from './location';
import { HeroLocation } from '../location';
vi.hoisted(() => {
vi.stubGlobal('main', { replayChecking: true });
@@ -1,7 +1,7 @@
// 测试勇士修饰器构件:数值/百分比公式、默认优先级、类型字符串与绑定重算
import { afterAll, describe, expect, it, vi } from 'vitest';
import { HeroAttribute } from './attribute';
import { PercentageModifier, ValueModifier } from './modifier';
import { HeroAttribute } from '../attribute';
import { PercentageModifier, ValueModifier } from '../modifier';
vi.hoisted(() => {
vi.stubGlobal('main', { replayChecking: true });
@@ -8,9 +8,9 @@ import {
TileStore
} from '@user/data-common';
import { logger } from '@motajs/common';
import { type IPassPredicate } from '../map';
import { HeroLocation } from './location';
import { type IHeroMoveTopHandler, type IHeroMoveTopImpl } from './types';
import { type IPassPredicate } from '../../map';
import { HeroLocation } from '../location';
import { type IHeroMoveTopHandler, type IHeroMoveTopImpl } from '../types';
vi.hoisted(() => {
vi.stubGlobal('main', { replayChecking: true });
@@ -1,8 +1,8 @@
// 测试 HeroRendering 构件:默认不透明度、setAlpha 与 onSetAlpha 钩子注册/解除
import { afterAll, describe, expect, it, vi } from 'vitest';
import { type IDataCommon, ItemStore, TileStore } from '@user/data-common';
import { HeroRendering } from './rendering';
import { type IHeroRenderingHooks } from './types';
import { HeroRendering } from '../rendering';
import { type IHeroRenderingHooks } from '../types';
vi.hoisted(() => {
vi.stubGlobal('main', { replayChecking: true });
@@ -13,16 +13,16 @@ import {
TileType
} from '@user/data-common';
import { logger } from '@motajs/common';
import { HeroAttribute } from './attribute';
import { PercentageModifier, ValueModifier } from './modifier';
import { HeroLocation } from './location';
import { HeroRendering } from './rendering';
import { HeroState } from './state';
import { HeroEquipment } from './equipment';
import { EquipmentState, HeroEquipsStore } from './equipStore';
import { HeroItems } from './items';
import { HeroFollowersController } from './follower';
import { type IHeroState } from './types';
import { HeroAttribute } from '../attribute';
import { PercentageModifier, ValueModifier } from '../modifier';
import { HeroLocation } from '../location';
import { HeroRendering } from '../rendering';
import { HeroState } from '../state';
import { HeroEquipment } from '../equipment';
import { EquipmentState, HeroEquipsStore } from '../equipStore';
import { HeroItems } from '../items';
import { HeroFollowersController } from '../follower';
import { type IHeroState } from '../types';
vi.hoisted(() => {
vi.stubGlobal('main', { replayChecking: true });
@@ -9,10 +9,10 @@ import {
TileStore
} from '@user/data-common';
import { logger } from '@motajs/common';
import { HeroAttribute } from './attribute';
import { ValueModifier } from './modifier';
import { HeroState } from './state';
import { type IHeroAttribute, type IHeroState } from './types';
import { HeroAttribute } from '../attribute';
import { ValueModifier } from '../modifier';
import { HeroState } from '../state';
import { type IHeroAttribute, type IHeroState } from '../types';
vi.hoisted(() => {
vi.stubGlobal('main', { replayChecking: true });
@@ -13,9 +13,9 @@ import {
TileType
} from '@user/data-common';
import { DirectionMapper, logger } from '@motajs/common';
import { type IResizableMapLayer } from './types';
import { MapState } from './mapState';
import { DynamicTile } from './dynamicTile';
import { type IResizableMapLayer } from '../types';
import { MapState } from '../mapState';
import { DynamicTile } from '../dynamicTile';
vi.hoisted(() => {
vi.stubGlobal('main', { replayChecking: true });
@@ -7,7 +7,7 @@ import {
} from '@user/data-common';
interface TestModules {
MapState: typeof import('./mapState').MapState;
MapState: typeof import('../mapState').MapState;
TileStore: typeof import('@user/data-common').TileStore;
RoleFaceBinder: typeof import('@user/data-common').RoleFaceBinder;
DirectionMapper: typeof import('@motajs/common').DirectionMapper;
@@ -29,7 +29,7 @@ beforeAll(async () => {
this.set(key, value);
return value;
};
const mapModule = await import('./mapState');
const mapModule = await import('../mapState');
const commonModule = await import('@user/data-common');
const loggerModule = await import('@motajs/common');
modules = {
@@ -1,7 +1,7 @@
// 测试 LayerEventView 的参考基准、dirty 状态和恢复行为
import { afterAll, describe, expect, it, vi } from 'vitest';
import { logger } from '@motajs/common';
import { LayerEventView } from './eventView';
import { LayerEventView } from '../eventView';
vi.hoisted(() => {
vi.stubGlobal('main', { replayChecking: true });
@@ -11,8 +11,8 @@ import {
TileType
} from '@user/data-common';
import { DirectionMapper, logger } from '@motajs/common';
import { type IMapLayer } from './types';
import { GameMap } from './gameMap';
import { type IMapLayer } from '../types';
import { GameMap } from '../gameMap';
vi.hoisted(() => {
vi.stubGlobal('main', { replayChecking: true });
@@ -18,9 +18,9 @@ import {
type IDynamicTile,
type IGameMap,
type IResizableMapLayer
} from './types';
import { DynamicTile } from './dynamicTile';
import { MapState } from './mapState';
} from '../types';
import { DynamicTile } from '../dynamicTile';
import { MapState } from '../mapState';
vi.hoisted(() => {
vi.stubGlobal('main', { replayChecking: true });
@@ -1,6 +1,6 @@
// 测试图块默认事件、点事件存读档、压缩聚合和尺寸变化
import { beforeAll, describe, expect, it, vi } from 'vitest';
import { type IResizableMapLayer } from './types';
import { type IResizableMapLayer } from '../types';
import {
type IDataCommon,
type ITileStore,
@@ -24,7 +24,7 @@ vi.hoisted(() => {
});
interface TestModules {
MapState: typeof import('./mapState').MapState;
MapState: typeof import('../mapState').MapState;
TileStore: typeof import('@user/data-common').TileStore;
RoleFaceBinder: typeof import('@user/data-common').RoleFaceBinder;
FaceManager: typeof import('@user/data-common').FaceManager;
@@ -37,7 +37,7 @@ let modules: TestModules;
beforeAll(async () => {
vi.stubGlobal('main', { replayChecking: true });
vi.stubGlobal('location', { origin: 'http://localhost' });
const mapModule = await import('./mapState');
const mapModule = await import('../mapState');
const commonModule = await import('@user/data-common');
const motaModule = await import('@motajs/common');
modules = {
@@ -12,7 +12,7 @@ import {
TileType
} from '@user/data-common';
import { DirectionMapper, logger } from '@motajs/common';
import { MapState } from './mapState';
import { MapState } from '../mapState';
vi.hoisted(() => {
vi.stubGlobal('main', { replayChecking: true });
@@ -12,10 +12,10 @@ import {
TileType
} from '@user/data-common';
import { DirectionMapper, logger } from '@motajs/common';
import { type IResizableMapLayer } from './types';
import { MapState } from './mapState';
import { DynamicTile } from './dynamicTile';
import { DynamicTileMover } from './mover';
import { type IResizableMapLayer } from '../types';
import { MapState } from '../mapState';
import { DynamicTile } from '../dynamicTile';
import { DynamicTileMover } from '../mover';
vi.hoisted(() => {
vi.stubGlobal('main', { replayChecking: true });
@@ -11,8 +11,8 @@ import {
TileType
} from '@user/data-common';
import { DirectionMapper, logger } from '@motajs/common';
import { type IGameMap, type IResizableMapLayer } from './types';
import { MapState } from './mapState';
import { type IGameMap, type IResizableMapLayer } from '../types';
import { MapState } from '../mapState';
vi.hoisted(() => {
vi.stubGlobal('main', { replayChecking: true });
@@ -11,9 +11,9 @@ import {
TileType
} from '@user/data-common';
import { DirectionMapper } from '@motajs/common';
import { type IResizableMapLayer } from './types';
import { MapState } from './mapState';
import { StaticTile } from './staticTile';
import { type IResizableMapLayer } from '../types';
import { MapState } from '../mapState';
import { StaticTile } from '../staticTile';
vi.hoisted(() => {
vi.stubGlobal('main', { replayChecking: true });
@@ -13,9 +13,9 @@ import {
TileType
} from '@user/data-common';
import { DirectionMapper } from '@motajs/common';
import { type IResizableMapLayer } from './types';
import { MapState } from './mapState';
import { StaticTile } from './staticTile';
import { type IResizableMapLayer } from '../types';
import { MapState } from '../mapState';
import { StaticTile } from '../staticTile';
vi.hoisted(() => {
vi.stubGlobal('main', { replayChecking: true });