Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import {
createOperatorToken,
createTestDeployment,
setupEnv,
skipOrphanSweepDelay,
teardownEnv,
type TestEnv,
} from './helpers.ts';
Expand Down Expand Up @@ -615,6 +616,7 @@ describe('managed shared subdomain recipients', () => {
});

it('keeps a reusable slug reserved through the real teardown route after an uncertain recipient create', async () => {
skipOrphanSweepDelay();
const { project, user, provider } = await setup({
failOn: { literalRuleCreate: { status: 503, message: 'unknown outcome' } },
failBeforeEffect: ['literalRuleCreate'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import {
mockCfApi,
readAllEvents,
setupEnv,
skipOrphanSweepDelay,
teardownEnv,
type TestEnv,
type MockCfApiHandle,
Expand Down Expand Up @@ -434,6 +435,7 @@ describe('managed native Durable Objects', () => {
});

it('cleans up project-owned namespaces through the project deletion workflow', async () => {
skipOrphanSweepDelay();
await deploy();
const worker = await durableObjectWorkerName(project.id, binding.className);
const response = await app.fetch(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import {
createTestUser,
mockCfApi,
setupEnv,
skipOrphanSweepDelay,
teardownEnv,
type TestEnv,
} from './helpers.ts';
Expand Down Expand Up @@ -153,6 +154,7 @@ async function settleOperation(platform: ApiEnv['Bindings']): Promise<void> {

describe('platform uninstall check against the API database', () => {
it('lets uninstall proceed once a project deletion that stopped partway is rerun', async () => {
skipOrphanSweepDelay();
const owner = await createTestUser(env.db, 'stopped-deletion-owner');
const project = await createTestProject(env.db, owner.id, 'stopped-deletion');
await env.ROUTING.put(project.slug, JSON.stringify({ projectId: project.id }));
Expand Down
10 changes: 10 additions & 0 deletions platform/packages/api/test/unit/check-run.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@ function reasonsOf(spy: ReturnType<typeof vi.spyOn>, phase: string): Array<unkno
.map((o) => o.reason);
}

/** Keep every retry attempt but run its backoff timer at once. */
function skipRetryDelay(): void {
const schedule = globalThis.setTimeout;
vi.spyOn(globalThis, 'setTimeout').mockImplementation((callback, delay, ...args) =>
schedule(callback, delay === 250 ? 0 : delay, ...args),
);
}

describe('createCheckRun', () => {
let warnSpy: ReturnType<typeof vi.spyOn>;
// Unique installation id per test — getInstallationToken caches the
Expand All @@ -89,6 +97,7 @@ describe('createCheckRun', () => {

beforeEach(() => {
warnSpy = vi.spyOn(console, 'warn').mockImplementation(() => {});
skipRetryDelay();
});

afterEach(() => {
Expand Down Expand Up @@ -268,6 +277,7 @@ describe('completeCheckRun', () => {

beforeEach(() => {
warnSpy = vi.spyOn(console, 'warn').mockImplementation(() => {});
skipRetryDelay();
});

afterEach(() => {
Expand Down
9 changes: 9 additions & 0 deletions platform/packages/api/test/unit/installation-token.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,14 @@ function assertSchema(spy: ReturnType<typeof vi.spyOn>, installationId: string):
}
}

/** Keep every retry attempt but run its backoff timer at once. */
function skipRetryDelay(): void {
const schedule = globalThis.setTimeout;
vi.spyOn(globalThis, 'setTimeout').mockImplementation((callback, delay, ...args) =>
schedule(callback, delay === 250 ? 0 : delay, ...args),
);
}

describe('getBranchHeadComparisonStatus structured logging', () => {
let warnSpy: ReturnType<typeof vi.spyOn>;
// Unique installation id per test — getInstallationToken caches the
Expand All @@ -101,6 +109,7 @@ describe('getBranchHeadComparisonStatus structured logging', () => {

beforeEach(() => {
warnSpy = vi.spyOn(console, 'warn').mockImplementation(() => {});
skipRetryDelay();
});

afterEach(() => {
Expand Down
18 changes: 17 additions & 1 deletion platform/packages/api/test/unit/webhook-deliveries.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { exportPKCS8, generateKeyPair } from 'jose';
import { afterEach, beforeAll, describe, expect, it, vi } from 'vite-plus/test';
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from 'vite-plus/test';
import type { ApiEnv } from '../../src/env.ts';
import { GITHUB_API_VERSION } from '../../src/github/installation-token.ts';
import {
Expand Down Expand Up @@ -63,7 +63,19 @@ function pageResponse(items: Array<Record<string, unknown>>, nextUrl?: string):
return new Response(JSON.stringify(items), { status: 200, headers });
}

/** Keep every retry attempt but run its backoff timer at once. */
function skipRetryDelay(): void {
const schedule = globalThis.setTimeout;
vi.spyOn(globalThis, 'setTimeout').mockImplementation((callback, delay, ...args) =>
schedule(callback, delay === 250 ? 0 : delay, ...args),
);
}

describe('listFailedWebhookDeliveries', () => {
beforeEach(() => {
skipRetryDelay();
});

afterEach(() => {
vi.restoreAllMocks();
vi.unstubAllGlobals();
Expand Down Expand Up @@ -246,6 +258,10 @@ describe('listFailedWebhookDeliveries', () => {
});

describe('redeliverWebhookDelivery', () => {
beforeEach(() => {
skipRetryDelay();
});

afterEach(() => {
vi.restoreAllMocks();
vi.unstubAllGlobals();
Expand Down
Loading