-
-
Notifications
You must be signed in to change notification settings - Fork 6
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
Add cypress tests #509
Add cypress tests #509
Conversation
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.
I don't think testing framework should affect teal
code. Isn't this better to get element by id
instead of adding cy-*
class?
Agree that the testing framework should not affect the core package code. However, in the future when some changes are made to the id or class they would break our tests, Adding the |
Contrary, changing testing framework will leave some redundant class specification in the package.
Fair point. On the other side any errors will be indicated by the cypress tests result.
We can use specific selectors to find the right elements. We will probably need to add class to the
|
beforeEach(() => { | ||
cy.visit("http://127.0.0.1:5555/"); | ||
cy.waitForStabilityAndCatchError("body"); | ||
cy.get(".cy-active-summary-table tbody tr").as("activeSummary"); |
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.
I don't like the fact id is duplicated with "cy_"
prefix. I propose following convention: since we need to be aware that certain element is tested let's just add cy-testable
class to the existing class (as a second class). Then selector for this like will be
cy.get(".cy-active-summary-table tbody tr").as("activeSummary"); | |
cy.get(".cy-testable.teal_active_summary_filter_panel tbody tr").as("activeSummary"); |
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.
👍🏽 Let's try to find out if it's possible to implement the tests without any change to the classes in the package as we talked about. If unsuccessful, we can use this convention, I like it.
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.
I respect the idea of having a distinction between what's testable and what is not so app developer won't change this casually (I hope at least). It will be good to write down this convention somewhere that "testable" means don't touch it ;)
Also, I think we need to review all html classes to follow some "template". They seem to be random
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.
Also, I think we need to review all html classes to follow some "template". They seem to be random
Agreed
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.
if testable
is propagated in some good-practice guidelines then this should be ok
cy.waitForStabilityAndCatchError("body"); | ||
|
||
cy.get("@numericCard") | ||
.get(".cy-numeric-selection-inputs input:first") |
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.
I'm thinking about parent-child naming convention for filters. In FilterState
card can have a general class like filter-card
, then RangeFilterState$ui_inputs
will just have .numeric-filter-inputs
.
.get(".cy-numeric-selection-inputs input:first") | |
.get(".filter-card > .numeric-filter > .cy-testable.filter-card input:first") |
Let's sit down and design a complete wireframe for teal/teal.slice and let's think about classes/ids of each element
data_frame$date <- as.Date(data_frame$datetime) | ||
}) | ||
datanames(data) <- c("data_frame", "iris") | ||
app <- teal::init( |
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.
It should be a generic shiny app instead of teal. Testing could be distorted by teal
. I suggest to use shiny app from vignette. Should also test the output if and how data gets filtererd?
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.
Please update:
- .gitignore to not include cypress artifacts and node modules
- .Rbuildignore to not include cypress at all
@@ -0,0 +1,150 @@ | |||
describe("data.frame filters", () => { |
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.
So for cypress tests you assume that there is a specific class id/name, so that's why you put all those divs(
around in R code. Then you need to have node
and know JavaScript to write tests? Is that right? Is JS part of CoreDev regular skillset?
Closing the PR as we chose to go with the |
A draft on adding cypress tests for
teal.slice
How to run?
tests
directory and runnpm i
to install the npm dependencies.tests/test_e2e.R
file. Make sure that the working directory istests
.npm run test-e2e