[7.x] Lexicographically sort location tags (#54832) (#54867)

* Lexicographically sort location tags (#54832)

Sort location tags lexicographically, fixes skipped test by providing a stable, non-time-based sort order

* Update ping list snapshot
This commit is contained in:
Andrew Cholakian 2020-01-14 22:11:24 -06:00 committed by GitHub
parent 7fd3e10a0a
commit 7556436796
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 7 additions and 15 deletions

View file

@ -151,7 +151,7 @@ exports[`LocationStatusTags component renders when all locations are up 1`] = `
<div
class="c2"
>
Islamabad
Berlin
</div>
</div>
</span>
@ -166,7 +166,7 @@ exports[`LocationStatusTags component renders when all locations are up 1`] = `
<div
class="euiTextColor euiTextColor--subdued"
>
5s ago
5d ago
</div>
</div>
</span>
@ -190,7 +190,7 @@ exports[`LocationStatusTags component renders when all locations are up 1`] = `
<div
class="c2"
>
Berlin
Islamabad
</div>
</div>
</span>
@ -205,7 +205,7 @@ exports[`LocationStatusTags component renders when all locations are up 1`] = `
<div
class="euiTextColor euiTextColor--subdued"
>
5d ago
5s ago
</div>
</div>
</span>

View file

@ -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 when there are many location', () => {

View file

@ -60,9 +60,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.locale('en', {

View file

@ -45,10 +45,6 @@ exports[`PingList component renders sorted list without errors 1`] = `
>
<EuiSelect
aria-label="Status"
compressed={false}
fullWidth={false}
hasNoInitialSelection={false}
isLoading={false}
onChange={[Function]}
options={
Array [
@ -83,10 +79,6 @@ exports[`PingList component renders sorted list without errors 1`] = `
>
<EuiSelect
aria-label="Location"
compressed={false}
fullWidth={false}
hasNoInitialSelection={false}
isLoading={false}
onChange={[Function]}
options={
Array [