forked from podman-desktop/podman-desktop
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: makes containers port(s) list multi line (podman-desktop#9554)
* feat: makes containers port multi line Signed-off-by: axel7083 <[email protected]> * fix: remove legacy tests Signed-off-by: axel7083 <[email protected]> --------- Signed-off-by: axel7083 <[email protected]>
- Loading branch information
Showing
5 changed files
with
95 additions
and
14 deletions.
There are no files selected for viewing
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
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
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
65 changes: 65 additions & 0 deletions
65
packages/renderer/src/lib/kube/details/KubeContainerPorts.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,65 @@ | ||
/********************************************************************** | ||
* 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 '@testing-library/jest-dom/vitest'; | ||
|
||
import { render } from '@testing-library/svelte'; | ||
import { expect, test } from 'vitest'; | ||
|
||
import KubeContainerPorts from '/@/lib/kube/details/KubeContainerPorts.svelte'; | ||
|
||
test('expect port title not to be visible when no ports provided', async () => { | ||
const { queryByText } = render(KubeContainerPorts); | ||
|
||
const title = queryByText('Ports'); | ||
expect(title).toBeNull(); | ||
}); | ||
|
||
test('expect port title to be visible when ports is defined', async () => { | ||
const { getByText } = render(KubeContainerPorts, { | ||
ports: [ | ||
{ | ||
containerPort: 80, | ||
}, | ||
], | ||
}); | ||
|
||
const title = getByText('Ports'); | ||
expect(title).toBeDefined(); | ||
}); | ||
|
||
test('expect multiple ports to be visible', async () => { | ||
const { getByText } = render(KubeContainerPorts, { | ||
ports: [ | ||
{ | ||
containerPort: 80, | ||
protocol: 'TCP', | ||
}, | ||
{ | ||
containerPort: 100, | ||
protocol: 'TCP', | ||
}, | ||
], | ||
}); | ||
|
||
const port80 = getByText('80/TCP'); | ||
expect(port80).toBeDefined(); | ||
|
||
const port100 = getByText('100/TCP'); | ||
expect(port100).toBeDefined(); | ||
}); |
27 changes: 27 additions & 0 deletions
27
packages/renderer/src/lib/kube/details/KubeContainerPorts.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,27 @@ | ||
<script lang="ts"> | ||
import type { V1ContainerPort } from '@kubernetes/client-node'; | ||
import Cell from '/@/lib/details/DetailsCell.svelte'; | ||
interface Props { | ||
ports?: V1ContainerPort[]; | ||
} | ||
let { ports }: Props = $props(); | ||
</script> | ||
|
||
{#if ports && ports.length > 0} | ||
<tr> | ||
<Cell class="flex">Ports</Cell> | ||
<Cell> | ||
<div class="flex gap-y-1 flex-col"> | ||
{#each ports as port (port.containerPort)} | ||
<span> | ||
{port.containerPort}/{port.protocol} | ||
</span> | ||
{/each} | ||
</div> | ||
</Cell> | ||
</tr> | ||
{/if} | ||
|