mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
Add e2e for the apm integration policy form (#129860)
* Grant fleet privileges and capabilities to power user * Add e2e for integration policy * Fix selector for Tail-based * Remove e2e releated to Fleet code * Decouple tests * Clean up assertion * Fix flaky test
This commit is contained in:
parent
d41fb22d92
commit
8022b0aba7
7 changed files with 152 additions and 46 deletions
|
@ -25,6 +25,10 @@
|
|||
"key": "xpack/cypress/fleet_cypress",
|
||||
"name": "Fleet - Cypress"
|
||||
},
|
||||
{
|
||||
"key": "xpack/cypress/apm_cypress",
|
||||
"name": "APM - Cypress"
|
||||
},
|
||||
{
|
||||
"key": "xpack/cigroup",
|
||||
"name": "Default CI Group",
|
||||
|
@ -43,4 +47,4 @@
|
|||
"name": "Default Accessibility"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
|
@ -0,0 +1,138 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
const integrationsPoliciesPath = '/app/integrations/detail/apm/policies';
|
||||
const policyName = 'apm-integration';
|
||||
const description = 'integration description';
|
||||
const host = 'myhost:8200';
|
||||
const url = 'http://myhost:8200';
|
||||
|
||||
const policyFormFields = [
|
||||
{
|
||||
selector: 'packagePolicyNameInput',
|
||||
value: 'apm-integration',
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
selector: 'packagePolicyDescriptionInput',
|
||||
value: 'apm policy descrtiption',
|
||||
required: false,
|
||||
},
|
||||
{
|
||||
selector: 'packagePolicyHostInput',
|
||||
value: 'myhost:8200',
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
selector: 'packagePolicyUrlInput',
|
||||
value: 'http://myhost:8200',
|
||||
required: true,
|
||||
},
|
||||
];
|
||||
|
||||
const apisToIntercept = [
|
||||
{
|
||||
endpoint: 'api/fleet/agent_policies*',
|
||||
name: 'fleetAgentPolicies',
|
||||
method: 'POST',
|
||||
},
|
||||
{
|
||||
endpoint: 'api/fleet/agent_status*',
|
||||
name: 'fleetAgentStatus',
|
||||
method: 'GET',
|
||||
},
|
||||
{
|
||||
endpoint: 'api/fleet/package_policies',
|
||||
name: 'fleetPackagePolicies',
|
||||
method: 'POST',
|
||||
},
|
||||
];
|
||||
|
||||
describe('when navigating to integration page', () => {
|
||||
beforeEach(() => {
|
||||
const integrationsPath = '/app/integrations/browse';
|
||||
|
||||
cy.loginAsPowerUser();
|
||||
cy.visit(integrationsPath);
|
||||
|
||||
// open integration policy form
|
||||
cy.get('[data-test-subj="integration-card:epr:apm:featured').click();
|
||||
cy.contains('Elastic APM in Fleet').click();
|
||||
cy.contains('a', 'APM integration').click();
|
||||
cy.get('[data-test-subj="addIntegrationPolicyButton"]').click();
|
||||
});
|
||||
|
||||
it('checks validators for required fields', () => {
|
||||
const requiredFields = policyFormFields.filter((field) => field.required);
|
||||
|
||||
requiredFields.map((field) => {
|
||||
cy.get(`[data-test-subj="${field.selector}"`).clear();
|
||||
cy.get('[data-test-subj="createPackagePolicySaveButton"').should(
|
||||
'be.disabled'
|
||||
);
|
||||
cy.get(`[data-test-subj="${field.selector}"`).type(field.value);
|
||||
});
|
||||
});
|
||||
|
||||
it('adds a new policy without agent', () => {
|
||||
apisToIntercept.map(({ endpoint, method, name }) => {
|
||||
cy.intercept(method, endpoint).as(name);
|
||||
});
|
||||
|
||||
cy.url().should('include', 'app/fleet/integrations/apm/add-integration');
|
||||
policyFormFields.map((field) => {
|
||||
cy.get(`[data-test-subj="${field.selector}"`).clear().type(field.value);
|
||||
});
|
||||
cy.contains('Save and continue').click();
|
||||
cy.wait('@fleetAgentPolicies');
|
||||
cy.wait('@fleetAgentStatus');
|
||||
cy.wait('@fleetPackagePolicies');
|
||||
|
||||
cy.get('[data-test-subj="confirmModalCancelButton').click();
|
||||
|
||||
cy.url().should('include', '/app/integrations/detail/apm/policies');
|
||||
cy.contains(policyName);
|
||||
});
|
||||
|
||||
it('updates an existing policy', () => {
|
||||
apisToIntercept.map(({ endpoint, method, name }) => {
|
||||
cy.intercept(method, endpoint).as(name);
|
||||
});
|
||||
|
||||
policyFormFields.map((field) => {
|
||||
cy.get(`[data-test-subj="${field.selector}"`)
|
||||
.clear()
|
||||
.type(`${field.value}-new`);
|
||||
});
|
||||
|
||||
cy.contains('Save and continue').click();
|
||||
cy.wait('@fleetAgentPolicies');
|
||||
cy.wait('@fleetAgentStatus');
|
||||
cy.wait('@fleetPackagePolicies');
|
||||
|
||||
cy.get('[data-test-subj="confirmModalCancelButton').click();
|
||||
cy.contains(`${policyName}-new`).click();
|
||||
|
||||
policyFormFields.map((field) => {
|
||||
cy.get(`[data-test-subj="${field.selector}"`)
|
||||
.clear()
|
||||
.type(`${field.value}-updated`);
|
||||
});
|
||||
cy.contains('Save integration').click();
|
||||
cy.contains(`${policyName}-updated`);
|
||||
});
|
||||
|
||||
it('should display Tail-based section on latest version', () => {
|
||||
cy.visit('/app/fleet/integrations/apm/add-integration');
|
||||
cy.contains('Tail-based sampling').should('exist');
|
||||
});
|
||||
|
||||
it('should hide Tail-based section for 8.0.0 apm package', () => {
|
||||
cy.visit('/app/fleet/integrations/apm-8.0.0/add-integration');
|
||||
cy.contains('Tail-based sampling').should('not.exist');
|
||||
});
|
||||
});
|
|
@ -1,44 +0,0 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
const integrationsPath = '/app/integrations/browse';
|
||||
|
||||
describe('when navigating to the integrations browse page', () => {
|
||||
beforeEach(() => {
|
||||
cy.loginAsReadOnlyUser();
|
||||
cy.visit(integrationsPath);
|
||||
});
|
||||
|
||||
it('should display Elastic APM integration option', () => {
|
||||
cy.get('[data-test-subj="integration-card:epr:apm:featured').should(
|
||||
'exist'
|
||||
);
|
||||
cy.contains('Elastic APM');
|
||||
});
|
||||
|
||||
describe('when clicking on the Elastic APM option but Fleet is not installed', () => {
|
||||
it('should display Elastic APM in Fleet tab', () => {
|
||||
cy.get('[data-test-subj="integration-card:epr:apm:featured').click();
|
||||
cy.get('[aria-selected="true"]').contains('Elastic APM in Fleet');
|
||||
cy.contains('Elastic APM now available in Fleet!');
|
||||
cy.contains('APM integration');
|
||||
});
|
||||
|
||||
it('should display no APM server detected when checking the apm server status', () => {
|
||||
cy.intercept('POST', '/api/home/hits_status', {
|
||||
count: 0,
|
||||
}).as('hitsStatus');
|
||||
|
||||
cy.get('[data-test-subj="integration-card:epr:apm:featured').click();
|
||||
cy.contains('Check APM Server status').click();
|
||||
cy.wait('@hitsStatus');
|
||||
cy.contains(
|
||||
'No APM Server detected. Please make sure it is running and you have updated to 7.0 or higher.'
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
|
@ -31,7 +31,7 @@ export function getApmSettings(): SettingsRow[] {
|
|||
'Host defines the host and port the server is listening on. URL is the unchangeable, publicly reachable server URL for deployments on Elastic Cloud or ECK.',
|
||||
}
|
||||
),
|
||||
|
||||
dataTestSubj: 'packagePolicyHostInput',
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
|
@ -44,6 +44,7 @@ export function getApmSettings(): SettingsRow[] {
|
|||
defaultMessage: 'URL',
|
||||
}
|
||||
),
|
||||
dataTestSubj: 'packagePolicyUrlInput',
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
|
|
|
@ -45,6 +45,7 @@ export function FormRowSetting({ row, value, onChange, isDisabled }: Props) {
|
|||
case 'boolean': {
|
||||
return (
|
||||
<EuiSwitch
|
||||
data-test-subj={row.dataTestSubj}
|
||||
disabled={isDisabled}
|
||||
label={row.placeholder || (value ? ENABLED_LABEL : DISABLED_LABEL)}
|
||||
checked={value}
|
||||
|
@ -58,6 +59,7 @@ export function FormRowSetting({ row, value, onChange, isDisabled }: Props) {
|
|||
case 'text': {
|
||||
return (
|
||||
<EuiFieldText
|
||||
data-test-subj={row.dataTestSubj}
|
||||
disabled={isDisabled}
|
||||
value={value}
|
||||
prepend={isDisabled ? <EuiIcon type="lock" /> : undefined}
|
||||
|
@ -70,6 +72,7 @@ export function FormRowSetting({ row, value, onChange, isDisabled }: Props) {
|
|||
case 'area': {
|
||||
return (
|
||||
<EuiTextArea
|
||||
data-test-subj={row.dataTestSubj}
|
||||
disabled={isDisabled}
|
||||
value={value}
|
||||
onChange={(e) => {
|
||||
|
@ -82,6 +85,7 @@ export function FormRowSetting({ row, value, onChange, isDisabled }: Props) {
|
|||
case 'integer': {
|
||||
return (
|
||||
<EuiFieldNumber
|
||||
data-test-subj={row.dataTestSubj}
|
||||
disabled={isDisabled}
|
||||
value={value}
|
||||
onChange={(e) => {
|
||||
|
@ -96,6 +100,7 @@ export function FormRowSetting({ row, value, onChange, isDisabled }: Props) {
|
|||
: [];
|
||||
return (
|
||||
<EuiComboBox
|
||||
data-test-subj={row.dataTestSubj}
|
||||
noSuggestions
|
||||
placeholder={i18n.translate(
|
||||
'xpack.apm.fleet_integration.settings.selectOrCreateOptions',
|
||||
|
|
|
@ -47,6 +47,7 @@ export interface BasicSettingRow {
|
|||
labelAppend?: string;
|
||||
labelAppendLink?: string;
|
||||
labelAppendLinkText?: string;
|
||||
dataTestSubj?: string;
|
||||
settings?: SettingsRow[];
|
||||
validation?: SettingValidation;
|
||||
required?: boolean;
|
||||
|
|
|
@ -67,6 +67,7 @@ export const powerUserRole: RoleType = {
|
|||
savedObjectsManagement: ['all'],
|
||||
stackAlerts: ['all'],
|
||||
fleet: ['all'],
|
||||
fleetv2: ['all'],
|
||||
actions: ['all'],
|
||||
},
|
||||
spaces: ['*'],
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue