Skip to content

Commit

Permalink
update event analytics cypress tests
Browse files Browse the repository at this point in the history
Signed-off-by: Ritvi Bhatt <[email protected]>
  • Loading branch information
Ritvi Bhatt committed Dec 5, 2024
1 parent da1f730 commit f9a98b6
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 41 deletions.
47 changes: 12 additions & 35 deletions .cypress/integration/event_analytics_test/event_analytics.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,28 +53,6 @@ describe('Has working breadcrumbs', () => {
});
});

describe('Search a query on event home', () => {
it('Search a query and redirect to explorer to display query output', () => {
landOnEventHome();

cy.get('[data-test-subj="searchAutocompleteTextArea"]').type(TEST_QUERIES[0].query);
cy.get('[data-test-subj="superDatePickerToggleQuickMenuButton"]').click();
cy.get('[data-test-subj="superDatePickerCommonlyUsed_Year_to date"]').click();
cy.get('[data-test-subj="superDatePickerApplyTimeButton"]').contains('Refresh').click();
cy.window()
.its('store')
.invoke('getState')
.then((state) => {
expect(Object.values(state.queries)[0]['rawQuery'].trim()).equal(TEST_QUERIES[0].query);
expect(Object.values(state.queries)[0]['selectedDateRange'][0]).equal('now/y');
expect(Object.values(state.queries)[0]['selectedDateRange'][1]).equal('now');
});

cy.url().should('contain', '#/explorer');
cy.get('[data-test-subj="searchAutocompleteTextArea"]').contains(TEST_QUERIES[0].query);
});
});

describe('Open flyout for a data row to see details', () => {
beforeEach(() => {
landOnEventExplorer();
Expand All @@ -83,7 +61,7 @@ describe('Open flyout for a data row to see details', () => {
});

it('Should be able to open flyout and see data, json and traces', () => {
cy.get('[data-test-subj="eventExplorer__flyoutArrow"]').first().click();
cy.get('[data-test-subj="eventExplorer__flyout"]').first().click();
cy.get('.observability-flyout').should('exist');
cy.get('.observability-flyout .osdDocViewer .euiTabs span.euiTab__content')
.contains('Table')
Expand All @@ -97,7 +75,7 @@ describe('Open flyout for a data row to see details', () => {
});

it('Should be able to see surrounding docs', () => {
cy.get('[data-test-subj="eventExplorer__flyoutArrow"]').first().click();
cy.get('[data-test-subj="eventExplorer__flyout"]').first().click();
cy.get('.observability-flyout span.euiButton__text')
.contains('View surrounding events')
.should('be.visible')
Expand Down Expand Up @@ -190,14 +168,12 @@ describe('Click actions test', () => {
});

it('Actions - click event explorer', () => {
cy.get('[data-test-subj="eventHomeAction"]').click();
cy.get('[data-test-subj="eventHomeAction__explorer"]').click();
cy.url().should('contain', '#/explorer');
});

it('Actions - add sample data', () => {
cy.get('[data-test-subj="eventHomeAction"]').click();
cy.get('[data-test-subj="eventHomeAction__addSamples"]').click();
cy.get('[data-test-subj="actionAddSamples"]').click();
cy.get('[data-test-subj="confirmModalConfirmButton"]').click();
cy.get('.euiToastHeader__title').should('contain', 'successfully');
});
Expand All @@ -218,6 +194,7 @@ describe('Saves a query on explorer page', () => {
querySearch(TEST_QUERIES[1].query, TEST_QUERIES[1].dateRangeDOM);
cy.get('button[id="main-content-vis"]').contains('Visualizations').click();
cy.get('[data-test-subj="eventExplorer__saveManagementPopover"]').click();
cy.get('[data-test-subj="comboBoxToggleListButton"]').eq(2).click();
cy.get('[data-test-subj="eventExplorer__querySaveName"]')

Check warning on line 198 in .cypress/integration/event_analytics_test/event_analytics.spec.js

View workflow job for this annotation

GitHub Actions / Lint

Do not use force on click and type calls
.focus()
.type(SAVE_QUERY2, { force: true });
Expand Down Expand Up @@ -299,7 +276,7 @@ describe('Override timestamp for an index', () => {
landOnEventExplorer();
clearQuerySearchBoxText('searchAutocompleteTextArea');
cy.get('[data-test-subj="searchAutocompleteTextArea"]').type(TEST_QUERIES[2].query);
cy.get('[data-test-subj="superDatePickerApplyTimeButton"]').contains('Refresh').click();
cy.get('[data-test-subj="superDatePickerApplyTimeButton"]').click();
cy.get('.tab-title').contains('Events').click();
cy.get('[data-test-subj="eventExplorer__overrideDefaultTimestamp"]').click({ force: true });

Check warning on line 281 in .cypress/integration/event_analytics_test/event_analytics.spec.js

View workflow job for this annotation

GitHub Actions / Lint

Do not use force on click and type calls

Expand All @@ -318,10 +295,10 @@ describe('Toggle the sidebar fields', () => {
querySearch(TEST_QUERIES[0].query, YEAR_TO_DATE_DOM_ID);
cy.get('[data-test-subj="fieldToggle-AvgTicketPrice"]').click();
cy.get('[data-test-subj="field-AvgTicketPrice"]').should('exist');
cy.get('[data-test-subj="docTable"]').find('th').contains('_source').should('not.exist');
cy.get('[data-test-subj="docTable"]').find('.euiDataGridHeaderCell').contains('Source').should('not.exist');
cy.get('[data-test-subj="fieldToggle-AvgTicketPrice"]').click();
cy.get('[data-test-subj="field-AvgTicketPrice"]').should('exist');
cy.get('[data-test-subj="docTable"]').find('th').contains('_source').should('exist');
cy.get('[data-test-subj="docTable"]').find('.euiDataGridHeaderCell').contains('Source').should('exist');
});
});

Expand Down Expand Up @@ -473,7 +450,7 @@ describe('Visualizing data', () => {
});

it('Visualize pie chart', () => {
cy.get('[data-test-subj="comboBoxInput"]').click();
cy.get('[data-test-subj="comboBoxInput"]').eq(1).click();
cy.get('[data-test-subj="comboBoxOptionsList "] span').contains(VIS_TYPE_PIE).click();
cy.get('[data-test-subj="vizConfigSection-series"]')
.find('[data-test-subj="viz-config-add-btn"]')
Expand All @@ -482,7 +459,7 @@ describe('Visualizing data', () => {
cy.get('[data-test-subj="vizConfigSection-dimensions"]')
.find('[data-test-subj="viz-config-add-btn"]')
.click();
cy.get('[data-test-subj="explorer__vizDataConfig-panel"]')
cy.get('.logExplorerVisConfig__section')
.find('[data-test-subj="comboBoxInput"]')
.click()
.type(FIELD_HOST);
Expand All @@ -497,7 +474,7 @@ describe('Visualizing data', () => {
});

it('Visualize vertical bar chart', () => {
cy.get('[data-test-subj="comboBoxInput"]').click();
cy.get('[data-test-subj="comboBoxInput"]').eq(1).click();
cy.get('[data-test-subj="comboBoxOptionsList "] span').contains(VIS_TYPE_VBAR).click();
cy.get('[data-test-subj="vizConfigSection-series"]')
.find('[data-test-subj="viz-config-add-btn"]')
Expand All @@ -506,7 +483,7 @@ describe('Visualizing data', () => {
cy.get('[data-test-subj="vizConfigSection-dimensions"]')
.find('[data-test-subj="viz-config-add-btn"]')
.click();
cy.get('[data-test-subj="explorer__vizDataConfig-panel"]')
cy.get('.logExplorerVisConfig__section')
.find('[data-test-subj="comboBoxInput"]')
.click()
.type(FIELD_HOST);
Expand All @@ -515,7 +492,7 @@ describe('Visualizing data', () => {
cy.get('[data-test-subj="vizConfigSection-breakdowns"]')
.find('[data-test-subj="viz-config-add-btn"]')
.click();
cy.get('[data-test-subj="explorer__vizDataConfig-panel"]')
cy.get('.logExplorerVisConfig__section')
.find('[data-test-subj="comboBoxInput"]')
.click()
.type(FIELD_AGENT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,10 +200,6 @@ export const FlyoutButton = forwardRef((props: FlyoutButtonProps, ref) => {
return cols;
};

const memorizedTds = useMemo(() => {
return getTds(doc, selectedCols, false);
}, [doc, selectedCols, detailsOpen, surroundingEventsOpen]);

const memorizedDocFlyout = useMemo(() => {
return (
<DocFlyout
Expand Down Expand Up @@ -296,6 +292,7 @@ export const FlyoutButton = forwardRef((props: FlyoutButtonProps, ref) => {
onClick={() => toggleDetailOpen()}
iconType={detailsOpen || surroundingEventsOpen ? 'minimize' : 'inspect'}
aria-label="inspect document details"
data-test-subj="eventExplorer__flyout"
/>
{flyout}
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ export const Field = (props: IFieldProps) => {
aria-label={'inspect'}
className="dscSidebarField__actionButton"
isDisabled={!(isDefaultDataSourceType || appLogEvents)}
data-test-subj={`field-${field.name}-showDetails`}
/>
}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ export const Sidebar = (props: ISidebarProps) => {
data-attr-field={field.name}
paddingSize="s"
className="dscSidebar__item"
data-test-subj={`fieldList-field`}
data-test-subj={`field-${field.name}`}
>
<Field
query={query}
Expand Down Expand Up @@ -324,7 +324,7 @@ export const Sidebar = (props: ISidebarProps) => {
data-attr-field={field.name}
paddingSize="s"
className="dscSidebar__item"
data-test-subj={`fieldList-field`}
data-test-subj={`field-${field.name}`}
>
<Field
query={query}
Expand Down

0 comments on commit f9a98b6

Please sign in to comment.