test: Fix flaky unit tests across three packages (no-changelog) (#28336)

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Declan Carroll
2026-04-13 11:58:24 +01:00
committed by GitHub
parent 06a666aaa0
commit 738d42cb54
3 changed files with 27 additions and 7 deletions

View File

@@ -215,22 +215,21 @@ describe('ExecutionPersistence', () => {
const target = { workflowId: 'wf-1', executionId: 'exec-1', storedAt: 'db' as const };
it('should soft-delete with backdated `deletedAt` when pruning is enabled', async () => {
jest.useFakeTimers();
const now = Date.now();
executionsConfig.pruneData = true;
executionsConfig.pruneDataHardDeleteBuffer = 1;
const executionPersistence = createPersistenceService('db');
await executionPersistence.deleteInFlightExecution(target);
const after = Date.now();
expect(executionRepository.update).toHaveBeenCalledWith('exec-1', {
deletedAt: expect.any(Date),
deletedAt: new Date(now - 3600_000),
});
const { deletedAt } = executionRepository.update.mock.calls[0][1] as { deletedAt: Date };
// deletedAt should be backdated by ~1 hour (the buffer)
// Use `after` to tolerate clock progression between before/after snapshots
expect(deletedAt.getTime()).toBeLessThanOrEqual(after - 3600_000);
expect(executionRepository.deleteByIds).not.toHaveBeenCalled();
jest.useRealTimers();
});
it('should hard-delete immediately when pruning is disabled', async () => {

View File

@@ -5,6 +5,15 @@ import { mock } from 'vitest-mock-extended';
import type { WorkerInitOptions } from '../types';
import { worker } from './typescript.worker';
vi.mock('@/app/plugins/cache', () => ({
indexedDbCache: async () => ({
getItem: () => '{}',
setItem: () => {},
removeItem: () => {},
clear: () => {},
getAllWithPrefix: async () => ({}),
}),
}));
vi.mock('@typescript/vfs');
vi.mock('typescript', async (importOriginal) => {
return await importOriginal();

View File

@@ -8,6 +8,18 @@ import { GoogleSheetsTrigger } from '../GoogleSheetsTrigger.node';
describe('GoogleSheetsTrigger', () => {
const baseUrl = 'https://sheets.googleapis.com';
beforeAll(() => {
nock.disableNetConnect();
});
afterAll(() => {
nock.enableNetConnect();
});
afterEach(() => {
nock.cleanAll();
});
describe('rowAdded event', () => {
it('should return rows without header', async () => {
const scope = nock(baseUrl);