@webpresso/agent-config 0.1.4 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +36 -12
- package/dist/esm/stryker/index.d.ts +0 -135
- package/dist/esm/stryker/index.js +0 -128
- package/dist/esm/tsconfig/base.json +0 -37
- package/dist/esm/tsconfig/cloudflare.json +0 -10
- package/dist/esm/tsconfig/library.json +0 -16
- package/dist/esm/tsconfig/react-library.json +0 -10
- package/dist/esm/tsconfig/react-router.json +0 -10
- package/dist/esm/vitest/bun-sqlite-shim.d.ts +0 -14
- package/dist/esm/vitest/bun-sqlite-shim.js +0 -14
- package/dist/esm/vitest/consumer-package.d.ts +0 -4
- package/dist/esm/vitest/consumer-package.js +0 -63
- package/dist/esm/vitest/flakiness-reporter.d.ts +0 -7
- package/dist/esm/vitest/flakiness-reporter.js +0 -53
- package/dist/esm/vitest/generated-runtime-aliases.d.ts +0 -6
- package/dist/esm/vitest/generated-runtime-aliases.js +0 -3
- package/dist/esm/vitest/node-setup.d.ts +0 -6
- package/dist/esm/vitest/node-setup.js +0 -16
- package/dist/esm/vitest/node.d.ts +0 -43
- package/dist/esm/vitest/node.js +0 -180
- package/dist/esm/vitest/pool-defaults.d.ts +0 -11
- package/dist/esm/vitest/pool-defaults.js +0 -43
- package/dist/esm/vitest/react-router.d.ts +0 -22
- package/dist/esm/vitest/react-router.js +0 -83
- package/dist/esm/vitest/react-setup.d.ts +0 -13
- package/dist/esm/vitest/react-setup.js +0 -27
- package/dist/esm/vitest/react.d.ts +0 -22
- package/dist/esm/vitest/react.js +0 -85
- package/dist/esm/vitest/version-guard.d.ts +0 -7
- package/dist/esm/vitest/version-guard.js +0 -42
- package/dist/esm/vitest/workers.d.ts +0 -28
- package/dist/esm/vitest/workers.js +0 -44
- package/dist/esm/workers-test/cloudflare-types.d.ts +0 -30
- package/dist/esm/workers-test/cloudflare-types.js +0 -2
- package/dist/esm/workers-test/durable-objects.d.ts +0 -60
- package/dist/esm/workers-test/durable-objects.js +0 -73
- package/dist/esm/workers-test/env.d.ts +0 -58
- package/dist/esm/workers-test/env.js +0 -74
- package/dist/esm/workers-test/execution-context.d.ts +0 -21
- package/dist/esm/workers-test/execution-context.js +0 -22
- package/dist/esm/workers-test/index.d.ts +0 -16
- package/dist/esm/workers-test/index.js +0 -15
- package/dist/esm/workers-test/requests.d.ts +0 -44
- package/dist/esm/workers-test/requests.js +0 -71
- package/dist/esm/workers-test/setup.d.ts +0 -63
- package/dist/esm/workers-test/setup.js +0 -86
- package/tsconfig/base.json +0 -37
- package/tsconfig/cloudflare.json +0 -10
- package/tsconfig/library.json +0 -16
- package/tsconfig/react-library.json +0 -10
- package/tsconfig/react-router.json +0 -10
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { vi } from 'vitest';
|
|
2
|
-
/**
|
|
3
|
-
* Mock DurableObject class for unit tests.
|
|
4
|
-
* Use this when you need to mock a DurableObject class in your test setup.
|
|
5
|
-
*
|
|
6
|
-
* @example
|
|
7
|
-
* ```typescript
|
|
8
|
-
* vi.mock('cloudflare:workers', () => ({
|
|
9
|
-
* DurableObject: MockDurableObject,
|
|
10
|
-
* }))
|
|
11
|
-
* ```
|
|
12
|
-
*/
|
|
13
|
-
export declare class MockDurableObject {
|
|
14
|
-
state: unknown;
|
|
15
|
-
env: unknown;
|
|
16
|
-
constructor(state: unknown, env: unknown);
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Mock Container class for unit tests.
|
|
20
|
-
* Use this when you need to mock a Cloudflare Container in your test setup.
|
|
21
|
-
*
|
|
22
|
-
* @example
|
|
23
|
-
* ```typescript
|
|
24
|
-
* vi.mock('@cloudflare/containers', () => ({
|
|
25
|
-
* Container: MockContainer,
|
|
26
|
-
* }))
|
|
27
|
-
* ```
|
|
28
|
-
*/
|
|
29
|
-
export declare class MockContainer {
|
|
30
|
-
defaultPort: number;
|
|
31
|
-
sleepAfter: string;
|
|
32
|
-
envVars: Record<string, string>;
|
|
33
|
-
enableInternet: boolean;
|
|
34
|
-
fetch: ReturnType<typeof vi.fn>;
|
|
35
|
-
destroy: ReturnType<typeof vi.fn>;
|
|
36
|
-
startAndWaitForPorts: ReturnType<typeof vi.fn>;
|
|
37
|
-
getState: ReturnType<typeof vi.fn>;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Creates mock Cloudflare Workers runtime modules.
|
|
41
|
-
* Includes DurableObject and Container classes that are only available in workerd.
|
|
42
|
-
*
|
|
43
|
-
* Use this in vitest module mocks:
|
|
44
|
-
*
|
|
45
|
-
* @example
|
|
46
|
-
* ```typescript
|
|
47
|
-
* const mocks = createCloudflareRuntimeMocks()
|
|
48
|
-
* vi.mock('cloudflare:workers', () => mocks['cloudflare:workers'])
|
|
49
|
-
* vi.mock('@cloudflare/containers', () => mocks['@cloudflare/containers'])
|
|
50
|
-
* ```
|
|
51
|
-
*/
|
|
52
|
-
export declare function createCloudflareRuntimeMocks(): {
|
|
53
|
-
'cloudflare:workers': {
|
|
54
|
-
DurableObject: typeof MockDurableObject;
|
|
55
|
-
};
|
|
56
|
-
'@cloudflare/containers': {
|
|
57
|
-
Container: typeof MockContainer;
|
|
58
|
-
};
|
|
59
|
-
};
|
|
60
|
-
//# sourceMappingURL=durable-objects.d.ts.map
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { vi } from 'vitest';
|
|
2
|
-
// ============================================================================
|
|
3
|
-
// Mock Classes
|
|
4
|
-
// ============================================================================
|
|
5
|
-
/**
|
|
6
|
-
* Mock DurableObject class for unit tests.
|
|
7
|
-
* Use this when you need to mock a DurableObject class in your test setup.
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* ```typescript
|
|
11
|
-
* vi.mock('cloudflare:workers', () => ({
|
|
12
|
-
* DurableObject: MockDurableObject,
|
|
13
|
-
* }))
|
|
14
|
-
* ```
|
|
15
|
-
*/
|
|
16
|
-
export class MockDurableObject {
|
|
17
|
-
state;
|
|
18
|
-
env;
|
|
19
|
-
constructor(state, env) {
|
|
20
|
-
this.state = state;
|
|
21
|
-
this.env = env;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Mock Container class for unit tests.
|
|
26
|
-
* Use this when you need to mock a Cloudflare Container in your test setup.
|
|
27
|
-
*
|
|
28
|
-
* @example
|
|
29
|
-
* ```typescript
|
|
30
|
-
* vi.mock('@cloudflare/containers', () => ({
|
|
31
|
-
* Container: MockContainer,
|
|
32
|
-
* }))
|
|
33
|
-
* ```
|
|
34
|
-
*/
|
|
35
|
-
export class MockContainer {
|
|
36
|
-
defaultPort = 8080;
|
|
37
|
-
sleepAfter = '1m';
|
|
38
|
-
envVars = {};
|
|
39
|
-
enableInternet = false;
|
|
40
|
-
fetch = vi.fn();
|
|
41
|
-
destroy = vi.fn();
|
|
42
|
-
startAndWaitForPorts = vi.fn();
|
|
43
|
-
getState = vi
|
|
44
|
-
.fn()
|
|
45
|
-
.mockResolvedValue({ status: 'running' });
|
|
46
|
-
}
|
|
47
|
-
// ============================================================================
|
|
48
|
-
// Mock Factories
|
|
49
|
-
// ============================================================================
|
|
50
|
-
/**
|
|
51
|
-
* Creates mock Cloudflare Workers runtime modules.
|
|
52
|
-
* Includes DurableObject and Container classes that are only available in workerd.
|
|
53
|
-
*
|
|
54
|
-
* Use this in vitest module mocks:
|
|
55
|
-
*
|
|
56
|
-
* @example
|
|
57
|
-
* ```typescript
|
|
58
|
-
* const mocks = createCloudflareRuntimeMocks()
|
|
59
|
-
* vi.mock('cloudflare:workers', () => mocks['cloudflare:workers'])
|
|
60
|
-
* vi.mock('@cloudflare/containers', () => mocks['@cloudflare/containers'])
|
|
61
|
-
* ```
|
|
62
|
-
*/
|
|
63
|
-
export function createCloudflareRuntimeMocks() {
|
|
64
|
-
return {
|
|
65
|
-
'cloudflare:workers': {
|
|
66
|
-
DurableObject: MockDurableObject,
|
|
67
|
-
},
|
|
68
|
-
'@cloudflare/containers': {
|
|
69
|
-
Container: MockContainer,
|
|
70
|
-
},
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
//# sourceMappingURL=durable-objects.js.map
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import type { DurableObjectNamespace, Hyperdrive } from './cloudflare-types.js';
|
|
2
|
-
/**
|
|
3
|
-
* Minimal common-denominator environment interface for Cloudflare Workers tests.
|
|
4
|
-
*
|
|
5
|
-
* Extend this in your project to add your own bindings:
|
|
6
|
-
* ```typescript
|
|
7
|
-
* interface MyWorkerEnv extends BaseWorkerEnv {
|
|
8
|
-
* MY_KV: KVNamespace
|
|
9
|
-
* MY_API_KEY: string
|
|
10
|
-
* }
|
|
11
|
-
* ```
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* // Webpresso example:
|
|
15
|
-
* interface WebpressoWorkerEnv extends BaseWorkerEnv {
|
|
16
|
-
* GOOGLE_CLIENT_ID: string
|
|
17
|
-
* GOOGLE_CLIENT_SECRET: string
|
|
18
|
-
* BETTER_AUTH_SECRET: string
|
|
19
|
-
* ENCRYPTION_KEY: string
|
|
20
|
-
* GRAPHQL_ADMIN_SECRET: string
|
|
21
|
-
* CF_ACCESS_TEAM_DOMAIN: string
|
|
22
|
-
* CF_ACCESS_AUD: string
|
|
23
|
-
* CHEF_URL: string
|
|
24
|
-
* ADMIN_WEB_URL?: string
|
|
25
|
-
* GRAPHQL_CONTAINERS: DurableObjectNamespace
|
|
26
|
-
* ENABLE_QUERY_TIMING?: string
|
|
27
|
-
* }
|
|
28
|
-
*/
|
|
29
|
-
export interface BaseWorkerEnv {
|
|
30
|
-
ENVIRONMENT: string;
|
|
31
|
-
DATABASE_URL?: string;
|
|
32
|
-
HYPERDRIVE?: Hyperdrive;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Creates a mock DurableObjectNamespace for testing.
|
|
36
|
-
*/
|
|
37
|
-
export declare function createMockDurableObjectNamespace(): DurableObjectNamespace;
|
|
38
|
-
/**
|
|
39
|
-
* Creates a mock Hyperdrive binding for testing.
|
|
40
|
-
*
|
|
41
|
-
* @param overrides - Optional partial overrides for Hyperdrive fields
|
|
42
|
-
* @returns A mock Hyperdrive instance
|
|
43
|
-
*/
|
|
44
|
-
export declare function createMockHyperdrive(overrides?: Partial<Hyperdrive>): Hyperdrive;
|
|
45
|
-
/**
|
|
46
|
-
* Creates a mock environment with sensible defaults.
|
|
47
|
-
* Override specific values by passing them in the overrides parameter.
|
|
48
|
-
*
|
|
49
|
-
* @param overrides - Partial environment to merge with defaults
|
|
50
|
-
* @returns Complete environment object for worker tests
|
|
51
|
-
*
|
|
52
|
-
* @example
|
|
53
|
-
* ```typescript
|
|
54
|
-
* const env = createMockEnv<MyWorkerEnv>({ MY_API_KEY: 'test-key' })
|
|
55
|
-
* ```
|
|
56
|
-
*/
|
|
57
|
-
export declare function createMockEnv<T extends BaseWorkerEnv>(overrides?: Partial<T>): T;
|
|
58
|
-
//# sourceMappingURL=env.d.ts.map
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { vi } from 'vitest';
|
|
2
|
-
// ============================================================================
|
|
3
|
-
// Mock Factories
|
|
4
|
-
// ============================================================================
|
|
5
|
-
/**
|
|
6
|
-
* Creates a mock DurableObjectNamespace for testing.
|
|
7
|
-
*/
|
|
8
|
-
export function createMockDurableObjectNamespace() {
|
|
9
|
-
return {
|
|
10
|
-
newUniqueId: vi.fn(() => ({
|
|
11
|
-
toString: () => 'test-do-id',
|
|
12
|
-
equals: () => false,
|
|
13
|
-
name: undefined,
|
|
14
|
-
})),
|
|
15
|
-
idFromName: vi.fn((name) => ({
|
|
16
|
-
toString: () => `do-${name}`,
|
|
17
|
-
equals: () => false,
|
|
18
|
-
name,
|
|
19
|
-
})),
|
|
20
|
-
idFromString: vi.fn((id) => ({
|
|
21
|
-
toString: () => id,
|
|
22
|
-
equals: () => false,
|
|
23
|
-
name: undefined,
|
|
24
|
-
})),
|
|
25
|
-
get: vi.fn(async () => ({
|
|
26
|
-
fetch: vi.fn(async () => new Response(JSON.stringify({ data: {} }))),
|
|
27
|
-
})),
|
|
28
|
-
getByName: vi.fn(async () => ({
|
|
29
|
-
fetch: vi.fn(async () => new Response(JSON.stringify({ data: {} }))),
|
|
30
|
-
})),
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Creates a mock Hyperdrive binding for testing.
|
|
35
|
-
*
|
|
36
|
-
* @param overrides - Optional partial overrides for Hyperdrive fields
|
|
37
|
-
* @returns A mock Hyperdrive instance
|
|
38
|
-
*/
|
|
39
|
-
export function createMockHyperdrive(overrides) {
|
|
40
|
-
return {
|
|
41
|
-
connectionString: 'postgresql://localhost/test',
|
|
42
|
-
connect: vi.fn(() => ({})),
|
|
43
|
-
host: 'localhost',
|
|
44
|
-
port: 5432,
|
|
45
|
-
user: 'test',
|
|
46
|
-
password: 'test',
|
|
47
|
-
database: 'test',
|
|
48
|
-
...overrides,
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Creates a mock environment with sensible defaults.
|
|
53
|
-
* Override specific values by passing them in the overrides parameter.
|
|
54
|
-
*
|
|
55
|
-
* @param overrides - Partial environment to merge with defaults
|
|
56
|
-
* @returns Complete environment object for worker tests
|
|
57
|
-
*
|
|
58
|
-
* @example
|
|
59
|
-
* ```typescript
|
|
60
|
-
* const env = createMockEnv<MyWorkerEnv>({ MY_API_KEY: 'test-key' })
|
|
61
|
-
* ```
|
|
62
|
-
*/
|
|
63
|
-
export function createMockEnv(overrides = {}) {
|
|
64
|
-
const defaultEnv = {
|
|
65
|
-
ENVIRONMENT: 'test',
|
|
66
|
-
DATABASE_URL: 'postgresql://localhost/test',
|
|
67
|
-
HYPERDRIVE: createMockHyperdrive(),
|
|
68
|
-
};
|
|
69
|
-
return {
|
|
70
|
-
...defaultEnv,
|
|
71
|
-
...overrides,
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
//# sourceMappingURL=env.js.map
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { ExecutionContext } from './cloudflare-types.js';
|
|
2
|
-
import { vi } from 'vitest';
|
|
3
|
-
/**
|
|
4
|
-
* ExecutionContext mock for worker tests
|
|
5
|
-
*/
|
|
6
|
-
export type MockExecutionContext = ExecutionContext<unknown> & {
|
|
7
|
-
waitUntil: ReturnType<typeof vi.fn>;
|
|
8
|
-
passThroughOnException: ReturnType<typeof vi.fn>;
|
|
9
|
-
};
|
|
10
|
-
/**
|
|
11
|
-
* Creates a mock ExecutionContext for worker tests.
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* ```typescript
|
|
15
|
-
* const ctx = createMockExecutionContext()
|
|
16
|
-
* const response = await app.fetch(request, env, ctx)
|
|
17
|
-
* expect(ctx.waitUntil).not.toHaveBeenCalled()
|
|
18
|
-
* ```
|
|
19
|
-
*/
|
|
20
|
-
export declare function createMockExecutionContext(): MockExecutionContext;
|
|
21
|
-
//# sourceMappingURL=execution-context.d.ts.map
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { vi } from 'vitest';
|
|
2
|
-
// ============================================================================
|
|
3
|
-
// Mock Factories
|
|
4
|
-
// ============================================================================
|
|
5
|
-
/**
|
|
6
|
-
* Creates a mock ExecutionContext for worker tests.
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* ```typescript
|
|
10
|
-
* const ctx = createMockExecutionContext()
|
|
11
|
-
* const response = await app.fetch(request, env, ctx)
|
|
12
|
-
* expect(ctx.waitUntil).not.toHaveBeenCalled()
|
|
13
|
-
* ```
|
|
14
|
-
*/
|
|
15
|
-
export function createMockExecutionContext() {
|
|
16
|
-
return {
|
|
17
|
-
waitUntil: vi.fn(),
|
|
18
|
-
passThroughOnException: vi.fn(),
|
|
19
|
-
props: {},
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
//# sourceMappingURL=execution-context.js.map
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @webpresso/agent-config/workers-test
|
|
3
|
-
*
|
|
4
|
-
* Production-ready Cloudflare Workers test mocks.
|
|
5
|
-
* Drop in BaseWorkerEnv, ExecutionContext, Hyperdrive, and Durable Object mocks
|
|
6
|
-
* for any Cloudflare Workers project without recreating them per-app.
|
|
7
|
-
*/
|
|
8
|
-
export type { BaseWorkerEnv } from './env.js';
|
|
9
|
-
export { createMockEnv, createMockHyperdrive, createMockDurableObjectNamespace } from './env.js';
|
|
10
|
-
export type { MockExecutionContext } from './execution-context.js';
|
|
11
|
-
export { createMockExecutionContext } from './execution-context.js';
|
|
12
|
-
export { MockDurableObject, MockContainer, createCloudflareRuntimeMocks, } from './durable-objects.js';
|
|
13
|
-
export { createAuthenticatedRequest, createUnauthenticatedRequest, createCorsRequest, } from './requests.js';
|
|
14
|
-
export type { WorkerTestOptions } from './setup.js';
|
|
15
|
-
export { setupWorkerTest, suppressConsole } from './setup.js';
|
|
16
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @webpresso/agent-config/workers-test
|
|
3
|
-
*
|
|
4
|
-
* Production-ready Cloudflare Workers test mocks.
|
|
5
|
-
* Drop in BaseWorkerEnv, ExecutionContext, Hyperdrive, and Durable Object mocks
|
|
6
|
-
* for any Cloudflare Workers project without recreating them per-app.
|
|
7
|
-
*/
|
|
8
|
-
export { createMockEnv, createMockHyperdrive, createMockDurableObjectNamespace } from './env.js';
|
|
9
|
-
export { createMockExecutionContext } from './execution-context.js';
|
|
10
|
-
// Durable Objects and Containers
|
|
11
|
-
export { MockDurableObject, MockContainer, createCloudflareRuntimeMocks, } from './durable-objects.js';
|
|
12
|
-
// Request helpers
|
|
13
|
-
export { createAuthenticatedRequest, createUnauthenticatedRequest, createCorsRequest, } from './requests.js';
|
|
14
|
-
export { setupWorkerTest, suppressConsole } from './setup.js';
|
|
15
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Creates an authenticated request with session cookie.
|
|
3
|
-
*
|
|
4
|
-
* @param path - Request path (e.g., '/graphql')
|
|
5
|
-
* @param options - Additional request options (method, headers, body)
|
|
6
|
-
* @param baseUrl - Base URL for the request (default: https://api.test)
|
|
7
|
-
* @returns Request object with authentication headers
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* ```typescript
|
|
11
|
-
* const request = createAuthenticatedRequest('/api/users', { method: 'POST', body: JSON.stringify(data) })
|
|
12
|
-
* ```
|
|
13
|
-
*/
|
|
14
|
-
export declare function createAuthenticatedRequest(path: string, options?: RequestInit, baseUrl?: string): Request;
|
|
15
|
-
/**
|
|
16
|
-
* Creates an unauthenticated request (no session cookie).
|
|
17
|
-
*
|
|
18
|
-
* @param path - Request path (e.g., '/health')
|
|
19
|
-
* @param options - Additional request options
|
|
20
|
-
* @param baseUrl - Base URL for the request (default: https://api.test)
|
|
21
|
-
* @returns Request object without authentication
|
|
22
|
-
*
|
|
23
|
-
* @example
|
|
24
|
-
* ```typescript
|
|
25
|
-
* const request = createUnauthenticatedRequest('/health')
|
|
26
|
-
* ```
|
|
27
|
-
*/
|
|
28
|
-
export declare function createUnauthenticatedRequest(path: string, options?: RequestInit, baseUrl?: string): Request;
|
|
29
|
-
/**
|
|
30
|
-
* Creates a request with custom origin for CORS testing.
|
|
31
|
-
*
|
|
32
|
-
* @param path - Request path
|
|
33
|
-
* @param origin - Origin header value
|
|
34
|
-
* @param options - Additional request options
|
|
35
|
-
* @param baseUrl - Base URL for the request (default: https://api.test)
|
|
36
|
-
* @returns Request object with Origin header
|
|
37
|
-
*
|
|
38
|
-
* @example
|
|
39
|
-
* ```typescript
|
|
40
|
-
* const request = createCorsRequest('/api/data', 'https://example.com')
|
|
41
|
-
* ```
|
|
42
|
-
*/
|
|
43
|
-
export declare function createCorsRequest(path: string, origin: string, options?: RequestInit, baseUrl?: string): Request;
|
|
44
|
-
//# sourceMappingURL=requests.d.ts.map
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
// ============================================================================
|
|
2
|
-
// Request Helpers
|
|
3
|
-
// ============================================================================
|
|
4
|
-
/**
|
|
5
|
-
* Creates an authenticated request with session cookie.
|
|
6
|
-
*
|
|
7
|
-
* @param path - Request path (e.g., '/graphql')
|
|
8
|
-
* @param options - Additional request options (method, headers, body)
|
|
9
|
-
* @param baseUrl - Base URL for the request (default: https://api.test)
|
|
10
|
-
* @returns Request object with authentication headers
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* ```typescript
|
|
14
|
-
* const request = createAuthenticatedRequest('/api/users', { method: 'POST', body: JSON.stringify(data) })
|
|
15
|
-
* ```
|
|
16
|
-
*/
|
|
17
|
-
export function createAuthenticatedRequest(path, options = {}, baseUrl = 'https://api.test') {
|
|
18
|
-
const { headers: optionHeaders, ...restOptions } = options;
|
|
19
|
-
return new Request(`${baseUrl}${path}`, {
|
|
20
|
-
...restOptions,
|
|
21
|
-
headers: {
|
|
22
|
-
Cookie: 'session=mock-session-token',
|
|
23
|
-
...optionHeaders,
|
|
24
|
-
},
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Creates an unauthenticated request (no session cookie).
|
|
29
|
-
*
|
|
30
|
-
* @param path - Request path (e.g., '/health')
|
|
31
|
-
* @param options - Additional request options
|
|
32
|
-
* @param baseUrl - Base URL for the request (default: https://api.test)
|
|
33
|
-
* @returns Request object without authentication
|
|
34
|
-
*
|
|
35
|
-
* @example
|
|
36
|
-
* ```typescript
|
|
37
|
-
* const request = createUnauthenticatedRequest('/health')
|
|
38
|
-
* ```
|
|
39
|
-
*/
|
|
40
|
-
export function createUnauthenticatedRequest(path, options = {}, baseUrl = 'https://api.test') {
|
|
41
|
-
return new Request(`${baseUrl}${path}`, {
|
|
42
|
-
headers: {
|
|
43
|
-
...options.headers,
|
|
44
|
-
},
|
|
45
|
-
...options,
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Creates a request with custom origin for CORS testing.
|
|
50
|
-
*
|
|
51
|
-
* @param path - Request path
|
|
52
|
-
* @param origin - Origin header value
|
|
53
|
-
* @param options - Additional request options
|
|
54
|
-
* @param baseUrl - Base URL for the request (default: https://api.test)
|
|
55
|
-
* @returns Request object with Origin header
|
|
56
|
-
*
|
|
57
|
-
* @example
|
|
58
|
-
* ```typescript
|
|
59
|
-
* const request = createCorsRequest('/api/data', 'https://example.com')
|
|
60
|
-
* ```
|
|
61
|
-
*/
|
|
62
|
-
export function createCorsRequest(path, origin, options = {}, baseUrl = 'https://api.test') {
|
|
63
|
-
return new Request(`${baseUrl}${path}`, {
|
|
64
|
-
headers: {
|
|
65
|
-
Origin: origin,
|
|
66
|
-
...options.headers,
|
|
67
|
-
},
|
|
68
|
-
...options,
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
//# sourceMappingURL=requests.js.map
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import type { BaseWorkerEnv } from './env.js';
|
|
2
|
-
import type { MockExecutionContext } from './execution-context.js';
|
|
3
|
-
import { createMockExecutionContext } from './execution-context.js';
|
|
4
|
-
import { createCloudflareRuntimeMocks } from './durable-objects.js';
|
|
5
|
-
import { createAuthenticatedRequest, createUnauthenticatedRequest, createCorsRequest } from './requests.js';
|
|
6
|
-
/**
|
|
7
|
-
* Options for configuring the worker test environment
|
|
8
|
-
*/
|
|
9
|
-
export interface WorkerTestOptions {
|
|
10
|
-
/** Enable Cloudflare Workers runtime mocking (DurableObject, Container) (default: true) */
|
|
11
|
-
mockCloudflareRuntime?: boolean;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Sets up common worker test environment with mocks.
|
|
15
|
-
* Call this in beforeEach() or at the top of your test file with vi.mock().
|
|
16
|
-
*
|
|
17
|
-
* @param envOverrides - Partial environment overrides
|
|
18
|
-
* @param options - Configuration for which mocks to enable
|
|
19
|
-
* @returns Object with mock instances for use in tests
|
|
20
|
-
*
|
|
21
|
-
* @example
|
|
22
|
-
* ```typescript
|
|
23
|
-
* const { mockEnv, mockCtx } = setupWorkerTest()
|
|
24
|
-
*
|
|
25
|
-
* beforeEach(() => {
|
|
26
|
-
* vi.clearAllMocks()
|
|
27
|
-
* })
|
|
28
|
-
*
|
|
29
|
-
* it('should handle request', async () => {
|
|
30
|
-
* const request = createAuthenticatedRequest('/api/test')
|
|
31
|
-
* const response = await app.fetch(request, mockEnv, mockCtx)
|
|
32
|
-
* expect(response.status).toBe(200)
|
|
33
|
-
* })
|
|
34
|
-
* ```
|
|
35
|
-
*/
|
|
36
|
-
export declare function setupWorkerTest<T extends BaseWorkerEnv>(envOverrides?: Partial<T>, options?: WorkerTestOptions): {
|
|
37
|
-
mocks: {
|
|
38
|
-
cloudflareRuntime: ReturnType<typeof createCloudflareRuntimeMocks> | null;
|
|
39
|
-
};
|
|
40
|
-
mockEnv: T;
|
|
41
|
-
mockCtx: MockExecutionContext;
|
|
42
|
-
createAuthenticatedRequest: typeof createAuthenticatedRequest;
|
|
43
|
-
createUnauthenticatedRequest: typeof createUnauthenticatedRequest;
|
|
44
|
-
createCorsRequest: typeof createCorsRequest;
|
|
45
|
-
createMockExecutionContext: typeof createMockExecutionContext;
|
|
46
|
-
clearAllMocks: () => void;
|
|
47
|
-
};
|
|
48
|
-
/**
|
|
49
|
-
* Suppress console output during tests.
|
|
50
|
-
* Call restore() in afterEach to restore console methods.
|
|
51
|
-
*
|
|
52
|
-
* @returns Object with restore function to restore console methods
|
|
53
|
-
*
|
|
54
|
-
* @example
|
|
55
|
-
* ```typescript
|
|
56
|
-
* const consoleControl = suppressConsole()
|
|
57
|
-
* afterEach(() => consoleControl.restore())
|
|
58
|
-
* ```
|
|
59
|
-
*/
|
|
60
|
-
export declare function suppressConsole(): {
|
|
61
|
-
restore: () => void;
|
|
62
|
-
};
|
|
63
|
-
//# sourceMappingURL=setup.d.ts.map
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import { vi } from 'vitest';
|
|
2
|
-
import { createMockEnv } from './env.js';
|
|
3
|
-
import { createMockExecutionContext } from './execution-context.js';
|
|
4
|
-
import { createCloudflareRuntimeMocks } from './durable-objects.js';
|
|
5
|
-
import { createAuthenticatedRequest, createUnauthenticatedRequest, createCorsRequest, } from './requests.js';
|
|
6
|
-
// ============================================================================
|
|
7
|
-
// Test Setup Function
|
|
8
|
-
// ============================================================================
|
|
9
|
-
/**
|
|
10
|
-
* Sets up common worker test environment with mocks.
|
|
11
|
-
* Call this in beforeEach() or at the top of your test file with vi.mock().
|
|
12
|
-
*
|
|
13
|
-
* @param envOverrides - Partial environment overrides
|
|
14
|
-
* @param options - Configuration for which mocks to enable
|
|
15
|
-
* @returns Object with mock instances for use in tests
|
|
16
|
-
*
|
|
17
|
-
* @example
|
|
18
|
-
* ```typescript
|
|
19
|
-
* const { mockEnv, mockCtx } = setupWorkerTest()
|
|
20
|
-
*
|
|
21
|
-
* beforeEach(() => {
|
|
22
|
-
* vi.clearAllMocks()
|
|
23
|
-
* })
|
|
24
|
-
*
|
|
25
|
-
* it('should handle request', async () => {
|
|
26
|
-
* const request = createAuthenticatedRequest('/api/test')
|
|
27
|
-
* const response = await app.fetch(request, mockEnv, mockCtx)
|
|
28
|
-
* expect(response.status).toBe(200)
|
|
29
|
-
* })
|
|
30
|
-
* ```
|
|
31
|
-
*/
|
|
32
|
-
export function setupWorkerTest(envOverrides = {}, options = {}) {
|
|
33
|
-
const { mockCloudflareRuntime = true } = options;
|
|
34
|
-
const mocks = {
|
|
35
|
-
cloudflareRuntime: mockCloudflareRuntime ? createCloudflareRuntimeMocks() : null,
|
|
36
|
-
};
|
|
37
|
-
const mockEnv = createMockEnv(envOverrides);
|
|
38
|
-
const mockCtx = createMockExecutionContext();
|
|
39
|
-
return {
|
|
40
|
-
mocks,
|
|
41
|
-
mockEnv,
|
|
42
|
-
mockCtx,
|
|
43
|
-
createAuthenticatedRequest,
|
|
44
|
-
createUnauthenticatedRequest,
|
|
45
|
-
createCorsRequest,
|
|
46
|
-
createMockExecutionContext,
|
|
47
|
-
clearAllMocks: () => vi.clearAllMocks(),
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
// ============================================================================
|
|
51
|
-
// Console Mocking Helpers
|
|
52
|
-
// ============================================================================
|
|
53
|
-
/**
|
|
54
|
-
* Suppress console output during tests.
|
|
55
|
-
* Call restore() in afterEach to restore console methods.
|
|
56
|
-
*
|
|
57
|
-
* @returns Object with restore function to restore console methods
|
|
58
|
-
*
|
|
59
|
-
* @example
|
|
60
|
-
* ```typescript
|
|
61
|
-
* const consoleControl = suppressConsole()
|
|
62
|
-
* afterEach(() => consoleControl.restore())
|
|
63
|
-
* ```
|
|
64
|
-
*/
|
|
65
|
-
export function suppressConsole() {
|
|
66
|
-
const originalLog = console.log;
|
|
67
|
-
const originalError = console.error;
|
|
68
|
-
const originalWarn = console.warn;
|
|
69
|
-
vi.spyOn(console, 'log').mockImplementation(() => {
|
|
70
|
-
// Intentionally empty - suppressing console output
|
|
71
|
-
});
|
|
72
|
-
vi.spyOn(console, 'error').mockImplementation(() => {
|
|
73
|
-
// Intentionally empty - suppressing console output
|
|
74
|
-
});
|
|
75
|
-
vi.spyOn(console, 'warn').mockImplementation(() => {
|
|
76
|
-
// Intentionally empty - suppressing console output
|
|
77
|
-
});
|
|
78
|
-
return {
|
|
79
|
-
restore: () => {
|
|
80
|
-
console.log = originalLog;
|
|
81
|
-
console.error = originalError;
|
|
82
|
-
console.warn = originalWarn;
|
|
83
|
-
},
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
//# sourceMappingURL=setup.js.map
|
package/tsconfig/base.json
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://json.schemastore.org/tsconfig",
|
|
3
|
-
"display": "Base",
|
|
4
|
-
"compilerOptions": {
|
|
5
|
-
"target": "ES2024",
|
|
6
|
-
"lib": [
|
|
7
|
-
"ES2024"
|
|
8
|
-
],
|
|
9
|
-
"module": "ESNext",
|
|
10
|
-
"moduleResolution": "Bundler",
|
|
11
|
-
"resolveJsonModule": true,
|
|
12
|
-
"allowImportingTsExtensions": true,
|
|
13
|
-
"declaration": true,
|
|
14
|
-
"declarationMap": true,
|
|
15
|
-
"sourceMap": true,
|
|
16
|
-
"strict": true,
|
|
17
|
-
"noImplicitAny": true,
|
|
18
|
-
"noUncheckedIndexedAccess": true,
|
|
19
|
-
"noEmit": true,
|
|
20
|
-
"esModuleInterop": true,
|
|
21
|
-
"skipLibCheck": true,
|
|
22
|
-
"forceConsistentCasingInFileNames": true,
|
|
23
|
-
"allowSyntheticDefaultImports": true,
|
|
24
|
-
"isolatedModules": true,
|
|
25
|
-
"verbatimModuleSyntax": true,
|
|
26
|
-
"types": [
|
|
27
|
-
"node"
|
|
28
|
-
]
|
|
29
|
-
},
|
|
30
|
-
"exclude": [
|
|
31
|
-
"node_modules",
|
|
32
|
-
"dist",
|
|
33
|
-
"build",
|
|
34
|
-
".next",
|
|
35
|
-
".react-router"
|
|
36
|
-
]
|
|
37
|
-
}
|
package/tsconfig/cloudflare.json
DELETED
package/tsconfig/library.json
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://json.schemastore.org/tsconfig",
|
|
3
|
-
"display": "Library",
|
|
4
|
-
"extends": "@webpresso/agent-config/tsconfig/base.json",
|
|
5
|
-
"compilerOptions": {
|
|
6
|
-
"declaration": true,
|
|
7
|
-
"declarationMap": true,
|
|
8
|
-
"outDir": "./dist",
|
|
9
|
-
"rootDir": "./src",
|
|
10
|
-
"paths": {
|
|
11
|
-
"#*": ["./src/*"]
|
|
12
|
-
}
|
|
13
|
-
},
|
|
14
|
-
"include": ["src/**/*.ts", "src/**/*.tsx"],
|
|
15
|
-
"exclude": ["src/**/*.test.ts", "src/**/*.test.tsx"]
|
|
16
|
-
}
|