test: root module spec supplies its own JWT secret
CI builds have no .env file; the handler discovery test compiled the API module without JWT_ACCESS_SECRET when no earlier suite in the same jest worker had set it. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
This commit is contained in:
1 parent
c2f71bcb03
commit
ffaefab834
1 file changed
+17
-4
@@ -100,11 +100,24 @@ describe('rootModuleFor', () => {
|
||||
// Only the worker dispatches events. A handler in a module the worker
|
||||
// does not import would be registered by the API and never run.
|
||||
it('the worker discovers exactly the domain event handlers of the API', async () => {
|
||||
const api = await discoveredHandlerIds(AppModule);
|
||||
const worker = await discoveredHandlerIds(WorkerModule);
|
||||
// Compiling the API constructs JwtStrategy, which needs a secret. CI
|
||||
// builds have no .env file, so the test supplies one itself instead of
|
||||
// relying on another suite of the same worker having set it.
|
||||
const previousSecret = process.env.JWT_ACCESS_SECRET;
|
||||
process.env.JWT_ACCESS_SECRET ||= 'root-module-spec-'.padEnd(40, 'x');
|
||||
try {
|
||||
const api = await discoveredHandlerIds(AppModule);
|
||||
const worker = await discoveredHandlerIds(WorkerModule);
|
||||
|
||||
expect(api).toContain('webhooks.forward');
|
||||
expect(worker).toEqual(api);
|
||||
expect(api).toContain('webhooks.forward');
|
||||
expect(worker).toEqual(api);
|
||||
} finally {
|
||||
if (previousSecret === undefined) {
|
||||
delete process.env.JWT_ACCESS_SECRET;
|
||||
} else {
|
||||
process.env.JWT_ACCESS_SECRET = previousSecret;
|
||||
}
|
||||
}
|
||||
}, 30_000);
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user