-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: adding model name column in service page (#541)
* feat: adding mode name column Signed-off-by: axel7083 <[email protected]> * test: ensuring the model name is displayed Signed-off-by: axel7083 <[email protected]> * fix: prettier Signed-off-by: axel7083 <[email protected]> * fix: Signed-off-by: axel7083 <[email protected]> * fix: prettier Signed-off-by: axel7083 <[email protected]> --------- Signed-off-by: axel7083 <[email protected]>
- Loading branch information
Showing
3 changed files
with
92 additions
and
1 deletion.
There are no files selected for viewing
73 changes: 73 additions & 0 deletions
73
packages/frontend/src/lib/table/service/ServiceColumnModelName.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/********************************************************************** | ||
* Copyright (C) 2024 Red Hat, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
***********************************************************************/ | ||
|
||
import { expect, test, vi, beforeEach } from 'vitest'; | ||
import { render, screen } from '@testing-library/svelte'; | ||
import ServiceColumnModelName from '/@/lib/table/service/ServiceColumnModelName.svelte'; | ||
import type { ModelInfo } from '@shared/src/models/IModelInfo'; | ||
|
||
beforeEach(() => { | ||
vi.resetAllMocks(); | ||
}); | ||
|
||
test('the model name should be displayed', async () => { | ||
render(ServiceColumnModelName, { | ||
object: { | ||
health: undefined, | ||
models: [ | ||
{ | ||
name: 'dummyName', | ||
} as unknown as ModelInfo, | ||
], | ||
connection: { port: 8888 }, | ||
status: 'running', | ||
container: { containerId: 'dummyContainerId', engineId: 'dummyEngineId' }, | ||
}, | ||
}); | ||
|
||
const modelName = screen.getByText('dummyName'); | ||
expect(modelName).toBeDefined(); | ||
expect(modelName.localName).toBe('span'); | ||
}); | ||
|
||
test('multiple models name should be displayed as list', async () => { | ||
render(ServiceColumnModelName, { | ||
object: { | ||
health: undefined, | ||
models: [ | ||
{ | ||
name: 'dummyName-1', | ||
} as unknown as ModelInfo, | ||
{ | ||
name: 'dummyName-2', | ||
} as unknown as ModelInfo, | ||
], | ||
connection: { port: 8888 }, | ||
status: 'running', | ||
container: { containerId: 'dummyContainerId', engineId: 'dummyEngineId' }, | ||
}, | ||
}); | ||
|
||
const model1Name = screen.getByText('dummyName-1'); | ||
expect(model1Name).toBeDefined(); | ||
expect(model1Name.localName).toBe('li'); | ||
|
||
const model2Name = screen.getByText('dummyName-2'); | ||
expect(model2Name).toBeDefined(); | ||
expect(model2Name.localName).toBe('li'); | ||
}); |
16 changes: 16 additions & 0 deletions
16
packages/frontend/src/lib/table/service/ServiceColumnModelName.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<script lang="ts"> | ||
import type { InferenceServer } from '@shared/src/models/IInference'; | ||
export let object: InferenceServer; | ||
</script> | ||
|
||
{#if object.models.length === 1} | ||
<span class="text-sm text-gray-700"> | ||
{object.models[0].name} | ||
</span> | ||
{:else} | ||
<ul> | ||
{#each object.models as model} | ||
<li class="text-sm text-gray-700">{model.name}</li> | ||
{/each} | ||
</ul> | ||
{/if} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters