Skip to content
This repository has been archived by the owner on Jun 4, 2024. It is now read-only.

Issue 681 - Clean up server-side tests #696

Merged
merged 39 commits into from
Feb 29, 2020
Merged

Conversation

Marc-Andre-Rivet
Copy link
Contributor

@Marc-Andre-Rivet Marc-Andre-Rivet commented Feb 18, 2020

Closes #582
Closes #681

While #582 was about moving to gunicorn, what proposed here is instead to put in place a new test infra using Selenium (1) to be consistent with other core projects, (2) use the testing infra work that was done over the last year with Selenium in Dash.

  • Add DataTable mixin
  • Expose selectors for cells / columns / etc. - to be completed when more tests will be added or transitioned
  • Rewrite a subset of tests

@chriddyp chriddyp temporarily deployed to dash-table-review-pr-696 February 18, 2020 14:17 Inactive
@chriddyp chriddyp temporarily deployed to dash-table-review-pr-696 February 18, 2020 14:18 Inactive
@chriddyp chriddyp temporarily deployed to dash-table-review-pr-696 February 18, 2020 15:01 Inactive
@chriddyp chriddyp temporarily deployed to dash-table-review-pr-696 February 18, 2020 18:47 Inactive
@chriddyp chriddyp temporarily deployed to dash-table-review-pr-696 February 18, 2020 18:53 Inactive
@chriddyp chriddyp temporarily deployed to dash-table-review-pr-696 February 18, 2020 19:21 Inactive
@chriddyp chriddyp temporarily deployed to dash-table-review-pr-696 February 18, 2020 19:26 Inactive
@chriddyp chriddyp temporarily deployed to dash-table-review-pr-696 February 18, 2020 19:33 Inactive
@chriddyp chriddyp temporarily deployed to dash-table-review-pr-696 February 18, 2020 19:35 Inactive
@chriddyp chriddyp temporarily deployed to dash-table-review-pr-696 February 18, 2020 19:41 Inactive
@chriddyp chriddyp temporarily deployed to dash-table-review-pr-696 February 18, 2020 19:58 Inactive


@pytest.fixture
def test(request, dash_thread_server, tmpdir):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the dash_duo, dash_dcc equivalent for the table. As testing the table is mostly about interacting with discreet items inside the table component itself, this mixin aims to expose in an easy to use way the various parts of the table. To begin: cell and column headers.

It puts into application some lessons learned from the Cypress/JS helper so as to minimize finicking. For example, when one passes an integer vs a string for a cell column name the helper will figure out what the right selector is. Also, a lot of validations have to do with getting the text content of the cells, this is also streamlined so that it's no longer necessary to click the cell / know that the cell is editable or readonly, etc.

@chriddyp chriddyp temporarily deployed to dash-table-review-pr-696 February 18, 2020 20:10 Inactive
_validate_row = lambda row: isinstance(row, int) and row >= 0
_validate_state = lambda state: state in [_READY, _LOADING, _ANY]
_validate_target = lambda target: isinstance(target, DataTableFacade)
_validate_mixin = lambda mixin: isinstance(mixin, DataTableMixin)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Use preconditions to validate the inputs. The param name in the lambda needs to match the param name in the function, hence all keys should be key, etc.


_READY = '.dash-spreadsheet:not(.dash-loading)'
_LOADING = '.dash-spreadsheet.dash-loading'
_ANY = '.dash-spreadsheet'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since the operations are async, it sometimes matters what the state of the table is. These are extra selectors that are used to make sure the table is ready (or not). Typically state = _READY is used by default.

return


class HoldKeyContext:
Copy link
Contributor Author

@Marc-Andre-Rivet Marc-Andre-Rivet Feb 18, 2020

Choose a reason for hiding this comment

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

Allows using contexts for holding keys, making it structurally clearer what's impacted by the "hold"

with test.hold(Keys.SHIFT):
  // SHIFT is pressed
  // do things

// SHIFT is released here

return self.target

def __exit__(self, type, value, traceback):
return
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Create a context to handle a specific table. Some tests require interactions between tables.

@chriddyp chriddyp temporarily deployed to dash-table-review-pr-696 February 21, 2020 21:25 Inactive
@Marc-Andre-Rivet
Copy link
Contributor Author

Lots of noise due to the update for flake and black + applying the format to everything.

Copy link
Collaborator

@alexcjohnson alexcjohnson left a comment

Choose a reason for hiding this comment

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

Love it! 💃

@Marc-Andre-Rivet Marc-Andre-Rivet merged commit 503a51e into dev Feb 29, 2020
@Marc-Andre-Rivet Marc-Andre-Rivet deleted the 582-new-selenium-tests branch February 29, 2020 01:08
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Clean up server-side tests Rewrite Cypress test servers using gunicorn
3 participants