DickinsonCollege / FD2School-FarmData2-S23

A fork of FarmData2 that is used for the FarmData2 School Activities.
Other
1 stars 36 forks source link

Seeding Report: Tests for Seeding Log Edit #217

Open sidlamsal opened 1 year ago

sidlamsal commented 1 year ago

Pull Request Description

Adds cypress test file "seedingReport.log.edit.spec.js" containing tests for the seeding report edit functionality. Tests the following:

closes #204

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.

sidlamsal commented 1 year ago

Cypress Error when interacting with user drop down element:

Description: To test that the cancel button works, I generated a seeding report and started editing the first row of the table. When trying to edit the value in the "User" column of the seeding report table, I get a cypress error when I try to select a different drop down option.

Observed: Code:

    //Edit user
    cy.get('[data-cy="r0-User-input"]')
        .select(0)

Output:

Screenshot 2023-04-15 at 12 37 20 AM

When trying to interact with the drop down (.select(0)), cypress runs into an error because "...the center of this element is hidden from view".

Expected: When running similar code to change the "Crop" column of the seeding report, cypress gets the drop down and changes the selected value without error. Code (lines 40-50):

  //Edit crop input
    cy.get('[data-cy="r0-Crop-input"]')
        .select(0)

To reproduce the error:

  1. Go to the file at: /home/fd2dev/FarmData2/farmdata2/farmdata2_modules/fd2_barn_kit/seedingReport/seedingReport.log.edit.spec.js
  2. Uncomment the lines to edit user (71-72)
  3. Run test in the cypress GUI using the electron browser
braughtg commented 1 year ago

When trying to interact with the drop down (.select(0)), cypress runs into an error because "...the center of this element is hidden from view".

Two comments here:

sidlamsal commented 1 year ago

Then see if the element you are trying to click actually becomes visible. If it does not, then looking at the page code to see if it can be fixed.

Thanks for the suggestions.

EliasBerhe commented 1 year ago

Edit button not showing up on the Seeding Report Page

Description

When trying to run some of the test we wrote, Cypress couldn't find the Edit button and generated an error. I even logged in from FireFox and when I inserted some date range and clicked generate report button, the edit button was not visible on the table that was generated. I tried to reload the page and start the FarmData2 again and still couldn't see the Edit button.

image image

The Funny thing is that the last time I was working on it on the same test, there was no problem but this time I only pulled the branch from origin to get new updates that were added by my teammates and I faced this problem. I am stuck at this because I can't move forward unless I resolve this issue because the whole point of this test relies on the edit button.

braughtg commented 1 year ago

When trying to run some of the test we wrote, Cypress couldn't find the Edit button and generated an error.

This is a known issue with FarmData2 and is reported in DickinsonCollege/FarmData2#592 with some additional information there.

As described in that issue, there is code in the SeedingReport.html page that causes different columns to be displayed depending on the screen width. So sometime changing the size of the browser window and/or messing with the display settings in the dev tools (see the issue for info) will make the Edit button reappear. There is also some possibility that the behavior is better in Chrome than in Firefox so perhaps testing in Chrome with Cypress will help.

A more complete approach would be find the code in the SeedingReport.html page that is checking the width and modify it so that all of the columns always appear. Then complete your tests. Then when the tests are working, you could turn to working on fixing this bug. That would be a huge help with the upstream FarmData2.

braughtg commented 1 year ago

The work here looks good. I am going to delay merging this until the issue with the screen width (DickinsonCollege#592 ) is properly resolved.