Skip to content

Commit

Permalink
PMM-11795-postgresql-operator: configuration, NetworkAndSecurity, Ope…
Browse files Browse the repository at this point in the history
…rator, KubernetesInventory tests fix
  • Loading branch information
solovevayaroslavna committed Apr 18, 2023
1 parent 18f19f4 commit e8baf3f
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@ describe('DBClusterAdvancedOptions Configurations::', () => {
)
);
expect(screen.getByTestId('configurations').querySelector('legend')).toHaveTextContent(
Messages.fieldSets.commonConfiguration
Messages.fieldSets.configuration(Databases.haproxy)
);
expect(screen.getByTestId('storageClass-field-label')).toHaveTextContent(Messages.labels.storageClass);
expect(screen.getByTestId('storageClass-field-container').querySelector('input')).toBeTruthy();
expect(screen.getByTestId('configuration-field-label')).toHaveTextContent(Messages.labels.commonConfiguration);
expect(screen.getByTestId('configuration-field-label')).toHaveTextContent(
Messages.labels.configuration(Databases.haproxy)
);
expect(screen.getByTestId('configuration-textarea-input')).toBeInTheDocument();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import arrayMutators from 'final-form-arrays';
import React from 'react';
import { Form } from 'react-final-form';

import { BasicOptionsFields } from 'app/percona/dbaas/components/DBCluster/EditDBClusterPage/DBClusterBasicOptions/DBClusterBasicOptions.types';
import { Databases } from 'app/percona/shared/core';

import NetworkAndSecurity from './NetworkAndSecurity';
import { Messages } from './NetworkAndSecurity.messages';
import { NetworkAndSecurityFields } from './NetworkAndSecurity.types';
Expand All @@ -11,7 +14,10 @@ describe('DBClusterAdvancedOptions NetworkAndSecurity::', () => {
it('render items correctly for create and edit mode', () => {
render(
<Form
initialValues={{ [NetworkAndSecurityFields.sourceRanges]: [{}] }}
initialValues={{
[NetworkAndSecurityFields.sourceRanges]: [{}],
[BasicOptionsFields.databaseType]: { value: Databases.mysql },
}}
onSubmit={jest.fn()}
mutators={{ ...arrayMutators }}
render={({ form }) => <NetworkAndSecurity form={form} />}
Expand All @@ -38,7 +44,10 @@ describe('DBClusterAdvancedOptions NetworkAndSecurity::', () => {
it('the delete button should not delete the first field', () => {
render(
<Form
initialValues={{ [NetworkAndSecurityFields.sourceRanges]: [{ sourceRange: '1' }] }}
initialValues={{
[NetworkAndSecurityFields.sourceRanges]: [{ sourceRange: '1' }],
[BasicOptionsFields.databaseType]: { value: Databases.mongodb },
}}
onSubmit={jest.fn()}
mutators={{ ...arrayMutators }}
render={({ form }) => <NetworkAndSecurity form={form} />}
Expand All @@ -58,7 +67,10 @@ describe('DBClusterAdvancedOptions NetworkAndSecurity::', () => {
it('the delete button should delete field from the form if it is not the first one ', () => {
render(
<Form
initialValues={{ [NetworkAndSecurityFields.sourceRanges]: [{ sourceRange: '1' }, { sourceRange: '2' }] }}
initialValues={{
[NetworkAndSecurityFields.sourceRanges]: [{ sourceRange: '1' }, { sourceRange: '2' }],
[BasicOptionsFields.databaseType]: { value: Databases.mysql },
}}
onSubmit={jest.fn()}
mutators={{ ...arrayMutators }}
render={({ form }) => <NetworkAndSecurity form={form} />}
Expand All @@ -74,4 +86,23 @@ describe('DBClusterAdvancedOptions NetworkAndSecurity::', () => {
fireEvent.click(deleteBtn);
expect(screen.queryByTestId('sourceRanges[1].sourceRange-text-input')).not.toBeInTheDocument();
});
it('source range field should be hidden whe database is postgreSQL ', () => {
render(
<Form
initialValues={{
[NetworkAndSecurityFields.sourceRanges]: [{ sourceRange: '1' }],
[BasicOptionsFields.databaseType]: { value: Databases.postgresql },
}}
onSubmit={jest.fn()}
mutators={{ ...arrayMutators }}
render={({ form }) => <NetworkAndSecurity form={form} />}
/>
);
expect(screen.getByTestId('toggle-network-and-security')).toBeInTheDocument();
const checkbox = screen.getByTestId('toggle-network-and-security');

fireEvent.click(checkbox);

expect(screen.queryByTestId('source-ranges')).not.toBeInTheDocument();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const NetworkAndSecurity: FC<NetworkAndSecurityProps> = ({ form }) => {
{databaseType.value !== Databases.postgresql && (
<FieldArray name={NetworkAndSecurityFields.sourceRanges}>
{({ fields }) => (
<div className={styles.fieldsWrapper}>
<div className={styles.fieldsWrapper} data-testid="source-ranges">
<Button
className={styles.button}
variant="secondary"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ describe('KubernetesInventory::', () => {
operators: {
psmdb: { status: KubernetesOperatorStatus.ok, version: '1', availableVersion: '1' },
pxc: { status: KubernetesOperatorStatus.ok, version: '1', availableVersion: '1' },
pg: { status: KubernetesOperatorStatus.ok, version: '1', availableVersion: '1' },
},
},
{
Expand All @@ -38,6 +39,7 @@ describe('KubernetesInventory::', () => {
operators: {
psmdb: { status: KubernetesOperatorStatus.ok, version: '1', availableVersion: '1' },
pxc: { status: KubernetesOperatorStatus.ok, version: '1', availableVersion: '1' },
pg: { status: KubernetesOperatorStatus.ok, version: '1', availableVersion: '1' },
},
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export const OperatorStatusRow: FC<OperatorStatusRowProps> = ({
<div>
{operators.map((item) => (
<OperatorStatusItem
key={`${item.operator}`}
key={`${item.databaseType}-${element.kubernetesClusterName}-operator`}
databaseType={item.databaseType}
operator={item.operator}
kubernetes={element}
Expand Down

0 comments on commit e8baf3f

Please sign in to comment.