CreateImageWizard: Implement user-friendly error messages

Puts the error messages in one place - LabelInput.tsx
This commit is contained in:
Florian Schüller 2025-05-12 12:48:24 +02:00 committed by Klara Simickova
parent 3f35101f68
commit ccfdb49db2
11 changed files with 156 additions and 97 deletions

View file

@ -63,19 +63,29 @@ test('Create a blueprint with Firewall customization', async ({
await test.step('Select and incorrectly fill the ports in Firewall step', async () => {
await frame.getByPlaceholder('Add ports').fill('x');
await frame.getByRole('button', { name: 'Add ports' }).click();
await expect(frame.getByText('Invalid format.').nth(0)).toBeVisible();
await expect(
frame
.getByText(
'Expected format: <port/port-name>:<protocol>. Example: 8080:tcp, ssh:tcp'
)
.nth(0)
).toBeVisible();
});
await test.step('Select and incorrectly fill the disabled services in Firewall step', async () => {
await frame.getByPlaceholder('Add disabled service').fill('1');
await frame.getByRole('button', { name: 'Add disabled service' }).click();
await expect(frame.getByText('Invalid format.').nth(1)).toBeVisible();
await expect(
frame.getByText('Expected format: <service-name>. Example: sshd').nth(0)
).toBeVisible();
});
await test.step('Select and incorrectly fill the enabled services in Firewall step', async () => {
await frame.getByPlaceholder('Add enabled service').fill('ťčš');
await frame.getByRole('button', { name: 'Add enabled service' }).click();
await expect(frame.getByText('Invalid format.').nth(2)).toBeVisible();
await expect(
frame.getByText('Expected format: <service-name>. Example: sshd').nth(1)
).toBeVisible();
});
await test.step('Fill the BP details', async () => {

View file

@ -49,7 +49,11 @@ test('Create a blueprint with Kernel customization', async ({
.getByPlaceholder('Add kernel argument')
.fill('invalid/argument');
await frame.getByRole('button', { name: 'Add kernel argument' }).click();
await expect(frame.getByText('Invalid format.')).toBeVisible();
await expect(
frame.getByText(
'Expected format: <kernel-argument>. Example: console=tty0'
)
).toBeVisible();
await frame.getByPlaceholder('Select kernel package').fill('new-package');
await frame
.getByRole('option', { name: 'Custom kernel package "new-' })

View file

@ -64,15 +64,21 @@ test('Create a blueprint with Systemd customization', async ({
await test.step('Select and incorrectly fill all of the service fields', async () => {
await frame.getByPlaceholder('Add disabled service').fill('&&');
await frame.getByRole('button', { name: 'Add disabled service' }).click();
await expect(frame.getByText('Invalid format.').nth(0)).toBeVisible();
await expect(
frame.getByText('Expected format: <service-name>. Example: sshd').nth(0)
).toBeVisible();
await frame.getByPlaceholder('Add enabled service').fill('áá');
await frame.getByRole('button', { name: 'Add enabled service' }).click();
await expect(frame.getByText('Invalid format.').nth(1)).toBeVisible();
await expect(
frame.getByText('Expected format: <service-name>. Example: sshd').nth(1)
).toBeVisible();
await frame.getByPlaceholder('Add masked service').fill('78');
await frame.getByRole('button', { name: 'Add masked service' }).click();
await expect(frame.getByText('Invalid format.').nth(2)).toBeVisible();
await expect(
frame.getByText('Expected format: <service-name>. Example: sshd').nth(2)
).toBeVisible();
});
await test.step('Fill the BP details', async () => {

View file

@ -55,7 +55,11 @@ test('Create a blueprint with Timezone customization', async ({
await expect(frame.getByText('NTP server already exists.')).toBeVisible();
await frame.getByPlaceholder('Add NTP servers').fill('xxxx');
await frame.getByRole('button', { name: 'Add NTP server' }).click();
await expect(frame.getByText('Invalid format.')).toBeVisible();
await expect(
frame
.getByText('Expected format: <ntp-server>. Example: time.redhat.com')
.nth(0)
).toBeVisible();
await frame.getByPlaceholder('Add NTP servers').fill('0.cz.pool.ntp.org');
await frame.getByRole('button', { name: 'Add NTP server' }).click();
await expect(frame.getByText('0.cz.pool.ntp.org')).toBeVisible();