From bba04e20b44dd0f8fd049d80f270424eb266533f Mon Sep 17 00:00:00 2001 From: Ariel Salem Date: Tue, 17 Dec 2019 15:15:09 -0800 Subject: [PATCH] fix(ui): front end sorting for numeric values now being handled correctly (#16237) fix(ui): front end table sort now works for numbers, skipping test until flake is resolved --- CHANGELOG.md | 6 ++++-- ui/cypress/e2e/explorer.test.ts | 25 +++++++++++++++++++++---- ui/src/dashboards/utils/tableGraph.ts | 12 +++++++++++- 3 files changed, 36 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index da7a31a57dc..6a6596f17f3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,13 +2,15 @@ ### Features -1. [16234](https://github.com/influxdata/influxdb/pull/16234): add support for notification endpoints to influx templates/pkgs. +1. [16234](https://github.com/influxdata/influxdb/pull/16234): add support for notification endpoints to influx templates/pkgs. ### Bug Fixes -1. [16225](https://github.com/influxdata/influxdb/pull/16225): Ensures env vars are applied consistently across cmd, and fixes issue where INFLUX_ env var prefix was not set globally. + +1. [16225](https://github.com/influxdata/influxdb/pull/16225): Ensures env vars are applied consistently across cmd, and fixes issue where INFLUX\_ env var prefix was not set globally. 1. [16235](https://github.com/influxdata/influxdb/pull/16235): Removed default frontend sorting when flux queries specify sorting 1. [16238](https://github.com/influxdata/influxdb/pull/16238): Store canceled task runs in the correct bucket +1. [16237](https://github.com/influxdata/influxdb/pull/16237): Updated Sortby functionality for table frontend sorts to sort numbers correctly ### UI Improvements diff --git a/ui/cypress/e2e/explorer.test.ts b/ui/cypress/e2e/explorer.test.ts index 5ed27fd30ea..822e07a9692 100644 --- a/ui/cypress/e2e/explorer.test.ts +++ b/ui/cypress/e2e/explorer.test.ts @@ -599,7 +599,9 @@ describe('DataExplorer', () => { }) }) - describe('visualize tables', () => { + // skipping until the sigin flake gets resolve in: + // https://github.com/influxdata/influxdb/issues/16253 + describe.skip('visualize tables', () => { const numLines = 360 beforeEach(() => { @@ -623,7 +625,7 @@ describe('DataExplorer', () => { }) }) - it('can view table data', () => { + it('can view table data & sort values numerically', () => { // build the query to return data from beforeEach cy.getByTestID(`selector-list m`).click() cy.getByTestID('selector-list v').click() @@ -654,8 +656,23 @@ describe('DataExplorer', () => { }) cy.getByTestID('_value-table-header').click() cy.get('.table-graph-cell__sort-asc').should('exist') - // TODO: complete testing when FE sorting functionality is sorted - // https://github.com/influxdata/influxdb/issues/16200 + cy.getByTestID('_value-table-header').click() + cy.get('.table-graph-cell__sort-desc').should('exist') + cy.getByTestID('_value-table-header') + .should('exist') + .then(el => { + // get the column index + const columnIndex = el[0].getAttribute('data-column-index') + let prev = Infinity + // get all the column values for that one and see if they are in order + cy.get(`[data-column-index="${columnIndex}"]`).each(val => { + const num = Number(val.text()) + if (isNaN(num) === false) { + expect(num < prev).to.equal(true) + prev = num + } + }) + }) }) }) }) diff --git a/ui/src/dashboards/utils/tableGraph.ts b/ui/src/dashboards/utils/tableGraph.ts index de9adc2fc42..e3e25971d72 100644 --- a/ui/src/dashboards/utils/tableGraph.ts +++ b/ui/src/dashboards/utils/tableGraph.ts @@ -220,7 +220,17 @@ export const sortTableData = ( const dataValues = _.drop(data, 1) const sortedData = [ data[0], - ..._.orderBy(dataValues, sortIndex, [sort.direction]), + ..._.orderBy( + dataValues, + row => { + const sortedValue = row[sortIndex] + if (isNaN(Number(sortedValue))) { + return sortedValue + } + return Number(sortedValue) + }, + [sort.direction] + ), ] as string[][] const sortedTimeVals = fastMap(