Skip to content

Commit

Permalink
Merge branch 'featureAnywhere' into bugbash
Browse files Browse the repository at this point in the history
Signed-off-by: Jackie Han <hnyng@amazon.com>
  • Loading branch information
jackiehanyang authored Jun 8, 2023
2 parents b8af76e + 7cd38cf commit 12f25c4
Show file tree
Hide file tree
Showing 19 changed files with 725 additions and 134 deletions.
3 changes: 1 addition & 2 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
# This should match the owning team set up in https://github.com/orgs/opensearch-project/teams
* @opensearch-project/anomaly-detection
* @ohltyler @kaituo @jackiehanyang @amitgalitz @sean-zheng-amazon
15 changes: 12 additions & 3 deletions MAINTAINERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,18 @@ This document contains a list of maintainers in this repo. See [opensearch-proje

## Current Maintainers

| Maintainer | GitHub ID | Affiliation |
| ----------------------- | ------------------------------------------------------- | ----------- |
| Tyler Ohlsen | [ohltyler](https://github.com/ohltyler) | Amazon |
| Maintainer | GitHub ID | Affiliation |
| ----------------------- | -------------------------------------------------------- | ----------- |
| Tyler Ohlsen | [ohltyler](https://github.com/ohltyler) | Amazon |
| Kaituo Li | [kaituo](https://github.com/kaituo) | Amazon |
| Jackie Han | [jackiehanyang](https://github.com/jackiehanyang) | Amazon |
| Amit Galitzky | [amitgalitz](https://github.com/amitgalitz) | Amazon |
| Sean Zheng | [sean-zheng-amazon](https://github.com/sean-zheng-amazon)| Amazon |

## Emeritus Maintainers

| Maintainer | GitHub ID | Affiliation |
| ----------------- | ------------------------------------------------------- | ----------- |
| Yaliang | [ylwu-amzn](https://github.com/ylwu-amzn) | Amazon |
| Yizhe Liu | [yizheliu-amazon](https://github.com/yizheliu-amazon) | Amazon |
| Vijayan Balasubramanian | [VijayanB](https://github.com/VijayanB) | Amazon |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const ConfirmUnlinkDetectorModal = (
return (
<EuiOverlayMask>
<EuiModal
data-test-subj="startDetectorsModal"
data-test-subj="unlinkDetectorsModal"
onClose={props.onHide}
maxWidth={450}
>
Expand All @@ -52,14 +52,14 @@ export const ConfirmUnlinkDetectorModal = (
<EuiModalFooter>
{isLoading ? null : (
<EuiButtonEmpty
data-test-subj="cancelButton"
data-test-subj="cancelUnlinkButton"
onClick={props.onHide}
>
Cancel
</EuiButtonEmpty>
)}
<EuiButton
data-test-subj="confirmButton"
data-test-subj="confirmUnlinkButton"
color="primary"
fill
isLoading={isLoading}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import React from 'react';
import { findAllByTestId, render, waitFor } from '@testing-library/react';
import { ConfirmUnlinkDetectorModal } from '../index';
import { getRandomDetector } from '../../../../../../public/redux/reducers/__tests__/utils';
import { DetectorListItem } from '../../../../../../public/models/interfaces';
import userEvent from '@testing-library/user-event';

describe('ConfirmUnlinkDetectorModal spec', () => {
beforeEach(() => {
jest.clearAllMocks();
});

const testDetectors = [
{
id: 'detectorId1',
name: 'test-detector-1',
},
{
id: 'detectorId2',
name: 'test-detector-2',
},
] as DetectorListItem[];

const ConfirmUnlinkDetectorModalProps = {
detector: testDetectors[0],
onHide: jest.fn(),
onConfirm: jest.fn(),
onUnlinkDetector: jest.fn(),
isListLoading: false,
};

test('renders the component correctly', () => {
const { container, getByText } = render(
<ConfirmUnlinkDetectorModal {...ConfirmUnlinkDetectorModalProps} />
);
getByText('Remove association?');
getByText(
'Removing association unlinks test-detector-1 detector from the visualization but does not delete it. The detector association can be restored.'
);
});
test('should call onConfirm() when closing', async () => {
const { container, getByText, getByTestId } = render(
<ConfirmUnlinkDetectorModal {...ConfirmUnlinkDetectorModalProps} />
);
getByText('Remove association?');
userEvent.click(getByTestId('confirmUnlinkButton'));
expect(ConfirmUnlinkDetectorModalProps.onConfirm).toHaveBeenCalled();
});
test('should call onConfirm() when closing', async () => {
const { container, getByText, getByTestId } = render(
<ConfirmUnlinkDetectorModal {...ConfirmUnlinkDetectorModalProps} />
);
getByText('Remove association?');
userEvent.click(getByTestId('confirmUnlinkButton'));
expect(ConfirmUnlinkDetectorModalProps.onConfirm).toHaveBeenCalled();
});
test('should call onHide() when closing', async () => {
const { getByTestId } = render(
<ConfirmUnlinkDetectorModal {...ConfirmUnlinkDetectorModalProps} />
);
userEvent.click(getByTestId('cancelUnlinkButton'));
expect(ConfirmUnlinkDetectorModalProps.onHide).toHaveBeenCalled();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import React from 'react';
import { findAllByTestId, render, waitFor } from '@testing-library/react';
import { EmptyAssociatedDetectorMessage } from '../index';
import { getRandomDetector } from '../../../../../../public/redux/reducers/__tests__/utils';
import { DetectorListItem } from '../../../../../../public/models/interfaces';
import userEvent from '@testing-library/user-event';

describe('ConfirmUnlinkDetectorModal spec', () => {
beforeEach(() => {
jest.clearAllMocks();
});

test('renders the component with filter applied', () => {
const { container, getByText } = render(
<EmptyAssociatedDetectorMessage
isFilterApplied={true}
embeddableTitle="test-title"
/>
);
getByText('There are no detectors matching your search');
expect(container).toMatchSnapshot();
});
test('renders the component with filter applied', () => {
const { container, getByText } = render(
<EmptyAssociatedDetectorMessage
isFilterApplied={false}
embeddableTitle="test-title"
/>
);
getByText(
'There are no anomaly detectors associated with test-title visualization.'
);
expect(container).toMatchSnapshot();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`ConfirmUnlinkDetectorModal spec renders the component with filter applied 1`] = `
<div>
<div
class="euiEmptyPrompt"
data-test-subj="emptyAssociatedDetectorFlyoutMessage"
style="max-width: 45em;"
>
<h3
class="euiTitle euiTitle--small"
>
No anomaly detectors to display
</h3>
<span
class="euiTextColor euiTextColor--subdued"
>
<div
class="euiSpacer euiSpacer--m"
/>
<div
class="euiText euiText--medium"
>
<div
class="euiText euiText--medium"
>
<p>
There are no detectors matching your search
</p>
</div>
</div>
</span>
</div>
</div>
`;

exports[`ConfirmUnlinkDetectorModal spec renders the component with filter applied 2`] = `
<div>
<div
class="euiEmptyPrompt"
data-test-subj="emptyAssociatedDetectorFlyoutMessage"
style="max-width: 45em;"
>
<h3
class="euiTitle euiTitle--small"
>
No anomaly detectors to display
</h3>
<span
class="euiTextColor euiTextColor--subdued"
>
<div
class="euiSpacer euiSpacer--m"
/>
<div
class="euiText euiText--medium"
>
<div
class="euiText euiText--medium"
>
<p>
There are no anomaly detectors associated with test-title visualization.
</p>
</div>
</div>
</span>
</div>
</div>
`;
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import {
prettifyErrorMessage,
NO_PERMISSIONS_KEY_WORD,
} from '../../../../../server/utils/helpers';
import { SavedObjectLoader } from '../../../../../../../src/plugins/saved_objects/public';
import {
EmptyAssociatedDetectorMessage,
ConfirmUnlinkDetectorModal,
Expand Down Expand Up @@ -138,9 +137,6 @@ function AssociatedDetectors({ embeddable, closeFlyout, setMode }) {
getAugmentVisSavedObjs(embeddable.vis.id, savedObjectLoader, uiSettings)
.then((savedAugmentObjectsArr: any) => {
if (savedAugmentObjectsArr != undefined) {
console.log(
'savedAugmentObjectsArr: ' + JSON.stringify(savedAugmentObjectsArr)
);
const curSelectedDetectors = getAssociatedDetectors(
Object.values(allDetectors),
savedAugmentObjectsArr
Expand Down Expand Up @@ -287,7 +283,7 @@ function AssociatedDetectors({ embeddable, closeFlyout, setMode }) {
<div className="associated-detectors">
<EuiFlyout ownFocus size="m" paddingSize="m" onClose={closeFlyout}>
<EuiFlyoutHeader hasBorder>
<EuiTitle size="s">
<EuiTitle>
<h2 id="associated-detectors__title">
Associated anomaly detectors
</h2>
Expand All @@ -306,7 +302,7 @@ function AssociatedDetectors({ embeddable, closeFlyout, setMode }) {
<EuiFlexGroup alignItems="center">
<EuiFlexItem component="span">
<EuiTitle size="xxs">
<h3>{embeddableTitle}</h3>
<h3>Visualization: {embeddableTitle}</h3>
</EuiTitle>
</EuiFlexItem>
<EuiFlexItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,8 @@
&__flex-group {
height: 100%;
}

&__associate-button {
flex: 0 0 auto;
}
}
Loading

0 comments on commit 12f25c4

Please sign in to comment.