Skip to content

Commit

Permalink
chore: display FQN of images to export
Browse files Browse the repository at this point in the history
fixes podman-desktop#6585
Signed-off-by: Florent Benoit <[email protected]>
  • Loading branch information
benoitf committed Apr 2, 2024
1 parent 120a4ba commit 0003467
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 15 deletions.
65 changes: 52 additions & 13 deletions packages/renderer/src/lib/image/SaveImages.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,16 @@ import SaveImages from './SaveImages.svelte';
const imageInfo: ImageInfoUI = {
id: 'id',
shortId: 'id',
name: 'image 1',
name: '<none>',
tag: '',
engineId: 'engine',
} as ImageInfoUI;

const imageInfo2: ImageInfoUI = {
id: 'id2',
shortId: 'id2',
name: 'image 2',
name: '<none>',
tag: '',
engineId: 'engine',
} as ImageInfoUI;

Expand Down Expand Up @@ -86,17 +88,18 @@ test('Expect deleteImage is not visible if page has been opened with one item',
test('Expect deleteImage is visible if page has been opened with multiple item', async () => {
saveImagesInfo.set([imageInfo, imageInfo2]);
await waitRender();

const itemBeforeDelete = screen.getAllByLabelText('container image path');
expect(itemBeforeDelete.length).equal(2);

const deleteButtons = screen.getAllByLabelText('Delete image');

await userEvent.click(deleteButtons[0]);

const itemAfterDelete = screen.getAllByLabelText('container image path');
expect(itemAfterDelete.length).equal(1);
expect(itemAfterDelete.length).toBeLessThan(itemBeforeDelete.length);
const itemBeforeDelete1 = screen.getByRole('textbox', { name: 'image id' });
expect(itemBeforeDelete1).toBeInTheDocument();
const itemBeforeDelete2 = screen.getByRole('textbox', { name: 'image id2' });
expect(itemBeforeDelete2).toBeInTheDocument();

const deleteButtonImage1 = screen.getByRole('button', { name: 'Delete image id' });

await userEvent.click(deleteButtonImage1);
const afterDeletionImage1 = screen.queryByRole('textbox', { name: 'image id' });
expect(afterDeletionImage1).not.toBeInTheDocument();
const afterDeletionImage2 = screen.getByRole('textbox', { name: 'image id2' });
expect(afterDeletionImage2).toBeInTheDocument();
});

test('Expect save button to be enabled if output target is selected and saveImages function called', async () => {
Expand Down Expand Up @@ -168,3 +171,39 @@ test('Expect error message dispayed if saveImages fails', async () => {
expect(errorDiv).toBeInTheDocument();
expect((errorDiv as HTMLDivElement).innerHTML).toContain('error while saving');
});

test('Expect display correctly images to save', async () => {
saveImagesInfo.set([
{
id: 'id1',
shortId: 'id1',
name: '<none>',
tag: '',
engineId: 'engine',
},
{
id: 'httpdid2',
shortId: 'httpdid2',
name: 'httpd',
tag: 'latest',
engineId: 'engine',
},
{
id: 'httpdid3',
shortId: 'httpdid3',
name: 'httpd',
tag: '1.2.3',
engineId: 'engine',
},
] as ImageInfoUI[]);
await waitRender();

// now expect to see the images with the correct names
// grap all input fields
const noImageName = screen.getByRole('textbox', { name: 'image id1' });
expect(noImageName).toBeInTheDocument();
const inputHttpdWithCustomTag = screen.getByRole('textbox', { name: 'image httpd:1.2.3' });
expect(inputHttpdWithCustomTag).toBeInTheDocument();
const inputHttpdWithDefaultTag = screen.getByRole('textbox', { name: 'image httpd:latest' });
expect(inputHttpdWithDefaultTag).toBeInTheDocument();
});
6 changes: 4 additions & 2 deletions packages/renderer/src/lib/image/SaveImages.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,13 @@ async function saveImages() {
<div class="flex flex-col grow">Images to save</div>
</div>
{#each imagesToSave as imageToSave, index}
{@const imageAndTag = `${imageToSave.name}:${imageToSave.tag}`}
{@const imageDisplayName = `${imageToSave.name === '<none>' ? imageToSave.shortId : imageAndTag}`}
<div class="flex flex-row justify-center w-full py-1">
<Input bind:value="{imageToSave.name}" aria-label="container image path" readonly="{true}" />
<Input value="{imageDisplayName}" aria-label="image {imageDisplayName}" readonly="{true}" />
<Button
type="link"
aria-label="Delete image"
aria-label="Delete image {imageDisplayName}"
on:click="{() => deleteImageToSave(index)}"
icon="{faMinusCircle}" />
</div>
Expand Down

0 comments on commit 0003467

Please sign in to comment.