mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
[APM] e2e tests fix (Comparison feature flag) (#137209)
* call api to update settings * fixing comparison test * adding return * addressing pr comments Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
2fdb0b37a3
commit
788d688f1a
3 changed files with 44 additions and 38 deletions
|
@ -8,14 +8,9 @@
|
|||
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.skip('Comparison feature flag', () => {
|
||||
const comparisonToggle =
|
||||
'[data-test-subj="advancedSetting-editField-observability:enableComparisonByDefault"]';
|
||||
|
||||
describe('Comparison feature flag', () => {
|
||||
before(async () => {
|
||||
await synthtrace.index(
|
||||
opbeans({
|
||||
|
@ -29,17 +24,9 @@ describe.skip('Comparison feature flag', () => {
|
|||
await synthtrace.clean();
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
cy.loginAsEditorUser();
|
||||
});
|
||||
|
||||
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');
|
||||
beforeEach(() => {
|
||||
cy.loginAsEditorUser();
|
||||
});
|
||||
|
||||
it('shows the comparison feature enabled in services overview', () => {
|
||||
|
@ -62,24 +49,19 @@ describe.skip('Comparison feature flag', () => {
|
|||
});
|
||||
|
||||
describe('when comparison feature is disabled', () => {
|
||||
// Reverts to default state, which is comparison enabled
|
||||
after(() => {
|
||||
cy.visit(settingsPath);
|
||||
cy.get(comparisonToggle).click();
|
||||
cy.contains('Save changes').should('not.be.disabled');
|
||||
cy.contains('Save changes').click();
|
||||
beforeEach(() => {
|
||||
cy.loginAsEditorUser().then(() => {
|
||||
// Disables comparison feature on advanced settings
|
||||
cy.updateAdvancedSettings({
|
||||
'observability:enableComparisonByDefault': false,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
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');
|
||||
after(() => {
|
||||
cy.updateAdvancedSettings({
|
||||
'observability:enableComparisonByDefault': true,
|
||||
});
|
||||
});
|
||||
|
||||
it('shows the comparison feature disabled in services overview', () => {
|
||||
|
@ -89,7 +71,11 @@ describe.skip('Comparison feature flag', () => {
|
|||
});
|
||||
|
||||
it('shows the comparison feature disabled in dependencies overview page', () => {
|
||||
cy.intercept('GET', '/internal/apm/dependencies/top_dependencies?*').as(
|
||||
'topDependenciesRequest'
|
||||
);
|
||||
cy.visit('/app/apm/dependencies');
|
||||
cy.wait('@topDependenciesRequest', { requestTimeout: 10000 });
|
||||
cy.get('input[type="checkbox"]#comparison').should('not.be.checked');
|
||||
cy.get('[data-test-subj="comparisonSelect"]').should('be.disabled');
|
||||
});
|
|
@ -11,11 +11,11 @@ import moment from 'moment';
|
|||
import { AXE_CONFIG, AXE_OPTIONS } from '@kbn/axe-config';
|
||||
|
||||
Cypress.Commands.add('loginAsViewerUser', () => {
|
||||
cy.loginAs({ username: 'viewer', password: 'changeme' });
|
||||
return cy.loginAs({ username: 'viewer', password: 'changeme' });
|
||||
});
|
||||
|
||||
Cypress.Commands.add('loginAsEditorUser', () => {
|
||||
cy.loginAs({ username: 'editor', password: 'changeme' });
|
||||
return cy.loginAs({ username: 'editor', password: 'changeme' });
|
||||
});
|
||||
|
||||
Cypress.Commands.add(
|
||||
|
@ -23,7 +23,7 @@ Cypress.Commands.add(
|
|||
({ username, password }: { username: string; password: string }) => {
|
||||
cy.log(`Logging in as ${username}`);
|
||||
const kibanaUrl = Cypress.env('KIBANA_URL');
|
||||
cy.request({
|
||||
return cy.request({
|
||||
log: false,
|
||||
method: 'POST',
|
||||
url: `${kibanaUrl}/internal/security/login`,
|
||||
|
@ -84,6 +84,22 @@ Cypress.Commands.add(
|
|||
}
|
||||
);
|
||||
|
||||
Cypress.Commands.add(
|
||||
'updateAdvancedSettings',
|
||||
(settings: Record<string, unknown>) => {
|
||||
const kibanaUrl = Cypress.env('KIBANA_URL');
|
||||
cy.request({
|
||||
log: false,
|
||||
method: 'POST',
|
||||
url: `${kibanaUrl}/api/kibana/settings`,
|
||||
body: { changes: settings },
|
||||
headers: {
|
||||
'kbn-xsrf': 'e2e_test',
|
||||
},
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
// A11y configuration
|
||||
|
||||
const axeConfig = {
|
||||
|
|
|
@ -7,14 +7,18 @@
|
|||
|
||||
declare namespace Cypress {
|
||||
interface Chainable {
|
||||
loginAsViewerUser(): void;
|
||||
loginAsEditorUser(): void;
|
||||
loginAs(params: { username: string; password: string }): void;
|
||||
loginAsViewerUser(): Cypress.Chainable<Cypress.Response<any>>;
|
||||
loginAsEditorUser(): Cypress.Chainable<Cypress.Response<any>>;
|
||||
loginAs(params: {
|
||||
username: string;
|
||||
password: string;
|
||||
}): Cypress.Chainable<Cypress.Response<any>>;
|
||||
changeTimeRange(value: string): void;
|
||||
selectAbsoluteTimeRange(start: string, end: string): void;
|
||||
expectAPIsToHaveBeenCalledWith(params: {
|
||||
apisIntercepted: string[];
|
||||
value: string;
|
||||
}): void;
|
||||
updateAdvancedSettings(settings: Record<string, unknown>): void;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue