-
Notifications
You must be signed in to change notification settings - Fork 8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Synthetics UI] Add or edit a monitor (#132204)
* add basic form setup * add validation * add edit flow * [CI] Auto-commit changed files from 'node scripts/precommit_hook.js --ref HEAD~1..HEAD --fix' * Delete context.tsx * [CI] Auto-commit changed files from 'node scripts/eslint --no-cache --fix' * add locations * update schedule field * adjust script recorder fields * adjust disclaimer to only show when using a service location * [CI] Auto-commit changed files from 'node scripts/eslint --no-cache --fix' * adjust edit flow * [CI] Auto-commit changed files from 'node scripts/eslint --no-cache --fix' * add Kibana space * adjust Kibana space logic * add throttling * update content * adjust hrefs * adjust content * adjust types * add editing * adjust monitor validation tests * fix integration tests * adjust tests * adjust content * add source field tests * add tests * add legacy validation * rename file * adjust legacy components * add tests * update tests * update content * adjust types * adjust routes * remove console logs * adjust types * update tests * [CI] Auto-commit changed files from 'node scripts/precommit_hook.js --ref HEAD~1..HEAD --fix' * add Playwright link * add placeholder * update getting started page link * add monitor details link * adjust content * Update x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_add_edit/fields/uploader.tsx * [CI] Auto-commit changed files from 'node scripts/precommit_hook.js --ref HEAD~1..HEAD --fix' * Apply suggestions from code review * Update x-pack/plugins/synthetics/public/apps/synthetics/routes.tsx * Update x-pack/plugins/synthetics/public/apps/synthetics/routes.tsx * fix jest * adjust tests * renaming * move exported type * move hook * adjust file structure * adjust test * move hook * adjust test * add script recorder button * adjust tests * adjust tests * adjust validation * add ui keys to skip * i18n misses * move text assertion box down * adjust content * adjust validation * adjust helpers * align connection profile field baseline * do not clear out url for single step monitors * adjust defaults * adjust types * Update x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_add_edit/fields/uploader.tsx Co-authored-by: Colleen McGinnis <colleen.j.mcginnis@gmail.com> * Update x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_add_edit/steps/step_config.tsx Co-authored-by: Colleen McGinnis <colleen.j.mcginnis@gmail.com> * Update x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_add_edit/steps/step_config.tsx Co-authored-by: Colleen McGinnis <colleen.j.mcginnis@gmail.com> * Update x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_add_edit/form/field_config.tsx Co-authored-by: Colleen McGinnis <colleen.j.mcginnis@gmail.com> * Update x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_add_edit/steps/step_config.tsx Co-authored-by: Colleen McGinnis <colleen.j.mcginnis@gmail.com> * Update x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_add_edit/steps/step_config.tsx Co-authored-by: Colleen McGinnis <colleen.j.mcginnis@gmail.com> * Update x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_add_edit/form/field_config.tsx Co-authored-by: Colleen McGinnis <colleen.j.mcginnis@gmail.com> * Update x-pack/plugins/synthetics/public/apps/synthetics/components/monitor_add_edit/form/field_config.tsx Co-authored-by: Colleen McGinnis <colleen.j.mcginnis@gmail.com> * merge edited monitor * add Loading spinners * update content * adjust errors * adjust types * adjust tests * adjust types * merge edited monitor settings * adjust tests * adjust types * subscribe to dirty fields Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: shahzad31 <shahzad.muhammad@elastic.co> Co-authored-by: Colleen McGinnis <colleen.j.mcginnis@gmail.com>
- Loading branch information
1 parent
6ad1d1d
commit 7a10739
Showing
89 changed files
with
6,228 additions
and
125 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
211 changes: 211 additions & 0 deletions
211
x-pack/plugins/synthetics/e2e/journeys/synthetics/add_monitor.journey.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,211 @@ | ||
/* | ||
* 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 uuid from 'uuid'; | ||
import { journey, step, expect, Page } from '@elastic/synthetics'; | ||
import { FormMonitorType } from '../../../common/runtime_types/monitor_management'; | ||
import { syntheticsAppPageProvider } from '../../page_objects/synthetics_app'; | ||
|
||
const customLocation = process.env.SYNTHETICS_TEST_LOCATION; | ||
|
||
const basicMonitorDetails = { | ||
location: customLocation || 'US Central', | ||
schedule: '3', | ||
}; | ||
const httpName = `http monitor ${uuid.v4()}`; | ||
const icmpName = `icmp monitor ${uuid.v4()}`; | ||
const tcpName = `tcp monitor ${uuid.v4()}`; | ||
const browserName = `browser monitor ${uuid.v4()}`; | ||
const browserRecorderName = `browser monitor recorder ${uuid.v4()}`; | ||
const apmServiceName = 'apmServiceName'; | ||
|
||
const configuration = { | ||
[FormMonitorType.HTTP]: { | ||
monitorType: FormMonitorType.HTTP, | ||
monitorConfig: { | ||
...basicMonitorDetails, | ||
name: httpName, | ||
url: 'https://elastic.co', | ||
locations: [basicMonitorDetails.location], | ||
apmServiceName, | ||
}, | ||
monitorListDetails: { | ||
...basicMonitorDetails, | ||
name: httpName, | ||
}, | ||
monitorEditDetails: [ | ||
['[data-test-subj=syntheticsMonitorConfigSchedule]', '3'], | ||
['[data-test-subj=syntheticsMonitorConfigName]', httpName], | ||
['[data-test-subj=syntheticsMonitorConfigURL]', 'https://elastic.co'], | ||
['[data-test-subj=syntheticsMonitorConfigAPMServiceName]', apmServiceName], | ||
], | ||
}, | ||
[FormMonitorType.TCP]: { | ||
monitorType: FormMonitorType.TCP, | ||
monitorConfig: { | ||
...basicMonitorDetails, | ||
name: tcpName, | ||
host: 'smtp.gmail.com:587', | ||
locations: [basicMonitorDetails.location], | ||
apmServiceName, | ||
}, | ||
monitorListDetails: { | ||
...basicMonitorDetails, | ||
name: tcpName, | ||
}, | ||
monitorEditDetails: [ | ||
['[data-test-subj=syntheticsMonitorConfigSchedule]', '3'], | ||
['[data-test-subj=syntheticsMonitorConfigName]', tcpName], | ||
['[data-test-subj=syntheticsMonitorConfigHost]', 'smtp.gmail.com:587'], | ||
['[data-test-subj=syntheticsMonitorConfigAPMServiceName]', apmServiceName], | ||
], | ||
}, | ||
[FormMonitorType.ICMP]: { | ||
monitorType: FormMonitorType.ICMP, | ||
monitorConfig: { | ||
...basicMonitorDetails, | ||
name: icmpName, | ||
host: '1.1.1.1', | ||
locations: [basicMonitorDetails.location], | ||
apmServiceName, | ||
}, | ||
monitorListDetails: { | ||
...basicMonitorDetails, | ||
name: icmpName, | ||
}, | ||
monitorEditDetails: [ | ||
['[data-test-subj=syntheticsMonitorConfigSchedule]', '3'], | ||
['[data-test-subj=syntheticsMonitorConfigName]', icmpName], | ||
['[data-test-subj=syntheticsMonitorConfigHost]', '1.1.1.1'], | ||
['[data-test-subj=syntheticsMonitorConfigAPMServiceName]', apmServiceName], | ||
// name: httpName, | ||
], | ||
}, | ||
[FormMonitorType.MULTISTEP]: { | ||
monitorType: FormMonitorType.MULTISTEP, | ||
monitorConfig: { | ||
...basicMonitorDetails, | ||
schedule: '10', | ||
name: browserName, | ||
inlineScript: 'step("test step", () => {})', | ||
locations: [basicMonitorDetails.location], | ||
apmServiceName, | ||
}, | ||
monitorListDetails: { | ||
...basicMonitorDetails, | ||
schedule: '10', | ||
name: browserName, | ||
}, | ||
monitorEditDetails: [ | ||
['[data-test-subj=syntheticsMonitorConfigSchedule]', '10'], | ||
['[data-test-subj=syntheticsMonitorConfigName]', browserName], | ||
['[data-test-subj=codeEditorContainer] textarea', 'step("test step", () => {})'], | ||
['[data-test-subj=syntheticsMonitorConfigAPMServiceName]', apmServiceName], | ||
], | ||
}, | ||
[`${FormMonitorType.MULTISTEP}__recorder`]: { | ||
monitorType: FormMonitorType.MULTISTEP, | ||
monitorConfig: { | ||
...basicMonitorDetails, | ||
schedule: '10', | ||
name: browserRecorderName, | ||
recorderScript: 'step("test step", () => {})', | ||
locations: [basicMonitorDetails.location], | ||
apmServiceName: 'Sample APM Service', | ||
}, | ||
monitorListDetails: { | ||
...basicMonitorDetails, | ||
schedule: '10', | ||
name: browserRecorderName, | ||
}, | ||
monitorEditDetails: [ | ||
['[data-test-subj=syntheticsMonitorConfigSchedule]', '10'], | ||
['[data-test-subj=syntheticsMonitorConfigName]', browserRecorderName], | ||
['[data-test-subj=codeEditorContainer] textarea', 'step("test step", () => {})'], | ||
// name: httpName, | ||
], | ||
}, | ||
}; | ||
|
||
const createMonitorJourney = ({ | ||
monitorName, | ||
monitorType, | ||
monitorConfig, | ||
monitorListDetails, | ||
monitorEditDetails, | ||
}: { | ||
monitorName: string; | ||
monitorType: FormMonitorType; | ||
monitorConfig: Record<string, string | string[]>; | ||
monitorListDetails: Record<string, string>; | ||
monitorEditDetails: Array<[string, string]>; | ||
}) => { | ||
journey( | ||
`Synthetics - add monitor - ${monitorName}`, | ||
async ({ page, params }: { page: Page; params: any }) => { | ||
const syntheticsApp = syntheticsAppPageProvider({ page, kibanaUrl: params.kibanaUrl }); | ||
|
||
step('Go to monitor management', async () => { | ||
await syntheticsApp.navigateToMonitorManagement(); | ||
}); | ||
|
||
step('login to Kibana', async () => { | ||
await syntheticsApp.loginToKibana(); | ||
const invalid = await page.locator( | ||
`text=Username or password is incorrect. Please try again.` | ||
); | ||
expect(await invalid.isVisible()).toBeFalsy(); | ||
}); | ||
|
||
step('Ensure all montiors are deleted', async () => { | ||
await syntheticsApp.navigateToMonitorManagement(); | ||
await syntheticsApp.waitForLoadingToFinish(); | ||
const isSuccessful = await syntheticsApp.deleteMonitors(); | ||
expect(isSuccessful).toBeTruthy(); | ||
}); | ||
|
||
step(`create ${monitorName}`, async () => { | ||
await syntheticsApp.navigateToAddMonitor(); | ||
await syntheticsApp.createMonitor({ monitorConfig, monitorType }); | ||
const isSuccessful = await syntheticsApp.confirmAndSave(); | ||
expect(isSuccessful).toBeTruthy(); | ||
}); | ||
|
||
step(`view ${monitorName} details in Monitor Management UI`, async () => { | ||
await syntheticsApp.navigateToMonitorManagement(); | ||
const hasFailure = await syntheticsApp.findMonitorConfiguration(monitorListDetails); | ||
expect(hasFailure).toBeFalsy(); | ||
}); | ||
|
||
step(`edit ${monitorName}`, async () => { | ||
await syntheticsApp.navigateToEditMonitor(); | ||
await syntheticsApp.findByText(monitorListDetails.location); | ||
const hasFailure = await syntheticsApp.findEditMonitorConfiguration( | ||
monitorEditDetails, | ||
monitorType | ||
); | ||
expect(hasFailure).toBeFalsy(); | ||
}); | ||
|
||
step('delete monitor', async () => { | ||
await syntheticsApp.navigateToMonitorManagement(); | ||
await syntheticsApp.findByText('Monitor name'); | ||
const isSuccessful = await syntheticsApp.deleteMonitors(); | ||
expect(isSuccessful).toBeTruthy(); | ||
}); | ||
} | ||
); | ||
}; | ||
|
||
Object.values(configuration).forEach((config) => { | ||
createMonitorJourney({ | ||
monitorType: config.monitorType, | ||
monitorName: `${config.monitorConfig.name} monitor`, | ||
monitorConfig: config.monitorConfig, | ||
monitorListDetails: config.monitorListDetails, | ||
monitorEditDetails: config.monitorEditDetails as Array<[string, string]>, | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,4 @@ | |
*/ | ||
|
||
export * from './getting_started.journey'; | ||
export * from './add_monitor.journey'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.