From 6cac02e6c1a14e854bc9566012d23ce8e70b882f Mon Sep 17 00:00:00 2001 From: Andrew Cholakian Date: Tue, 14 Jan 2020 17:29:49 -0600 Subject: [PATCH] Lexicographically sort location tags (#54832) Sort location tags lexicographically, fixes skipped test by providing a stable, non-time-based sort order --- .../__snapshots__/location_status_tags.test.tsx.snap | 8 ++++---- .../location_map/__tests__/location_status_tags.test.tsx | 2 +- .../functional/location_map/location_status_tags.tsx | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/location_map/__tests__/__snapshots__/location_status_tags.test.tsx.snap b/x-pack/legacy/plugins/uptime/public/components/functional/location_map/__tests__/__snapshots__/location_status_tags.test.tsx.snap index aee122fdcc046..26f899eb8d161 100644 --- a/x-pack/legacy/plugins/uptime/public/components/functional/location_map/__tests__/__snapshots__/location_status_tags.test.tsx.snap +++ b/x-pack/legacy/plugins/uptime/public/components/functional/location_map/__tests__/__snapshots__/location_status_tags.test.tsx.snap @@ -228,7 +228,7 @@ exports[`LocationStatusTags component renders when all locations are up 1`] = `
- Islamabad + Berlin
@@ -243,7 +243,7 @@ exports[`LocationStatusTags component renders when all locations are up 1`] = `
- 5s ago + 5d ago
@@ -267,7 +267,7 @@ exports[`LocationStatusTags component renders when all locations are up 1`] = `
- Berlin + Islamabad
@@ -282,7 +282,7 @@ exports[`LocationStatusTags component renders when all locations are up 1`] = `
- 5d ago + 5s ago
diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/location_map/__tests__/location_status_tags.test.tsx b/x-pack/legacy/plugins/uptime/public/components/functional/location_map/__tests__/location_status_tags.test.tsx index f43a5494dc16a..2359938dbbc35 100644 --- a/x-pack/legacy/plugins/uptime/public/components/functional/location_map/__tests__/location_status_tags.test.tsx +++ b/x-pack/legacy/plugins/uptime/public/components/functional/location_map/__tests__/location_status_tags.test.tsx @@ -11,7 +11,7 @@ import { MonitorLocation } from '../../../../../common/runtime_types/monitor'; import { LocationStatusTags } from '../'; // Failing: https://github.com/elastic/kibana/issues/54818 -describe.skip('LocationStatusTags component', () => { +describe('LocationStatusTags component', () => { let monitorLocations: MonitorLocation[]; it('renders properly against props', () => { diff --git a/x-pack/legacy/plugins/uptime/public/components/functional/location_map/location_status_tags.tsx b/x-pack/legacy/plugins/uptime/public/components/functional/location_map/location_status_tags.tsx index e7107b5246c37..b8735f682adef 100644 --- a/x-pack/legacy/plugins/uptime/public/components/functional/location_map/location_status_tags.tsx +++ b/x-pack/legacy/plugins/uptime/public/components/functional/location_map/location_status_tags.tsx @@ -61,9 +61,9 @@ export const LocationStatusTags = ({ locations }: Props) => { } }); - // Sort by recent timestamp + // Sort lexicographically by label upLocations.sort((a, b) => { - return a.timestamp < b.timestamp ? 1 : b.timestamp < a.timestamp ? -1 : 0; + return a.label > b.label ? 1 : b.label > a.label ? -1 : 0; }); moment.updateLocale('en', {