mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 01:13:23 -04:00
[Fleet] Add basic cypress tests for download source section (#137079)
This commit is contained in:
parent
0596007f64
commit
f4348e6c9c
6 changed files with 152 additions and 4 deletions
|
@ -0,0 +1,102 @@
|
|||
/*
|
||||
* 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 {
|
||||
SETTINGS_TAB,
|
||||
AGENT_BINARY_SOURCES_TABLE,
|
||||
AGENT_BINARY_SOURCES_TABLE_ACTIONS,
|
||||
AGENT_BINARY_SOURCES_FLYOUT,
|
||||
AGENT_POLICY_FORM,
|
||||
CONFIRM_MODAL_CONFIRM_BUTTON,
|
||||
} from '../screens/fleet';
|
||||
import { cleanupDownloadSources } from '../tasks/cleanup';
|
||||
import { FLEET, navigateTo } from '../tasks/navigation';
|
||||
|
||||
describe('Agent binary download source section', () => {
|
||||
beforeEach(() => {
|
||||
cleanupDownloadSources();
|
||||
navigateTo(FLEET);
|
||||
});
|
||||
|
||||
it('has a default value and allows to edit an existing object', () => {
|
||||
cy.getBySel(SETTINGS_TAB).click();
|
||||
|
||||
cy.getBySel(AGENT_BINARY_SOURCES_TABLE).find('tr').should('have.length', '2');
|
||||
cy.getBySel(AGENT_BINARY_SOURCES_TABLE_ACTIONS.HOST).contains(
|
||||
'https://artifacts.elastic.co/downloads/beats/elastic-agent'
|
||||
);
|
||||
cy.getBySel(AGENT_BINARY_SOURCES_TABLE_ACTIONS.DEFAULT_VALUE).should('exist');
|
||||
cy.getBySel(AGENT_BINARY_SOURCES_TABLE_ACTIONS.EDIT).click();
|
||||
cy.getBySel(AGENT_BINARY_SOURCES_FLYOUT.NAME_INPUT).clear().type('New Name');
|
||||
cy.getBySel(AGENT_BINARY_SOURCES_FLYOUT.HOST_INPUT)
|
||||
.clear()
|
||||
.type('https://edited-default-host.co');
|
||||
cy.getBySel(AGENT_BINARY_SOURCES_FLYOUT.SUBMIT_BUTTON).click();
|
||||
cy.getBySel(CONFIRM_MODAL_CONFIRM_BUTTON).click();
|
||||
|
||||
cy.intercept('api/fleet/agent_download_sources/fleet-default-download-source', {
|
||||
host: 'https://edited-default-host.co',
|
||||
is_default: true,
|
||||
name: 'New Name',
|
||||
});
|
||||
});
|
||||
|
||||
it('allows to create new download source objects', () => {
|
||||
cy.getBySel(SETTINGS_TAB).click();
|
||||
|
||||
cy.getBySel(AGENT_BINARY_SOURCES_TABLE_ACTIONS.ADD).click();
|
||||
cy.getBySel(AGENT_BINARY_SOURCES_FLYOUT.NAME_INPUT).clear().type('New Host');
|
||||
cy.getBySel(AGENT_BINARY_SOURCES_FLYOUT.HOST_INPUT).clear().type('https://new-test-host.co');
|
||||
cy.getBySel(AGENT_BINARY_SOURCES_FLYOUT.SUBMIT_BUTTON).click();
|
||||
cy.getBySel(AGENT_BINARY_SOURCES_TABLE).find('tr').should('have.length', '3');
|
||||
cy.intercept('api/fleet/agent_download_sources', {
|
||||
name: 'New Host',
|
||||
is_default: false,
|
||||
host: 'https://new-test-host.co',
|
||||
});
|
||||
|
||||
cy.getBySel(AGENT_BINARY_SOURCES_TABLE_ACTIONS.ADD).click();
|
||||
cy.getBySel(AGENT_BINARY_SOURCES_FLYOUT.NAME_INPUT).clear().type('New Default Host');
|
||||
cy.getBySel(AGENT_BINARY_SOURCES_FLYOUT.HOST_INPUT).clear().type('https://new-default-host.co');
|
||||
cy.getBySel(AGENT_BINARY_SOURCES_FLYOUT.IS_DEFAULT_SWITCH).click();
|
||||
cy.getBySel(AGENT_BINARY_SOURCES_FLYOUT.SUBMIT_BUTTON).click();
|
||||
|
||||
cy.intercept('api/fleet/agent_download_sources', {
|
||||
name: 'New Default Host',
|
||||
is_default: true,
|
||||
host: 'https://new-default-host.co',
|
||||
});
|
||||
});
|
||||
|
||||
it('the download source is displayed in agent policy settings', () => {
|
||||
cy.request({
|
||||
method: 'POST',
|
||||
url: `api/fleet/agent_download_sources`,
|
||||
body: {
|
||||
name: 'Custom Host',
|
||||
id: 'fleet-local-registry',
|
||||
host: 'https://new-custom-host.co',
|
||||
},
|
||||
headers: { 'kbn-xsrf': 'kibana' },
|
||||
});
|
||||
cy.request({
|
||||
method: 'POST',
|
||||
url: '/api/fleet/agent_policies',
|
||||
body: {
|
||||
name: 'Test Agent policy',
|
||||
namespace: 'default',
|
||||
description: '',
|
||||
monitoring_enabled: ['logs', 'metrics'],
|
||||
id: 'new-agent-policy',
|
||||
download_source_id: 'fleet-local-registry',
|
||||
},
|
||||
headers: { 'kbn-xsrf': 'kibana' },
|
||||
}).then((response: any) => {
|
||||
navigateTo('app/fleet/policies/new-agent-policy/settings');
|
||||
cy.getBySel(AGENT_POLICY_FORM.DOWNLOAD_SOURCE_SELECT).contains('Custom Host');
|
||||
});
|
||||
});
|
||||
});
|
|
@ -27,7 +27,7 @@ import {
|
|||
import { ADD_PACKAGE_POLICY_BTN } from '../screens/fleet';
|
||||
import { cleanupAgentPolicies } from '../tasks/cleanup';
|
||||
|
||||
describe('Add Integration - Real API', () => {
|
||||
describe.skip('Add Integration - Real API', () => {
|
||||
const integration = 'Apache';
|
||||
|
||||
after(() => {
|
||||
|
|
|
@ -24,7 +24,31 @@ export const AGENT_POLICY_SAVE_INTEGRATION = 'saveIntegration';
|
|||
export const PACKAGE_POLICY_TABLE_LINK = 'PackagePoliciesTableLink';
|
||||
export const ADD_PACKAGE_POLICY_BTN = 'addPackagePolicyButton';
|
||||
|
||||
export const AGENT_BINARY_SOURCES_TABLE = 'AgentDownloadSourcesTable';
|
||||
export const AGENT_BINARY_SOURCES_TABLE_ACTIONS = {
|
||||
DEFAULT_VALUE: 'editDownloadSourceTable.defaultIcon',
|
||||
HOST: 'editDownloadSourceTable.host',
|
||||
ADD: 'addDownloadSourcesBtn',
|
||||
EDIT: 'editDownloadSourceTable.edit.btn',
|
||||
DELETE: 'editDownloadSourceTable.delete.btn',
|
||||
DEFAULT_ICON: 'editDownloadSourceTable.defaultIcon',
|
||||
HOST_NAME: 'editDownloadSourceTable.host',
|
||||
};
|
||||
export const AGENT_BINARY_SOURCES_FLYOUT = {
|
||||
NAME_INPUT: 'editDownloadSourcesFlyout.nameInput',
|
||||
HOST_INPUT: 'editDownloadSourcesFlyout.hostInput',
|
||||
IS_DEFAULT_SWITCH: 'editDownloadSourcesFlyout.isDefaultSwitch',
|
||||
SUBMIT_BUTTON: 'editDownloadSourcesFlyout.submitBtn',
|
||||
CANCEL_BUTTON: 'editDownloadSourcesFlyout.cancelBtn',
|
||||
};
|
||||
|
||||
export const ADD_AGENT_FLYOUT = {
|
||||
CONFIRM_AGENT_ENROLLMENT_BUTTON: 'ConfirmAgentEnrollmentButton',
|
||||
INCOMING_DATA_CONFIRMED_CALL_OUT: 'IncomingDataConfirmedCallOut',
|
||||
};
|
||||
export const CONFIRM_MODAL_CONFIRM_BUTTON = 'confirmModalConfirmButton';
|
||||
export const CONFIRM_MODAL_CANCEL_BUTTON = 'confirmModalCancelButton';
|
||||
|
||||
export const AGENT_POLICY_FORM = {
|
||||
DOWNLOAD_SOURCE_SELECT: 'agentPolicyForm.downloadSource.select',
|
||||
};
|
||||
|
|
|
@ -34,3 +34,17 @@ export function unenrollAgent() {
|
|||
}
|
||||
);
|
||||
}
|
||||
|
||||
export function cleanupDownloadSources() {
|
||||
cy.request('/api/fleet/agent_download_sources').then((response: any) => {
|
||||
response.body.items
|
||||
.filter((ds: any) => !ds.is_default)
|
||||
.forEach((ds: any) => {
|
||||
cy.request({
|
||||
method: 'DELETE',
|
||||
url: `/api/fleet/agent_download_sources/${ds.id}`,
|
||||
headers: { 'kbn-xsrf': 'kibana' },
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -76,7 +76,9 @@ export const DownloadSourceTable: React.FunctionComponent<DownloadSourceTablePro
|
|||
},
|
||||
{
|
||||
render: (downloadSource: DownloadSource) =>
|
||||
downloadSource.is_default ? <EuiIcon type="check" /> : null,
|
||||
downloadSource.is_default ? (
|
||||
<EuiIcon type="check" data-test-subj="editDownloadSourceTable.defaultIcon" />
|
||||
) : null,
|
||||
width: '200px',
|
||||
name: i18n.translate('xpack.fleet.settings.downloadSourcesTable.defaultColumnTitle', {
|
||||
defaultMessage: 'Default',
|
||||
|
@ -131,5 +133,11 @@ export const DownloadSourceTable: React.FunctionComponent<DownloadSourceTablePro
|
|||
];
|
||||
}, [deleteDownloadSource, getHref]);
|
||||
|
||||
return <EuiBasicTable columns={columns} items={downloadSources} />;
|
||||
return (
|
||||
<EuiBasicTable
|
||||
columns={columns}
|
||||
items={downloadSources}
|
||||
data-test-subj="AgentDownloadSourcesTable"
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
|
|
@ -50,7 +50,7 @@ export const AgentBinarySection: React.FunctionComponent<AgentBinarySectionProps
|
|||
<EuiButtonEmpty
|
||||
iconType="plusInCircle"
|
||||
href={getHref('settings_create_download_sources')}
|
||||
data-test-subj="adddownloadSourcesBtn"
|
||||
data-test-subj="addDownloadSourcesBtn"
|
||||
>
|
||||
<FormattedMessage
|
||||
id="xpack.fleet.settings.downloadSourcesSection.CreateButtonLabel"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue