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

Fix UX E2E tests #85722

Merged
merged 2 commits into from
Dec 14, 2020
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
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@

import { Given, When, Then } from 'cypress-cucumber-preprocessor/steps';
import { DEFAULT_TIMEOUT } from './csm_dashboard';
import { waitForLoadingToFinish } from './utils';

/** The default time in ms to wait for a Cypress command to complete */

Given(`a user clicks the page load breakdown filter`, () => {
// wait for all loading to finish
cy.get('kbnLoadingIndicator').should('not.be.visible');
waitForLoadingToFinish();
cy.get('.euiStat__title-isLoading').should('not.be.visible');
const breakDownBtn = cy.get(
'[data-test-subj=pldBreakdownFilter]',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/

import { DEFAULT_TIMEOUT } from './csm_dashboard';
import { waitForLoadingToFinish } from './utils';

/**
* Verifies the behavior of the client metrics component
Expand All @@ -17,8 +18,7 @@ export function verifyClientMetrics(
) {
const clientMetricsSelector = '[data-cy=client-metrics] .euiStat__title';

// wait for all loading to finish
cy.get('kbnLoadingIndicator').should('not.be.visible');
waitForLoadingToFinish();

if (checkTitleStatus) {
cy.get('.euiStat__title', DEFAULT_TIMEOUT).should('be.visible');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import { Given, Then } from 'cypress-cucumber-preprocessor/steps';
import { loginAndWaitForPage } from '../../../integration/helpers';
import { verifyClientMetrics } from './client_metrics_helper';
import { waitForLoadingToFinish } from './utils';

/** The default time in ms to wait for a Cypress command to complete */
export const DEFAULT_TIMEOUT = { timeout: 60 * 1000 };
Expand Down Expand Up @@ -36,8 +37,8 @@ Then(`should display percentile for page load chart`, () => {

cy.get('.euiLoadingChart', DEFAULT_TIMEOUT).should('be.visible');

// wait for all loading to finish
cy.get('kbnLoadingIndicator').should('not.be.visible');
waitForLoadingToFinish();

cy.get('.euiStat__title-isLoading').should('not.be.visible');

cy.get(pMarkers).eq(0).should('have.text', '50th');
Expand All @@ -52,8 +53,7 @@ Then(`should display percentile for page load chart`, () => {
Then(`should display chart legend`, () => {
const chartLegend = 'div.echLegendItem__label';

// wait for all loading to finish
cy.get('kbnLoadingIndicator').should('not.be.visible');
waitForLoadingToFinish();
cy.get('.euiLoadingChart').should('not.be.visible');

cy.get(chartLegend, DEFAULT_TIMEOUT).eq(0).should('have.text', 'Overall');
Expand All @@ -64,8 +64,7 @@ Then(`should display tooltip on hover`, () => {

const pMarkers = '[data-cy=percentile-markers] span.euiToolTipAnchor';

// wait for all loading to finish
cy.get('kbnLoadingIndicator').should('not.be.visible');
waitForLoadingToFinish();
cy.get('.euiLoadingChart').should('not.be.visible');

const marker = cy.get(pMarkers, DEFAULT_TIMEOUT).eq(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
import { When, Then } from 'cypress-cucumber-preprocessor/steps';
import { DEFAULT_TIMEOUT } from './csm_dashboard';
import { verifyClientMetrics } from './client_metrics_helper';
import { waitForLoadingToFinish } from './utils';

When(/^the user filters by "([^"]*)"$/, (filterName) => {
// wait for all loading to finish
cy.get('kbnLoadingIndicator').should('not.be.visible');
waitForLoadingToFinish();
cy.get('.euiStat__title-isLoading').should('not.be.visible');
cy.get(`#local-filter-${filterName}`).click();

Expand Down Expand Up @@ -51,8 +51,7 @@ When(/^the user filters by "([^"]*)"$/, (filterName) => {
});

Then(/^it filters the client metrics "([^"]*)"$/, (filterName) => {
// wait for all loading to finish
cy.get('kbnLoadingIndicator').should('not.be.visible');
waitForLoadingToFinish();
cy.get('.euiStat__title-isLoading').should('not.be.visible');

const data =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@

import { When, Then } from 'cypress-cucumber-preprocessor/steps';
import { verifyClientMetrics } from './client_metrics_helper';
import { getDataTestSubj } from './utils';
import { getDataTestSubj, waitForLoadingToFinish } from './utils';

When('the user changes the selected percentile', () => {
// wait for all loading to finish
cy.get('kbnLoadingIndicator').should('not.be.visible');
waitForLoadingToFinish();

getDataTestSubj('uxPercentileSelect').select('95');
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
import { When, Then } from 'cypress-cucumber-preprocessor/steps';
import { verifyClientMetrics } from './client_metrics_helper';
import { DEFAULT_TIMEOUT } from './csm_dashboard';
import { waitForLoadingToFinish } from './utils';

When('the user changes the selected service name', () => {
// wait for all loading to finish
cy.get('kbnLoadingIndicator').should('not.be.visible');
waitForLoadingToFinish();
cy.get(`[data-cy=serviceNameFilter]`, DEFAULT_TIMEOUT).select('client');
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@

import { When, Then } from 'cypress-cucumber-preprocessor/steps';
import { DEFAULT_TIMEOUT } from './csm_dashboard';
import { waitForLoadingToFinish } from './utils';

When(`a user clicks inside url search field`, () => {
// wait for all loading to finish
cy.get('kbnLoadingIndicator').should('not.be.visible');
waitForLoadingToFinish();
cy.get('.euiStat__title-isLoading').should('not.be.visible');
cy.get('span[data-cy=csmUrlFilter]', DEFAULT_TIMEOUT).within(() => {
cy.get('input.euiFieldSearch').click();
});
});

Then(`it displays top pages in the suggestion popover`, () => {
cy.get('kbnLoadingIndicator').should('not.be.visible');
waitForLoadingToFinish();

cy.get('div.euiPopover__panel-isOpen', DEFAULT_TIMEOUT).within(() => {
const listOfUrls = cy.get('li.euiSelectableListItem');
Expand All @@ -38,17 +38,17 @@ Then(`it displays top pages in the suggestion popover`, () => {
});

When(`a user enters a query in url search field`, () => {
cy.get('kbnLoadingIndicator').should('not.be.visible');
waitForLoadingToFinish();

cy.get('[data-cy=csmUrlFilter]').within(() => {
cy.get('input.euiSelectableSearch').type('cus');
});

cy.get('kbnLoadingIndicator').should('not.be.visible');
waitForLoadingToFinish();
});

Then(`it should filter results based on query`, () => {
cy.get('kbnLoadingIndicator').should('not.be.visible');
waitForLoadingToFinish();

cy.get('div.euiPopover__panel-isOpen', DEFAULT_TIMEOUT).within(() => {
const listOfUrls = cy.get('li.euiSelectableListItem');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@

import { DEFAULT_TIMEOUT } from './csm_dashboard';

export function waitForLoadingToFinish() {
cy.get('[data-test-subj=globalLoadingIndicator]', DEFAULT_TIMEOUT);
}

export function getDataTestSubj(dataTestSubj: string) {
// wait for all loading to finish
cy.get('kbnLoadingIndicator').should('not.be.visible');
waitForLoadingToFinish();

return cy.get(`[data-test-subj=${dataTestSubj}]`, DEFAULT_TIMEOUT);
}