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

Migrate status page app to core #72017

Merged
merged 26 commits into from
Jul 23, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
ba9e213
move http.anonymousPaths.register('/status'); logic into core, remove…
pgayvallet Jul 16, 2020
5964ffc
Merge remote-tracking branch 'upstream/master' into kbn-67979-status-…
pgayvallet Jul 16, 2020
f63d8d2
move status_page to core & migrate lib
pgayvallet Jul 16, 2020
dcc1f0a
migrate the status_app components to TS/KP APIs
pgayvallet Jul 16, 2020
6b42c45
update rendering snapshots
pgayvallet Jul 16, 2020
854211e
use import type syntax
pgayvallet Jul 16, 2020
c4dbd19
moves `/status` server-side route to core
pgayvallet Jul 16, 2020
7f927f7
fix route registration
pgayvallet Jul 16, 2020
c857b74
Merge remote-tracking branch 'upstream/master' into kbn-67979-status-…
pgayvallet Jul 17, 2020
8a2f98e
update generated file
pgayvallet Jul 17, 2020
0a7b243
change statusPage i18n prefix
pgayvallet Jul 20, 2020
d65c125
Merge remote-tracking branch 'upstream/master' into kbn-67979-status-…
pgayvallet Jul 20, 2020
7bdc3c2
(temporary) try to restore legacy plugin to check behavior
pgayvallet Jul 20, 2020
e91d5b7
Merge remote-tracking branch 'upstream/master' into kbn-67979-status-…
pgayvallet Jul 21, 2020
b7bc230
add some FTR tests
pgayvallet Jul 21, 2020
4beb5d3
do not import whole lodash
pgayvallet Jul 21, 2020
66337af
update snapshots
pgayvallet Jul 21, 2020
46c5adf
Merge remote-tracking branch 'upstream/master' into kbn-67979-status-…
pgayvallet Jul 22, 2020
716dee7
review comments
pgayvallet Jul 22, 2020
92924b7
improve / clean component unit tests
pgayvallet Jul 22, 2020
7352ad9
change url for legacy status app
pgayvallet Jul 22, 2020
3a3e2e9
set status app as chromeless
pgayvallet Jul 22, 2020
5b8719e
fix FTR test due to chromeless app
pgayvallet Jul 22, 2020
1a0c2ae
fix typings
pgayvallet Jul 22, 2020
920f52b
add unit test for CoreApp /status registration
pgayvallet Jul 22, 2020
71f4273
Merge remote-tracking branch 'upstream/master' into kbn-67979-status-…
pgayvallet Jul 23, 2020
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
15 changes: 13 additions & 2 deletions src/core/public/core_app/status/components/metric_tiles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,14 @@ import { formatNumber, Metric } from '../lib';
*/
export const MetricTile: FunctionComponent<{ metric: Metric }> = ({ metric }) => {
const { name } = metric;
return <EuiCard layout="horizontal" title={formatMetric(metric)} description={name} />;
return (
<EuiCard
data-test-subj={`serverMetric-${formatMetricId(metric)}`}
layout="horizontal"
title={formatMetric(metric)}
description={name}
/>
);
};

/*
Expand All @@ -35,7 +42,7 @@ export const MetricTile: FunctionComponent<{ metric: Metric }> = ({ metric }) =>
export const MetricTiles: FunctionComponent<{ metrics: Metric[] }> = ({ metrics }) => (
<EuiFlexGrid columns={3}>
{metrics.map((metric) => (
<EuiFlexItem key={metric.name}>
<EuiFlexItem key={metric.name} data-test-subj="serverMetric">
<MetricTile metric={metric} />
</EuiFlexItem>
))}
Expand All @@ -46,3 +53,7 @@ const formatMetric = ({ value, type }: Metric) => {
const metrics = Array.isArray(value) ? value : [value];
return metrics.map((metric) => formatNumber(metric, type)).join(', ');
};

const formatMetricId = ({ name }: Metric) => {
return name.toLowerCase().replace(' ', '');
pgayvallet marked this conversation as resolved.
Show resolved Hide resolved
};
12 changes: 10 additions & 2 deletions src/core/public/core_app/status/components/server_status.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,20 @@ export const ServerStatus: FunctionComponent<ServerStateProps> = ({ name, server
<EuiFlexGroup alignItems="center" justifyContent="spaceBetween" style={{ flexGrow: 0 }}>
<EuiFlexItem grow={false}>
<EuiTitle>
<h2>
<h2 data-test-subj="serverStatusTitle">
<FormattedMessage
id="core.statusPage.serverStatus.statusTitle"
defaultMessage="Kibana status is {kibanaStatus}"
values={{
kibanaStatus: <EuiBadge color={serverState.uiColor}>{serverState.title}</EuiBadge>,
kibanaStatus: (
<EuiBadge
data-test-subj="serverStatusTitleBadge"
color={serverState.uiColor}
aria-label={serverState.title}
>
{serverState.title}
</EuiBadge>
),
}}
/>
</h2>
Expand Down
4 changes: 2 additions & 2 deletions src/core/public/core_app/status/status_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export class StatusApp extends Component<StatusAppProps, StatusAppState> {
<EuiFlexGroup>
<EuiFlexItem grow={false}>
<EuiText size="s">
<p>
<p data-test-subj="statusBuildNumber">
<FormattedMessage
id="core.statusPage.statusApp.statusActions.buildText"
defaultMessage="BUILD {buildNum}"
Expand All @@ -129,7 +129,7 @@ export class StatusApp extends Component<StatusAppProps, StatusAppState> {
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiText size="s">
<p>
<p data-test-subj="statusBuildHash">
<FormattedMessage
id="core.statusPage.statusApp.statusActions.commitText"
defaultMessage="COMMIT {buildSha}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@
*/

import expect from '@kbn/expect';
import { FtrProviderContext } from '../../ftr_provider_context';

export default function ({ getService, getPageObjects }) {
export default function ({ getService, getPageObjects }: FtrProviderContext) {
const retry = getService('retry');
const testSubjects = getService('testSubjects');
const PageObjects = getPageObjects(['common']);
Expand All @@ -31,11 +32,32 @@ export default function ({ getService, getPageObjects }) {
await PageObjects.common.navigateToApp('status_page');
});

it('should show the kibana plugin as ready', async function () {
it('should show the kibana plugin as ready', async () => {
await retry.tryForTime(6000, async () => {
const text = await testSubjects.getVisibleText('statusBreakdown');
expect(text.indexOf('plugin:kibana')).to.be.above(-1);
});
});

it('should show the build hash and number', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

should we add tests for an anonymous user?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We would need to add an x-pack suite for that, as the current suite is running on OSS. Should I do so?

Copy link
Contributor

Choose a reason for hiding this comment

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

I would add it. Config is a public API.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nm, there is already one:

it('allows user to navigate without authentication', async () => {
await PageObjects.security.forceLogout();
await PageObjects.statusPage.navigateToPage();
await PageObjects.statusPage.expectStatusPage();
});

Copy link
Contributor Author

@pgayvallet pgayvallet Jul 22, 2020

Choose a reason for hiding this comment

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

I can add a similar test when status.allowAnonymous is false, but that would require to create a specific test suite to start the server with the correct option. Either that, or I can just add a unit test for src/core/server/core_app/core_app.ts to ensure the route is declared with correct options depending on the configuration value. wdyt?

Copy link
Contributor

Choose a reason for hiding this comment

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

Either that, or I can just add a unit test for src/core/server/core_app/core_app.ts to ensure the route is declared with correct options depending on the configuration value. wdyt?

👍

const buildNumberText = await testSubjects.getVisibleText('statusBuildNumber');
expect(buildNumberText).to.contain('BUILD ');

const hashText = await testSubjects.getVisibleText('statusBuildHash');
expect(hashText).to.contain('COMMIT ');
});

it('should display the server metrics', async () => {
const metrics = await testSubjects.findAll('serverMetric');
expect(metrics).to.have.length(6);
});

it('should display the server status', async () => {
const titleText = await testSubjects.getVisibleText('serverStatusTitle');
expect(titleText).to.contain('Kibana status is');

const serverStatus = await testSubjects.getAttribute('serverStatusTitleBadge', 'aria-label');
expect(serverStatus).to.be('Green');
});
});
}