Skip to content

Commit

Permalink
fix: display status of recipe/model (#747)
Browse files Browse the repository at this point in the history
* fix: display status of recipe/model

Signed-off-by: Philippe Martin <phmartin@redhat.com>

* test: add unit tests

Signed-off-by: Philippe Martin <phmartin@redhat.com>

---------

Signed-off-by: Philippe Martin <phmartin@redhat.com>
  • Loading branch information
feloy committed Mar 29, 2024
1 parent 1919f3d commit 921b41c
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 2 deletions.
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 @@ -25,7 +25,7 @@ import Spinner from './button/Spinner.svelte';
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 @@ -84,7 +84,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}">
{#if getApplicationStatus(appState) === 'STARTING'}
<Spinner />
Expand Down

0 comments on commit 921b41c

Please sign in to comment.