Browse Source

test(core): Fix job queue e2e test

Michael Bromley 1 year ago
parent
commit
1ee91513c2

+ 1 - 1
packages/core/e2e/fixtures/test-plugins/with-job-queue.ts

@@ -41,7 +41,7 @@ class TestController implements OnModuleInit {
         return job
             .updates()
             .toPromise()
-            .then(update => update.result);
+            .then(update => update?.result);
     }
 }
 

+ 9 - 1
packages/core/e2e/job-queue.e2e-spec.ts

@@ -31,7 +31,13 @@ describe('JobQueue', () => {
 
     const { server, adminClient } = createTestEnvironment(
         mergeConfig(activeConfig, {
-            plugins: [DefaultJobQueuePlugin, PluginWithJobQueue],
+            plugins: [
+                DefaultJobQueuePlugin.init({
+                    pollInterval: 50,
+                    gracefulShutdownTimeout: 1_000,
+                }),
+                PluginWithJobQueue,
+            ],
         }),
     );
 
@@ -141,6 +147,8 @@ describe('JobQueue', () => {
         const jobs2 = await getJobsInTestQueue(JobState.CANCELLED);
         expect(jobs.items.length).toBe(1);
         expect(jobs.items[0].id).toBe(jobId);
+
+        PluginWithJobQueue.jobSubject.next();
     });
 
     it('subscribe to result of job', async () => {