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

Event cypress tests #611

Merged
merged 20 commits into from
Apr 5, 2022
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
2961e46
Bump prismjs from 1.25.0 to 1.27.0 in /dashboards-observability (#508…
opensearch-trigger-bot[bot] Mar 10, 2022
4afca56
change to support java 8 in compile and runtime (#575) (#576)
opensearch-trigger-bot[bot] Mar 11, 2022
c85b9ef
Add 1.3.0 release notes (#580) (#582)
opensearch-trigger-bot[bot] Mar 14, 2022
f1c410d
Merge branch '1.3' of github.com:opensearch-project/trace-analytics
mengweieric Mar 28, 2022
341dd53
cypress tests
mengweieric Mar 29, 2022
1ff675b
add stashed changes and resolve intermittent failed tests
mengweieric Mar 29, 2022
f0c5192
run tests and update snapshots
mengweieric Mar 29, 2022
82db8c1
Merge branch 'main' of github.com:opensearch-project/trace-analytics
mengweieric Mar 29, 2022
56ef7f8
merge main and resolve conflicts
mengweieric Mar 29, 2022
1a51a42
added one missed changes
mengweieric Mar 30, 2022
8543dd6
update snapshots after merging main
mengweieric Mar 30, 2022
c187725
added back one missing tests
mengweieric Mar 30, 2022
ebcf5d4
Merge branch 'main' of github.com:opensearch-project/trace-analytics
mengweieric Mar 30, 2022
902e956
Merge branch 'main' into event-cypress-tests
mengweieric Mar 30, 2022
f8ce665
merged main and run tests
mengweieric Mar 30, 2022
2dfd988
Merge branch 'main' of github.com:opensearch-project/trace-analytics
mengweieric Mar 31, 2022
389bf46
Merge branch 'main' into event-cypress-tests
mengweieric Mar 31, 2022
91e19a8
added snapshots
mengweieric Mar 31, 2022
9da1830
Merge branch 'main' of github.com:opensearch-project/trace-analytics
mengweieric Mar 31, 2022
c1b6a50
Merge branch 'main' into event-cypress-tests
mengweieric Mar 31, 2022
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
285 changes: 215 additions & 70 deletions dashboards-observability/.cypress/integration/event_analytics.spec.js

Large diffs are not rendered by default.

19 changes: 0 additions & 19 deletions dashboards-observability/.cypress/utils/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,25 +93,6 @@ export const PPL_QUERY_TEXT = `%ppl
source=opensearch_dashboards_sample_data_flights
`

// event analytics
export const TEST_QUERIES = [
{
query: 'source = opensearch_dashboards_sample_data_flights'
},
{
query: 'source = opensearch_dashboards_sample_data_flights | stats avg(FlightDelayMin) by Carrier'
},
{
query: 'source = opensearch_dashboards_sample_data_logs'
},
];

export const TESTING_PANEL = 'Mock Testing Panels';
export const SAVE_QUERY1 = 'Mock Flight Events Overview';
export const SAVE_QUERY2 = 'Mock Flight count by destination';
export const SAVE_QUERY3 = 'Mock Flight count by destination save to panel';
export const SAVE_QUERY4 = 'Mock Flight peek';

export const supressResizeObserverIssue = () => {
// exception is thrown on loading EuiDataGrid in cypress only, ignore for now
cy.on('uncaught:exception', (err, runnable) => {
Expand Down
71 changes: 71 additions & 0 deletions dashboards-observability/.cypress/utils/event_constants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import { supressResizeObserverIssue } from './constants'

export const delay = 1000;
export const YEAR_TO_DATE_DOM_ID = '[data-test-subj="superDatePickerCommonlyUsed_Year_to date"]'

export const TEST_QUERIES = [
{
query: 'source = opensearch_dashboards_sample_data_flights',
dateRangeDOM: YEAR_TO_DATE_DOM_ID
},
{
query: 'source = opensearch_dashboards_sample_data_flights | stats avg(FlightDelayMin) by Carrier'
},
{
query: 'source = opensearch_dashboards_sample_data_logs'
},
{
query: 'source = opensearch_dashboards_sample_data_logs | stats count() by host',
dateRangeDOM: YEAR_TO_DATE_DOM_ID
},
{
query: 'source = opensearch_dashboards_sample_data_logs | stats count(), avg(bytes) by host, tags',
dateRangeDOM: YEAR_TO_DATE_DOM_ID
},
];

export const TESTING_PANEL = 'Mock Testing Panels';
export const SAVE_QUERY1 = 'Mock Flight Events Overview';
export const SAVE_QUERY2 = 'Mock Flight count by destination';
export const SAVE_QUERY3 = 'Mock Flight count by destination save to panel';
export const SAVE_QUERY4 = 'Mock Flight peek';

export const querySearch = (query, rangeSelected) => {
cy.get('[data-test-subj="searchAutocompleteTextArea"]').type(query);
cy.get('[data-test-subj="superDatePickerToggleQuickMenuButton"]').click();
cy.get(rangeSelected).click();
cy.get('[data-test-subj="superDatePickerApplyTimeButton"]').contains('Refresh').click();
};

export const landOnEventHome = () => {
cy.visit(`${Cypress.env('opensearchDashboards')}/app/observability-dashboards#/event_analytics`);
cy.wait(delay);
};

export const landOnEventExplorer = () => {
cy.visit(
`${Cypress.env('opensearchDashboards')}/app/observability-dashboards#/event_analytics/explorer`
);
cy.wait(delay);
};

export const landOnEventVisualizations = () => {
cy.visit(
`${Cypress.env('opensearchDashboards')}/app/observability-dashboards#/event_analytics/explorer`
);
cy.get('button[id="main-content-vis"]').contains('Visualizations').click();
supressResizeObserverIssue();
cy.wait(delay);
};

export const landOnPanels = () => {
cy.visit(
`${Cypress.env('opensearchDashboards')}/app/observability-dashboards#/operational_panels`
);
cy.wait(delay);
};
5 changes: 5 additions & 0 deletions dashboards-observability/public/components/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ interface ObservabilityAppDeps {
timestampUtils: any;
}

// for cypress to test redux store
if (window.Cypress) {
window.store = store;
}

export const App = ({
CoreStartProp,
DepsStart,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export const FieldInsights = ({ field, query }: any) => {
}, [curReport, reportContent, field.name]);

return (
<EuiFlexGroup direction="column">
<EuiFlexGroup direction="column" data-test-subj="sidebarField__fieldInsights">
<EuiFlexItem grow={false}>
<EuiFlexGroup wrap>
{generalReports.map((report) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export function TimechartHeader({
})}
compressed
id="dscResultsIntervalSelector"
data-test-subj="discoverIntervalSelect"
data-test-subj="eventAnalytics__EventIntervalSelect"
options={options}
value={interval}
onChange={handleIntervalChange}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const ConfigValueOptions = ({
vizState,
handleConfigChange,
sectionName,
sectionId = 'valueOptions'
}: any) => {
const { data } = visualizations;
const { data: vizData = {}, metadata: { fields = [] } = {} } = data?.rawVizData;
Expand Down Expand Up @@ -55,7 +56,7 @@ export const ConfigValueOptions = ({
return (
<EuiAccordion
initialIsOpen
id={`configPanel__${sectionName}`}
id={`configPanel__${sectionId}`}
buttonContent={sectionName}
paddingSize="s"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export const VizDataPanel = ({ visualizations, onConfigChange, vizState = {}, ta
handleConfigChange={handleConfigEditing(section.mapTo)}
vizState={vizState[section.mapTo] || section.defaultState || {}}
sectionName={section.name}
sectionId={section.id}
/>
</EuiFormRow>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,9 @@ export const ConfigPanel = ({ visualizations, setCurVisId }: any) => {
gutterSize="none"
responsive={false}
>
<EuiFlexItem>
<EuiFlexItem
data-test-subj="configPane__vizTypeSelector"
>
<EuiSpacer size="s" />
<EuiComboBox
aria-label="config chart selector"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,4 +169,185 @@ exports[`Count distribution component Renders count distribution component with
</CountDistribution>
`;

exports[`Count distribution component Renders count distribution component with data 2`] = `
<CountDistribution
countDistribution={
Object {
"data": Object {
"count()": Array [
2549,
9337,
1173,
],
"span(timestamp,1M)": Array [
"2021-05-01 00:00:00",
"2021-06-01 00:00:00",
"2021-07-01 00:00:00",
],
},
"jsonData": Array [
Object {
"count()": 2549,
"span(timestamp,1M)": "2021-05-01 00:00:00",
},
Object {
"count()": 9337,
"span(timestamp,1M)": "2021-06-01 00:00:00",
},
Object {
"count()": 2549,
"span(timestamp,1M)": "2021-07-01 00:00:00",
},
],
"metadata": Object {
"fields": Array [
Object {
"name": "count()",
"type": "integer",
},
Object {
"name": "span(timestamp,1M)",
"type": "timestamp",
},
],
},
}
}
>
<Plt
data={
Array [
Object {
"name": Object {
"name": "count()",
"type": "integer",
},
"orientation": "v",
"type": "bar",
"x": Array [
"2021-05-01 00:00:00",
"2021-06-01 00:00:00",
"2021-07-01 00:00:00",
],
"y": Array [
2549,
9337,
1173,
],
},
]
}
layout={
Object {
"colorway": Array [
"#8C55A3",
],
"height": 220,
"margin": Object {
"b": 15,
"l": 60,
"pad": 0,
"r": 10,
"t": 30,
},
"showlegend": true,
}
}
>
<PlotlyComponent
config={
Object {
"displayModeBar": false,
}
}
data={
Array [
Object {
"name": Object {
"name": "count()",
"type": "integer",
},
"orientation": "v",
"type": "bar",
"x": Array [
"2021-05-01 00:00:00",
"2021-06-01 00:00:00",
"2021-07-01 00:00:00",
],
"y": Array [
2549,
9337,
1173,
],
},
]
}
debug={false}
layout={
Object {
"autosize": true,
"barmode": "stack",
"colorway": Array [
"#8C55A3",
],
"height": 220,
"hovermode": "closest",
"legend": Object {
"orientation": "h",
"traceorder": "normal",
},
"margin": Object {
"b": 15,
"l": 60,
"pad": 0,
"r": 10,
"t": 30,
},
"showlegend": true,
"xaxis": Object {
"automargin": true,
"autorange": true,
"range": Array [
"2021-04-16",
"2021-07-16",
],
"rangemode": "normal",
"showgrid": true,
"type": "date",
"zeroline": false,
},
"yaxis": Object {
"autorange": true,
"range": Array [
0,
9828.421052631578,
],
"rangemode": "normal",
"showgrid": true,
"type": "linear",
"zeroline": false,
},
}
}
style={
Object {
"height": "100%",
"width": "100%",
}
}
useResizeHandler={true}
>
<div
style={
Object {
"height": "100%",
"width": "100%",
}
}
/>
</PlotlyComponent>
</Plt>
</CountDistribution>
`;

exports[`Count distribution component Renders empty count distribution component 1`] = `<CountDistribution />`;
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ exports[`Shared components Renders empty placeholder component 1`] = `
<EuiText
className="lnsChart__empty"
color="subdued"
data-test-subj="vizWorkspace__noData"
size="xs"
textAlign="center"
>
<div
className="euiText euiText--extraSmall lnsChart__empty"
data-test-subj="vizWorkspace__noData"
>
<EuiTextAlign
textAlign="center"
Expand Down Expand Up @@ -71,7 +73,7 @@ exports[`Shared components Renders empty placeholder component 1`] = `
<p>
<FormattedMessage
defaultMessage="No results found"
id="xpack.lens.xyVisualization.noDataLabel"
id="visualization_noData"
values={Object {}}
>
<span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import { FormattedMessage } from '@osd/i18n/react';

export const EmptyPlaceholder = (props: {icon: string}) => (
<>
<EuiText className="lnsChart__empty" textAlign="center" color="subdued" size="xs">
<EuiText className="lnsChart__empty" textAlign="center" color="subdued" size="xs" data-test-subj="vizWorkspace__noData">
<EuiIcon type={props.icon} color="subdued" size="l" />
<EuiSpacer size="s" />
<p>
<FormattedMessage
id="xpack.lens.xyVisualization.noDataLabel"
id="visualization_noData"
defaultMessage="No results found"
/>
</p>
Expand Down
Loading