Skip to content

Commit 6a7b4b4

Browse files
committed
addressed comments
Signed-off-by: rsun19 <robertssun1234@gmail.com>
1 parent 7d016fb commit 6a7b4b4

File tree

3 files changed

+23
-36
lines changed

3 files changed

+23
-36
lines changed

clients/ui/frontend/src/app/hooks/__tests__/useModelTransferJobs.spec.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { waitFor } from '@testing-library/react';
1+
import { act, waitFor } from '@testing-library/react';
22
import { useFetchState, POLL_INTERVAL } from 'mod-arch-core';
33
import useModelTransferJobs from '~/app/hooks/useModelTransferJobs';
44
import { useModelRegistryAPI } from '~/app/hooks/useModelRegistryAPI';
@@ -129,10 +129,9 @@ describe('useModelTransferJobs', () => {
129129
// toggle hasActiveJobs to true and cause a re-render with refreshRate = POLL_INTERVAL.
130130
const capturedCallback = getCapturedCallback();
131131
expect(capturedCallback).toBeDefined();
132-
await capturedCallback?.({});
133-
134-
// Wait for the hook to re-render after state update
135-
await renderResult.waitForNextUpdate();
132+
await act(async () => {
133+
await capturedCallback?.({});
134+
});
136135

137136
// The latest call to useFetchState should have refreshRate set to POLL_INTERVAL
138137
const lastCallOptions = optionsCalls[optionsCalls.length - 1];
@@ -184,7 +183,9 @@ describe('useModelTransferJobs', () => {
184183
// so refreshRate should remain undefined (no need to wait for another update).
185184
const capturedCallback = getCapturedCallback();
186185
expect(capturedCallback).toBeDefined();
187-
await capturedCallback?.({});
186+
await act(async () => {
187+
await capturedCallback?.({});
188+
});
188189

189190
const lastCallOptions = optionsCalls[optionsCalls.length - 1];
190191
expect(lastCallOptions.refreshRate).toBeUndefined();

clients/ui/frontend/src/app/pages/modelRegistry/screens/ModelTransferJobs/__tests__/getStatusLabel.spec.ts

Lines changed: 15 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,19 @@ import { ModelTransferJobStatus } from '~/app/types';
22
import { getStatusLabel } from '~/app/pages/modelRegistry/screens/ModelTransferJobs/ModelTransferJobTableRow';
33

44
describe('getStatusLabel', () => {
5-
it('returns green "Complete" for COMPLETED status', () => {
6-
const result = getStatusLabel(ModelTransferJobStatus.COMPLETED);
7-
expect(result.label).toBe('Complete');
8-
expect(result.color).toBe('green');
9-
});
10-
11-
it('returns blue "Running" for RUNNING status', () => {
12-
const result = getStatusLabel(ModelTransferJobStatus.RUNNING);
13-
expect(result.label).toBe('Running');
14-
expect(result.color).toBe('blue');
15-
});
16-
17-
it('returns purple "Pending" for PENDING status', () => {
18-
const result = getStatusLabel(ModelTransferJobStatus.PENDING);
19-
expect(result.label).toBe('Pending');
20-
expect(result.color).toBe('purple');
21-
});
22-
23-
it('returns red "Failed" for FAILED status', () => {
24-
const result = getStatusLabel(ModelTransferJobStatus.FAILED);
25-
expect(result.label).toBe('Failed');
26-
expect(result.color).toBe('red');
27-
});
28-
29-
it('returns grey "Canceled" for CANCELLED status', () => {
30-
const result = getStatusLabel(ModelTransferJobStatus.CANCELLED);
31-
expect(result.label).toBe('Canceled');
32-
expect(result.color).toBe('grey');
33-
});
5+
it.each([
6+
[ModelTransferJobStatus.COMPLETED, 'Complete', 'green'],
7+
[ModelTransferJobStatus.RUNNING, 'Running', 'blue'],
8+
[ModelTransferJobStatus.PENDING, 'Pending', 'purple'],
9+
[ModelTransferJobStatus.FAILED, 'Failed', 'red'],
10+
[ModelTransferJobStatus.CANCELLED, 'Canceled', 'grey'],
11+
])(
12+
'returns correct label, color, and icon for %s status',
13+
(status, expectedLabel, expectedColor) => {
14+
const result = getStatusLabel(status);
15+
expect(result.label).toBe(expectedLabel);
16+
expect(result.color).toBe(expectedColor);
17+
expect(result.icon).toBeDefined();
18+
},
19+
);
3420
});

clients/ui/frontend/src/app/pages/settings/__tests__/ModelRegistryTableRowStatus.spec.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ describe('ModelRegistryTableRowStatus', () => {
169169
);
170170
expect(screen.getByText('Ready')).toBeVisible();
171171
});
172-
it('renders "Progressing" status', async () => {
172+
it('renders "Unavailable" status', async () => {
173173
const user = userEvent.setup();
174174

175175
render(

0 commit comments

Comments
 (0)