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

Updates to workflow, unit tests, and some appearance #114

Merged
merged 2 commits into from
Sep 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions .github/workflows/cypress-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
with:
repository: opensearch-project/OpenSearch
path: OpenSearch
ref: '1.x'
ref: '1.1'
- name: Build OpenSearch
working-directory: ./OpenSearch
run: ./gradlew publishToMavenLocal
Expand All @@ -40,7 +40,7 @@ jobs:
with:
repository: opensearch-project/common-utils
path: common-utils
ref: 'main'
ref: '1.1'
- name: Build common-utils
working-directory: ./common-utils
run: ./gradlew publishToMavenLocal -Dopensearch.version=${{ env.OPENSEARCH_VERSION }}
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/unit-tests-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,6 @@ jobs:
- name: Run tests
run: |
cd OpenSearch-Dashboards/plugins/alerting-dashboards-plugin
yarn run test:jest
yarn run test:jest --coverage
- name: Uploads coverage
uses: codecov/codecov-action@v1
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
[![Unit tests](https://github.com/opensearch-project/alerting-dashboards-plugin/workflows/Unit%20tests%20workflow/badge.svg)](https://github.com/opensearch-project/alerting-dashboards-plugin/actions?query=workflow%3A%22Unit+tests+workflow%22)
[![Integration tests](https://github.com/opensearch-project/alerting-dashboards-plugin/workflows/E2E%20Cypress%20tests/badge.svg)](https://github.com/opensearch-project/alerting-dashboards-plugin/actions?query=workflow%3A%22E2E+Cypress+tests%22)
[![codecov](https://codecov.io/gh/opensearch-project/alerting-dashboards-plugin/branch/main/graph/badge.svg)](https://codecov.io/gh/opensearch-project/alerting-dashboards-plugin)
[![Documentation](https://img.shields.io/badge/doc-reference-blue)](https://opensearch.org/docs/monitoring-plugins/alerting/index/)
[![Forum](https://img.shields.io/badge/chat-on%20forums-blue)](https://discuss.opendistrocommunity.dev/c/Use-this-category-for-all-questions-around-machine-learning-plugins)
![PRs welcome!](https://img.shields.io/badge/PRs-welcome!-success)

<img src="https://opensearch.org/assets/brand/SVG/Logo/opensearch_logo_default.svg" height="64px"/>

- [OpenSearch Alerting Dashboards](#opensearch-alerting-dashboards)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Object {
exports[`getBreadcrumb returns correct constant breadcrumbs 3`] = `
Object {
"href": "/dashboard",
"text": "Dashboard",
"text": "Alerts",
}
`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ exports[`ContentPanel renders 1`] = `
</div>
</div>
</div>
<div
class="euiText euiText--extraSmall"
style="padding:0px 10px"
>
<div
class="euiTextColor euiTextColor--subdued"
/>
</div>
<hr
class="euiHorizontalRule euiHorizontalRule--full euiHorizontalRule--marginXSmall"
/>
Expand Down
1 change: 1 addition & 0 deletions public/components/Flyout/__snapshots__/Flyout.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ exports[`Flyout renders 1`] = `
<ul>
<li>
<EuiLink
external={true}
href="https://mustache.github.io/mustache.5.html"
target="_blank"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Object {
<ul>
<li>
<EuiLink
external={true}
href="https://mustache.github.io/mustache.5.html"
target="_blank"
>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/

import React from 'react';
import { render } from 'enzyme';
import { Formik } from 'formik';

import FormikCheckableCard from './FormikCheckableCard';

describe('FormikCheckableCard', () => {
test('render formRow', () => {
const component = (
<Formik>
<FormikCheckableCard name="testing" formRow />
</Formik>
);

expect(render(component)).toMatchSnapshot();
});

test('render', () => {
const component = (
<Formik>
<FormikCheckableCard name="testing" />
</Formik>
);

expect(render(component)).toMatchSnapshot();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`FormikCheckableCard render 1`] = `
<div
class="euiCheckableCard"
>
<div
class="euiCheckableCard__row"
>
<div
class="euiCheckableCard__control"
>
<div
class="euiRadio euiRadio--noLabel"
>
<input
class="euiRadio__input"
name="testing"
type="radio"
/>
<div
class="euiRadio__circle"
/>
</div>
</div>
<label
class="euiCheckableCard__label"
/>
</div>
</div>
`;

exports[`FormikCheckableCard render formRow 1`] = `
<div
class="euiFormRow"
id="testing-form-row-row"
>
<div
class="euiFormRow__fieldWrapper"
>
<div
class="euiCheckableCard"
>
<div
class="euiCheckableCard__row"
>
<div
class="euiCheckableCard__control"
>
<div
class="euiRadio euiRadio--noLabel"
>
<input
class="euiRadio__input"
name="testing"
type="radio"
/>
<div
class="euiRadio__circle"
/>
</div>
</div>
<label
class="euiCheckableCard__label"
/>
</div>
</div>
</div>
</div>
`;
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,20 @@ import { render } from 'enzyme';
import { Formik } from 'formik';

import FormikCodeEditor from './FormikCodeEditor';
import FormikCheckableCard from '../FormikCheckableCard';

// FIXME: This has an issue where EuiCodeEditor is generating a random HTML id and failing snapshot test

describe.skip('FormikCodeEditor', () => {
describe('FormikCodeEditor', () => {
test('render formRow', () => {
const component = (
<Formik>
<FormikCodeEditor name="testing" formRow />
</Formik>
);

expect(render(component)).toMatchSnapshot();
});
test('renders', () => {
const component = (
<Formik>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`FormikCodeEditor render formRow 1`] = `
<div
class="euiFormRow"
id="testing-form-row-row"
>
<div
class="euiFormRow__fieldWrapper"
>
<div
class="euiCodeEditorWrapper"
data-test-subj="codeEditorContainer"
>
<div
class="euiCodeEditorKeyboardHint"
data-test-subj="codeEditorHint"
id="generated-id"
role="button"
tabindex="0"
>
<p
class="euiText"
>
Press Enter to start editing.
</p>
<p
class="euiText"
>
When you're done, press Escape to stop editing.
</p>
</div>
<div
id="generated-id"
style="width:500px;height:500px"
/>
</div>
</div>
</div>
`;

exports[`FormikCodeEditor renders 1`] = `
<div
class="euiCodeEditorWrapper"
data-test-subj="codeEditorContainer"
>
<div
class="euiCodeEditorKeyboardHint"
data-test-subj="codeEditorHint"
id="generated-id"
role="button"
tabindex="0"
>
<p
class="euiText"
>
Press Enter to start editing.
</p>
<p
class="euiText"
>
When you're done, press Escape to stop editing.
</p>
</div>
<div
id="generated-id"
style="width:500px;height:500px"
/>
</div>
`;
22 changes: 22 additions & 0 deletions public/components/IconToolTip/IconToolTip.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/

import React from 'react';
import { render } from 'enzyme';

import IconToolTip from './IconToolTip';

describe('IconToolTip', () => {
test('renders', () => {
const component = <IconToolTip iconType="questionInCircle" content="test content" />;
expect(render(component)).toMatchSnapshot();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`IconToolTip renders 1`] = `
<span
class="euiToolTipAnchor"
>
<div>
EuiIconMock
</div>
</span>
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
* Modifications Copyright OpenSearch Contributors. See
* GitHub history for details.
*/

import React from 'react';
import { mount, render } from 'enzyme';
import { FeatureChart } from './FeatureChart';
import AlertingFakes from '../../../../../../test/utils/helpers';

const alertingFakes = new AlertingFakes('random seed');

function getMountWrapper(customProps = {}) {
return mount(
<FeatureChart
startDateTime={alertingFakes.randomTime()}
endDateTime={alertingFakes.randomTime()}
featureData={[]}
isLoading={false}
title="Test"
/>
);
}

describe('FeatureChart', () => {
test('renders ', () => {
const component = (
<FeatureChart
startDateTime={alertingFakes.randomTime()}
endDateTime={alertingFakes.randomTime()}
featureData={[]}
isLoading={false}
title="Test"
/>
);
expect(render(component)).toMatchSnapshot();
});

test('go to page ', () => {
const mountWrapper = getMountWrapper();
mountWrapper.instance().goToPage(1);
expect(mountWrapper.instance().state.activePage).toBe(1);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`FeatureChart renders 1`] = `null`;
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,16 @@ import React from 'react';
import { render } from 'enzyme';

import ExtractionQuery from './ExtractionQuery';
import { Formik } from 'formik';
import { FORMIK_INITIAL_VALUES } from '../../containers/CreateMonitor/utils/constants';

describe.skip('ExtractionQuery', () => {
describe('ExtractionQuery', () => {
test('renders', () => {
const component = <ExtractionQuery response={JSON.stringify({ hits: 10 })} />;
const component = (
<Formik initialValues={FORMIK_INITIAL_VALUES}>
{() => <ExtractionQuery response={JSON.stringify({ hits: 10 })} />}
</Formik>
);

expect(render(component)).toMatchSnapshot();
});
Expand Down
Loading