Skip to content

Commit

Permalink
[Uptime] Adjust monitor frequency in UI Monitor Management table (#12…
Browse files Browse the repository at this point in the history
…5841)

* adjust monitor frequency

* rename monitor interval to frequency

* adjust e2e tests

* adjust e2e tests

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
  • Loading branch information
dominiqueclarke and kibanamachine authored Feb 22, 2022
1 parent fea3f7b commit ae58a57
Show file tree
Hide file tree
Showing 11 changed files with 34 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const customLocation = process.env.SYNTHETICS_TEST_LOCATION;

const basicMonitorDetails = {
location: customLocation || 'US Central',
schedule: '@every 3m',
schedule: '3',
};
const httpName = 'http monitor';
const icmpName = 'icmp monitor';
Expand Down Expand Up @@ -158,7 +158,7 @@ journey('Monitor Management breadcrumbs', async ({ page, params }: { page: Page;
const defaultMonitorDetails = {
name: 'Sample monitor',
location: 'US Central',
schedule: '@every 3m',
schedule: '3',
apmServiceName: 'service',
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,14 @@ export const BrowserSimpleFields = memo<Props>(({ validate }) => {
label={
<FormattedMessage
id="xpack.uptime.createPackagePolicy.stepConfigure.monitorIntegrationSettingsSection.monitorInterval"
defaultMessage="Monitor interval"
defaultMessage="Frequency"
/>
}
isInvalid={!!validate[ConfigKey.SCHEDULE]?.(fields)}
error={
<FormattedMessage
id="xpack.uptime.createPackagePolicy.stepConfigure.monitorIntegrationSettingsSection.monitorInterval.error"
defaultMessage="Monitor interval is required"
defaultMessage="Monitor frequency is required"
/>
}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export function CommonFields({ fields, onChange, validate }: Props) {
) : (
<FormattedMessage
id="xpack.uptime.createPackagePolicy.stepConfigure.monitorIntegrationSettingsSection.timeout.lessThanIntervalError"
defaultMessage="Timeout must be less than the monitor interval"
defaultMessage="Timeout must be less than the monitor frequency"
/>
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ describe('<CustomFields />', () => {
fireEvent.change(timeout, { target: { value: '-1' } });

const urlError = getByText('URL is required');
const monitorIntervalError = getByText('Monitor interval is required');
const monitorIntervalError = getByText('Monitor frequency is required');
const maxRedirectsError = getByText('Max redirects must be 0 or greater');
const timeoutError = getByText('Timeout must be greater than or equal to 0');

Expand All @@ -321,15 +321,15 @@ describe('<CustomFields />', () => {
fireEvent.change(timeout, { target: { value: '1' } });

expect(queryByText('URL is required')).not.toBeInTheDocument();
expect(queryByText('Monitor interval is required')).not.toBeInTheDocument();
expect(queryByText('Monitor frequency is required')).not.toBeInTheDocument();
expect(queryByText('Max redirects must be 0 or greater')).not.toBeInTheDocument();
expect(queryByText('Timeout must be greater than or equal to 0')).not.toBeInTheDocument();

// create more errors
fireEvent.change(monitorIntervalNumber, { target: { value: '1' } }); // 1 minute
fireEvent.change(timeout, { target: { value: '611' } }); // timeout cannot be more than monitor interval

const timeoutError2 = getByText('Timeout must be less than the monitor interval');
const timeoutError2 = getByText('Timeout must be less than the monitor frequency');

expect(timeoutError2).toBeInTheDocument();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@ export const HTTPSimpleFields = memo<Props>(({ validate }) => {
label={
<FormattedMessage
id="xpack.uptime.createPackagePolicy.stepConfigure.monitorIntegrationSettingsSection.monitorInterval"
defaultMessage="Monitor interval"
defaultMessage="Frequency"
/>
}
isInvalid={!!validate[ConfigKey.SCHEDULE]?.(fields)}
error={
<FormattedMessage
id="xpack.uptime.createPackagePolicy.stepConfigure.monitorIntegrationSettingsSection.monitorInterval.error"
defaultMessage="Monitor interval is required"
defaultMessage="Monitor frequency is required"
/>
}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ export const ICMPSimpleFields = memo<Props>(({ validate }) => {
label={
<FormattedMessage
id="xpack.uptime.createPackagePolicy.stepConfigure.monitorIntegrationSettingsSection.monitorInterval"
defaultMessage="Monitor interval"
defaultMessage="Frequency"
/>
}
isInvalid={!!validate[ConfigKey.SCHEDULE]?.(fields)}
error={
<FormattedMessage
id="xpack.uptime.createPackagePolicy.stepConfigure.monitorIntegrationSettingsSection.monitorInterval.error"
defaultMessage="Monitor interval is required"
defaultMessage="Monitor frequency is required"
/>
}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ describe('<SyntheticsPolicyCreateExtension />', () => {
fireEvent.change(timeout, { target: { value: '-1' } });

const urlError = getByText('URL is required');
const monitorIntervalError = getByText('Monitor interval is required');
const monitorIntervalError = getByText('Monitor frequency is required');
const maxRedirectsError = getByText('Max redirects must be 0 or greater');
const timeoutError = getByText('Timeout must be greater than or equal to 0');

Expand All @@ -590,7 +590,7 @@ describe('<SyntheticsPolicyCreateExtension />', () => {
// expect onChange to be called with isValid true
await waitFor(() => {
expect(queryByText('URL is required')).not.toBeInTheDocument();
expect(queryByText('Monitor interval is required')).not.toBeInTheDocument();
expect(queryByText('Monitor frequency is required')).not.toBeInTheDocument();
expect(queryByText('Max redirects must be 0 or greater')).not.toBeInTheDocument();
expect(queryByText('Timeout must be greater than or equal to 0')).not.toBeInTheDocument();
expect(onChange).toBeCalledWith(
Expand Down Expand Up @@ -618,7 +618,7 @@ describe('<SyntheticsPolicyCreateExtension />', () => {

await waitFor(() => {
const hostError = getByText('Host and port are required');
const monitorIntervalError = getByText('Monitor interval is required');
const monitorIntervalError = getByText('Monitor frequency is required');
const timeoutError = getByText('Timeout must be greater than or equal to 0');

expect(hostError).toBeInTheDocument();
Expand All @@ -638,7 +638,7 @@ describe('<SyntheticsPolicyCreateExtension />', () => {

await waitFor(() => {
expect(queryByText('Host and port are required')).not.toBeInTheDocument();
expect(queryByText('Monitor interval is required')).not.toBeInTheDocument();
expect(queryByText('Monitor frequency is required')).not.toBeInTheDocument();
expect(queryByText('Max redirects must be 0 or greater')).not.toBeInTheDocument();
expect(queryByText('Timeout must be greater than or equal to 0')).not.toBeInTheDocument();
expect(onChange).toBeCalledWith(
Expand Down Expand Up @@ -668,7 +668,7 @@ describe('<SyntheticsPolicyCreateExtension />', () => {

await waitFor(() => {
const hostError = getByText('Host is required');
const monitorIntervalError = getByText('Monitor interval is required');
const monitorIntervalError = getByText('Monitor frequency is required');
const timeoutError = getByText('Timeout must be greater than or equal to 0');
const waitError = getByText('Wait must be 0 or greater');

Expand All @@ -691,7 +691,7 @@ describe('<SyntheticsPolicyCreateExtension />', () => {

await waitFor(() => {
expect(queryByText('Host is required')).not.toBeInTheDocument();
expect(queryByText('Monitor interval is required')).not.toBeInTheDocument();
expect(queryByText('Monitor frequency is required')).not.toBeInTheDocument();
expect(queryByText('Timeout must be greater than or equal to 0')).not.toBeInTheDocument();
expect(queryByText('Wait must be 0 or greater')).not.toBeInTheDocument();
expect(onChange).toBeCalledWith(
Expand All @@ -717,7 +717,7 @@ describe('<SyntheticsPolicyCreateExtension />', () => {

await waitFor(() => {
const hostError = getByText('Zip URL is required');
const monitorIntervalError = getByText('Monitor interval is required');
const monitorIntervalError = getByText('Monitor frequency is required');

expect(hostError).toBeInTheDocument();
expect(monitorIntervalError).toBeInTheDocument();
Expand All @@ -734,7 +734,7 @@ describe('<SyntheticsPolicyCreateExtension />', () => {

await waitFor(() => {
expect(queryByText('Zip URL is required')).not.toBeInTheDocument();
expect(queryByText('Monitor interval is required')).not.toBeInTheDocument();
expect(queryByText('Monitor frequency is required')).not.toBeInTheDocument();
expect(onChange).toBeCalledWith(
expect.objectContaining({
isValid: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ describe('<SyntheticsPolicyEditExtension />', () => {
fireEvent.change(timeout, { target: { value: '-1' } });

const urlError = getByText('URL is required');
const monitorIntervalError = getByText('Monitor interval is required');
const monitorIntervalError = getByText('Monitor frequency is required');
const maxRedirectsError = getByText('Max redirects must be 0 or greater');
const timeoutError = getByText('Timeout must be greater than or equal to 0');

Expand All @@ -566,7 +566,7 @@ describe('<SyntheticsPolicyEditExtension />', () => {
// expect onChange to be called with isValid true
await waitFor(() => {
expect(queryByText('URL is required')).not.toBeInTheDocument();
expect(queryByText('Monitor interval is required')).not.toBeInTheDocument();
expect(queryByText('Monitor frequency is required')).not.toBeInTheDocument();
expect(queryByText('Max redirects must be 0 or greater')).not.toBeInTheDocument();
expect(queryByText('Timeout must be greater than or equal to 0')).not.toBeInTheDocument();
expect(onChange).toBeCalledWith(
Expand Down Expand Up @@ -650,7 +650,7 @@ describe('<SyntheticsPolicyEditExtension />', () => {

await waitFor(() => {
const hostError = getByText('Zip URL is required');
const monitorIntervalError = getByText('Monitor interval is required');
const monitorIntervalError = getByText('Monitor frequency is required');

expect(hostError).toBeInTheDocument();
expect(monitorIntervalError).toBeInTheDocument();
Expand All @@ -667,7 +667,7 @@ describe('<SyntheticsPolicyEditExtension />', () => {
expect(zipUrl.value).toEqual('http://github.com/tests.zip');
expect(monitorIntervalNumber.value).toEqual('2');
expect(queryByText('Zip URL is required')).not.toBeInTheDocument();
expect(queryByText('Monitor interval is required')).not.toBeInTheDocument();
expect(queryByText('Monitor frequency is required')).not.toBeInTheDocument();
expect(queryByText('Timeout must be greater than or equal to 0')).not.toBeInTheDocument();
expect(onChange).toBeCalledWith(
expect.objectContaining({
Expand Down Expand Up @@ -716,7 +716,7 @@ describe('<SyntheticsPolicyEditExtension />', () => {

await waitFor(() => {
const hostError = getByText('Host and port are required');
const monitorIntervalError = getByText('Monitor interval is required');
const monitorIntervalError = getByText('Monitor frequency is required');
const timeoutError = getByText('Timeout must be greater than or equal to 0');

expect(hostError).toBeInTheDocument();
Expand All @@ -736,7 +736,7 @@ describe('<SyntheticsPolicyEditExtension />', () => {

await waitFor(() => {
expect(queryByText('Host is required')).not.toBeInTheDocument();
expect(queryByText('Monitor interval is required')).not.toBeInTheDocument();
expect(queryByText('Monitor frequency is required')).not.toBeInTheDocument();
expect(queryByText('Timeout must be greater than or equal to 0')).not.toBeInTheDocument();
expect(onChange).toBeCalledWith(
expect.objectContaining({
Expand Down Expand Up @@ -782,7 +782,7 @@ describe('<SyntheticsPolicyEditExtension />', () => {

await waitFor(() => {
const hostError = getByText('Host is required');
const monitorIntervalError = getByText('Monitor interval is required');
const monitorIntervalError = getByText('Monitor frequency is required');
const timeoutError = getByText('Timeout must be greater than or equal to 0');
const waitError = getByText('Wait must be 0 or greater');

Expand All @@ -805,7 +805,7 @@ describe('<SyntheticsPolicyEditExtension />', () => {

await waitFor(() => {
expect(queryByText('Host is required')).not.toBeInTheDocument();
expect(queryByText('Monitor interval is required')).not.toBeInTheDocument();
expect(queryByText('Monitor frequency is required')).not.toBeInTheDocument();
expect(queryByText('Timeout must be greater than or equal to 0')).not.toBeInTheDocument();
expect(queryByText('Wait must be 0 or greater')).not.toBeInTheDocument();
expect(onChange).toBeCalledWith(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ export const TCPSimpleFields = memo<Props>(({ validate }) => {
label={
<FormattedMessage
id="xpack.uptime.createPackagePolicy.stepConfigure.monitorIntegrationSettingsSection.monitorInterval"
defaultMessage="Monitor interval"
defaultMessage="Frequency"
/>
}
isInvalid={!!validate[ConfigKey.SCHEDULE]?.(fields)}
error={
<FormattedMessage
id="xpack.uptime.createPackagePolicy.stepConfigure.monitorIntegrationSettingsSection.monitorInterval.error"
defaultMessage="Monitor interval is required"
defaultMessage="Monitor frequency is required"
/>
}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe('<MonitorManagementList />', () => {
enabled: true,
schedule: {
unit: ScheduleUnit.MINUTES,
number: `${i}`,
number: `${i * 10}`,
},
urls: `https://test-${i}.co`,
type: DataStream.HTTP,
Expand Down Expand Up @@ -76,11 +76,7 @@ describe('<MonitorManagementList />', () => {
monitor.attributes.tags.forEach((tag) => {
expect(screen.getByText(tag)).toBeInTheDocument();
});
expect(
screen.getByText(
`@every ${monitor.attributes.schedule.number}${monitor.attributes.schedule.unit}`
)
).toBeInTheDocument();
expect(screen.getByText(monitor.attributes.schedule.number)).toBeInTheDocument();
});

it('handles changing per page', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,9 @@ export const MonitorManagementList = ({
align: 'left' as const,
field: ConfigKey.SCHEDULE,
name: i18n.translate('xpack.uptime.monitorManagement.monitorList.schedule', {
defaultMessage: 'Schedule',
defaultMessage: 'Frequency (min)',
}),
render: (schedule: CommonFields[ConfigKey.SCHEDULE]) =>
`@every ${schedule?.number}${schedule?.unit}`,
render: (schedule: CommonFields[ConfigKey.SCHEDULE]) => schedule?.number,
},
{
align: 'left' as const,
Expand Down

0 comments on commit ae58a57

Please sign in to comment.