From 57f52996f08b9a3abe6c26d1f884b3df5aaa1f34 Mon Sep 17 00:00:00 2001 From: Bria Morgan Date: Tue, 14 Jan 2025 10:06:33 -0500 Subject: [PATCH] only notify for jobs in this workspace --- src/workspace-data/import-jobs.test.ts | 6 ++++-- src/workspace-data/import-jobs.ts | 5 ++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/workspace-data/import-jobs.test.ts b/src/workspace-data/import-jobs.test.ts index 9421a27da2..5b024a9c9b 100644 --- a/src/workspace-data/import-jobs.test.ts +++ b/src/workspace-data/import-jobs.test.ts @@ -79,14 +79,14 @@ describe('useImportJobs', () => { it('notifies if a failed job is in import store', async () => { // Arrange asyncImportJobStore.set([ - { targetWorkspace: { namespace: 'test-workspaces', name: 'google-workspace' }, jobId: 'job-1' }, + { targetWorkspace: { namespace: 'test-workspaces', name: 'google-workspace2' }, jobId: 'job-4' }, { targetWorkspace: { namespace: 'test-workspaces', name: 'google-workspace' }, jobId: 'job-2' }, ]); const listImportJobs: MockedFn = jest.fn(); listImportJobs.mockResolvedValue([{ jobId: 'job-1' }, { jobId: 'job-3' }]); const getImportJobStatus: MockedFn = jest.fn(); - getImportJobStatus.mockResolvedValue({ jobId: 'job-1', status: 'Error', message: 'This job failed.' }); + getImportJobStatus.mockResolvedValue({ jobId: 'job-2', status: 'Error', message: 'This job failed.' }); asMockedFn(Workspaces).mockReturnValue( partial({ @@ -100,6 +100,8 @@ describe('useImportJobs', () => { await act(() => hookReturnRef.current.refresh()); // Assert + expect(getImportJobStatus).toHaveBeenCalledWith('job-2'); + expect(getImportJobStatus).not.toHaveBeenCalledWith('job-4'); expect(notify).toHaveBeenCalledWith('error', 'Error importing data.', { message: 'This job failed.', }); diff --git a/src/workspace-data/import-jobs.ts b/src/workspace-data/import-jobs.ts index 9d808cacd6..14db85c2e2 100644 --- a/src/workspace-data/import-jobs.ts +++ b/src/workspace-data/import-jobs.ts @@ -38,7 +38,10 @@ export const useImportJobs = (workspace: WorkspaceWrapper): UseImportJobsResult // In cases where jobs failed before this query completes, users won't be notified of failure // But they are momentarily in the job store, so check for them and notify here const jobsToNotify = allRunningJobs.filter( - (job) => !runningJobsInWorkspace.some(({ jobId }) => job.jobId === jobId) + (job) => + job.targetWorkspace.namespace === namespace && + job.targetWorkspace.name === name && + !runningJobsInWorkspace.some(({ jobId }) => job.jobId === jobId) ); jobsToNotify.forEach((job) => {