diff --git a/x-pack/solutions/observability/plugins/apm/ftr_e2e/cypress/e2e/deep_links.cy.ts b/x-pack/solutions/observability/plugins/apm/ftr_e2e/cypress/e2e/deep_links.cy.ts index b220bd0493009..3a44217423a5c 100644 --- a/x-pack/solutions/observability/plugins/apm/ftr_e2e/cypress/e2e/deep_links.cy.ts +++ b/x-pack/solutions/observability/plugins/apm/ftr_e2e/cypress/e2e/deep_links.cy.ts @@ -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); }