From 5db59e0e7583baaf970ccc7c39594a914f36a190 Mon Sep 17 00:00:00 2001 From: Justin Kambic Date: Fri, 15 Jan 2021 10:25:06 -0500 Subject: [PATCH] [Uptime] Unskip "Observer location" test block (#87571) * Unskip "Observer location" test block. * Commit temp "describe.only" to make flaky test runner go faster. * Add optional chain for some potentially-null props. * Make overview filters type partial. * Repair broken types. * Remove \`only\` call from test. --- .../overview_filters/overview_filters.ts | 2 +- .../alerts_containers/alert_monitor_status.tsx | 2 +- .../overview/filter_group/filter_group.tsx | 18 +++++++++++------- .../test/functional/apps/uptime/locations.ts | 3 +-- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/x-pack/plugins/uptime/common/runtime_types/overview_filters/overview_filters.ts b/x-pack/plugins/uptime/common/runtime_types/overview_filters/overview_filters.ts index 9b9241494f001..854b4b6b6e9b8 100644 --- a/x-pack/plugins/uptime/common/runtime_types/overview_filters/overview_filters.ts +++ b/x-pack/plugins/uptime/common/runtime_types/overview_filters/overview_filters.ts @@ -6,7 +6,7 @@ import * as t from 'io-ts'; -export const OverviewFiltersType = t.type({ +export const OverviewFiltersType = t.partial({ locations: t.array(t.string), ports: t.array(t.number), schemes: t.array(t.string), diff --git a/x-pack/plugins/uptime/public/components/overview/alerts/alerts_containers/alert_monitor_status.tsx b/x-pack/plugins/uptime/public/components/overview/alerts/alerts_containers/alert_monitor_status.tsx index 50b6fe2aa0ef1..1c1deb2104970 100644 --- a/x-pack/plugins/uptime/public/components/overview/alerts/alerts_containers/alert_monitor_status.tsx +++ b/x-pack/plugins/uptime/public/components/overview/alerts/alerts_containers/alert_monitor_status.tsx @@ -122,7 +122,7 @@ export const AlertMonitorStatus: React.FC = ({ enabled={enabled} hasFilters={!!overviewFilters?.filters} isOldAlert={isOldAlert} - locations={locations} + locations={locations || []} numTimes={numTimes} setAlertParams={setAlertParams} shouldUpdateUrl={shouldUpdateUrl} diff --git a/x-pack/plugins/uptime/public/components/overview/filter_group/filter_group.tsx b/x-pack/plugins/uptime/public/components/overview/filter_group/filter_group.tsx index 45268977a543f..a5256ee1e2626 100644 --- a/x-pack/plugins/uptime/public/components/overview/filter_group/filter_group.tsx +++ b/x-pack/plugins/uptime/public/components/overview/filter_group/filter_group.tsx @@ -24,6 +24,10 @@ const Container = styled(EuiFilterGroup)` margin-bottom: 10px; `; +function isDisabled(array?: T[]) { + return array ? array.length === 0 : true; +} + export const FilterGroupComponent: React.FC = ({ overviewFilters, loading, @@ -51,7 +55,7 @@ export const FilterGroupComponent: React.FC = ({ onFilterFieldChange, fieldName: 'observer.geo.name', id: 'location', - items: locations, + items: locations || [], selectedItems: selectedLocations, title: filterLabels.LOCATION, }, @@ -63,8 +67,8 @@ export const FilterGroupComponent: React.FC = ({ onFilterFieldChange, fieldName: 'url.port', id: 'port', - disabled: ports.length === 0, - items: ports.map((p: number) => p.toString()), + disabled: isDisabled(ports), + items: ports?.map((p: number) => p.toString()) ?? [], selectedItems: selectedPorts, title: filterLabels.PORT, }, @@ -73,8 +77,8 @@ export const FilterGroupComponent: React.FC = ({ onFilterFieldChange, fieldName: 'monitor.type', id: 'scheme', - disabled: schemes.length === 0, - items: schemes, + disabled: isDisabled(schemes), + items: schemes ?? [], selectedItems: selectedSchemes, title: filterLabels.SCHEME, }, @@ -83,8 +87,8 @@ export const FilterGroupComponent: React.FC = ({ onFilterFieldChange, fieldName: 'tags', id: 'tags', - disabled: tags.length === 0, - items: tags, + disabled: isDisabled(tags), + items: tags ?? [], selectedItems: selectedTags, title: filterLabels.TAGS, }, diff --git a/x-pack/test/functional/apps/uptime/locations.ts b/x-pack/test/functional/apps/uptime/locations.ts index eb5a642c8d69d..6bfa19c6ef578 100644 --- a/x-pack/test/functional/apps/uptime/locations.ts +++ b/x-pack/test/functional/apps/uptime/locations.ts @@ -38,8 +38,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { await makeChecksWithStatus(es, LessAvailMonitor, 5, 2, 10000, {}, 'down'); }; - // FLAKY: https://github.com/elastic/kibana/issues/85208 - describe.skip('Observer location', () => { + describe('Observer location', () => { const start = '~ 15 minutes ago'; const end = 'now';