Open thorpIV opened 1 year ago
Please provide a description of your PR in and include a "Closes" line that links to the issue that will be resolved when the PR is merged.
We had trouble accessing the delete button, such that it does not show up on the Cypress page but shows up on the Firefox browser. We set up the test to function once the delete button problem is solved.
We had trouble accessing the delete button, such that it does not show up on the Cypress page but shows up on the Firefox browser.
This issue happens sometimes in Cypress testing due to the way a particular component is being rendered in the browser. While it appears that the button is there, the browser for some reason believes that it is hidden behind another element.
The fix is to add the {force: true}
argument to click. So call click({force: true})
instead of click()
as described here: https://subscription.packtpub.com/book/web-development/9781839213854/9/ch09lvl1sec51/forcing-actionability.
Description:
When creating new logs, we made 3 copies of the makeDirectSedding() with different values (dates, crops, etc) using cy.wrap. When the test is rendered, it only shows 1 seeding report instead of 3. If we try to loop or make multiple copies of cy.wrap it gives an error. How can this be resolved?
If we try to loop or make multiple copies of cy.wrap it gives an error. How can this be resolved?
It would be very helpful if you could give the code you are using that is causing the error and also a clear illustration of the specific error that is caused. Please add the code that you are using to create the records and a screenshot of the error that is happening.
I am not sure why when I run the Cypress test it fails at waitForPage. Here is the error and the code:
I am not sure why when I run the Cypress test it fails at waitForPage. Here is the error and the code:
This looks like it could be a timeout issue with the speed of the machine on which it is running. Try quitting any other applications that are running and see if that gets you past this point.
I suggest that because when I ran the test it got past that point, but then failed later. The error that I was seeing is:
Here it looks like you are getting r1-cbuttonCheckbox
but the report you have generated contains only one row which would be r0
.
Description: To test whether the created new logs(s) are being deleted, I created 4 different functions for creating new logs and used "cy.wrap" to get the logs into the database. However, even before the test begins, I get wrap{} error indicating creating the logs in the database failed.
The code to be run and the error response:
Code from seedingReport.deleteLog.spec.js:
Output when the test is run:
Steps to Reproduce:
Observation:
Expected Result:
After running the lines in seedingReport.deleteLog.spec.js, the cy.wrap and cy.get should successfully get the logs that was created and begin the actual testing.
The above report is rendered after only using 1 cy.wrap and cy.get to get the log. However, it should work for multiple logs not only 1.
We had trouble accessing the delete button, such that it does not show up on the Cypress page but shows up on the Firefox browser.
This issue happens sometimes in Cypress testing due to the way a particular component is being rendered in the browser. While it appears that the button is there, the browser for some reason believes that it is hidden behind another element.
The fix is to add the
{force: true}
argument to click. So callclick({force: true})
instead ofclick()
as described here: https://subscription.packtpub.com/book/web-development/9781839213854/9/ch09lvl1sec51/forcing-actionability.
I tried this possible solution, and received the same error message. There is no button element in the div when I looked on the developer tools.
@udvale Nicely presented question! Well done.
To test whether the created new logs(s) are being deleted, I created 4 different functions for creating new logs and used "cy.wrap" to get the logs into the database. However, even before the test begins, I get wrap{} error indicating creating the logs in the database failed.
I pulled your code, tried it out and reduced it to a small example that I was able to get to run. Below is the context
that I came up with. It creates 2 logs and then deletes them. You'll need to adapt it to your purposes. In particular:
makeDirectSeeding
functions. One that you call multiple times will do.cy.wrap
and a different cy.wait
and a different logID
variable for each log that you createit
using the UI, then you will not want to delete the log in the afterEach
it
tests are not actually testing that the action was successful. You cannot check the status code when you click a button in the UI. That deletes the log, but you'll need to check the database directly using the getLog
function from FarmOSAPI
. See the example in the testdb
example in the fd2_example
module.context("Create new log(s), delete the log(s)", () => {
let logID0 = null
let logID1 = null
//Create new logs for testing and add dates
beforeEach(() => {
cy.wrap(makeDirectSeeding("Test Seeding0")).as("make-seeding0")
cy.get("@make-seeding0")
.then((response) => {
logID0 = response.data.id
})
cy.wrap(makeDirectSeeding("Test Seeding1")).as("make-seeding1")
cy.get("@make-seeding1")
.then((response) => {
logID1 = response.data.id
})
cy.get('[data-cy=start-date-select]')
.should("exist")
.type('2023-05-01')
cy.get('[data-cy=end-date-select]')
.should("exist")
.type('2023-05-04')
cy.get('[data-cy=generate-rpt-btn]')
.click()
})
it("Delete a singular seeding log from the row.", () => {
expect(true).to.equal(true)
})
//Delete the created logs so the database is refreshed
afterEach(() => {
cy.wrap(deleteRecord("/log/"+logID0, sessionToken)).as("delete-seeding0")
cy.wrap(deleteRecord("/log/"+logID1, sessionToken)).as("delete-seeding1")
cy.get("@delete-seeding0")
cy.get("@delete-seeding1")
})
})
I tried this possible solution, and received the same error message. There is no button element in the div when I looked on the developer tools.
@thorpIV This may be related to the organization of the tests overall. When I ran the code I posted above, I was able to get the delete button element with no error. So, I'd suggest that you check my reply to @udvale above and once you have the tests reorganized a little, see if it works for you. If not get back in touch if the problem persists.
Also, there appears to be changes to a lot of files in this PR that are not related to the PR itself. It is possible that you can resolve those by synchronizing your main
branch with the upstream
and then merging your main
into this feature branch.
Pull Request Description
The test allows you to create new logs and check if they are deleted from the database. The test accomplishes the following requirements to check whether the seeding report is deleting log(s) properly:
1.) When a single row is deleted from a table, the corresponding log is also removed from database. 2.) When multiple rows are deleted from a table, all the corresponding logs are removed from the database. 3.) When a row is checked to be deleted but cancels so no log is removed from the database.
Closes #205
Licensing Certification
FarmData2 is a Free Cultural Work and all accepted contributions are licensed as described in the LICENSE.md file. This requires that the contributor holds the rights to do so. By submitting this pull request I certify that I satisfy the terms of the Developer Certificate of Origin for its contents.