Scope live chat to the current match and save match history
This commit is contained in:
@@ -7,6 +7,7 @@ vi.mock('../../src/lib/server/maintenance/index.js', () => ({ runMaintenance: vi
|
||||
vi.mock('../../src/lib/server/game-files/index.js', () => ({ cleanupControllerLibraries: vi.fn(async () => {}) }));
|
||||
vi.mock('../../src/lib/server/provisioning/worker.js', () => ({ processProvisioning: vi.fn(async () => {}) }));
|
||||
vi.mock('../../src/lib/server/retention.js', () => ({ pruneHistory: vi.fn(), pruneSampleHistory: vi.fn() }));
|
||||
vi.mock('../../src/lib/server/fleet/chat.js', () => ({ collectFleetChat: vi.fn(async () => {}) }));
|
||||
|
||||
function deferred() {
|
||||
let resolve!: () => void;
|
||||
@@ -32,6 +33,29 @@ async function setup() {
|
||||
}
|
||||
|
||||
describe('independent provisioning scheduling', () => {
|
||||
it('collects match chat on worker ticks without overlapping a slow collection', async () => {
|
||||
const s = await setup();
|
||||
const { collectFleetChat } = await import('../../src/lib/server/fleet/chat.js');
|
||||
const collection = deferred();
|
||||
vi.mocked(collectFleetChat).mockImplementationOnce(() => collection.promise);
|
||||
vi.useFakeTimers();
|
||||
try {
|
||||
s.startWorker();
|
||||
expect(collectFleetChat).toHaveBeenCalledTimes(1);
|
||||
await vi.advanceTimersByTimeAsync(30_000);
|
||||
expect(collectFleetChat).toHaveBeenCalledTimes(1);
|
||||
collection.resolve();
|
||||
await vi.advanceTimersByTimeAsync(0);
|
||||
await vi.advanceTimersByTimeAsync(15_000);
|
||||
expect(collectFleetChat).toHaveBeenCalledTimes(2);
|
||||
} finally {
|
||||
s.stopWorker(); collection.resolve(); s.background.resolve();
|
||||
await vi.advanceTimersByTimeAsync(0);
|
||||
vi.useRealTimers();
|
||||
await vi.waitFor(() => expect(s.workerActivity()).toEqual([]));
|
||||
}
|
||||
});
|
||||
|
||||
it('runs retention at most every five minutes across ticks and explicit kicks', async () => {
|
||||
const s = await setup();
|
||||
const { pruneHistory, pruneSampleHistory } = await import('../../src/lib/server/retention.js');
|
||||
|
||||
Reference in New Issue
Block a user