Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ui): front end sorting for numeric values now being handled correctly #16237

Merged
merged 4 commits into from
Dec 17, 2019

Conversation

asalem1
Copy link
Contributor

@asalem1 asalem1 commented Dec 17, 2019

Closes #16200

Problem

Sorting tables via the front end sorted resulted in unordered numbers due to the fact that numbers were being ordered as strings

Solution

Type checked to-be sorted values to ensure that values are numeric before sorting. Completed testing for table sorting to ensure stability

  • CHANGELOG.md updated with a link to the PR (not the Issue)

@asalem1 asalem1 requested a review from a team December 17, 2019 14:54
@ghost ghost requested review from hoorayimhelping and zoesteinkamp and removed request for a team December 17, 2019 14:54
Copy link
Contributor

@hoorayimhelping hoorayimhelping left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was trying to run the e2e test with it.only to see if it's possible to clean up the testing code a little bit, and the test crashes when run with only. Looks like we're inadvertently coupling our tests together, which is an antipattern in cyperess.

// 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')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i like the eagerness to test a lot of things, but i think this is bit too implementation heavy, in that it's testing implementation over behavior. it's an implementation detail that we change the class to reflect the sort order. the behavior is that we change the sort order, which you're testing below. i think testing this will lead to brittle tests, because if we ever want to change the name of the class, or the component the class targets, or any implementation detail around showing an indicator of the sort order, these tests will likely break. i don't think we should assert on these things.

Copy link
Contributor Author

@asalem1 asalem1 Dec 17, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a bit of both. The only indication that a specific cell header isn't toggled by the front end sort is the classname associated with it, hence the check for it. I do think it's necessary in this case to perform this check here so that we can validate that an action has occurred that is reflected in the UI, in addition to its functionality

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't think it's necessary at all - it really feels like an implementation detail: we could change our underlying css so that we render columns sorted ascending with some kind squiggly underline and columns sorted descending with a dashed outline. making those changes would render this test invalid.

either way, i think it's enough discussion on a test - i think this is a bit implementation heavy, but if you're comfortable with this, go for it

cy.getByTestID('_value-table-header').click()
cy.get('.table-graph-cell__sort-desc').should('exist')
cy.getByTestID('_value-table-header')
.should('exist')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fyi, cy.get('foo').should('exist') is almost always superfluous. the get operation implicitly asserts existence.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, but it is a way of maintaining UI stability in that we want to know whether the UI is manipulated by the click event

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@asalem1

but it is a way of maintaining UI stability in that we want to know whether the UI is manipulated by the click event

i'm curious how should('exist') does that where cy.getByTestID('_value-table-header') doesn't?

@@ -623,7 +623,7 @@ describe('DataExplorer', () => {
})
})

it('can view table data', () => {
it('can view table data & sort values numerically', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this test fails when run with it.only which means it's coupled to another part of the test. i think this needs to get fixed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll take a look and try to reproduce it locally and see whether I can make it less flakey

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

until we sort this out, i think you should skip this test and link to this issue: #16253

Copy link
Contributor

@ebb-tide ebb-tide left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Contributor

@hoorayimhelping hoorayimhelping left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mostly comments around testing, which i realized are an ass reason to hold up a fix (my bad). i think you should just skip the flaky test since the fix is important for silencing HB and we have an issue to address flaky tests

cy.getByTestID('_value-table-header').click()
cy.get('.table-graph-cell__sort-desc').should('exist')
cy.getByTestID('_value-table-header')
.should('exist')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@asalem1

but it is a way of maintaining UI stability in that we want to know whether the UI is manipulated by the click event

i'm curious how should('exist') does that where cy.getByTestID('_value-table-header') doesn't?

// 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')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't think it's necessary at all - it really feels like an implementation detail: we could change our underlying css so that we render columns sorted ascending with some kind squiggly underline and columns sorted descending with a dashed outline. making those changes would render this test invalid.

either way, i think it's enough discussion on a test - i think this is a bit implementation heavy, but if you're comfortable with this, go for it

@@ -623,7 +623,7 @@ describe('DataExplorer', () => {
})
})

it('can view table data', () => {
it('can view table data & sort values numerically', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

until we sort this out, i think you should skip this test and link to this issue: #16253

@asalem1 asalem1 merged commit bba04e2 into master Dec 17, 2019
@asalem1 asalem1 deleted the fe-sort-fix branch December 17, 2019 23:16
alexpaxton pushed a commit that referenced this pull request Jan 9, 2020
…ctly (#16237)

fix(ui): front end table sort now works for numbers, skipping test until flake is resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Table sort is not working
3 participants