Skip to content

Commit e8baf3f

Browse files
author
solovevayaroslavna
committed
PMM-11795-postgresql-operator: configuration, NetworkAndSecurity, Operator, KubernetesInventory tests fix
1 parent 18f19f4 commit e8baf3f

File tree

5 files changed

+42
-7
lines changed

5 files changed

+42
-7
lines changed

public/app/percona/dbaas/components/DBCluster/EditDBClusterPage/DBClusterAdvancedOptions/Configurations/Configurations.test.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,13 @@ describe('DBClusterAdvancedOptions Configurations::', () => {
2121
)
2222
);
2323
expect(screen.getByTestId('configurations').querySelector('legend')).toHaveTextContent(
24-
Messages.fieldSets.commonConfiguration
24+
Messages.fieldSets.configuration(Databases.haproxy)
2525
);
2626
expect(screen.getByTestId('storageClass-field-label')).toHaveTextContent(Messages.labels.storageClass);
2727
expect(screen.getByTestId('storageClass-field-container').querySelector('input')).toBeTruthy();
28-
expect(screen.getByTestId('configuration-field-label')).toHaveTextContent(Messages.labels.commonConfiguration);
28+
expect(screen.getByTestId('configuration-field-label')).toHaveTextContent(
29+
Messages.labels.configuration(Databases.haproxy)
30+
);
2931
expect(screen.getByTestId('configuration-textarea-input')).toBeInTheDocument();
3032
});
3133

public/app/percona/dbaas/components/DBCluster/EditDBClusterPage/NetworkAndSecurity/NetworkAndSecurity.test.tsx

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ import arrayMutators from 'final-form-arrays';
33
import React from 'react';
44
import { Form } from 'react-final-form';
55

6+
import { BasicOptionsFields } from 'app/percona/dbaas/components/DBCluster/EditDBClusterPage/DBClusterBasicOptions/DBClusterBasicOptions.types';
7+
import { Databases } from 'app/percona/shared/core';
8+
69
import NetworkAndSecurity from './NetworkAndSecurity';
710
import { Messages } from './NetworkAndSecurity.messages';
811
import { NetworkAndSecurityFields } from './NetworkAndSecurity.types';
@@ -11,7 +14,10 @@ describe('DBClusterAdvancedOptions NetworkAndSecurity::', () => {
1114
it('render items correctly for create and edit mode', () => {
1215
render(
1316
<Form
14-
initialValues={{ [NetworkAndSecurityFields.sourceRanges]: [{}] }}
17+
initialValues={{
18+
[NetworkAndSecurityFields.sourceRanges]: [{}],
19+
[BasicOptionsFields.databaseType]: { value: Databases.mysql },
20+
}}
1521
onSubmit={jest.fn()}
1622
mutators={{ ...arrayMutators }}
1723
render={({ form }) => <NetworkAndSecurity form={form} />}
@@ -38,7 +44,10 @@ describe('DBClusterAdvancedOptions NetworkAndSecurity::', () => {
3844
it('the delete button should not delete the first field', () => {
3945
render(
4046
<Form
41-
initialValues={{ [NetworkAndSecurityFields.sourceRanges]: [{ sourceRange: '1' }] }}
47+
initialValues={{
48+
[NetworkAndSecurityFields.sourceRanges]: [{ sourceRange: '1' }],
49+
[BasicOptionsFields.databaseType]: { value: Databases.mongodb },
50+
}}
4251
onSubmit={jest.fn()}
4352
mutators={{ ...arrayMutators }}
4453
render={({ form }) => <NetworkAndSecurity form={form} />}
@@ -58,7 +67,10 @@ describe('DBClusterAdvancedOptions NetworkAndSecurity::', () => {
5867
it('the delete button should delete field from the form if it is not the first one ', () => {
5968
render(
6069
<Form
61-
initialValues={{ [NetworkAndSecurityFields.sourceRanges]: [{ sourceRange: '1' }, { sourceRange: '2' }] }}
70+
initialValues={{
71+
[NetworkAndSecurityFields.sourceRanges]: [{ sourceRange: '1' }, { sourceRange: '2' }],
72+
[BasicOptionsFields.databaseType]: { value: Databases.mysql },
73+
}}
6274
onSubmit={jest.fn()}
6375
mutators={{ ...arrayMutators }}
6476
render={({ form }) => <NetworkAndSecurity form={form} />}
@@ -74,4 +86,23 @@ describe('DBClusterAdvancedOptions NetworkAndSecurity::', () => {
7486
fireEvent.click(deleteBtn);
7587
expect(screen.queryByTestId('sourceRanges[1].sourceRange-text-input')).not.toBeInTheDocument();
7688
});
89+
it('source range field should be hidden whe database is postgreSQL ', () => {
90+
render(
91+
<Form
92+
initialValues={{
93+
[NetworkAndSecurityFields.sourceRanges]: [{ sourceRange: '1' }],
94+
[BasicOptionsFields.databaseType]: { value: Databases.postgresql },
95+
}}
96+
onSubmit={jest.fn()}
97+
mutators={{ ...arrayMutators }}
98+
render={({ form }) => <NetworkAndSecurity form={form} />}
99+
/>
100+
);
101+
expect(screen.getByTestId('toggle-network-and-security')).toBeInTheDocument();
102+
const checkbox = screen.getByTestId('toggle-network-and-security');
103+
104+
fireEvent.click(checkbox);
105+
106+
expect(screen.queryByTestId('source-ranges')).not.toBeInTheDocument();
107+
});
77108
});

public/app/percona/dbaas/components/DBCluster/EditDBClusterPage/NetworkAndSecurity/NetworkAndSecurity.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export const NetworkAndSecurity: FC<NetworkAndSecurityProps> = ({ form }) => {
5151
{databaseType.value !== Databases.postgresql && (
5252
<FieldArray name={NetworkAndSecurityFields.sourceRanges}>
5353
{({ fields }) => (
54-
<div className={styles.fieldsWrapper}>
54+
<div className={styles.fieldsWrapper} data-testid="source-ranges">
5555
<Button
5656
className={styles.button}
5757
variant="secondary"

public/app/percona/dbaas/components/Kubernetes/KubernetesInventory.test.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ describe('KubernetesInventory::', () => {
3030
operators: {
3131
psmdb: { status: KubernetesOperatorStatus.ok, version: '1', availableVersion: '1' },
3232
pxc: { status: KubernetesOperatorStatus.ok, version: '1', availableVersion: '1' },
33+
pg: { status: KubernetesOperatorStatus.ok, version: '1', availableVersion: '1' },
3334
},
3435
},
3536
{
@@ -38,6 +39,7 @@ describe('KubernetesInventory::', () => {
3839
operators: {
3940
psmdb: { status: KubernetesOperatorStatus.ok, version: '1', availableVersion: '1' },
4041
pxc: { status: KubernetesOperatorStatus.ok, version: '1', availableVersion: '1' },
42+
pg: { status: KubernetesOperatorStatus.ok, version: '1', availableVersion: '1' },
4143
},
4244
},
4345
],

public/app/percona/dbaas/components/Kubernetes/OperatorStatusRow/OperatorStatusRow.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export const OperatorStatusRow: FC<OperatorStatusRowProps> = ({
5656
<div>
5757
{operators.map((item) => (
5858
<OperatorStatusItem
59-
key={`${item.operator}`}
59+
key={`${item.databaseType}-${element.kubernetesClusterName}-operator`}
6060
databaseType={item.databaseType}
6161
operator={item.operator}
6262
kubernetes={element}

0 commit comments

Comments
 (0)