Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
32e615d
Refactor BeatsCM
mattapperson Dec 4, 2018
759a145
update deps
mattapperson Dec 4, 2018
130609e
update more deps
mattapperson Dec 4, 2018
9e59135
update for new EUI definitions
mattapperson Dec 4, 2018
1e37dcd
update import
mattapperson Dec 4, 2018
09bc444
Revert "update deps"
mattapperson Dec 4, 2018
7dd62a0
use _source_includes
mattapperson Dec 4, 2018
7802abf
remove _source_includes
mattapperson Dec 4, 2018
c6721ae
Merge branch 'master' of github.com:elastic/kibana into refactor/ga-q…
mattapperson Dec 4, 2018
acb1db8
work-around due to watcher UI tests
mattapperson Dec 5, 2018
ba8f75e
Keep all xpack checks safe because we cant trust its there in tests f…
mattapperson Dec 5, 2018
033b95c
VALIDATION. This commit is to ensure the errors in CI are coming from…
mattapperson Dec 5, 2018
3c1628d
remove validation that this is a beats CM issue
mattapperson Dec 5, 2018
33757e0
More try/catch to try and find where this error is
mattapperson Dec 5, 2018
776c347
testing another call
mattapperson Dec 5, 2018
9121ac3
revert back to dangerouslyGetActiveInjector
mattapperson Dec 5, 2018
8aea8c3
Merge branch 'master' of github.com:elastic/kibana into refactor/ga-q…
mattapperson Dec 5, 2018
cd18dbc
ensure expire always is a number
mattapperson Dec 5, 2018
301491d
Merge branch 'master' of github.com:elastic/kibana into refactor/ga-q…
mattapperson Dec 6, 2018
ca6082b
[BeatsCM] Fixes #26016 - beat type always updates in command now
mattapperson Dec 6, 2018
8f118ea
Merge branch 'master' of github.com:elastic/kibana into beats/fix-com…
mattapperson Dec 10, 2018
506a4d6
Merge branch 'master' of github.com:elastic/kibana into beats/fix-com…
mattapperson Dec 10, 2018
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
26 changes: 10 additions & 16 deletions x-pack/plugins/beats_management/public/components/enroll_beats.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -144,17 +144,15 @@ export class EnrollBeat extends React.Component<ComponentProps, ComponentState>
value={this.state.command}
options={[
{
value: `sudo ${this.state.beatType}`,
value: `sudo {{beatType}}`,
text: 'DEB / RPM',
},
{
value: `PS C:\\Program Files\\${capitalize(this.state.beatType)}> ${
this.state.beatType
}.exe`,
value: `PS C:\\Program Files\\{{beatTypeInCaps)}}> {{beatType}}.exe`,
text: 'Windows',
},
{
value: `./${this.state.beatType}`,
value: `./{{beatType}}`,
text: 'MacOS',
},
]}
Expand Down Expand Up @@ -188,17 +186,13 @@ export class EnrollBeat extends React.Component<ComponentProps, ComponentState>
className="euiFieldText euiFieldText--fullWidth"
style={{ textAlign: 'left' }}
>
<FormattedMessage
id="xpack.beatsManagement.enrollBeat.stateCommandEnrollLocationProtocolTitle"
defaultMessage="$ {stateCommand} enroll {locationProtocol}"
values={{
stateCommand: this.state.command,
locationProtocol: window.location.protocol,
}}
/>
{`//`}
{window.location.host}
{this.props.frameworkBasePath} {this.props.enrollmentToken}
{`$ ${this.state.command
.replace('{{beatType}}', this.state.beatType)
.replace('{{beatTypeInCaps}}', capitalize(this.state.beatType))} enroll ${
window.location.protocol
}://${window.location.host} ${this.props.frameworkBasePath} ${
this.props.enrollmentToken
}`}
</div>
</div>
<br />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`RouteTreeBuilder routeTreeFromPaths Should create a route tree 1`] = `
Array [
Object {
"component": null,
"path": "/tag",
},
Object {
"component": null,
"path": "/beat",
"routes": Array [
Object {
"component": null,
"path": "/beat/detail",
},
Object {
"component": null,
"path": "/beat/tags",
},
],
},
Object {
"component": null,
"path": "/error/enforce_security",
},
Object {
"component": null,
"path": "/error/invalid_license",
},
Object {
"component": null,
"path": "/error/no_access",
},
Object {
"component": null,
"path": "/overview",
"routes": Array [
Object {
"component": null,
"path": "/overview/enrolled_beats",
},
Object {
"component": null,
"path": "/overview/tag_configurations",
},
],
},
Object {
"component": null,
"path": "/walkthrough/initial",
"routes": Array [
Object {
"component": null,
"path": "/walkthrough/initial/beat",
},
Object {
"component": null,
"path": "/walkthrough/initial/finish",
},
Object {
"component": null,
"path": "/walkthrough/initial/tag",
},
],
},
Object {
"component": null,
"path": "*",
},
]
`;

exports[`RouteTreeBuilder routeTreeFromPaths Should create a route tree, with top level route having params 1`] = `
Array [
Object {
"component": null,
"path": "/tag/:action/:tagid?",
},
Object {
"component": null,
"path": "/beat",
"routes": Array [
Object {
"component": null,
"path": "/beat/detail",
},
Object {
"component": null,
"path": "/beat/tags",
},
],
},
Object {
"component": null,
"path": "/error/enforce_security",
},
Object {
"component": null,
"path": "/error/invalid_license",
},
Object {
"component": null,
"path": "/error/no_access",
},
Object {
"component": null,
"path": "/overview",
"routes": Array [
Object {
"component": null,
"path": "/overview/enrolled_beats",
},
Object {
"component": null,
"path": "/overview/tag_configurations",
},
],
},
Object {
"component": null,
"path": "/walkthrough/initial",
"routes": Array [
Object {
"component": null,
"path": "/walkthrough/initial/beat",
},
Object {
"component": null,
"path": "/walkthrough/initial/finish",
},
Object {
"component": null,
"path": "/walkthrough/initial/tag",
},
],
},
Object {
"component": null,
"path": "*",
},
]
`;
138 changes: 138 additions & 0 deletions x-pack/plugins/beats_management/public/utils/page_loader.test.ts
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;
* you may not use this file except in compliance with the Elastic License.
*/

import { RouteTreeBuilder } from './page_loader';

const pages = [
'./_404.tsx',
'./beat/detail.tsx',
'./beat/index.tsx',
'./beat/tags.tsx',
'./error/enforce_security.tsx',
'./error/invalid_license.tsx',
'./error/no_access.tsx',
'./overview/enrolled_beats.tsx',
'./overview/index.tsx',
'./overview/tag_configurations.tsx',
'./tag.tsx',
'./walkthrough/initial/beat.tsx',
'./walkthrough/initial/finish.tsx',
'./walkthrough/initial/index.tsx',
'./walkthrough/initial/tag.tsx',
];

describe('RouteTreeBuilder', () => {
describe('routeTreeFromPaths', () => {
it('Should fail to create a route tree due to no exported *Page component', () => {
const mockRequire = jest.fn(path => ({
path,
testComponent: null,
}));

const treeBuilder = new RouteTreeBuilder(mockRequire);

expect(() => {
treeBuilder.routeTreeFromPaths(pages);
}).toThrowError(/in the pages folder does not include an exported/);
});

it('Should create a route tree', () => {
const mockRequire = jest.fn(path => ({
path,
testPage: null,
}));

const treeBuilder = new RouteTreeBuilder(mockRequire);

let tree;
expect(() => {
tree = treeBuilder.routeTreeFromPaths(pages);
}).not.toThrow();
expect(tree).toMatchSnapshot();
});

it('Should fail to create a route tree due to no exported custom *Component component', () => {
const mockRequire = jest.fn(path => ({
path,
testComponent: null,
}));

const treeBuilder = new RouteTreeBuilder(mockRequire, /Component$/);

expect(() => {
treeBuilder.routeTreeFromPaths(pages);
}).not.toThrow();
});

it('Should create a route tree, with top level route having params', () => {
const mockRequire = jest.fn(path => ({
path,
testPage: null,
}));

const treeBuilder = new RouteTreeBuilder(mockRequire);
const tree = treeBuilder.routeTreeFromPaths(pages, {
'/tag': ['action', 'tagid?'],
});
expect(tree).toMatchSnapshot();
});

it('Should create a route tree, with a nested route having params', () => {
const mockRequire = jest.fn(path => ({
path,
testPage: null,
}));

const treeBuilder = new RouteTreeBuilder(mockRequire);
const tree = treeBuilder.routeTreeFromPaths(pages, {
'/beat': ['beatId'],
});
expect(tree[1].path).toEqual('/beat/:beatId');
});
});
it('Should create a route tree, with a deep nested route having params', () => {
const mockRequire = jest.fn(path => ({
path,
testPage: null,
}));

const treeBuilder = new RouteTreeBuilder(mockRequire);
const tree = treeBuilder.routeTreeFromPaths(pages, {
'/beat': ['beatId'],
'/beat/detail': ['other'],
});
expect(tree[1].path).toEqual('/beat/:beatId');
expect(tree[1].routes![0].path).toEqual('/beat/:beatId/detail/:other');
expect(tree[1].routes![1].path).toEqual('/beat/:beatId/tags');
});
it('Should throw an error on invalid mapped path', () => {
const mockRequire = jest.fn(path => ({
path,
testPage: null,
}));

const treeBuilder = new RouteTreeBuilder(mockRequire);
expect(() => {
treeBuilder.routeTreeFromPaths(pages, {
'/non-existant-path': ['beatId'],
});
}).toThrowError(/Invalid overideMap provided to 'routeTreeFromPaths', \/non-existant-path /);
});
it('Should rended 404.tsx as a 404 route not /404', () => {
const mockRequire = jest.fn(path => ({
path,
testPage: null,
}));

const treeBuilder = new RouteTreeBuilder(mockRequire);
const tree = treeBuilder.routeTreeFromPaths(pages);
const firstPath = tree[0].path;
const lastPath = tree[tree.length - 1].path;

expect(firstPath).not.toBe('/_404');
expect(lastPath).toBe('*');
});
});
Loading