refactor: get all tests passing; configure at top-level

This commit is contained in:
Christian Benincasa
2025-07-06 20:51:18 -04:00
parent ed8cac8782
commit fe7736591c
10 changed files with 205 additions and 869 deletions

View File

@@ -37,7 +37,7 @@
"prettier": "^3.5.1",
"turbo": "^2.5.3",
"typescript": "5.7.3",
"vitest": "^1.6.0"
"vitest": "^3.2.4"
},
"engines": {
"node": "22"

975
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@@ -114,6 +114,6 @@
"typescript": "5.7.3",
"typescript-eslint": "^8.19.0",
"unzip-stream": "^0.3.4",
"vitest": "^2.1.8"
"vitest": "^3.2.4"
}
}

View File

@@ -48,7 +48,7 @@
"ts-essentials": "^9.4.1",
"tsup": "^8.0.2",
"typescript": "^5.3.3",
"vitest": "^3.0.3"
"vitest": "^3.2.4"
},
"peerDependencies": {
"ts-pattern": "^5.4.0"

View File

@@ -56,7 +56,7 @@ test('ApiProgramMinter mints Plex movies', () => {
id: 'plex://movie/123',
},
],
externalSourceId: 'media source',
externalSourceId: 'mediaSource.123',
persisted: false,
uniqueId: 'plex|media source|123',
id: 'plex|media source|123',

View File

@@ -25,48 +25,72 @@ describe('randomSlotsService', () => {
padMs: 30 * 60 * 1000,
padStyle: 'slot',
randomDistribution: 'uniform',
lockWeights: false,
slots: [
{
weight: 37.5,
cooldownMs: 0.0,
durationMs: +dayjs.duration({ minutes: 30 }),
durationSpec: {
type: 'fixed',
durationMs: +dayjs.duration({ minutes: 30 }),
},
programming: {
type: 'show',
showId: 'test.1',
},
order: 'next',
direction: 'asc',
},
{
weight: 25.0,
cooldownMs: 0.0,
durationMs: +dayjs.duration({ hours: 3 }),
durationSpec: {
type: 'fixed',
durationMs: +dayjs.duration({ hours: 3 }),
},
programming: {
type: 'movie',
},
order: 'next',
direction: 'asc',
},
{
weight: 37.5,
cooldownMs: 0.0,
durationMs: +dayjs.duration({ minutes: 30 }),
durationSpec: {
type: 'fixed',
durationMs: +dayjs.duration({ minutes: 30 }),
},
programming: {
type: 'show',
showId: 'test.2',
},
order: 'next',
direction: 'asc',
},
],
}).generateSchedule([
...map(range(0, 5), (i) => ({
type: 'content' as const,
duration: +dayjs.duration({
hours: random(1, 3, false),
minutes: random(0, 60),
}),
externalIds: [],
persisted: true,
subtype: 'movie' as const,
title: `Movie${i}`,
uniqueId: `Movie${i}`,
// showId: 'test.1',
})),
...map(
range(0, 5),
(i) =>
({
type: 'content' as const,
duration: +dayjs.duration({
hours: random(1, 3, false),
minutes: random(0, 60),
}),
externalIds: [],
persisted: true,
subtype: 'movie' as const,
title: `Movie${i}`,
uniqueId: `Movie${i}`,
externalKey: '123',
externalSourceId: 'abc',
externalSourceName: 'plex',
externalSourceType: 'plex',
// showId: 'test.1',
}) satisfies ChannelProgram,
),
{
type: 'content',
duration: +dayjs.duration({ minutes: 22 }),
@@ -76,7 +100,11 @@ describe('randomSlotsService', () => {
title: 'Show1.Ep1',
uniqueId: 'Show1.Ep1',
showId: 'test.1',
},
externalKey: '123',
externalSourceId: 'abc',
externalSourceName: 'plex',
externalSourceType: 'plex',
} satisfies ChannelProgram,
{
type: 'content',
duration: +dayjs.duration({ minutes: 22 }),
@@ -86,17 +114,18 @@ describe('randomSlotsService', () => {
title: 'Show2.Ep1',
uniqueId: 'Show2.Ep1',
showId: 'test.2',
},
externalKey: '123',
externalSourceId: 'abc',
externalSourceName: 'plex',
externalSourceType: 'plex',
} satisfies ChannelProgram,
]);
let start = dayjs(result.startTime);
for (const program of result.programs) {
for (const program of result) {
console.log(
start.format(),
formatProgram(program),
dayjs.duration(program.duration).humanize(),
);
start = start.add(program.duration);
}
});
});

View File

@@ -22,8 +22,7 @@
"interruptible": true
},
"test": {
"cache": false,
"persistent": true
"cache": false
},
"test:watch": {
"cache": false,

7
vitest.config.ts Normal file
View File

@@ -0,0 +1,7 @@
import { defineConfig } from 'vitest/config';
export default defineConfig({
test: {
projects: ['web', 'server', 'shared'],
},
});

View File

@@ -84,6 +84,6 @@
"typescript": "5.4.3",
"vite": "^5.4.1",
"vite-plugin-svgr": "^4.2.0",
"vitest": "^2.0.5"
"vitest": "^3.2.4"
}
}

View File

@@ -1,6 +1,12 @@
import path from 'node:path';
import { defineConfig } from 'vitest/config';
export default defineConfig({
resolve: {
alias: {
'@': path.resolve(__dirname, 'src'),
},
},
test: {
globals: true,
includeSource: ['src/**/*.test.ts'],