mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-04-10 04:19:25 -07:00
fix(test): seed launcher smoke setup state
This commit is contained in:
@@ -4,6 +4,13 @@ import fs from 'node:fs';
|
|||||||
import os from 'node:os';
|
import os from 'node:os';
|
||||||
import path from 'node:path';
|
import path from 'node:path';
|
||||||
import { spawn, spawnSync } from 'node:child_process';
|
import { spawn, spawnSync } from 'node:child_process';
|
||||||
|
import {
|
||||||
|
createDefaultSetupState,
|
||||||
|
getDefaultConfigDir,
|
||||||
|
getSetupStatePath,
|
||||||
|
readSetupState,
|
||||||
|
writeSetupState,
|
||||||
|
} from '../src/shared/setup-state.js';
|
||||||
|
|
||||||
type RunResult = {
|
type RunResult = {
|
||||||
status: number | null;
|
status: number | null;
|
||||||
@@ -58,6 +65,13 @@ function createSmokeCase(name: string): SmokeCase {
|
|||||||
`socket_path=${socketPath}\n`,
|
`socket_path=${socketPath}\n`,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const configDir = getDefaultConfigDir({ xdgConfigHome, homeDir });
|
||||||
|
const setupState = createDefaultSetupState();
|
||||||
|
setupState.status = 'completed';
|
||||||
|
setupState.completedAt = '2026-03-07T00:00:00.000Z';
|
||||||
|
setupState.completionSource = 'user';
|
||||||
|
writeSetupState(getSetupStatePath(configDir), setupState);
|
||||||
|
|
||||||
const fakeMpvLogPath = path.join(artifactsDir, 'fake-mpv.log');
|
const fakeMpvLogPath = path.join(artifactsDir, 'fake-mpv.log');
|
||||||
const fakeAppLogPath = path.join(artifactsDir, 'fake-app.log');
|
const fakeAppLogPath = path.join(artifactsDir, 'fake-app.log');
|
||||||
const fakeAppStartLogPath = path.join(artifactsDir, 'fake-app-start.log');
|
const fakeAppStartLogPath = path.join(artifactsDir, 'fake-app-start.log');
|
||||||
@@ -224,6 +238,22 @@ async function waitForJsonLines(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test('launcher smoke fixture seeds completed setup state', () => {
|
||||||
|
const smokeCase = createSmokeCase('setup-state');
|
||||||
|
try {
|
||||||
|
const configDir = getDefaultConfigDir({
|
||||||
|
xdgConfigHome: smokeCase.xdgConfigHome,
|
||||||
|
homeDir: smokeCase.homeDir,
|
||||||
|
});
|
||||||
|
const statePath = getSetupStatePath(configDir);
|
||||||
|
|
||||||
|
assert.equal(readSetupState(statePath)?.status, 'completed');
|
||||||
|
} finally {
|
||||||
|
fs.rmSync(smokeCase.root, { recursive: true, force: true });
|
||||||
|
fs.rmSync(smokeCase.socketDir, { recursive: true, force: true });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
test('launcher mpv status returns ready when socket is connectable', async () => {
|
test('launcher mpv status returns ready when socket is connectable', async () => {
|
||||||
await withSmokeCase('mpv-status', async (smokeCase) => {
|
await withSmokeCase('mpv-status', async (smokeCase) => {
|
||||||
const env = makeTestEnv(smokeCase);
|
const env = makeTestEnv(smokeCase);
|
||||||
|
|||||||
Reference in New Issue
Block a user