Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .buildkite/pipelines/flaky_tests/groups.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -43,4 +47,4 @@
"name": "Default Accessibility"
}
]
}
}
Original file line number Diff line number Diff line change
@@ -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');
});
});

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
{
Expand All @@ -44,6 +44,7 @@ export function getApmSettings(): SettingsRow[] {
defaultMessage: 'URL',
}
),
dataTestSubj: 'packagePolicyUrlInput',
required: true,
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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}
Expand All @@ -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) => {
Expand All @@ -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) => {
Expand All @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export interface BasicSettingRow {
labelAppend?: string;
labelAppendLink?: string;
labelAppendLinkText?: string;
dataTestSubj?: string;
Comment thread
kpatticha marked this conversation as resolved.
settings?: SettingsRow[];
validation?: SettingValidation;
required?: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export const powerUserRole: RoleType = {
savedObjectsManagement: ['all'],
stackAlerts: ['all'],
fleet: ['all'],
fleetv2: ['all'],
actions: ['all'],
},
spaces: ['*'],
Expand Down