-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUI.test.ts
More file actions
87 lines (75 loc) · 3.24 KB
/
Copy pathUI.test.ts
File metadata and controls
87 lines (75 loc) · 3.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import { panelDefinitions } from '@ui/panelRegistry.js';
import { panelRouter } from '@ui/PanelRouter.js';
import { vi } from 'vitest';
// Mock Config
vi.mock('../configManager.js', () => ({
getConfig: vi.fn().mockReturnValue({
// Minimal config
bounties: { enabled: true },
tpa: { enabled: true },
economy: { enabled: true }
}),
updateConfig: vi.fn(),
updateMultipleConfig: vi.fn(),
resetConfigSection: vi.fn(),
onConfigUpdated: vi.fn(),
initializeConfigManager: vi.fn(),
reloadConfig: vi.fn()
}));
// Mock feature managers if needed by panels
vi.mock('../bountyManager.js', () => ({
bountyManager: { getBounties: () => [] }
}));
// Import panels (trigger registration)
const { initialize } = await import('@ui/panels/index.js');
initialize();
// Also initialize feature panels that were modularized
const { initialize: initEconomy } = await import('@features/economy/index.js');
const { initialize: initEssentials } = await import('@features/essentials/index.js');
const { initialize: initKit } = await import('@features/kit/index.js');
const { initialize: initModeration } = await import('@features/moderation/index.js');
const { initialize: initShop } = await import('@features/shop/index.js');
const { initialize: initSocial } = await import('@features/social/index.js');
const { initialize: initTeam } = await import('@features/team/index.js');
const { initialize: initTeleport } = await import('@features/teleport/index.js');
const { initialize: initGames } = await import('@features/games/index.js');
// Initialize with wait for async modules (some config loaders are async)
await initEconomy(false);
await initGames(false);
await initEssentials(false);
initKit();
initModeration();
await initShop(false);
await initSocial(false);
await initTeam(false);
initTeleport();
describe('UI Integrity Check', () => {
it('should have a registered handler for every panel in registry', () => {
const missingHandlers: string[] = [];
for (const panelId of Object.keys(panelDefinitions)) {
// Some panels might be dynamic config panels handled by a generic handler
// But they should still be claimed by *some* handler.
const handler = panelRouter.getHandler(panelId);
if (!handler) {
missingHandlers.push(panelId);
}
}
expect(missingHandlers).toEqual([]);
});
it('should validate button actions point to valid targets', () => {
const brokenLinks: string[] = [];
for (const [panelId, def] of Object.entries(panelDefinitions)) {
for (const item of def.items) {
if (item.actionType === 'openPanel') {
// Target panel must exist in registry OR be a known dynamic pattern
const targetId = item.actionValue;
const isKnown = panelDefinitions[targetId] || targetId.startsWith('config_') || panelRouter.getHandler(targetId); // Some dynamic panels might not be in static registry but have handlers
if (!isKnown) {
brokenLinks.push(`${panelId} -> ${targetId}`);
}
}
}
}
expect(brokenLinks).toEqual([]);
});
});