Skip to content

Commit

Permalink
[APM] Add e2e tests for feature flags (#125201)
Browse files Browse the repository at this point in the history
* [APM] Add e2e tests for feature flags

* Do not abstracth apm base url
  • Loading branch information
kpatticha authored Feb 10, 2022
1 parent 9c87f23 commit 63bd4c6
Show file tree
Hide file tree
Showing 2 changed files with 165 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
/*
* 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.
*/

import { synthtrace } from '../../../../synthtrace';
import { opbeans } from '../../../fixtures/synthtrace/opbeans';

const settingsPath = '/app/management/kibana/settings';

const start = '2021-10-10T00:00:00.000Z';
const end = '2021-10-10T00:15:00.000Z';
describe('Comparison feature flag', () => {
const comparisonToggle =
'[data-test-subj="advancedSetting-editField-observability:enableComparisonByDefault"]';

before(async () => {
await synthtrace.index(
opbeans({
from: new Date(start).getTime(),
to: new Date(end).getTime(),
})
);
});

after(async () => {
await synthtrace.clean();
});

beforeEach(() => {
cy.loginAsPowerUser();
});

describe('when comparison feature is enabled', () => {
it('shows the flag as enabled in kibana advanced settings', () => {
cy.visit(settingsPath);

cy.get(comparisonToggle)
.should('have.attr', 'aria-checked')
.and('equal', 'true');
});

it('shows the comparison feature enabled in services overview', () => {
cy.visit('/app/apm/services');
cy.get('input[type="checkbox"]#comparison').should('be.checked');
cy.get('[data-test-subj="comparisonSelect"]').should('not.be.disabled');
});

it('shows the comparison feature enabled in services overview', () => {
cy.visit('/app/apm/backends');
cy.get('input[type="checkbox"]#comparison').should('be.checked');
cy.get('[data-test-subj="comparisonSelect"]').should('not.be.disabled');
});

it('shows the comparison feature disabled in service map overview page', () => {
cy.visit('/app/apm/service-map');
cy.get('input[type="checkbox"]#comparison').should('be.checked');
cy.get('[data-test-subj="comparisonSelect"]').should('not.be.disabled');
});
});

describe('when comparison feature is disabled', () => {
it('shows the flag as disabled in kibana advanced settings', () => {
cy.visit(settingsPath);
cy.get(comparisonToggle).click();
cy.contains('Save changes').should('not.be.disabled');
cy.contains('Save changes').click();
cy.get(comparisonToggle).should('not.be.checked');

cy.get(comparisonToggle)
.should('have.attr', 'aria-checked')
.and('equal', 'false');
});

it('shows the comparison feature disabled in services overview', () => {
cy.visit('/app/apm/services');
cy.get('input[type="checkbox"]#comparison').should('not.be.checked');
cy.get('[data-test-subj="comparisonSelect"]').should('be.disabled');
});

it('shows the comparison feature disabled in dependencies overview page', () => {
cy.visit('/app/apm/backends');
cy.get('input[type="checkbox"]#comparison').should('not.be.checked');
cy.get('[data-test-subj="comparisonSelect"]').should('be.disabled');
});

it('shows the comparison feature disabled in service map overview page', () => {
cy.visit('/app/apm/service-map');
cy.get('input[type="checkbox"]#comparison').should('not.be.checked');
cy.get('[data-test-subj="comparisonSelect"]').should('be.disabled');
});
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
* 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.
*/

import { synthtrace } from '../../../../synthtrace';
import { opbeans } from '../../../fixtures/synthtrace/opbeans';

const settingsPath = '/app/management/kibana/settings';
const serviceOverviewPath = '/app/apm/services/opbeans-python/overview';

const start = '2021-10-10T00:00:00.000Z';
const end = '2021-10-10T00:15:00.000Z';

describe('Infrastracture feature flag', () => {
const infraToggle =
'[data-test-subj="advancedSetting-editField-observability:enableInfrastructureView"]';

before(async () => {
await synthtrace.index(
opbeans({
from: new Date(start).getTime(),
to: new Date(end).getTime(),
})
);
});

after(async () => {
await synthtrace.clean();
});

beforeEach(() => {
cy.loginAsPowerUser();
});

describe('when infrastracture feature is enabled', () => {
it('shows the flag as enabled in kibana advanced settings', () => {
cy.visit(settingsPath);

cy.get(infraToggle)
.should('have.attr', 'aria-checked')
.and('equal', 'true');
});

it('shows infrastructure tab in service overview page', () => {
cy.visit(serviceOverviewPath);
cy.contains('a[role="tab"]', 'Infrastructure').click();
});
});

describe('when infrastracture feature is disabled', () => {
it('shows the flag as disabled in kibana advanced settings', () => {
cy.visit(settingsPath);
cy.get(infraToggle).click();
cy.contains('Save changes').should('not.be.disabled');
cy.contains('Save changes').click();

cy.get(infraToggle)
.should('have.attr', 'aria-checked')
.and('equal', 'false');
});

it('hides infrastructure tab in service overview page', () => {
cy.visit(serviceOverviewPath);
cy.contains('a[role="tab"]', 'Infrastructure').should('not.exist');
});
});
});

0 comments on commit 63bd4c6

Please sign in to comment.