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

Cypress Testing v12.8.1 - Trace Analytics (Services & Traces) fixes #493

Merged
merged 2 commits into from
May 31, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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: 0 additions & 1 deletion .cypress/integration/4_trace_analytics_dashboard.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ describe('Testing dashboard table', () => {
});

it('Adds the percentile filters', () => {
cy.wait(delay);//Needed after removing waits from setTimeFilter()
cy.contains(' >= 95 percentile').click({ force: true });
cy.contains(' >= 95 percentile').click({ force: true });

Expand Down
33 changes: 5 additions & 28 deletions .cypress/integration/5_trace_analytics_services.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ describe('Testing services table empty state', () => {
win.sessionStorage.clear();
},
});
cy.wait(delay * 3);
});

it('Renders empty state', () => {
Expand Down Expand Up @@ -72,11 +71,6 @@ describe('Testing services table', () => {

describe('Testing service view empty state', () => {
beforeEach(() => {
// exception is thrown on loading EuiDataGrid in cypress only, ignore for now
cy.on('uncaught:exception', (err, runnable) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I LOVE that we're removing this. This is a super-wide ignore nad the test will be far more accurate with uncaught:exceptions bubbling.

Thanks for making this happen!

if (err.message.includes('ResizeObserver loop'))
return false;
});
cy.visit(`app/observability-traces#/services/${SERVICE_NAME}`, {
onBeforeLoad: (win) => {
win.sessionStorage.clear();
Expand All @@ -93,11 +87,6 @@ describe('Testing service view empty state', () => {

describe('Testing service view', () => {
beforeEach(() => {
// exception is thrown on loading EuiDataGrid in cypress only, ignore for now
cy.on('uncaught:exception', (err, runnable) => {
if (err.message.includes('ResizeObserver loop'))
return false;
});
cy.visit(`app/observability-traces#/services`, {
onBeforeLoad: (win) => {
win.sessionStorage.clear();
Expand All @@ -106,7 +95,7 @@ describe('Testing service view', () => {
setTimeFilter();
cy.get('input[type="search"]').first().focus().type(`${SERVICE_NAME}`);
cy.get('[data-test-subj="superDatePickerApplyTimeButton"]').click();
cy.wait(delay);
cy.get('.euiTableRow').should('have.length.lessThan', 3);//Replaces wait
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice.

cy.get('[data-test-subj="service-link"]').eq(0).click();
});

Expand All @@ -119,28 +108,22 @@ describe('Testing service view', () => {

it('Has working breadcrumbs', () => {
cy.get('.euiBreadcrumb').contains(SERVICE_NAME).click();
cy.wait(delay);
cy.get('h2.euiTitle').contains(SERVICE_NAME).should('exist');
cy.get('.euiBreadcrumb').contains('Services').click();
cy.wait(delay);
cy.get('.euiTitle').contains('Services').should('exist');
cy.get('.euiBreadcrumb').contains('Trace analytics').click();
cy.wait(delay);
cy.get('.euiTitle').contains('Dashboard').should('exist');
cy.get('.euiBreadcrumb').contains('Observability').click();
cy.wait(delay);
cy.get('.euiTitle').contains('Event analytics').should('exist');
cy.get('.euiTitle').contains('Logs').should('exist');
});

it('Renders spans data grid, flyout, filters', () => {
cy.get("[data-test-subj='spanId-link']").contains(SERVICE_SPAN_ID).trigger('mouseover', { force: true });
cy.get('button[data-datagrid-interactable="true"]').eq(0).click({ force: true });
cy.wait(delay);
cy.contains('Span detail').should('exist');
cy.contains('Span attributes').should('exist');
cy.get('.euiTextColor').contains('Span ID').trigger('mouseover');
cy.get('.euiButtonIcon[aria-label="span-flyout-filter-icon"').click({ force: true });
cy.wait(delay);
cy.get('.euiBadge__text').contains('spanId: ').should('exist');
cy.get('[data-test-subj="euiFlyoutCloseButton"]').click({ force: true });
cy.contains('Spans (1)').should('exist');
Expand Down Expand Up @@ -172,10 +155,6 @@ describe('Testing Service map', () => {

describe('Testing traces Spans table verify table headers functionality', () => {
beforeEach(() => {
cy.on('uncaught:exception', (err, runnable) => {
if (err.message.includes('ResizeObserver loop'))
return false;
});
cy.visit('app/observability-traces#/services', {
onBeforeLoad: (win) => {
win.sessionStorage.clear();
Expand Down Expand Up @@ -211,6 +190,7 @@ describe('Testing traces Spans table verify table headers functionality', () =>

it('Hide all button Spans table', () => {
cy.get('.euiLink.euiLink--primary').contains('authentication').should('exist').click();
cy.get('.euiTableRow').should('have.length.lessThan', 2);//Replace wait
cy.get('[data-test-subj = "dataGridColumnSelectorButton"]').click();
cy.get('.euiPopoverFooter .euiFlexItem.euiFlexItem--flexGrowZero').eq(1).should('have.text', 'Hide all').click();
cy.get('.euiDataGrid__focusWrap').click().should('exist');
Expand Down Expand Up @@ -268,10 +248,8 @@ describe('Testing traces Spans table and verify columns functionality', () => {
cy.get('[aria-label="span-flyout-filter-icon"]').click();
cy.get('.euiFlyout__closeButton.euiFlyout__closeButton--inside').click();
cy.get('.euiBadge__content .euiBadge__text').contains('spanId: 277a5934acf55dcf').should('exist');
cy.wait(delay);
count_table_row(1);
cy.get('[aria-label="remove current filter"]').click();
cy.wait(delay);
count_table_row(8);
});

Expand All @@ -298,6 +276,7 @@ describe('Testing switch mode to jaeger', () => {
setTimeFilter();
cy.get("[data-test-subj='indexPattern-switch-link']").click();
cy.get("[data-test-subj='jaeger-mode']").click();
//cy.get('.euiButtonEmpty__text').should('contain', 'Jaeger');
});

it('Verifies columns and data', () => {
Expand All @@ -312,10 +291,8 @@ describe('Testing switch mode to jaeger', () => {
});

it('Verifies traces links to traces page with filter applied', () => {
cy.wait(delay);
cy.get('.euiTableRow').should('have.length.lessThan', 7);//Replaces Wait
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 or 3 is immediately understandable. 7 ? Is that just the injected trace data?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The previous state has 7 listings, my thought process is to detect the minimal change to indicate the previous action was applied before running get(). This can be lowered but wanted to use the assertions just to check that the action had been applied while keeping reference to what the previous state had, for going back through the snapshots.

cy.get('.euiLink').contains('7').click();
cy.wait(delay);

cy.get('h2.euiTitle').contains('Traces').should('exist');
cy.contains(' (7)').should('exist');
cy.get("[data-test-subj='filterBadge']").eq(0).contains('process.serviceName: customer')
Expand Down
14 changes: 3 additions & 11 deletions .cypress/integration/6_trace_analytics_traces.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ describe('Testing traces table empty state', () => {
win.sessionStorage.clear();
},
});
cy.wait(delay * 3);
});

it('Renders empty state', () => {
Expand Down Expand Up @@ -69,7 +68,7 @@ describe('Testing trace view', () => {
setTimeFilter();
cy.get('input[type="search"]').focus().type(`${TRACE_ID}`);
cy.get('.euiButton__text').contains('Refresh').click();
cy.wait(delay);
cy.get('.euiTableRow').should('have.length.lessThan', 3);//Replaces wait
cy.get('[data-test-subj="trace-link"]').eq(0).click();
});

Expand All @@ -86,33 +85,27 @@ describe('Testing trace view', () => {

it('Has working breadcrumbs', () => {
cy.get(`.euiBreadcrumb[href="#/traces/${TRACE_ID}"]`).click();
cy.wait(delay);
cy.get('h2.euiTitle').contains(TRACE_ID).should('exist');
cy.get('.euiBreadcrumb[href="#/traces"]').click();
cy.wait(delay);
cy.get('.euiTitle').contains('Traces').should('exist');
cy.get('.euiBreadcrumb[href="#/"]').click();
cy.wait(delay);
cy.get('.euiTitle').contains('Dashboard').should('exist');
cy.get('.euiBreadcrumb[href="observability-logs#/"]').click();
cy.wait(delay);
cy.get('.euiTitle').contains('Event analytics').should('exist');
cy.get('.euiTitle').contains('Logs').should('exist');
});

it('Renders data grid, flyout and filters', () => {
cy.get('.euiButton__text[title="Span list"]').click({ force: true });
cy.contains('2 columns hidden').should('exist');

cy.wait(delay);
cy.get('.euiLink').contains(SPAN_ID).trigger('mouseover', { force: true });
cy.get('button[data-datagrid-interactable="true"]').eq(0).click({ force: true });
cy.get('button[data-datagrid-interactable="true"]').eq(0).click({ force: true }); // first click doesn't go through eui data grid
cy.wait(delay);

cy.contains('Span detail').should('exist');
cy.contains('Span attributes').should('exist');
cy.get('.euiTextColor').contains('Span ID').trigger('mouseover');
cy.get('.euiButtonIcon[aria-label="span-flyout-filter-icon"').click({ force: true });
cy.wait(delay);

cy.get('.euiBadge__text').contains('spanId: ').should('exist');
cy.contains('Spans (1)').should('exist');
Expand Down Expand Up @@ -146,7 +139,6 @@ describe('Testing traces table', () => {
cy.contains('client_create_order').should('exist');
cy.get('path[style*="rgb(116, 146, 231)"]').should('exist');
cy.go('back');
cy.wait(delay);
cy.get('.euiButtonEmpty__text').contains('Rows per page').click();
cy.get('.euiContextMenuItem__text').contains('15 rows').click();
let expected_row_count=15;
Expand Down
1 change: 1 addition & 0 deletions .cypress/utils/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export const setTimeFilter = (setEndTime = false, refresh = true) => {
.type('{selectall}' + endTime, { force: true });
}
if (refresh) cy.get('.euiButton__text').contains('Refresh').click();
cy.get('.euiTableRow').should('have.length.greaterThan', 3);//Replaces Wait
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This assertion ensures the page is loaded before moving on to the 'cy.get()' commands in the testing following this function call. The click of refresh applying the filter adds to the rows and waiting for this change to occur ensures cypress won't search to early before it exist. This was put in place to move towards removing all cy.wait() commands and create more reliable and efficient testing.
Guidance from - https://glebbahmutov.com/blog/check-more-things/
Screenshot 2023-05-26 at 9 00 34 AM

};

// notebooks
Expand Down