Skip to content

Commit

Permalink
[Logs onboarding] e2e tests - entry points (#164561)
Browse files Browse the repository at this point in the history
Relates to #164022.
  • Loading branch information
yngrdyn authored Aug 28, 2023
1 parent 142e625 commit 78ba034
Show file tree
Hide file tree
Showing 6 changed files with 104 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,24 @@ describe('[Observability onboarding] Landing page', () => {
cy.loginAsElastic();
});

it('shows landing page', () => {
describe('Entry point', () => {
it('when clicking on the logs card the user is navigated to the observability onboarding page', () => {
cy.getByTestSubj('guideButtonRedirect').click();
cy.getByTestSubj('onboarding--observability--logs').click();

cy.url().should('include', '/app/observabilityOnboarding');
});

it('when clicking on observability overview callout the user is navigated to the observability onboarding page', () => {
cy.visitKibana('/app/observability');
cy.getByTestSubj('observability-onboarding-callout').should('exist');
cy.getByTestSubj('o11yObservabilityOnboardingGetStartedButton').click();

cy.url().should('include', '/app/observabilityOnboarding');
});
});

it('when user navigates to observability onboarding landing page is showed', () => {
cy.visitKibana('/app/observabilityOnboarding');
cy.contains('Get started with Observability');
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@
*/

import { defineCypressConfig } from '@kbn/cypress-config';
import { kbnTestConfig } from '@kbn/test';

import Url from 'url';

const kibanaUrlWithoutAuth = Url.format({
protocol: kbnTestConfig.getUrlParts().protocol,
hostname: kbnTestConfig.getUrlParts().hostname,
port: kbnTestConfig.getUrlParts().port,
});

export default defineCypressConfig({
fileServerFolder: './cypress',
Expand All @@ -30,4 +39,9 @@ export default defineCypressConfig({
supportFile: './support/e2e.ts',
specPattern: './e2e/**/*.cy.ts',
},
env: {
username: kbnTestConfig.getUrlParts().username,
password: kbnTestConfig.getUrlParts().password,
kibanaUrlWithoutAuth,
},
});
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@
*/

describe('Serverless', () => {
it('Should login', () => {
beforeEach(() => {
cy.loginAsElasticUser();
});

it('contains the side navigation for observabilitity serverless', () => {
cy.loginAsElasticUser();
cy.contains('Discover');
cy.contains('Dashboards');
cy.contains('Alerts');
Expand All @@ -23,8 +22,6 @@ describe('Serverless', () => {
});

it('navigates to discover-dashboard-viz links', () => {
cy.loginAsElasticUser();

cy.contains('Discover').click();
cy.url().should('include', '/app/discover');

Expand All @@ -36,8 +33,6 @@ describe('Serverless', () => {
});

it('navigates to alerts links', () => {
cy.loginAsElasticUser();

cy.contains('Alerts').click();
cy.url().should('include', '/observability/alerts');

Expand All @@ -49,8 +44,6 @@ describe('Serverless', () => {
});

it('navigates to apm links', () => {
cy.loginAsElasticUser();

cy.contains('Applications').click();
cy.contains('Services').click();
cy.url().should('include', '/apm/services');
Expand All @@ -63,15 +56,11 @@ describe('Serverless', () => {
});

it('navigates to get started links', () => {
cy.loginAsElasticUser();

cy.contains('Add data').click();
cy.url().should('include', '/app/observabilityOnboarding');
});

it('navigates to AIOps links', () => {
cy.loginAsElasticUser();

cy.contains('AIOps').click();
cy.contains('Anomaly detection').click();
cy.url().should('include', '/app/ml/jobs');
Expand All @@ -87,8 +76,6 @@ describe('Serverless', () => {
});

it('navigates to project settings', () => {
cy.loginAsElasticUser();

cy.contains('Project settings').click();
cy.contains('Management').click();
cy.url().should('include', '/app/management');
Expand All @@ -101,22 +88,21 @@ describe('Serverless', () => {
});

it('sets service nav item as active', () => {
cy.loginAsElasticUser('/app/apm/service-groups');

cy.visitKibana('/app/apm/service-groups');
cy.getByTestSubj('nav-item-id-apm').should('have.class', 'euiSideNavItemButton-isOpen');
cy.getByTestSubj('nav-item-id-apm:services').should(
'have.class',
'euiSideNavItemButton-isSelected'
);

cy.loginAsElasticUser('/app/apm/service-maps');
cy.visitKibana('/app/apm/service-maps');
cy.getByTestSubj('nav-item-id-apm').should('have.class', 'euiSideNavItemButton-isOpen');
cy.getByTestSubj('nav-item-id-apm:services').should(
'have.class',
'euiSideNavItemButton-isSelected'
);

cy.loginAsElasticUser('/app/apm/mobile-services/foo');
cy.visitKibana('/app/apm/mobile-services/foo');
cy.getByTestSubj('nav-item-id-apm').should('have.class', 'euiSideNavItemButton-isOpen');
cy.getByTestSubj('nav-item-id-apm:services').should(
'have.class',
Expand All @@ -125,15 +111,14 @@ describe('Serverless', () => {
});

it('sets dependencies nav item as active', () => {
cy.loginAsElasticUser('/app/apm/dependencies/inventory');

cy.visitKibana('/app/apm/dependencies/inventory');
cy.getByTestSubj('nav-item-id-apm').should('have.class', 'euiSideNavItemButton-isOpen');
cy.getByTestSubj('nav-item-id-apm:dependencies').should(
'have.class',
'euiSideNavItemButton-isSelected'
);

cy.loginAsElasticUser('/app/apm/dependencies/operations?dependencyName=foo');
cy.visitKibana('/app/apm/dependencies/operations?dependencyName=foo');
cy.getByTestSubj('nav-item-id-apm').should('have.class', 'euiSideNavItemButton-isOpen');
cy.getByTestSubj('nav-item-id-apm:dependencies').should(
'have.class',
Expand All @@ -142,15 +127,15 @@ describe('Serverless', () => {
});

it('sets traces nav item as active', () => {
cy.loginAsElasticUser('/app/apm/traces/explorer/waterfall');
cy.visitKibana('/app/apm/traces/explorer/waterfall');

cy.getByTestSubj('nav-item-id-apm').should('have.class', 'euiSideNavItemButton-isOpen');
cy.getByTestSubj('nav-item-id-apm:traces').should(
'have.class',
'euiSideNavItemButton-isSelected'
);

cy.loginAsElasticUser('/app/apm/traces/explorer/critical_path');
cy.visitKibana('/app/apm/traces/explorer/critical_path');
cy.getByTestSubj('nav-item-id-apm').should('have.class', 'euiSideNavItemButton-isOpen');
cy.getByTestSubj('nav-item-id-apm:traces').should(
'have.class',
Expand All @@ -159,15 +144,15 @@ describe('Serverless', () => {
});

it('sets AIOps nav item as active', () => {
cy.loginAsElasticUser('app/ml/aiops/explain_log_rate_spikes');
cy.visitKibana('/app/ml/aiops/explain_log_rate_spikes');

cy.getByTestSubj('nav-item-id-aiops').should('have.class', 'euiSideNavItemButton-isOpen');
cy.getByTestSubj('nav-item-id-ml:logRateAnalysis').should(
'have.class',
'euiSideNavItemButton-isSelected'
);

cy.loginAsElasticUser('app/ml/aiops/change_point_detection');
cy.visitKibana('/app/ml/aiops/change_point_detection');
cy.getByTestSubj('nav-item-id-aiops').should('have.class', 'euiSideNavItemButton-isOpen');
cy.getByTestSubj('nav-item-id-ml:changePointDetections').should(
'have.class',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

describe('[Serverless Observability onboarding] Landing page', () => {
beforeEach(() => {
cy.loginAsElasticUser();
});

it('when user navigates to observability onboarding landing page is showed', () => {
cy.visitKibana('/app/observabilityOnboarding');
cy.contains('Get started with Observability');
});

describe('Entry point', () => {
it('when clicking on Add data the user is navigated to the observability onboarding page', () => {
cy.contains('Add data').click();
cy.url().should('include', '/app/observabilityOnboarding');
});
});
});

export {};
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,47 @@
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import 'cypress-real-events/support';
import 'cypress-axe';
import 'cypress-real-events/support';
import URL from 'url';

Cypress.Commands.add('loginAsElasticUser', (path?: string) => {
cy.visit(path ?? '/', {
auth: {
username: 'elastic',
password: 'changeme',
Cypress.Commands.add('loginAsElasticUser', () => {
const username = Cypress.env('username');
const password = Cypress.env('password');
const kibanaUrlWithoutAuth = Cypress.env('kibanaUrlWithoutAuth');
cy.log(`Logging in as ${username} on ${kibanaUrlWithoutAuth}`);
cy.visit('/');
cy.request({
log: true,
method: 'POST',
url: `${kibanaUrlWithoutAuth}/internal/security/login`,
body: {
providerType: 'basic',
providerName: 'basic',
currentURL: `${kibanaUrlWithoutAuth}/login`,
params: { username, password },
},
headers: {
'kbn-xsrf': 'e2e_test',
'x-elastic-internal-origin': 'kibana',
},
});
cy.visit('/');
});

Cypress.Commands.add('getByTestSubj', (selector: string) => {
return cy.get(`[data-test-subj*="${selector}"]`);
});

Cypress.Commands.add('visitKibana', (url: string, rangeFrom?: string, rangeTo?: string) => {
const urlPath = URL.format({
pathname: url,
query: { rangeFrom, rangeTo },
});

cy.visit(urlPath);
cy.getByTestSubj('kbnLoadingMessage').should('exist');
cy.getByTestSubj('kbnLoadingMessage').should('not.exist', {
timeout: 50000,
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ declare namespace Cypress {
interface Chainable {
loginAsElasticUser(path?: string): Cypress.Chainable<Cypress.Response<any>>;
getByTestSubj(selector: string): Chainable<JQuery<Element>>;
visitKibana(url: string, rangeFrom?: string, rangeTo?: string): void;
}
}

0 comments on commit 78ba034

Please sign in to comment.