Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[APM] Custom links creation don't work #110676

Merged
merged 3 commits into from Sep 1, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions x-pack/plugins/apm/ftr_e2e/config.ts
Expand Up @@ -35,6 +35,7 @@ async function config({ readConfigFile }: FtrConfigProviderContext) {
...xpackFunctionalTestsConfig.get('kbnTestServer.serverArgs'),
'--home.disableWelcomeScreen=true',
'--csp.strict=false',
'--csp.warnLegacyBrowsers=false',
// define custom kibana server args here
`--elasticsearch.ssl.certificateAuthorities=${CA_CERT_PATH}`,
],
Expand Down
@@ -0,0 +1,37 @@
/*
* 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 basePath = '/app/apm/settings/customize-ui';

describe('Custom links', () => {
beforeEach(() => {
cy.loginAsPowerUser();
});

it('shows empty message and create button', () => {
cy.visit(basePath);
cy.contains('No links found');
cy.contains('Create custom link');
});

it('creates custom link', () => {
cy.visit(basePath);
const emptyPrompt = cy.get('[data-test-subj="customLinksEmptyPrompt"]');
cy.contains('Create custom link').click();
cy.contains('Create link');
cy.contains('Save').should('be.disabled');
cy.get('input[name="label"]').type('foo');
cy.get('input[name="url"]').type('https://foo.com');
cy.contains('Save').should('not.be.disabled');
cy.contains('Save').click();
emptyPrompt.should('not.exist');
cy.contains('foo');
cy.contains('https://foo.com');
cy.get('[data-test-subj="editCustomLink"]').click();
cy.contains('Delete').click();
});
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for adding this. Our new e2e suite is on fire (in the best possible way! :D )

4 changes: 2 additions & 2 deletions x-pack/plugins/apm/ftr_e2e/cypress/support/commands.ts
Expand Up @@ -11,8 +11,8 @@ Cypress.Commands.add('loginAsReadOnlyUser', () => {
cy.loginAs({ username: 'apm_read_user', password: 'changeme' });
});

Cypress.Commands.add('loginAsSuperUser', () => {
cy.loginAs({ username: 'elastic', password: 'changeme' });
Cypress.Commands.add('loginAsPowerUser', () => {
cy.loginAs({ username: 'apm_power_user', password: 'changeme' });
});

Cypress.Commands.add(
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/apm/ftr_e2e/cypress/support/types.d.ts
Expand Up @@ -8,7 +8,7 @@
declare namespace Cypress {
interface Chainable {
loginAsReadOnlyUser(): void;
loginAsSuperUser(): void;
loginAsPowerUser(): void;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for removing the superuser. We really should only use the two others.
Going forward I think we can replace our custom roles with the built in roles viewer and editor.

loginAs(params: { username: string; password: string }): void;
changeTimeRange(value: string): void;
expectAPIsToHaveBeenCalledWith(params: {
Expand Down
Expand Up @@ -17,6 +17,7 @@ export function EmptyPrompt({
}) {
return (
<EuiEmptyPrompt
data-test-subj="customLinksEmptyPrompt"
iconType="link"
iconColor=""
title={
Expand Down
Expand Up @@ -47,6 +47,7 @@ export function FlyoutFooter({
<DeleteButton customLinkId={customLinkId} onDelete={onDelete} />
)}
<EuiButton
form="customLink_form"
fill
type="submit"
isLoading={isSaving}
Expand Down
Expand Up @@ -9,7 +9,6 @@ import {
EuiFlyout,
EuiFlyoutBody,
EuiFlyoutHeader,
EuiPortal,
EuiSpacer,
EuiText,
EuiTitle,
Expand Down Expand Up @@ -76,69 +75,67 @@ export function CreateEditCustomLinkFlyout({
};

return (
<EuiPortal>
<form onSubmit={onSubmit}>
<EuiFlyout ownFocus onClose={onClose} size="m">
<EuiFlyoutHeader hasBorder>
<EuiTitle size="s">
<h2>
{i18n.translate(
'xpack.apm.settings.customizeUI.customLink.flyout.title',
<form onSubmit={onSubmit} id="customLink_form">
<EuiFlyout ownFocus onClose={onClose} size="m">
<EuiFlyoutHeader hasBorder>
<EuiTitle size="s">
<h2>
{i18n.translate(
'xpack.apm.settings.customizeUI.customLink.flyout.title',
{
defaultMessage: 'Create link',
}
)}
</h2>
</EuiTitle>
</EuiFlyoutHeader>
<EuiFlyoutBody>
<EuiText>
<p>
{i18n.translate(
'xpack.apm.settings.customizeUI.customLink.flyout.label',
{
defaultMessage:
'Links will be available in the context of transaction details throughout the APM app. You can create an unlimited number of links. You can refer to dynamic variables by using any of the transaction metadata to fill in your URLs. More information, including examples, are available in the',
}
)}{' '}
<Documentation
label={i18n.translate(
'xpack.apm.settings.customizeUI.customLink.flyout.label.doc',
{
defaultMessage: 'Create link',
defaultMessage: 'documentation.',
}
)}
</h2>
</EuiTitle>
</EuiFlyoutHeader>
<EuiFlyoutBody>
<EuiText>
<p>
{i18n.translate(
'xpack.apm.settings.customizeUI.customLink.flyout.label',
{
defaultMessage:
'Links will be available in the context of transaction details throughout the APM app. You can create an unlimited number of links. You can refer to dynamic variables by using any of the transaction metadata to fill in your URLs. More information, including examples, are available in the',
}
)}{' '}
<Documentation
label={i18n.translate(
'xpack.apm.settings.customizeUI.customLink.flyout.label.doc',
{
defaultMessage: 'documentation.',
}
)}
/>
</p>
</EuiText>
/>
</p>
</EuiText>

<EuiSpacer size="l" />
<EuiSpacer size="l" />

<LinkSection
label={label}
onChangeLabel={setLabel}
url={url}
onChangeUrl={setUrl}
/>
<LinkSection
label={label}
onChangeLabel={setLabel}
url={url}
onChangeUrl={setUrl}
/>

<EuiSpacer size="l" />
<EuiSpacer size="l" />

<FiltersSection filters={filters} onChangeFilters={setFilters} />
<FiltersSection filters={filters} onChangeFilters={setFilters} />

<EuiSpacer size="l" />
<EuiSpacer size="l" />

<LinkPreview label={label} url={url} filters={filters} />
</EuiFlyoutBody>
<LinkPreview label={label} url={url} filters={filters} />
</EuiFlyoutBody>

<FlyoutFooter
isSaveButtonEnabled={isFormValid}
onClose={onClose}
isSaving={isSaving}
onDelete={onDelete}
customLinkId={customLinkId}
/>
</EuiFlyout>
</form>
</EuiPortal>
<FlyoutFooter
isSaveButtonEnabled={isFormValid}
onClose={onClose}
isSaving={isSaving}
onDelete={onDelete}
customLinkId={customLinkId}
/>
</EuiFlyout>
</form>
);
}
Expand Up @@ -79,6 +79,7 @@ export function CustomLinkTable({ items = [], onCustomLinkSelected }: Props) {
icon: 'pencil',
color: 'primary',
type: 'icon',
'data-test-subj': 'editCustomLink',
onClick: (customLink: CustomLink) => {
onCustomLinkSelected(customLink);
},
Expand Down