Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: display status of recipe/model #747

Merged
merged 2 commits into from
Mar 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
47 changes: 47 additions & 0 deletions packages/frontend/src/lib/RecipeDetails.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,3 +281,50 @@ test('local clone and delete local clone buttons should be visible if local repo

expect(mocks.requestDeleteLocalRepositoryMock).toBeCalled();
});

test('should display app state for default model when model is the recommended', async () => {
mocks.getApplicationsStateMock.mockResolvedValue([
{
recipeId: 'recipe 1',
modelId: 'model1',
pod: {
Name: 'pod1',
Status: 'Running',
},
},
]);
vi.mocked(catalogStore).catalog = readable<ApplicationCatalog>(initialCatalog);
render(RecipeDetails, {
recipeId: 'recipe 1',
modelId: 'model1',
});

await new Promise(resolve => setTimeout(resolve, 0));
const appStatus = screen.getByLabelText('app-status');
expect(appStatus.textContent).toContain('RUNNING');
expect(appStatus.textContent).toContain('pod1');
});

test('should display app state for other model when model is not the recommended', async () => {
mocks.getApplicationsStateMock.mockResolvedValue([
{
recipeId: 'recipe 1',
modelId: 'model1',
pod: {
Name: 'pod1',
Status: 'Running',
},
},
]);
vi.mocked(catalogStore).catalog = readable<ApplicationCatalog>(initialCatalog);
render(RecipeDetails, {
recipeId: 'recipe 1',
modelId: 'model2',
});

await new Promise(resolve => setTimeout(resolve, 0));
const appStatus = screen.queryByLabelText('app-status');
expect(appStatus).not.toBeInTheDocument();
const btnRunApplication = screen.getByText('Start AI App');
expect(btnRunApplication).toBeInTheDocument();
});
4 changes: 2 additions & 2 deletions packages/frontend/src/lib/RecipeDetails.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import type { ModelInfo } from '@shared/src/models/IModelInfo';
export let recipeId: string;
export let modelId: string;

$: appState = $applicationStates.find((app: ApplicationState) => app.recipeId === recipeId);
$: appState = $applicationStates.find((app: ApplicationState) => app.recipeId === recipeId && app.modelId === modelId);
$: recipe = $catalog.recipes.find(r => r.id === recipeId);

$: filteredTasks = filterByLabel($tasks, {
Expand Down Expand Up @@ -82,7 +82,7 @@ const deleteLocalClone = () => {
<div class="w-full bg-charcoal-600 rounded-md p-4">
<div class="flex flex-row items-center">
{#if appState && appState.pod}
<div class="grow flex overflow-hidden whitespace-nowrap items-center">
<div class="grow flex overflow-hidden whitespace-nowrap items-center" aria-label="app-status">
<a title="Navigate to Pod details" href="{'javascript:void(0);'}" on:click="{navigateToPod}">
<StatusIcon size="{22}" status="{appState.pod.Status.toUpperCase()}" icon="{PodIcon}" />
</a>
Expand Down