@stratal/testing 0.0.15 → 0.0.17
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/README.md +12 -0
- package/dist/index-D-Q2cR2v.d.mts +118 -0
- package/dist/index-D-Q2cR2v.d.mts.map +1 -0
- package/dist/index.d.mts +5 -127
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +20 -221
- package/dist/index.mjs.map +1 -1
- package/dist/storage/index.d.mts +2 -0
- package/dist/storage/index.mjs +2 -0
- package/dist/storage-PcJUKxwp.mjs +206 -0
- package/dist/storage-PcJUKxwp.mjs.map +1 -0
- package/package.json +12 -6
package/README.md
CHANGED
|
@@ -19,6 +19,18 @@ yarn add -D @stratal/testing
|
|
|
19
19
|
npm install -D stratal vitest
|
|
20
20
|
```
|
|
21
21
|
|
|
22
|
+
### AI Agent Skills
|
|
23
|
+
|
|
24
|
+
Stratal provides [Agent Skills](https://agentskills.io) for AI coding assistants like Claude Code and Cursor. Install to give your AI agent knowledge of Stratal patterns, conventions, and APIs:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
npx skills add strataljs/stratal
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
| Skill | Description |
|
|
31
|
+
|---|---|
|
|
32
|
+
| `stratal` | Build Cloudflare Workers apps with the Stratal framework — modules, DI, controllers, routing, OpenAPI, queues, cron, events, seeders, CLI, auth, database, RBAC, testing, and more |
|
|
33
|
+
|
|
22
34
|
## Quick Start
|
|
23
35
|
|
|
24
36
|
Set up base modules once in your Vitest setup file, then create test modules in each test:
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { DownloadResult, PresignedUrlResult, StorageConfig, StorageManagerService, StorageService, StreamingBlobPayloadInputTypes, UploadOptions, UploadResult } from "stratal/storage";
|
|
2
|
+
|
|
3
|
+
//#region src/storage/fake-storage.service.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Stored file representation in memory
|
|
6
|
+
*/
|
|
7
|
+
interface StoredFile {
|
|
8
|
+
content: Uint8Array;
|
|
9
|
+
mimeType: string;
|
|
10
|
+
size: number;
|
|
11
|
+
metadata?: Record<string, string>;
|
|
12
|
+
uploadedAt: Date;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* FakeStorageService
|
|
16
|
+
*
|
|
17
|
+
* In-memory storage implementation for testing.
|
|
18
|
+
* Registered by default in TestingModuleBuilder.
|
|
19
|
+
*
|
|
20
|
+
* Similar to Laravel's Storage::fake() - stores files in memory
|
|
21
|
+
* and provides assertion helpers for testing.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* // Access via TestingModule
|
|
26
|
+
* module.storage.assertExists('path/to/file.pdf')
|
|
27
|
+
* module.storage.assertMissing('deleted/file.pdf')
|
|
28
|
+
* module.storage.clear() // Reset between tests
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
declare class FakeStorageService extends StorageService {
|
|
32
|
+
protected readonly storageManager: StorageManagerService;
|
|
33
|
+
protected readonly options: StorageConfig;
|
|
34
|
+
private files;
|
|
35
|
+
constructor(storageManager: StorageManagerService, options: StorageConfig);
|
|
36
|
+
/**
|
|
37
|
+
* Upload content to fake storage
|
|
38
|
+
*/
|
|
39
|
+
upload(body: StreamingBlobPayloadInputTypes, relativePath: string, options: UploadOptions, disk?: string): Promise<UploadResult>;
|
|
40
|
+
/**
|
|
41
|
+
* Download a file from fake storage
|
|
42
|
+
*/
|
|
43
|
+
download(path: string): Promise<DownloadResult>;
|
|
44
|
+
/**
|
|
45
|
+
* Delete a file from fake storage
|
|
46
|
+
*/
|
|
47
|
+
delete(path: string): Promise<void>;
|
|
48
|
+
/**
|
|
49
|
+
* Check if a file exists in fake storage
|
|
50
|
+
*/
|
|
51
|
+
exists(path: string): Promise<boolean>;
|
|
52
|
+
/**
|
|
53
|
+
* Generate a fake presigned download URL
|
|
54
|
+
*/
|
|
55
|
+
getPresignedDownloadUrl(path: string, expiresIn?: number): Promise<PresignedUrlResult>;
|
|
56
|
+
/**
|
|
57
|
+
* Generate a fake presigned upload URL
|
|
58
|
+
*/
|
|
59
|
+
getPresignedUploadUrl(path: string, expiresIn?: number): Promise<PresignedUrlResult>;
|
|
60
|
+
/**
|
|
61
|
+
* Generate a fake presigned delete URL
|
|
62
|
+
*/
|
|
63
|
+
getPresignedDeleteUrl(path: string, expiresIn?: number): Promise<PresignedUrlResult>;
|
|
64
|
+
/**
|
|
65
|
+
* Chunked upload (same as regular upload for fake)
|
|
66
|
+
*/
|
|
67
|
+
chunkedUpload(body: StreamingBlobPayloadInputTypes, path: string, options: Omit<UploadOptions, 'size'> & {
|
|
68
|
+
size?: number;
|
|
69
|
+
}, disk?: string): Promise<UploadResult>;
|
|
70
|
+
/**
|
|
71
|
+
* Assert that a file exists at the given path
|
|
72
|
+
*
|
|
73
|
+
* @param path - Path to check
|
|
74
|
+
* @throws AssertionError if file does not exist
|
|
75
|
+
*/
|
|
76
|
+
assertExists(path: string): void;
|
|
77
|
+
/**
|
|
78
|
+
* Assert that a file does NOT exist at the given path
|
|
79
|
+
*
|
|
80
|
+
* @param path - Path to check
|
|
81
|
+
* @throws AssertionError if file exists
|
|
82
|
+
*/
|
|
83
|
+
assertMissing(path: string): void;
|
|
84
|
+
/**
|
|
85
|
+
* Assert storage is empty
|
|
86
|
+
*
|
|
87
|
+
* @throws AssertionError if any files exist
|
|
88
|
+
*/
|
|
89
|
+
assertEmpty(): void;
|
|
90
|
+
/**
|
|
91
|
+
* Assert storage has exactly N files
|
|
92
|
+
*
|
|
93
|
+
* @param count - Expected number of files
|
|
94
|
+
* @throws AssertionError if count doesn't match
|
|
95
|
+
*/
|
|
96
|
+
assertCount(count: number): void;
|
|
97
|
+
/**
|
|
98
|
+
* Get all stored files (for inspection)
|
|
99
|
+
*/
|
|
100
|
+
getStoredFiles(): Map<string, StoredFile>;
|
|
101
|
+
/**
|
|
102
|
+
* Get all stored file paths
|
|
103
|
+
*/
|
|
104
|
+
getStoredPaths(): string[];
|
|
105
|
+
/**
|
|
106
|
+
* Get a specific file by path
|
|
107
|
+
*/
|
|
108
|
+
getFile(path: string): StoredFile | undefined;
|
|
109
|
+
/**
|
|
110
|
+
* Clear all stored files (call in beforeEach for test isolation)
|
|
111
|
+
*/
|
|
112
|
+
clear(): void;
|
|
113
|
+
private createPresignedUrl;
|
|
114
|
+
private bodyToUint8Array;
|
|
115
|
+
}
|
|
116
|
+
//#endregion
|
|
117
|
+
export { StoredFile as n, FakeStorageService as t };
|
|
118
|
+
//# sourceMappingURL=index-D-Q2cR2v.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-D-Q2cR2v.d.mts","names":[],"sources":["../src/storage/fake-storage.service.ts"],"mappings":";;;;;AAkBA;UAAiB,UAAA;EACf,OAAA,EAAS,UAAA;EACT,QAAA;EACA,IAAA;EACA,QAAA,GAAW,MAAA;EACX,UAAA,EAAY,IAAA;AAAA;;;;;;;;;;;AAoBd;;;;;;;cACa,kBAAA,SAA2B,cAAA;EAAA,mBAKjB,cAAA,EAAgB,qBAAA;EAAA,mBAEhB,OAAA,EAAS,aAAA;EAAA,QANtB,KAAA;cAIa,cAAA,EAAgB,qBAAA,EAEhB,OAAA,EAAS,aAAA;EAsCN;;;EA9BlB,MAAA,CACJ,IAAA,EAAM,8BAAA,EACN,YAAA,UACA,OAAA,EAAS,aAAA,EACT,IAAA,YACC,OAAA,CAAQ,YAAA;EAoER;;;EA3CH,QAAA,CAAS,IAAA,WAAe,OAAA,CAAQ,cAAA;EA+D7B;;;EAtCH,MAAA,CAAO,IAAA,WAAe,OAAA;EAkDX;;;EA1CX,MAAA,CAAO,IAAA,WAAe,OAAA;EAyHC;;;EAlHvB,uBAAA,CACE,IAAA,UACA,SAAA,YACC,OAAA,CAAQ,kBAAA;EAxF2B;;;EA+FtC,qBAAA,CACE,IAAA,UACA,SAAA,YACC,OAAA,CAAQ,kBAAA;EA3FmB;;;EAkG9B,qBAAA,CACE,IAAA,UACA,SAAA,YACC,OAAA,CAAQ,kBAAA;EAvGU;;;EA8Gf,aAAA,CACJ,IAAA,EAAM,8BAAA,EACN,IAAA,UACA,OAAA,EAAS,IAAA,CAAK,aAAA;IAA2B,IAAA;EAAA,GACzC,IAAA,YACC,OAAA,CAAQ,YAAA;EAvGT;;;;;;EAwHF,YAAA,CAAa,IAAA;EA5FJ;;;;;;EAyGT,aAAA,CAAc,IAAA;EAxEP;;;;;EAoFP,WAAA,CAAA;EA1EW;;;;;;EAuFX,WAAA,CAAY,KAAA;EArEV;;;EA+EF,cAAA,CAAA,GAAkB,GAAA,SAAY,UAAA;EAtExB;;;EA6EN,cAAA,CAAA;EA1EW;;;EAiFX,OAAA,CAAQ,IAAA,WAAe,UAAA;EAhFrB;;;EAuFF,KAAA,CAAA;EAAA,QAQQ,kBAAA;EAAA,QAeM,gBAAA;AAAA"}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { t as FakeStorageService } from "./index-D-Q2cR2v.mjs";
|
|
2
|
+
import { Application, ApplicationConfig, Constructor, StratalEnv, StratalExecutionContext } from "stratal";
|
|
2
3
|
import { DynamicModule, InjectionToken, ModuleClass, ModuleOptions } from "stratal/module";
|
|
3
|
-
import { DownloadResult, PresignedUrlResult, StorageConfig, StorageManagerService, StorageService, StreamingBlobPayloadInputTypes, UploadOptions, UploadResult } from "stratal/storage";
|
|
4
4
|
import { Container } from "stratal/di";
|
|
5
5
|
import { ConnectionName, DatabaseService } from "@stratal/framework/database";
|
|
6
6
|
import { Seeder } from "stratal/seeder";
|
|
@@ -8,120 +8,6 @@ import { AuthService } from "@stratal/framework/auth";
|
|
|
8
8
|
import { HttpResponse, RequestHandler, http } from "msw";
|
|
9
9
|
import { CommandInput, CommandResult } from "stratal/quarry";
|
|
10
10
|
|
|
11
|
-
//#region src/storage/fake-storage.service.d.ts
|
|
12
|
-
/**
|
|
13
|
-
* Stored file representation in memory
|
|
14
|
-
*/
|
|
15
|
-
interface StoredFile {
|
|
16
|
-
content: Uint8Array;
|
|
17
|
-
mimeType: string;
|
|
18
|
-
size: number;
|
|
19
|
-
metadata?: Record<string, string>;
|
|
20
|
-
uploadedAt: Date;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* FakeStorageService
|
|
24
|
-
*
|
|
25
|
-
* In-memory storage implementation for testing.
|
|
26
|
-
* Registered by default in TestingModuleBuilder.
|
|
27
|
-
*
|
|
28
|
-
* Similar to Laravel's Storage::fake() - stores files in memory
|
|
29
|
-
* and provides assertion helpers for testing.
|
|
30
|
-
*
|
|
31
|
-
* @example
|
|
32
|
-
* ```typescript
|
|
33
|
-
* // Access via TestingModule
|
|
34
|
-
* module.storage.assertExists('path/to/file.pdf')
|
|
35
|
-
* module.storage.assertMissing('deleted/file.pdf')
|
|
36
|
-
* module.storage.clear() // Reset between tests
|
|
37
|
-
* ```
|
|
38
|
-
*/
|
|
39
|
-
declare class FakeStorageService extends StorageService {
|
|
40
|
-
protected readonly storageManager: StorageManagerService;
|
|
41
|
-
protected readonly options: StorageConfig;
|
|
42
|
-
private files;
|
|
43
|
-
constructor(storageManager: StorageManagerService, options: StorageConfig);
|
|
44
|
-
/**
|
|
45
|
-
* Upload content to fake storage
|
|
46
|
-
*/
|
|
47
|
-
upload(body: StreamingBlobPayloadInputTypes, relativePath: string, options: UploadOptions, disk?: string): Promise<UploadResult>;
|
|
48
|
-
/**
|
|
49
|
-
* Download a file from fake storage
|
|
50
|
-
*/
|
|
51
|
-
download(path: string): Promise<DownloadResult>;
|
|
52
|
-
/**
|
|
53
|
-
* Delete a file from fake storage
|
|
54
|
-
*/
|
|
55
|
-
delete(path: string): Promise<void>;
|
|
56
|
-
/**
|
|
57
|
-
* Check if a file exists in fake storage
|
|
58
|
-
*/
|
|
59
|
-
exists(path: string): Promise<boolean>;
|
|
60
|
-
/**
|
|
61
|
-
* Generate a fake presigned download URL
|
|
62
|
-
*/
|
|
63
|
-
getPresignedDownloadUrl(path: string, expiresIn?: number): Promise<PresignedUrlResult>;
|
|
64
|
-
/**
|
|
65
|
-
* Generate a fake presigned upload URL
|
|
66
|
-
*/
|
|
67
|
-
getPresignedUploadUrl(path: string, expiresIn?: number): Promise<PresignedUrlResult>;
|
|
68
|
-
/**
|
|
69
|
-
* Generate a fake presigned delete URL
|
|
70
|
-
*/
|
|
71
|
-
getPresignedDeleteUrl(path: string, expiresIn?: number): Promise<PresignedUrlResult>;
|
|
72
|
-
/**
|
|
73
|
-
* Chunked upload (same as regular upload for fake)
|
|
74
|
-
*/
|
|
75
|
-
chunkedUpload(body: StreamingBlobPayloadInputTypes, path: string, options: Omit<UploadOptions, 'size'> & {
|
|
76
|
-
size?: number;
|
|
77
|
-
}, disk?: string): Promise<UploadResult>;
|
|
78
|
-
/**
|
|
79
|
-
* Assert that a file exists at the given path
|
|
80
|
-
*
|
|
81
|
-
* @param path - Path to check
|
|
82
|
-
* @throws AssertionError if file does not exist
|
|
83
|
-
*/
|
|
84
|
-
assertExists(path: string): void;
|
|
85
|
-
/**
|
|
86
|
-
* Assert that a file does NOT exist at the given path
|
|
87
|
-
*
|
|
88
|
-
* @param path - Path to check
|
|
89
|
-
* @throws AssertionError if file exists
|
|
90
|
-
*/
|
|
91
|
-
assertMissing(path: string): void;
|
|
92
|
-
/**
|
|
93
|
-
* Assert storage is empty
|
|
94
|
-
*
|
|
95
|
-
* @throws AssertionError if any files exist
|
|
96
|
-
*/
|
|
97
|
-
assertEmpty(): void;
|
|
98
|
-
/**
|
|
99
|
-
* Assert storage has exactly N files
|
|
100
|
-
*
|
|
101
|
-
* @param count - Expected number of files
|
|
102
|
-
* @throws AssertionError if count doesn't match
|
|
103
|
-
*/
|
|
104
|
-
assertCount(count: number): void;
|
|
105
|
-
/**
|
|
106
|
-
* Get all stored files (for inspection)
|
|
107
|
-
*/
|
|
108
|
-
getStoredFiles(): Map<string, StoredFile>;
|
|
109
|
-
/**
|
|
110
|
-
* Get all stored file paths
|
|
111
|
-
*/
|
|
112
|
-
getStoredPaths(): string[];
|
|
113
|
-
/**
|
|
114
|
-
* Get a specific file by path
|
|
115
|
-
*/
|
|
116
|
-
getFile(path: string): StoredFile | undefined;
|
|
117
|
-
/**
|
|
118
|
-
* Clear all stored files (call in beforeEach for test isolation)
|
|
119
|
-
*/
|
|
120
|
-
clear(): void;
|
|
121
|
-
private createPresignedUrl;
|
|
122
|
-
private bodyToUint8Array;
|
|
123
|
-
}
|
|
124
|
-
//#endregion
|
|
125
11
|
//#region src/core/http/test-response.d.ts
|
|
126
12
|
/**
|
|
127
13
|
* TestResponse
|
|
@@ -692,7 +578,7 @@ declare class TestingModule {
|
|
|
692
578
|
private readonly ctx;
|
|
693
579
|
private _http;
|
|
694
580
|
private readonly _requestContainer;
|
|
695
|
-
constructor(app: Application, env: StratalEnv, ctx:
|
|
581
|
+
constructor(app: Application, env: StratalEnv, ctx: StratalExecutionContext);
|
|
696
582
|
/**
|
|
697
583
|
* Resolve a service from the container
|
|
698
584
|
*/
|
|
@@ -806,6 +692,7 @@ declare class TestingModuleBuilder {
|
|
|
806
692
|
* Merge additional environment bindings
|
|
807
693
|
*/
|
|
808
694
|
withEnv(env: Partial<StratalEnv>): this;
|
|
695
|
+
private getCloudflareWorkers;
|
|
809
696
|
/**
|
|
810
697
|
* Compile the testing module
|
|
811
698
|
*
|
|
@@ -1098,15 +985,6 @@ declare class ActingAs {
|
|
|
1098
985
|
}): Promise<Headers>;
|
|
1099
986
|
}
|
|
1100
987
|
//#endregion
|
|
1101
|
-
//#region src/core/env/test-env.d.ts
|
|
1102
|
-
/**
|
|
1103
|
-
* Get test environment with optional overrides
|
|
1104
|
-
*
|
|
1105
|
-
* @param overrides - Optional partial env to merge with cloudflare:test env
|
|
1106
|
-
* @returns Complete Env object for testing
|
|
1107
|
-
*/
|
|
1108
|
-
declare function getTestEnv(overrides?: Partial<StratalEnv>): StratalEnv;
|
|
1109
|
-
//#endregion
|
|
1110
988
|
//#region src/errors/test-error.d.ts
|
|
1111
989
|
/**
|
|
1112
990
|
* Base error class for all test framework errors.
|
|
@@ -1126,5 +1004,5 @@ declare class TestSetupError extends TestError {
|
|
|
1126
1004
|
constructor(message: string, cause?: Error);
|
|
1127
1005
|
}
|
|
1128
1006
|
//#endregion
|
|
1129
|
-
export { ActingAs,
|
|
1007
|
+
export { ActingAs, HttpResponse, type MockErrorOptions, MockFetch, type MockJsonOptions, ProviderOverrideBuilder, type ProviderOverrideConfig, Test, TestCommandRequest, TestCommandResult, TestError, TestHttpClient, TestHttpRequest, TestResponse, TestSetupError, TestSseConnection, type TestSseEvent, TestSseRequest, TestWsConnection, TestWsRequest, TestingModule, TestingModuleBuilder, type TestingModuleConfig, createMockFetch, http };
|
|
1130
1008
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/core/http/test-response.ts","../src/core/http/test-http-request.ts","../src/core/http/test-http-client.ts","../src/core/quarry/test-command-result.ts","../src/core/quarry/test-command-request.ts","../src/core/sse/test-sse-connection.ts","../src/core/sse/test-sse-request.ts","../src/core/ws/test-ws-connection.ts","../src/core/ws/test-ws-request.ts","../src/core/testing-module.ts","../src/core/testing-module-builder.ts","../src/core/override/provider-override-builder.ts","../src/core/test.ts","../src/core/http/fetch-mock.types.ts","../src/core/http/mock-fetch.ts","../src/auth/acting-as.ts","../src/errors/test-error.ts","../src/errors/setup-error.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAeA;;cAAa,YAAA;EAAA,iBAIkB,QAAA;EAAA,QAHrB,QAAA;EAAA,QACA,QAAA;cAEqB,QAAA,EAAU,QAAA;EA0BZ;;;EAAA,IArBvB,GAAA,CAAA,GAAO,QAAA;EAuJ4C;;;EAAA,IAhJnD,MAAA,CAAA;EAuND;;;EAAA,IAhN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,CAAqB,IAAA;IAAQ,EAAA;EAAA,IAAe,OAAA,CAAQ,OAAA;AAAA;;;;;;;cCnC/C,SAAA,SAAkB,KAAA;EAAA,SAGX,KAAA,GAAQ,KAAA;cADxB,OAAA,UACgB,KAAA,GAAQ,KAAA;AAAA;;;;;;;cCDf,cAAA,SAAuB,SAAA;cACtB,OAAA,UAAiB,KAAA,GAAQ,KAAA;AAAA"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as __decorate, t as FakeStorageService } from "./storage-PcJUKxwp.mjs";
|
|
2
2
|
import { Application } from "stratal";
|
|
3
3
|
import { LogLevel } from "stratal/logger";
|
|
4
4
|
import { Module } from "stratal/module";
|
|
5
|
-
import {
|
|
6
|
-
import { DI_TOKENS
|
|
5
|
+
import { STORAGE_TOKENS } from "stratal/storage";
|
|
6
|
+
import { DI_TOKENS } from "stratal/di";
|
|
7
7
|
import { expect } from "vitest";
|
|
8
8
|
import { connectionSymbol } from "@stratal/framework/database";
|
|
9
9
|
import { SEEDER_TOKENS, SeederNotRegisteredError } from "stratal/seeder";
|
|
@@ -105,220 +105,6 @@ var ProviderOverrideBuilder = class {
|
|
|
105
105
|
}
|
|
106
106
|
};
|
|
107
107
|
//#endregion
|
|
108
|
-
//#region \0@oxc-project+runtime@0.115.0/helpers/decorateMetadata.js
|
|
109
|
-
function __decorateMetadata(k, v) {
|
|
110
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
111
|
-
}
|
|
112
|
-
//#endregion
|
|
113
|
-
//#region \0@oxc-project+runtime@0.115.0/helpers/decorateParam.js
|
|
114
|
-
function __decorateParam(paramIndex, decorator) {
|
|
115
|
-
return function(target, key) {
|
|
116
|
-
decorator(target, key, paramIndex);
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
//#endregion
|
|
120
|
-
//#region \0@oxc-project+runtime@0.115.0/helpers/decorate.js
|
|
121
|
-
function __decorate(decorators, target, key, desc) {
|
|
122
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
123
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
124
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
125
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
126
|
-
}
|
|
127
|
-
//#endregion
|
|
128
|
-
//#region src/storage/fake-storage.service.ts
|
|
129
|
-
var _ref;
|
|
130
|
-
let FakeStorageService = class FakeStorageService extends StorageService {
|
|
131
|
-
files = /* @__PURE__ */ new Map();
|
|
132
|
-
constructor(storageManager, options) {
|
|
133
|
-
super(storageManager, options);
|
|
134
|
-
this.storageManager = storageManager;
|
|
135
|
-
this.options = options;
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* Upload content to fake storage
|
|
139
|
-
*/
|
|
140
|
-
async upload(body, relativePath, options, disk) {
|
|
141
|
-
const content = await this.bodyToUint8Array(body);
|
|
142
|
-
const diskName = this.resolveDisk(disk);
|
|
143
|
-
this.files.set(relativePath, {
|
|
144
|
-
content,
|
|
145
|
-
mimeType: options.mimeType ?? "application/octet-stream",
|
|
146
|
-
size: options.size,
|
|
147
|
-
metadata: options.metadata,
|
|
148
|
-
uploadedAt: /* @__PURE__ */ new Date()
|
|
149
|
-
});
|
|
150
|
-
return {
|
|
151
|
-
path: relativePath,
|
|
152
|
-
disk: diskName,
|
|
153
|
-
fullPath: relativePath,
|
|
154
|
-
size: options.size,
|
|
155
|
-
mimeType: options.mimeType ?? "application/octet-stream",
|
|
156
|
-
uploadedAt: /* @__PURE__ */ new Date()
|
|
157
|
-
};
|
|
158
|
-
}
|
|
159
|
-
/**
|
|
160
|
-
* Download a file from fake storage
|
|
161
|
-
*/
|
|
162
|
-
download(path) {
|
|
163
|
-
const file = this.files.get(path);
|
|
164
|
-
if (!file) return Promise.reject(new FileNotFoundError(path));
|
|
165
|
-
return Promise.resolve({
|
|
166
|
-
toStream: () => new ReadableStream({ start(controller) {
|
|
167
|
-
controller.enqueue(file.content);
|
|
168
|
-
controller.close();
|
|
169
|
-
} }),
|
|
170
|
-
toString: () => Promise.resolve(new TextDecoder().decode(file.content)),
|
|
171
|
-
toArrayBuffer: () => Promise.resolve(file.content),
|
|
172
|
-
contentType: file.mimeType,
|
|
173
|
-
size: file.size,
|
|
174
|
-
metadata: file.metadata
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
|
-
/**
|
|
178
|
-
* Delete a file from fake storage
|
|
179
|
-
*/
|
|
180
|
-
delete(path) {
|
|
181
|
-
this.files.delete(path);
|
|
182
|
-
return Promise.resolve();
|
|
183
|
-
}
|
|
184
|
-
/**
|
|
185
|
-
* Check if a file exists in fake storage
|
|
186
|
-
*/
|
|
187
|
-
exists(path) {
|
|
188
|
-
return Promise.resolve(this.files.has(path));
|
|
189
|
-
}
|
|
190
|
-
/**
|
|
191
|
-
* Generate a fake presigned download URL
|
|
192
|
-
*/
|
|
193
|
-
getPresignedDownloadUrl(path, expiresIn) {
|
|
194
|
-
return Promise.resolve(this.createPresignedUrl(path, "GET", expiresIn));
|
|
195
|
-
}
|
|
196
|
-
/**
|
|
197
|
-
* Generate a fake presigned upload URL
|
|
198
|
-
*/
|
|
199
|
-
getPresignedUploadUrl(path, expiresIn) {
|
|
200
|
-
return Promise.resolve(this.createPresignedUrl(path, "PUT", expiresIn));
|
|
201
|
-
}
|
|
202
|
-
/**
|
|
203
|
-
* Generate a fake presigned delete URL
|
|
204
|
-
*/
|
|
205
|
-
getPresignedDeleteUrl(path, expiresIn) {
|
|
206
|
-
return Promise.resolve(this.createPresignedUrl(path, "DELETE", expiresIn));
|
|
207
|
-
}
|
|
208
|
-
/**
|
|
209
|
-
* Chunked upload (same as regular upload for fake)
|
|
210
|
-
*/
|
|
211
|
-
async chunkedUpload(body, path, options, disk) {
|
|
212
|
-
const content = await this.bodyToUint8Array(body);
|
|
213
|
-
const size = options.size ?? content.length;
|
|
214
|
-
return this.upload(body, path, {
|
|
215
|
-
...options,
|
|
216
|
-
size
|
|
217
|
-
}, disk);
|
|
218
|
-
}
|
|
219
|
-
/**
|
|
220
|
-
* Assert that a file exists at the given path
|
|
221
|
-
*
|
|
222
|
-
* @param path - Path to check
|
|
223
|
-
* @throws AssertionError if file does not exist
|
|
224
|
-
*/
|
|
225
|
-
assertExists(path) {
|
|
226
|
-
expect(this.files.has(path), `Expected file to exist at: ${path}\nStored files: ${this.getStoredPaths().join(", ") || "(none)"}`).toBe(true);
|
|
227
|
-
}
|
|
228
|
-
/**
|
|
229
|
-
* Assert that a file does NOT exist at the given path
|
|
230
|
-
*
|
|
231
|
-
* @param path - Path to check
|
|
232
|
-
* @throws AssertionError if file exists
|
|
233
|
-
*/
|
|
234
|
-
assertMissing(path) {
|
|
235
|
-
expect(this.files.has(path), `Expected file NOT to exist at: ${path}`).toBe(false);
|
|
236
|
-
}
|
|
237
|
-
/**
|
|
238
|
-
* Assert storage is empty
|
|
239
|
-
*
|
|
240
|
-
* @throws AssertionError if any files exist
|
|
241
|
-
*/
|
|
242
|
-
assertEmpty() {
|
|
243
|
-
expect(this.files.size, `Expected storage to be empty but found ${this.files.size} files: ${this.getStoredPaths().join(", ")}`).toBe(0);
|
|
244
|
-
}
|
|
245
|
-
/**
|
|
246
|
-
* Assert storage has exactly N files
|
|
247
|
-
*
|
|
248
|
-
* @param count - Expected number of files
|
|
249
|
-
* @throws AssertionError if count doesn't match
|
|
250
|
-
*/
|
|
251
|
-
assertCount(count) {
|
|
252
|
-
expect(this.files.size, `Expected ${count} files in storage but found ${this.files.size}`).toBe(count);
|
|
253
|
-
}
|
|
254
|
-
/**
|
|
255
|
-
* Get all stored files (for inspection)
|
|
256
|
-
*/
|
|
257
|
-
getStoredFiles() {
|
|
258
|
-
return new Map(this.files);
|
|
259
|
-
}
|
|
260
|
-
/**
|
|
261
|
-
* Get all stored file paths
|
|
262
|
-
*/
|
|
263
|
-
getStoredPaths() {
|
|
264
|
-
return Array.from(this.files.keys());
|
|
265
|
-
}
|
|
266
|
-
/**
|
|
267
|
-
* Get a specific file by path
|
|
268
|
-
*/
|
|
269
|
-
getFile(path) {
|
|
270
|
-
return this.files.get(path);
|
|
271
|
-
}
|
|
272
|
-
/**
|
|
273
|
-
* Clear all stored files (call in beforeEach for test isolation)
|
|
274
|
-
*/
|
|
275
|
-
clear() {
|
|
276
|
-
this.files.clear();
|
|
277
|
-
}
|
|
278
|
-
createPresignedUrl(path, method, expiresIn = 300) {
|
|
279
|
-
const expiresAt = new Date(Date.now() + expiresIn * 1e3);
|
|
280
|
-
return {
|
|
281
|
-
url: `https://fake-storage.test/${path}?method=${method}&expires=${expiresAt.toISOString()}`,
|
|
282
|
-
expiresIn,
|
|
283
|
-
expiresAt,
|
|
284
|
-
method
|
|
285
|
-
};
|
|
286
|
-
}
|
|
287
|
-
async bodyToUint8Array(body) {
|
|
288
|
-
if (!body) return new Uint8Array(0);
|
|
289
|
-
if (body instanceof Uint8Array) return body;
|
|
290
|
-
if (body instanceof ArrayBuffer) return new Uint8Array(body);
|
|
291
|
-
if (typeof body === "string") return new TextEncoder().encode(body);
|
|
292
|
-
if (body instanceof Blob) {
|
|
293
|
-
const buffer = await body.arrayBuffer();
|
|
294
|
-
return new Uint8Array(buffer);
|
|
295
|
-
}
|
|
296
|
-
if (body instanceof ReadableStream) return new Uint8Array(await new Response(body).arrayBuffer());
|
|
297
|
-
if (body instanceof FormData || body instanceof URLSearchParams) return new Uint8Array(await new Response(body).arrayBuffer());
|
|
298
|
-
return new Uint8Array(0);
|
|
299
|
-
}
|
|
300
|
-
};
|
|
301
|
-
FakeStorageService = __decorate([
|
|
302
|
-
Transient(STORAGE_TOKENS.StorageService),
|
|
303
|
-
__decorateParam(0, inject(STORAGE_TOKENS.StorageManager)),
|
|
304
|
-
__decorateParam(1, inject(STORAGE_TOKENS.Options)),
|
|
305
|
-
__decorateMetadata("design:paramtypes", [typeof (_ref = typeof StorageManagerService !== "undefined" && StorageManagerService) === "function" ? _ref : Object, Object])
|
|
306
|
-
], FakeStorageService);
|
|
307
|
-
//#endregion
|
|
308
|
-
//#region src/core/env/test-env.ts
|
|
309
|
-
/**
|
|
310
|
-
* Get test environment with optional overrides
|
|
311
|
-
*
|
|
312
|
-
* @param overrides - Optional partial env to merge with cloudflare:test env
|
|
313
|
-
* @returns Complete Env object for testing
|
|
314
|
-
*/
|
|
315
|
-
function getTestEnv(overrides) {
|
|
316
|
-
return {
|
|
317
|
-
...env,
|
|
318
|
-
...overrides
|
|
319
|
-
};
|
|
320
|
-
}
|
|
321
|
-
//#endregion
|
|
322
108
|
//#region src/auth/acting-as.ts
|
|
323
109
|
async function makeSignature(value, secret) {
|
|
324
110
|
const algorithm = {
|
|
@@ -1541,14 +1327,27 @@ var TestingModuleBuilder = class {
|
|
|
1541
1327
|
};
|
|
1542
1328
|
return this;
|
|
1543
1329
|
}
|
|
1330
|
+
async getCloudflareWorkers() {
|
|
1331
|
+
try {
|
|
1332
|
+
return await import("cloudflare:workers");
|
|
1333
|
+
} catch {
|
|
1334
|
+
return null;
|
|
1335
|
+
}
|
|
1336
|
+
}
|
|
1544
1337
|
/**
|
|
1545
1338
|
* Compile the testing module
|
|
1546
1339
|
*
|
|
1547
1340
|
* Creates the Application, applies overrides, initializes, and returns TestingModule.
|
|
1548
1341
|
*/
|
|
1549
1342
|
async compile() {
|
|
1550
|
-
const
|
|
1551
|
-
const
|
|
1343
|
+
const cf = await this.getCloudflareWorkers();
|
|
1344
|
+
const env = {
|
|
1345
|
+
...cf?.env,
|
|
1346
|
+
...this.config.env
|
|
1347
|
+
};
|
|
1348
|
+
const ctx = { waitUntil: cf ? cf.waitUntil : (p) => {
|
|
1349
|
+
p.catch(() => {});
|
|
1350
|
+
} };
|
|
1552
1351
|
const allImports = [...Test.getBaseModules(), ...this.config.imports ?? []];
|
|
1553
1352
|
const app = new Application({
|
|
1554
1353
|
module: this.createTestRootModule({
|
|
@@ -1566,6 +1365,7 @@ var TestingModuleBuilder = class {
|
|
|
1566
1365
|
ctx
|
|
1567
1366
|
});
|
|
1568
1367
|
app.container.registerSingleton(STORAGE_TOKENS.StorageService, FakeStorageService);
|
|
1368
|
+
await app.initialize();
|
|
1569
1369
|
for (const override of this.overrides) switch (override.type) {
|
|
1570
1370
|
case "value":
|
|
1571
1371
|
app.container.registerValue(override.token, override.implementation);
|
|
@@ -1580,7 +1380,6 @@ var TestingModuleBuilder = class {
|
|
|
1580
1380
|
app.container.registerExisting(override.token, override.implementation);
|
|
1581
1381
|
break;
|
|
1582
1382
|
}
|
|
1583
|
-
await app.initialize();
|
|
1584
1383
|
return new TestingModule(app, env, ctx);
|
|
1585
1384
|
}
|
|
1586
1385
|
/**
|
|
@@ -1783,6 +1582,6 @@ var TestSetupError = class extends TestError {
|
|
|
1783
1582
|
}
|
|
1784
1583
|
};
|
|
1785
1584
|
//#endregion
|
|
1786
|
-
export { ActingAs,
|
|
1585
|
+
export { ActingAs, HttpResponse, MockFetch, ProviderOverrideBuilder, Test, TestCommandRequest, TestCommandResult, TestError, TestHttpClient, TestHttpRequest, TestResponse, TestSetupError, TestSseConnection, TestSseRequest, TestWsConnection, TestWsRequest, TestingModule, TestingModuleBuilder, createMockFetch, http };
|
|
1787
1586
|
|
|
1788
1587
|
//# sourceMappingURL=index.mjs.map
|