Skip to content
This repository has been archived by the owner on Aug 17, 2023. It is now read-only.

Seeding Report: Test Direct Seeding Summary Values #206

Open
5 tasks
braughtg opened this issue Apr 11, 2023 · 12 comments
Open
5 tasks

Seeding Report: Test Direct Seeding Summary Values #206

braughtg opened this issue Apr 11, 2023 · 12 comments
Assignees
Labels
Good Second Issue An issue that is a little deeper than a good first issue. testing Issue related to testing FarmData2 functionality

Comments

@braughtg
Copy link
Member

braughtg commented Apr 11, 2023

When a Seeding Report that contains direct seedings is generated, a Direct Seeding Summary table appears below the table. This summary contains data that is computed from the data in the table.

This test must check that the values reported for the following quantities agree with the data in the table:

  • Total Row Feet Planted
  • Total Bed Feet Planted
  • Total Hours
  • Average Row Feet/Hour
  • Average Bed Feet/Hour

Notes:

  • The report that is tested on must contain a minimum of 3 direct seeding logs.
  • Every summary value must depend upon values in multiple logs.
  • No summary value may be zero.
  • Expected values should be hand computed from the sample data that are hard coded into the test.

Additional Information:

Some additional notes relevant to this issue:

  • The .spec.js file containing your test should be stored in an appropriate location and have a short but descriptive name. Use the locations and an naming from the "Good First issues" as examples.
  • The .spec.js file should include a comment at the top that describes what the file as a whole is testing.
  • The message for the describe should describe in a short phrase what the file is testing.
  • After logging in and visiting the desired page the beforeEach method should call cy.waitForPage(). This will ensure that the page is fully loaded (e.g. that all the Maps used by the page are loaded) before performing any tests.
  • It is not necessary to include a separate it for each of the things to be tested.
    • You should decide how to divide the things being tested into its so that each it tests a cohesive set of things.
    • The message for each it should describe in a short phrase what the it is testing.
  • The .spec.js files in the farmdata2/farmdata2_modules/fd2_example/ sub-tabs (e.g. ui, api) may provide some helpful examples.
  • These tests should utilize logs that are in the sample database. Information about the data contained in the sample database can be found in the "The Sample Database" section of the docker/sampleDB/README.md file.
@braughtg braughtg added testing Issue related to testing FarmData2 functionality Good Second Issue An issue that is a little deeper than a good first issue. labels Apr 11, 2023
@qnhn22
Copy link

qnhn22 commented Apr 19, 2023

I would like to work on this issue.

@phong260702
Copy link

I would like to work on this issue.

@nguyenbanhducA1K51
Copy link

I would like to work on this issue

@johnmaccormick
Copy link
Collaborator

good luck

@phong260702
Copy link

Access variable outside cypress
I was quite stuck with looping through cypress. So in this test, I've created a variable called "total" to hold the sum value of row feet. The values add up correctly inside the cypress for loop; however, when I try to access the "total" variable outside the cypress, it returns 0. How should I use the value in this cypress for loop to compare it to the value in the direct seeding summary?
image
image

@braughtg
Copy link
Member Author

braughtg commented Apr 24, 2023

@phong260702 Please push your branch and make a draft PR containing this code that links back to this issue with a "Closes #" line. That will make your code easily available to the project maintainers to experiment with to help develop an answer.

@phong260702
Copy link

@phong260702 Please push your branch and make a draft PR containing this code that links back to this issue with a "Closes #" line. That will make your code easily available to the project maintainers to experiment with to help develop an answer.

I've pushed the branch and created a draft PR.

@braughtg
Copy link
Member Author

There is some good information on how to do this on the Variables and Aliases page in the Cypress Documentation. Read through it, but I think the right approach is described in the section on Sharing Context in the sub-section on Avoiding the use of this.

@qnhn22
Copy link

qnhn22 commented Apr 26, 2023

Is possible to use global variables?
I am working on 2 last sub-tasks which are checking the average row feet/hour and the average bed feet/hour. These sub-tasks can simply be done by checking (total row feet / total hour) and (total bed feet / total hour). If we use multiple it statements, for example, one it statement for each sub-task, would it be possible to declare global variables and use them through different it statements? If not, I need to write code to perform the same computation like calculating the total row feet planted, the total bed feet, and the total hour. This may cause writing repetitive code, which is considered to be bad practice.

@qnhn22
Copy link

qnhn22 commented Apr 27, 2023

There is some good information on how to do this on the Variables and Aliases page in the Cypress Documentation. Read through it, but I think the right approach is described in the section on Sharing Context in the sub-section on Avoiding the use of this.

I think the problem occurs because the code is executed synchronously. cy.log() is executed before the cy.get() inside the loop. To avoid this, my solution is to use each() to iterate through a list of elements, and then add then() to check the total.

@johnmaccormick
Copy link
Collaborator

@qnhn22 Quan -- I'm not sure if you have figured out a solution to the problem of repeating a lot of test code. If not, don't worry about it, just write the tests with a large amount of repeated code. Then we can look at it and determine if there is a way to factor out repeated content. For now, use the simplest possible approach even if that causes repeated code. (Unless you already found a better solution.)

@qnhn22
Copy link

qnhn22 commented Apr 28, 2023

@qnhn22 Quan -- I'm not sure if you have figured out a solution to the problem of repeating a lot of test code. If not, don't worry about it, just write the tests with a large amount of repeated code. Then we can look at it and determine if there is a way to factor out repeated content. For now, use the simplest possible approach even if that causes repeated code. (Unless you already found a better solution.)

@johnmaccormick Hi Professor MacCormick,
I've tried to declare a variable outside the describe block and then use the variable in different it blocks. This works perfectly for all the written tests.

Screenshot 2023-04-28 at 3 12 34 PM

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Good Second Issue An issue that is a little deeper than a good first issue. testing Issue related to testing FarmData2 functionality
Projects
None yet
Development

No branches or pull requests

5 participants