Files
RedditBot/tests/dashboard-assets.test.ts
T

28 lines
1016 B
TypeScript

import path from 'node:path';
import { describe, expect, it, vi } from 'vitest';
import { resolveDashboardAssets } from '../src/web/dashboard-assets.js';
describe('resolveDashboardAssets', () => {
it('selects the built React dashboard when its index exists', () => {
const workspace = path.resolve('workspace');
const reactIndex = path.join(workspace, 'apps', 'dashboard', 'dist', 'index.html');
const fileExists = vi.fn((candidate: string) => candidate === reactIndex);
expect(resolveDashboardAssets(workspace, fileExists)).toEqual({
directory: path.dirname(reactIndex),
indexFile: reactIndex,
isLegacy: false,
});
});
it('falls back to the legacy dashboard during incremental migration', () => {
const workspace = path.resolve('workspace');
expect(resolveDashboardAssets(workspace, () => false)).toEqual({
directory: path.join(workspace, 'public'),
indexFile: path.join(workspace, 'public', 'index.html'),
isLegacy: true,
});
});
});