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

[8.x] [APM] Fix Deep Links Cypress Flaky Test (#206000) #206065

Merged
merged 1 commit into from
Jan 9, 2025
Merged
Changes from all commits
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 @@ -10,83 +10,97 @@ describe('Applications deep links', () => {
cy.loginAsViewerUser();
});

it('navigates to Application links on "application" search', () => {
cy.visitKibana('/');
navigatesToApmLinks('applications');
});
['apm', 'applications'].forEach((keyword) => {
describe(`Deep links for ${keyword} keyword`, () => {
it('contains all the expected deep links', () => {
// navigates to home page
cy.visitKibana('/');
// Wait until the page content is fully loaded
// otherwise, the search results may disappear before all checks are completed, making this test flaky
cy.waitUntilPageContentIsLoaded();
cy.getByTestSubj('nav-search-input').should('be.visible').type(keyword, { force: true });

it('navigates to Application links on "apm" search', () => {
cy.visitKibana('/');
navigatesToApmLinks('apm');
});
cy.contains('Applications');
cy.contains('Applications / Service Inventory');
cy.contains('Applications / Service groups');
// scroll to the center & bottom because results are not rendering otherwise
scrollToPositionResults('center');
cy.contains('Applications / Traces');
cy.contains('Applications / Service Map');
scrollToPositionResults('bottom');
cy.contains('Applications / Dependencies');
cy.contains('Applications / Settings');
});

function navigatesToApmLinks(keyword: string) {
// Wait until the page content is fully loaded
// otherwise, the search results may disappear before all checks are completed, making this test flaky
cy.waitUntilPageContentIsLoaded();
cy.getByTestSubj('nav-search-input')
.should('be.visible')
.type(keyword, { force: true })
.focus();
cy.contains('Applications');
cy.contains('Applications / Service Inventory');
cy.contains('Applications / Service groups');
cy.contains('Applications / Traces');
cy.contains('Applications / Service Map');
// scroll to the bottom because results are not rendering otherwise
scrollToBottomResults();
cy.contains('Applications / Dependencies');
cy.contains('Applications / Settings');
it('navigates to Service Inventory page', () => {
cy.visitKibana('/');
assertDeepLink(keyword, 'Applications / Service Inventory', '/apm/services');
});

// navigates to home page
// Force click because welcome screen changes
// https://github.com/elastic/kibana/pull/108193
cy.contains('Applications').click({ force: true });
cy.url().should('include', '/apm/services');
it('navigates to Service groups page', () => {
cy.visitKibana('/');
assertDeepLink(keyword, 'Applications / Service groups', '/apm/service-groups');
});

cy.waitUntilPageContentIsLoaded();
cy.getByTestSubj('nav-search-input').should('be.visible').type(keyword, { force: true });
// navigates to services page
cy.contains('Applications / Service Inventory').click({ force: true });
cy.url().should('include', '/apm/services');
it('navigates to Traces page', () => {
cy.visitKibana('/');
assertDeepLink(keyword, 'Applications / Traces', '/apm/traces', 'center');
});

cy.waitUntilPageContentIsLoaded();
cy.getByTestSubj('nav-search-input').should('be.visible').type(keyword, { force: true });
// navigates to service groups page
cy.contains('Applications / Service groups').click({ force: true });
cy.url().should('include', '/apm/service-groups');
it('navigates to Service Map page', () => {
cy.visitKibana('/');
assertDeepLink(keyword, 'Applications / Service Map', '/apm/service-map', 'center');
});

cy.waitUntilPageContentIsLoaded();
cy.getByTestSubj('nav-search-input').should('be.visible').type(keyword, { force: true });
// navigates to traces page
cy.contains('Applications / Traces').click({ force: true });
cy.url().should('include', '/apm/traces');
it('navigates to Dependencies page', () => {
cy.visitKibana('/');
assertDeepLink(
keyword,
'Applications / Dependencies',
'/apm/dependencies/inventory',
'bottom'
);
});

cy.waitUntilPageContentIsLoaded();
cy.getByTestSubj('nav-search-input').should('be.visible').type(keyword, { force: true });
scrollToBottomResults();
// navigates to service maps
cy.contains('Applications / Service Map').click({ force: true });
cy.url().should('include', '/apm/service-map');
it('navigates to Settings page', () => {
cy.visitKibana('/');
assertDeepLink(
keyword,
'Applications / Settings',
'/apm/settings/general-settings',
'bottom'
);
});
});
});
});

cy.waitUntilPageContentIsLoaded();
cy.getByTestSubj('nav-search-input').should('be.visible').type(keyword, { force: true });
// scroll to the bottom because results are not rendering otherwise
scrollToBottomResults();
// navigates to dependencies page
cy.contains('Applications / Dependencies').click({ force: true });
cy.url().should('include', '/apm/dependencies/inventory');
function assertDeepLink(
keyword: string,
title: string,
url: string,
scroll?: Cypress.PositionType
) {
// Wait until the page content is fully loaded
// otherwise, the search results may disappear before all checks are completed, making this test flaky
cy.waitUntilPageContentIsLoaded();
cy.getByTestSubj('nav-search-input').should('be.visible').type(keyword, { force: true });

cy.waitUntilPageContentIsLoaded();
cy.getByTestSubj('nav-search-input').should('be.visible').type(keyword, { force: true });
// scroll to the bottom because results are not rendering otherwise
scrollToBottomResults();
// navigates to settings page
cy.contains('Applications / Settings').click({ force: true });
cy.url().should('include', '/apm/settings/general-settings');
if (scroll) {
scrollToPositionResults(scroll);
}
});

function scrollToBottomResults() {
cy.getByTestSubj('euiSelectableList').find('div > div').scrollTo('bottom');
// Force click because welcome screen changes
// https://github.com/elastic/kibana/pull/108193
cy.contains(title).click({ force: true });
cy.url().should('include', url);
}

function scrollToPositionResults(position: Cypress.PositionType) {
// Make sure the search results are visible and we can scroll
cy.getByTestSubj('euiSelectableList')
.should('be.visible')
.find('div > div')
.should('have.length.greaterThan', 0)
.scrollTo(position);
}
Loading