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

Unit test #88

Merged
merged 10 commits into from
Nov 8, 2022
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
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
},
"dependencies": {},
"devDependencies": {
"@types/enzyme-adapter-react-16": "^1.0.6",
"cypress": "9.5.4",
"eslint": "^6.8.0"
}
Expand Down
4,640 changes: 4,640 additions & 0 deletions public/components/common/__test__/__snapshots__/flyout.test.tsx.snap

Large diffs are not rendered by default.

261 changes: 261 additions & 0 deletions public/components/common/__test__/__snapshots__/header.test.tsx.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,261 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Header component Renders header component 1`] = `
<Header>
<EuiPanel
borderRadius="none"
grow={false}
hasBorder={false}
hasShadow={false}
style={
Object {
"borderBottom": "1px solid #D3DAE6",
}
}
>
<div
className="euiPanel euiPanel--paddingMedium euiPanel--borderRadiusNone euiPanel--plain euiPanel--noShadow euiPanel--noBorder euiPanel--flexGrowZero"
style={
Object {
"borderBottom": "1px solid #D3DAE6",
}
}
>
<EuiPageHeader
pageTitle="Compare search results"
>
<header
className="euiPageHeader euiPageHeader--responsive euiPageHeader--center"
>
<EuiPageHeaderContent
pageTitle="Compare search results"
responsive={true}
>
<div
className="euiPageHeaderContent"
>
<EuiFlexGroup
alignItems="flexStart"
className="euiPageHeaderContent__top"
gutterSize="l"
responsive={true}
>
<div
className="euiFlexGroup euiFlexGroup--gutterLarge euiFlexGroup--alignItemsFlexStart euiFlexGroup--directionRow euiFlexGroup--responsive euiPageHeaderContent__top"
>
<EuiFlexItem>
<div
className="euiFlexItem"
>
<EuiTitle
size="l"
>
<h1
className="euiTitle euiTitle--large"
>
Compare search results
</h1>
</EuiTitle>
</div>
</EuiFlexItem>
</div>
</EuiFlexGroup>
<div
className="euiPageHeaderContent__bottom"
>
<EuiSpacer>
<div
className="euiSpacer euiSpacer--l"
/>
</EuiSpacer>
<EuiCallOut
iconType="iInCircle"
title="Experimental Feature"
>
<div
className="euiCallOut euiCallOut--primary"
>
<div
className="euiCallOutHeader"
>
<EuiIcon
aria-hidden="true"
className="euiCallOutHeader__icon"
color="inherit"
size="m"
type="iInCircle"
>
<EuiIconEmpty
aria-hidden={true}
className="euiIcon euiIcon--medium euiIcon--inherit euiIcon-isLoading euiCallOutHeader__icon"
focusable="false"
role="img"
style={null}
>
<svg
aria-hidden={true}
className="euiIcon euiIcon--medium euiIcon--inherit euiIcon-isLoading euiCallOutHeader__icon"
focusable="false"
height={16}
role="img"
style={null}
viewBox="0 0 16 16"
width={16}
xmlns="http://www.w3.org/2000/svg"
/>
</EuiIconEmpty>
</EuiIcon>
<span
className="euiCallOutHeader__title"
>
Experimental Feature
</span>
</div>
<EuiText
color="default"
size="s"
>
<div
className="euiText euiText--small"
>
<EuiTextColor
color="default"
component="div"
>
<div
className="euiTextColor euiTextColor--default"
>
<EuiText>
<div
className="euiText euiText--medium"
>
<p>
Compare results using the same search text with different queries. For more information, see the

<EuiLink
href="https://opensearch.org/docs/latest/search-plugins/search-relevance"
target="_blank"
>
<a
className="euiLink euiLink--primary"
href="https://opensearch.org/docs/latest/search-plugins/search-relevance"
rel="noopener noreferrer"
target="_blank"
>
Compare Search Results Documentation
<EuiIcon
aria-label="External link"
className="euiLink__externalIcon"
size="s"
type="popout"
>
<EuiIconEmpty
aria-hidden={true}
aria-label="External link"
className="euiIcon euiIcon--small euiIcon-isLoading euiLink__externalIcon"
focusable="false"
role="img"
style={null}
>
<svg
aria-hidden={true}
aria-label="External link"
className="euiIcon euiIcon--small euiIcon-isLoading euiLink__externalIcon"
focusable="false"
height={16}
role="img"
style={null}
viewBox="0 0 16 16"
width={16}
xmlns="http://www.w3.org/2000/svg"
/>
</EuiIconEmpty>
</EuiIcon>
<EuiScreenReaderOnly>
<span
className="euiScreenReaderOnly"
>
<EuiI18n
default="(opens in a new tab or window)"
token="euiLink.newTarget.screenReaderOnlyText"
>
(opens in a new tab or window)
</EuiI18n>
</span>
</EuiScreenReaderOnly>
</a>
</EuiLink>
. To leave feedback, visit

<EuiLink
href="https://forum.opensearch.org/t/feedback-experimental-feature-compare-search-results/11331"
target="_blank"
>
<a
className="euiLink euiLink--primary"
href="https://forum.opensearch.org/t/feedback-experimental-feature-compare-search-results/11331"
rel="noopener noreferrer"
target="_blank"
>
forums.opensearch.com
<EuiIcon
aria-label="External link"
className="euiLink__externalIcon"
size="s"
type="popout"
>
<EuiIconEmpty
aria-hidden={true}
aria-label="External link"
className="euiIcon euiIcon--small euiIcon-isLoading euiLink__externalIcon"
focusable="false"
role="img"
style={null}
>
<svg
aria-hidden={true}
aria-label="External link"
className="euiIcon euiIcon--small euiIcon-isLoading euiLink__externalIcon"
focusable="false"
height={16}
role="img"
style={null}
viewBox="0 0 16 16"
width={16}
xmlns="http://www.w3.org/2000/svg"
/>
</EuiIconEmpty>
</EuiIcon>
<EuiScreenReaderOnly>
<span
className="euiScreenReaderOnly"
>
<EuiI18n
default="(opens in a new tab or window)"
token="euiLink.newTarget.screenReaderOnlyText"
>
(opens in a new tab or window)
</EuiI18n>
</span>
</EuiScreenReaderOnly>
</a>
</EuiLink>
.
</p>
</div>
</EuiText>
</div>
</EuiTextColor>
</div>
</EuiText>
</div>
</EuiCallOut>
</div>
</div>
</EuiPageHeaderContent>
</header>
</EuiPageHeader>
</div>
</EuiPanel>
</Header>
`;
29 changes: 29 additions & 0 deletions public/components/common/__test__/flyout.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import { configure, mount } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import React from 'react';
import { waitFor } from '@testing-library/react';
import { Flyout } from '../flyout';
import { SearchRelevanceContextProvider } from '../../../contexts';

describe('Flyout component', () => {
configure({ adapter: new Adapter() });

it('Renders flyout component', async () => {
const wrapper = mount(
<SearchRelevanceContextProvider>
<Flyout />
</SearchRelevanceContextProvider>
);

wrapper.update();

await waitFor(() => {
expect(wrapper).toMatchSnapshot();
});
});
});
24 changes: 24 additions & 0 deletions public/components/common/__test__/header.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import { configure, mount } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import React from 'react';
import { waitFor } from '@testing-library/react';
import { Header } from '../header';

describe('Header component', () => {
configure({ adapter: new Adapter() });

it('Renders header component', async () => {
const wrapper = mount(<Header />);

wrapper.update();

await waitFor(() => {
expect(wrapper).toMatchSnapshot();
});
});
});
Loading