Skip to content

Commit

Permalink
Unit tests for public components (opensearch-project#383)
Browse files Browse the repository at this point in the history
* [FEATURE] Detector must have at least one alert set opensearch-project#288

Signed-off-by: Jovan Cvetkovic <[email protected]>

* [BUG] Create detector | Interval field can be empty opensearch-project#378

Signed-off-by: Jovan Cvetkovic <[email protected]>

* Adjust styling for Finding details flyout opensearch-project#369

Signed-off-by: Jovan Cvetkovic <[email protected]>

* unit tests

Signed-off-by: Jovan Cvetkovic <[email protected]>

* detector unit tests

Signed-off-by: Jovan Cvetkovic <[email protected]>

* detector unit tests

Signed-off-by: Jovan Cvetkovic <[email protected]>

* detector unit tests

Signed-off-by: Jovan Cvetkovic <[email protected]>

* detector unit tests

Signed-off-by: Jovan Cvetkovic <[email protected]>

* detector unit tests

Signed-off-by: Jovan Cvetkovic <[email protected]>

* detector unit tests

Signed-off-by: Jovan Cvetkovic <[email protected]>

* detector unit tests

Signed-off-by: Jovan Cvetkovic <[email protected]>

* detector unit tests

Signed-off-by: Jovan Cvetkovic <[email protected]>

* detector unit tests

Signed-off-by: Jovan Cvetkovic <[email protected]>

* unit tests review

Signed-off-by: Jovan Cvetkovic <[email protected]>

* unit tests review

Signed-off-by: Jovan Cvetkovic <[email protected]>

* unit tests review

Signed-off-by: Jovan Cvetkovic <[email protected]>

* unit tests review

Signed-off-by: Jovan Cvetkovic <[email protected]>

* unit tests review

Signed-off-by: Jovan Cvetkovic <[email protected]>

* unit tests review

Signed-off-by: Jovan Cvetkovic <[email protected]>

* unit tests review

Signed-off-by: Jovan Cvetkovic <[email protected]>

* unit tests review

Signed-off-by: Jovan Cvetkovic <[email protected]>

* Feature/update vertical domain opensearch-project#372

Signed-off-by: Jovan Cvetkovic <[email protected]>

* Unit tests for public components opensearch-project#383

Signed-off-by: Jovan Cvetkovic <[email protected]>

* Unit tests for public components opensearch-project#383

Signed-off-by: Jovan Cvetkovic <[email protected]>

* Unit tests for public components opensearch-project#383

Signed-off-by: Jovan Cvetkovic <[email protected]>

* Unit tests for public components opensearch-project#383

Signed-off-by: Jovan Cvetkovic <[email protected]>

* Unit tests for public components opensearch-project#383
[BUG] Detector Edit | Custom rule are not selected on update rules opensearch-project#406

Signed-off-by: Jovan Cvetkovic <[email protected]>

* Unit tests for public components opensearch-project#383
[BUG] Detector Edit | Custom rule are not selected on update rules opensearch-project#406

Signed-off-by: Jovan Cvetkovic <[email protected]>

* PR code review

Signed-off-by: Jovan Cvetkovic <[email protected]>

* PR code review

Signed-off-by: Jovan Cvetkovic <[email protected]>

---------

Signed-off-by: Jovan Cvetkovic <[email protected]>
  • Loading branch information
jovancvetkovic3006 authored Feb 17, 2023
1 parent c19107e commit 0150c89
Show file tree
Hide file tree
Showing 94 changed files with 29,859 additions and 111 deletions.
2 changes: 1 addition & 1 deletion models/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export interface Rule {

export interface Detector {
id?: string;
type: 'detector';
type: string;
detector_type: string;
name: string;
enabled: boolean;
Expand Down
1 change: 1 addition & 0 deletions public/components/DeleteModal/DeleteModal.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ describe('<DeleteModal /> spec', () => {
type={'some type'}
/>
);

expect(tree).toMatchSnapshot();
});
});
1 change: 1 addition & 0 deletions public/components/FormFieldHeader/FormFieldHeader.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { FormFieldHeader } from './FormFieldHeader';
describe('<FormFieldHeader /> spec', () => {
it('renders the component', () => {
const tree = render(<FormFieldHeader headerTitle={'some title'} />);

expect(tree).toMatchSnapshot();
});
});
8 changes: 4 additions & 4 deletions public/components/Modal/Modal.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ import { EuiButton, EuiOverlayMask, EuiModal } from '@elastic/eui';
import { render, fireEvent } from '@testing-library/react';
import ModalRoot from './ModalRoot';
import { ModalConsumer, ModalProvider } from './Modal';
import { ServicesConsumer, ServicesContext } from '../../services/Services';
import { browserServicesMock } from '../../../test/mocks';
import { ServicesConsumer, ServicesContext } from '../../services';
import services from '../../../test/mocks/services';

describe('<ModalRoot /> spec', () => {
it('renders nothing when not used', () => {
const { container } = render(
<ServicesContext.Provider value={browserServicesMock}>
<ServicesContext.Provider value={services}>
<ModalProvider>
<ServicesConsumer>
{(services) => services && <ModalRoot services={services} />}
Expand All @@ -34,7 +34,7 @@ describe('<ModalRoot /> spec', () => {
);
const { queryByText, getByTestId, getByLabelText } = render(
<div>
<ServicesContext.Provider value={browserServicesMock}>
<ServicesContext.Provider value={services}>
<ModalProvider>
<ServicesConsumer>
{(services) => services && <ModalRoot services={services} />}
Expand Down
16 changes: 16 additions & 0 deletions public/pages/Alerts/components/AlertFlyout/AlertFlyout.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import React from 'react';
import { render } from '@testing-library/react';
import { AlertFlyout } from './AlertFlyout';
import alertFlyoutMock from '../../../../../test/mocks/Alerts/components/AlertFlyout/AlertFlyout.mock';

describe('<AlertFlyout /> spec', () => {
it('renders the component', () => {
const { container } = render(<AlertFlyout {...alertFlyoutMock} />);
expect(container).toMatchSnapshot();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`<AlertFlyout /> spec renders the component 1`] = `
<div
aria-hidden="true"
data-aria-hidden="true"
/>
`;
28 changes: 28 additions & 0 deletions public/pages/Alerts/containers/Alerts/Alerts.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import React from 'react';
import Alerts from './Alerts';
import contextMock from '../../../../../test/mocks/useContext.mock';
import { mount } from 'enzyme';
import alertsMock from '../../../../../test/mocks/Alerts/Alerts.mock';
import { shallowToJson } from 'enzyme-to-json';
import { Router } from 'react-router-dom';
import browserHistoryMock from '../../../../../test/mocks/services/browserHistory.mock';

describe('<Alerts /> spec', () => {
it('renders the component', () => {
Alerts.WrappedComponent.contextType = contextMock;
const wrapper = mount(
<Router history={browserHistoryMock}>
<Alerts {...alertsMock} />
</Router>,
{
context: contextMock,
}
);
expect(shallowToJson(wrapper.root().children())).toMatchSnapshot();
});
});
2 changes: 1 addition & 1 deletion public/pages/Alerts/containers/Alerts/Alerts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ const groupByOptions = [
{ text: 'Alert severity', value: 'severity' },
];

class Alerts extends Component<AlertsProps, AlertsState> {
export class Alerts extends Component<AlertsProps, AlertsState> {
static contextType = CoreServicesContext;

constructor(props: AlertsProps) {
Expand Down
Loading

0 comments on commit 0150c89

Please sign in to comment.