Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Everest-1809 | show wizard errors on sidebar #1068

Open
wants to merge 34 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
6272ca4
feat: check form errors
fabio-silva Jan 28, 2025
36cce34
chore: remove logs
fabio-silva Jan 28, 2025
85840c7
feat: prevent errors from going back and forth
fabio-silva Jan 28, 2025
35730e1
feat: use resolver to check step errors
fabio-silva Jan 29, 2025
e250aab
Merge branch 'main' into EVEREST-1809-wizard-errors
fabio-silva Jan 30, 2025
f595f59
chore: remove unused code
fabio-silva Jan 30, 2025
3b14e8c
chore: remove log
fabio-silva Jan 30, 2025
0e4d490
chore: add missing props to unit tests
fabio-silva Jan 30, 2025
81d4974
fix: unit tests
fabio-silva Jan 30, 2025
32872dd
test: e2e for wizard errors
fabio-silva Jan 30, 2025
70ab358
chore: remove misused ".only"
fabio-silva Jan 30, 2025
c92b77d
fix: moveForward
fabio-silva Jan 30, 2025
9b96fdc
test: remove misused assertion
fabio-silva Jan 30, 2025
080f748
fix: wrong e2e test
fabio-silva Jan 31, 2025
415954f
Merge branch 'main' into EVEREST-1809-wizard-errors
percona-robot Jan 31, 2025
dfcf4ec
Merge branch 'main' into EVEREST-1809-wizard-errors
percona-robot Jan 31, 2025
e63beb4
fix: add missing awaits to e2e tests
fabio-silva Jan 31, 2025
ee307b2
Merge branch 'EVEREST-1809-wizard-errors' of https://github.com/perco…
fabio-silva Jan 31, 2025
5c1d684
fix: re-render when errors change for config servers
fabio-silva Jan 31, 2025
1207d34
Merge branch 'main' into EVEREST-1809-wizard-errors
percona-robot Feb 3, 2025
e93d4aa
Merge branch 'main' into EVEREST-1809-wizard-errors
percona-robot Feb 4, 2025
8a74411
Merge branch 'main' into EVEREST-1809-wizard-errors
percona-robot Feb 5, 2025
5106082
Merge branch 'main' into EVEREST-1809-wizard-errors
percona-robot Feb 5, 2025
c7c11dd
Merge branch 'main' into EVEREST-1809-wizard-errors
percona-robot Feb 5, 2025
cafb5f9
Merge branch 'main' into EVEREST-1809-wizard-errors
percona-robot Feb 5, 2025
ed85054
Merge branch 'main' into EVEREST-1809-wizard-errors
percona-robot Feb 5, 2025
a87b80f
Merge branch 'main' into EVEREST-1809-wizard-errors
percona-robot Feb 6, 2025
53fac7f
Merge branch 'main' into EVEREST-1809-wizard-errors
percona-robot Feb 7, 2025
61ce910
Merge branch 'main' into EVEREST-1809-wizard-errors
percona-robot Feb 10, 2025
dd491c9
Merge branch 'main' into EVEREST-1809-wizard-errors
percona-robot Feb 12, 2025
37b559e
Merge branch 'main' into EVEREST-1809-wizard-errors
percona-robot Feb 12, 2025
0a1aac6
chore: lint/format
percona-robot Feb 12, 2025
f9c3460
Merge branch 'main' into EVEREST-1809-wizard-errors
percona-robot Feb 12, 2025
2fb9150
Merge branch 'main' into EVEREST-1809-wizard-errors
percona-robot Feb 12, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,9 @@ test.describe('DB Cluster creation', () => {
expect(addedCluster).not.toBeUndefined();
expect(addedCluster?.spec.engine.type).toBe('psmdb');
expect(addedCluster?.spec.engine.replicas).toBe(3);
expect(addedCluster?.spec.engine.resources?.cpu.toString()).toBe('1');
expect(addedCluster?.spec.engine.resources?.memory.toString()).toBe('4G');
expect(addedCluster?.spec.engine.storage.size.toString()).toBe('25Gi');
expect(addedCluster?.spec.engine.resources?.cpu.toString()).toBe('600m');
expect(addedCluster?.spec.engine.resources?.memory.toString()).toBe('1G');
expect(addedCluster?.spec.engine.storage.size.toString()).toBe('1Gi');
expect(addedCluster?.spec.proxy.expose.type).toBe('internal');
// TODO commented, because we use only psmdb in this test
// expect(addedCluster?.spec.proxy.replicas).toBe(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ import { goToStep, moveForward } from '@e2e/utils/db-wizard';
import { selectDbEngine } from '../db-wizard-utils';

test.describe('DB Cluster creation', () => {
test('Blocking the edit buttons when an error occurs in the form', async ({
page,
}) => {
test('Wizard form errors', async ({ page }) => {
await page.goto('/databases');
await selectDbEngine(page, 'pxc');

Expand All @@ -47,18 +45,56 @@ test.describe('DB Cluster creation', () => {
page.getByTestId('button-edit-preview-backups')
).not.toBeDisabled();

// Introduce an error on resources step
await page.getByTestId('text-input-memory').fill('');
await expect(page.getByTestId('preview-error-resources')).not.toBeVisible();

await expect(page.getByTestId('db-wizard-previous-button')).toBeDisabled();
await expect(page.getByTestId('db-wizard-continue-button')).toBeDisabled();
await expect(
page.getByTestId('db-wizard-cancel-button')
).not.toBeDisabled();

// Backups step
await moveForward(page);
// Advanced Configurations step
await moveForward(page);

await page
.getByTestId('switch-input-external-access')
.getByRole('checkbox')
.check();
await page.getByTestId('add-text-input-button').click();
// Introduce an error on advanced configs step: two invalid IPs
await page
.getByTestId('text-input-source-ranges.0.source-range')
.fill('invalid-ip');
await page
.getByTestId('text-input-source-ranges.1.source-range')
.fill('another-invalid-ip');
await expect(
page.getByTestId('button-edit-preview-basic-information')
).toBeDisabled();
page.getByTestId('preview-error-advanced-configurations')
).not.toBeVisible();

// Monitoring step
await moveForward(page);
await expect(page.getByTestId('db-wizard-submit-button')).toBeDisabled();
await expect(page.getByTestId('preview-error-resources')).toBeVisible();
await expect(
page.getByTestId('button-edit-preview-backups')
).toBeDisabled();
page.getByTestId('preview-error-advanced-configurations')
).toBeVisible();
await goToStep(page, 'resources');
await page.getByTestId('text-input-memory').fill('1');
await goToStep(page, 'advanced-configurations');
await page.getByTestId('delete-text-input-1-button').click();
await page
.getByTestId('text-input-source-ranges.0.source-range')
.fill('192.168.1.1');
await goToStep(page, 'monitoring');
await expect(
page.getByTestId('db-wizard-submit-button')
).not.toBeDisabled();
await expect(page.getByTestId('preview-error-resources')).not.toBeVisible();
await expect(
page.getByTestId('preview-error-advanced-configurations')
).not.toBeVisible();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -154,20 +154,26 @@ test.describe('Sharding (psmdb)', () => {
);

await page.getByTestId('shard-config-servers-1').click();
expect(page.getByTestId('shard-config-servers-error')).toBeVisible();
expect(page.getByTestId('db-wizard-continue-button')).toBeDisabled();
await expect(page.getByTestId('shard-config-servers-error')).toBeVisible();

await page.getByTestId('toggle-button-nodes-1').click();
expect(page.getByTestId('shard-config-servers-error')).not.toBeVisible();
expect(page.getByTestId('db-wizard-continue-button')).not.toBeDisabled();
await expect(
page.getByTestId('shard-config-servers-error')
).not.toBeVisible();
await expect(
page.getByTestId('db-wizard-continue-button')
).not.toBeDisabled();

await page.getByTestId('toggle-button-nodes-3').click();
expect(page.getByTestId('shard-config-servers-error')).toBeVisible();
expect(page.getByTestId('db-wizard-continue-button')).toBeDisabled();
await expect(page.getByTestId('shard-config-servers-error')).toBeVisible();

await page.getByTestId('shard-config-servers-3').click();
expect(page.getByTestId('shard-config-servers-error')).not.toBeVisible();
expect(page.getByTestId('db-wizard-continue-button')).not.toBeDisabled();
await expect(
page.getByTestId('shard-config-servers-error')
).not.toBeVisible();
await expect(
page.getByTestId('db-wizard-continue-button')
).not.toBeDisabled();
});

test('0 value of the Nº of shards causes an error', async ({ page }) => {
Expand All @@ -180,10 +186,13 @@ test.describe('Sharding (psmdb)', () => {
await moveForward(page);

await page.getByTestId('text-input-shard-nr').fill('0');
expect(page.getByText('The value cannot be less than 1')).toBeVisible();
expect(page.getByTestId('db-wizard-continue-button')).toBeDisabled();
await expect(
page.getByText('The value cannot be less than 1')
).toBeVisible();
await page.getByTestId('text-input-shard-nr').fill('1');
expect(page.getByTestId('db-wizard-continue-button')).not.toBeDisabled();
await expect(
page.getByTestId('db-wizard-continue-button')
).not.toBeDisabled();
});

test('Changing the Nº of nodes causes changing the confing servers Nº automatically, until the user touches confing servers Nº', async ({
Expand Down
11 changes: 8 additions & 3 deletions ui/apps/everest/.e2e/utils/db-wizard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,15 @@ export const storageLocationAutocompleteEmptyValidationCheck = async (
};

export const moveForward = async (page: Page) => {
await expect(
page.getByTestId('db-wizard-continue-button')
).not.toBeDisabled();
const currHeader = await page.getByTestId('step-header').textContent();
await page.getByTestId('db-wizard-continue-button').click();

do {
if ((await page.getByTestId('step-header').textContent()) !== currHeader) {
break;
}
page.waitForTimeout(200);
} while (1);
};

export const moveBack = (page: Page) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@

import { ResourcesTogglesProps, ResourceInputProps } from './resources.types';
import { Messages } from './messages';
import { DbWizardType } from 'pages/database-form/database-form-schema';

const humanizeResourceSizeMap = (type: ResourceSize): string =>
humanizedResourceSizeMap[type];
Expand Down Expand Up @@ -189,7 +190,7 @@
}
setValue(memoryInputName, sizeOptions[resourceSizePerUnit].memory);
}
}, [resourceSizePerUnit, allowDiskInputUpdate, setValue]);

Check warning on line 193 in ui/apps/everest/src/components/cluster-form/resources/resources.tsx

View workflow job for this annotation

GitHub Actions / CI_checks (lint)

React Hook useEffect has missing dependencies: 'cpuInputName', 'diskInputName', 'memoryInputName', and 'sizeOptions'. Either include them or remove the dependency array

useEffect(() => {
if (diskCapacityExceeded) {
Expand All @@ -197,7 +198,7 @@
} else {
clearErrors(diskInputName);
}
}, [diskCapacityExceeded, clearErrors, setError]);

Check warning on line 201 in ui/apps/everest/src/components/cluster-form/resources/resources.tsx

View workflow job for this annotation

GitHub Actions / CI_checks (lint)

React Hook useEffect has a missing dependency: 'diskInputName'. Either include it or remove the dependency array

useEffect(() => {
if (
Expand All @@ -206,7 +207,7 @@
) {
setValue(resourceSizePerUnitInputName, ResourceSize.custom);
}
}, [cpu, setValue]);

Check warning on line 210 in ui/apps/everest/src/components/cluster-form/resources/resources.tsx

View workflow job for this annotation

GitHub Actions / CI_checks (lint)

React Hook useEffect has missing dependencies: 'resourceSizePerUnit', 'resourceSizePerUnitInputName', and 'sizeOptions'. Either include them or remove the dependency array

useEffect(() => {
if (
Expand All @@ -216,7 +217,7 @@
) {
setValue(resourceSizePerUnitInputName, ResourceSize.custom);
}
}, [disk, allowDiskInputUpdate, setValue]);

Check warning on line 220 in ui/apps/everest/src/components/cluster-form/resources/resources.tsx

View workflow job for this annotation

GitHub Actions / CI_checks (lint)

React Hook useEffect has missing dependencies: 'resourceSizePerUnit', 'resourceSizePerUnitInputName', and 'sizeOptions'. Either include them or remove the dependency array

useEffect(() => {
if (
Expand All @@ -225,7 +226,7 @@
) {
setValue(resourceSizePerUnitInputName, ResourceSize.custom);
}
}, [memory, setValue]);

Check warning on line 229 in ui/apps/everest/src/components/cluster-form/resources/resources.tsx

View workflow job for this annotation

GitHub Actions / CI_checks (lint)

React Hook useEffect has missing dependencies: 'resourceSizePerUnit', 'resourceSizePerUnitInputName', and 'sizeOptions'. Either include them or remove the dependency array

return (
<FormGroup sx={{ mt: 3 }}>
Expand Down Expand Up @@ -443,22 +444,23 @@
const [expanded, setExpanded] = useState<'nodes' | 'proxies' | false>(
'nodes'
);
const { watch, getFieldState, setValue, trigger, clearErrors } =
useFormContext();
const {
watch,
getFieldState,
setValue,
trigger,
clearErrors,
formState: { errors },
} = useFormContext<DbWizardType>();

const numberOfNodes: string = watch(DbWizardFormFields.numberOfNodes);

const sharding: boolean = watch(DbWizardFormFields.sharding);
const shardConfigServers: number = watch(
DbWizardFormFields.shardConfigServers
);
const { error: shardConfigServersError } = getFieldState(
DbWizardFormFields.shardConfigServers
);
const shardConfigServers = watch(DbWizardFormFields.shardConfigServers);

const numberOfProxies: string = watch(DbWizardFormFields.numberOfProxies);
const customNrOfNodes: string = watch(DbWizardFormFields.customNrOfNodes);
const customNrOfProxies: string = watch(DbWizardFormFields.customNrOfProxies);
const customNrOfNodes = watch(DbWizardFormFields.customNrOfNodes);
const customNrOfProxies = watch(DbWizardFormFields.customNrOfProxies);
const proxyUnitNames = getProxyUnitNamesFromDbType(dbType);
const nodesAccordionSummaryNumber =
numberOfNodes === CUSTOM_NR_UNITS_INPUT_VALUE
Expand Down Expand Up @@ -526,7 +528,9 @@
clearErrors(DbWizardFormFields.shardConfigServers);
setValue(
DbWizardFormFields.shardConfigServers,
getDefaultNumberOfconfigServersByNumberOfNodes(+customNrOfNodes)
getDefaultNumberOfconfigServersByNumberOfNodes(
+(customNrOfNodes || '')
)
);
}
}
Expand Down Expand Up @@ -579,7 +583,7 @@
>
<CustomAccordionSummary
unitPlural="Nodes"
nr={parseInt(nodesAccordionSummaryNumber, 10)}
nr={parseInt(nodesAccordionSummaryNumber || '', 10)}
/>
<Divider />
<ResourcesToggles
Expand Down Expand Up @@ -609,7 +613,7 @@
>
<CustomAccordionSummary
unitPlural={proxyUnitNames.plural}
nr={parseInt(proxiesAccordionSummaryNumber, 10)}
nr={parseInt(proxiesAccordionSummaryNumber || '', 10)}
/>
<Divider />
<ResourcesToggles
Expand Down Expand Up @@ -649,8 +653,9 @@
toggleButtonGroupProps={{
size: 'small',
onChange: (_, value) => {
setValue(DbWizardFormFields.shardConfigServers, value);
trigger(DbWizardFormFields.shardConfigServers);
setValue(DbWizardFormFields.shardConfigServers, value, {
shouldValidate: true,
});
},
}}
>
Expand All @@ -674,12 +679,12 @@
</ToggleRegularButton>
))}
</ToggleButtonGroupInputRegular>
{shardConfigServersError && (
{errors.shardConfigServers && (
<FormHelperText
data-testid="shard-config-servers-error"
error={true}
>
{shardConfigServersError?.message}
{errors.shardConfigServers.message}
</FormHelperText>
)}
</Stack>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import DatabaseFormStepControllers from './DatabaseFormStepControllers';
const DatabaseFormBody = ({
activeStep,
longestAchievedStep,
disableNext,
isSubmitting,
hasErrors,
onCancel,
Expand Down Expand Up @@ -52,8 +51,7 @@ const DatabaseFormBody = ({
})}
</Box>
<DatabaseFormStepControllers
disableBack={isFirstStep || hasErrors}
disableNext={disableNext}
disableBack={isFirstStep}
disableSubmit={isSubmitting || hasErrors}
disableCancel={isSubmitting}
showSubmit={activeStep === steps.length - 1}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import { DatabaseFormStepControllersProps } from './types';

const DatabaseFormStepControllers = ({
disableBack,
disableNext,
disableSubmit,
disableCancel,
showSubmit,
Expand Down Expand Up @@ -66,7 +65,6 @@ const DatabaseFormStepControllers = ({
onClick={onNextClick}
variant="contained"
data-testid="db-wizard-continue-button"
disabled={disableNext}
>
{Messages.continue}
</Button>
Expand Down
Loading
Loading