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 all 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
279 changes: 220 additions & 59 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 @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ interface IWorkSpacePanel {
export function WorkspacePanel({ visualizations }: IWorkSpacePanel) {
const [isTableViewOn, setIsTableViewOn] = useState(false);
const VisualizationPanel = useMemo(() => {
return <Visualization visualizations={visualizations} />;
return <Visualization visualizations={visualizations} data-test-subj="workspace__visualizations" />;
}, [visualizations]);

return (
Expand Down Expand Up @@ -55,6 +55,7 @@ export function WorkspacePanel({ visualizations }: IWorkSpacePanel) {
setIsTableViewOn((staleState) => !staleState);
}}
aria-describedby="table view switcher"
data-test-subj="workspace__dataTableViewSwitch"
compressed
/>
</EuiPanel>
Expand All @@ -64,7 +65,10 @@ export function WorkspacePanel({ visualizations }: IWorkSpacePanel) {
</EuiFlexItem>
<EuiFlexItem>
<EuiPanel paddingSize="s">
{isTableViewOn ? <DataTable visualizations={visualizations} /> : VisualizationPanel}
{isTableViewOn ?
<DataTable
visualizations={visualizations}
/> : VisualizationPanel}
</EuiPanel>
</EuiFlexItem>
</EuiFlexGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ export const DataTable = ({ visualizations }: any) => {
return (
<EuiDataGrid
aria-label="viz data table"
data-test-subj="workspace__dataTable"
columns={columns}
columnVisibility={{ visibleColumns, setVisibleColumns }}
rowCount={raw_data.length}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ export const Text = ({ visualizations }: any) => {
const { dataConfig = {} } = visualizations?.data?.userConfigs;

return (
<EuiMarkdownFormat>
{dataConfig.text?.markdown ? dataConfig.text?.markdown : DEFAULT_MARKDOWN}
</EuiMarkdownFormat>
<div data-test-subj="workspace__viz_markdown">
<EuiMarkdownFormat>
{dataConfig.text?.markdown ? dataConfig.text?.markdown : DEFAULT_MARKDOWN}
</EuiMarkdownFormat>
</div>
);
};