Skip to content

Commit

Permalink
Update jest unit tests (opensearch-project#112)
Browse files Browse the repository at this point in the history
* Update .opensearch_dashboards-plugin-helpers.json

* Update snapshots

* Update whereExpression.test and some snapshots

* Update whereExpression.test and some snapshots

Signed-off-by: Annie Lee <leeyun@amazon.com>

* Update snapshots

* Update formikToTrigger.test.js

* Update formikToTrigger.test.js

* Update formikToTrigger.test.js

* Add icon tooltip

* Add test

* Update tests

* remove license

* Update TriggerExpressions.test.js

* Update Triggers.test.js

* Update validation test

* Update getOverviewStats.test.js

* Update validate.test.js

* Update helpers.test.js and remove unused import

* Update Triggers.test.js

* Update helpers.js

* Update CreateMonitor test and clean up code

* Update CreateMonitor test and clean up code

Signed-off-by: Annie Lee <leeyun@amazon.com>

* Update release note and adding more tests

* Add test and modify cypress common-utils branch

* Update MonitorDefinitionCard.test.js.snap

* Update cypress-workflow.yml

Signed-off-by: Annie Lee <leeyun@amazon.com>
  • Loading branch information
annie3431 authored and Annie Lee committed Sep 15, 2021
1 parent ed1fedb commit d6a44c6
Show file tree
Hide file tree
Showing 60 changed files with 2,779 additions and 990 deletions.
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
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

0 comments on commit d6a44c6

Please sign in to comment.