-
-
Notifications
You must be signed in to change notification settings - Fork 73
Issue 681 - Clean up server-side tests #696
Conversation
|
||
|
||
@pytest.fixture | ||
def test(request, dash_thread_server, tmpdir): |
There was a problem hiding this comment.
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.
tests/selenium/conftest.py
Outdated
_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) |
There was a problem hiding this comment.
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.
tests/selenium/conftest.py
Outdated
|
||
_READY = '.dash-spreadsheet:not(.dash-loading)' | ||
_LOADING = '.dash-spreadsheet.dash-loading' | ||
_ANY = '.dash-spreadsheet' |
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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
tests/selenium/conftest.py
Outdated
return self.target | ||
|
||
def __exit__(self, type, value, traceback): | ||
return |
There was a problem hiding this comment.
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.
Lots of noise due to the update for flake and black + applying the format to everything. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love it! 💃
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.