1
0
mirror of https://github.com/misskey-dev/misskey.git synced 2026-07-27 05:24:39 +02:00
Files
syuilo b51d5ba0a0 frontend bundle diagnostics と frontend browser diagnostics を統合 (#17757)
* refactor(gh): unify frontend diagnostics

* refactor(gh): unify frontend diagnostics markdown rendering

* docs(gh): restore frontend diagnostics comments

* wip

* fix

* refactor: 呼称をbase/headに統一

* tweak

* Update types.ts

* fix
2026-07-21 11:26:53 +09:00

48 lines
1.4 KiB
TypeScript

/*
* SPDX-FileCopyrightText: syuilo and misskey-project
* SPDX-License-Identifier: AGPL-3.0-only
*/
import { EventEmitter } from 'node:events';
import { afterEach, expect, test, vi } from 'vitest';
import { stopServer, waitForServer } from '../../src/browser/server';
import type { ChildProcess } from 'node:child_process';
vi.mock('node:child_process', async () => {
const actual = await vi.importActual<typeof import('node:child_process')>('node:child_process');
return {
...actual,
spawnSync: vi.fn(),
};
});
function signaledChild() {
return Object.assign(new EventEmitter(), {
exitCode: null,
signalCode: 'SIGTERM' as NodeJS.Signals,
pid: undefined,
kill: vi.fn(),
}) as unknown as ChildProcess;
}
afterEach(() => {
vi.unstubAllGlobals();
});
test('waitForServer fails immediately when the server exited by signal', async () => {
const fetchMock = vi.fn().mockResolvedValue({ status: 200 });
vi.stubGlobal('fetch', fetchMock);
await expect(waitForServer('http://127.0.0.1:61812', signaledChild()))
.rejects.toThrow('Misskey server exited early with signal SIGTERM');
expect(fetchMock).not.toHaveBeenCalled();
});
test('stopServer returns immediately when the server already exited by signal', async () => {
const child = signaledChild();
const stopPromise = stopServer(child);
expect(child.listenerCount('exit')).toBe(0);
await stopPromise;
});