[Testing:InstructorUI] Add Cypress for Manage Teams#13043
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #13043 +/- ##
=========================================
Coverage 21.16% 21.16%
Complexity 10103 10103
=========================================
Files 285 285
Lines 38773 38773
Branches 596 596
=========================================
Hits 8205 8205
Misses 29986 29986
Partials 582 582
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
NicholasCiuica
left a comment
There was a problem hiding this comment.
I have done a code review, and have tested the new spec headfully (npx cypress open), and everything looks good. I've added some suggestions for things I noticed in the code. Also, I was unable to run the spec headlessly because of an npm issue that will require me to rebuild my VM, but I will test it tomorrow.
@NicholasCiuica I've updated the spec to assert the states of the section + subsection for the students at appropriate times. |
NicholasCiuica
left a comment
There was a problem hiding this comment.
I did a code review and all of the requests have been addressed. I tested locally with cypress run and open and all tests are passing and behaving as expected. Good work!
IDzyre
left a comment
There was a problem hiding this comment.
A couple comments about test structuring, but the code in the test themselves looks good. After the restructuring, I will re-review and approve if it's better.
| cyAssertRegistration(STUDENT_3, '1'); | ||
| }); | ||
|
|
||
| context('Test Instructor team management', () => { |
There was a problem hiding this comment.
All the "it" blocks in this PR should be combined. It is better to have one larger one, than a bunch of smaller ones. And since they are on the same page, just testing different items on that page, this is significantly better and faster, especially on windows machines.
There was a problem hiding this comment.
Alright, I combined it for the latest commit and did notice a speed increase. One downside I observed with combining them was that it was now harder to debug certain steps using the Cypress GUI, since I couldn't run each individual it block. But hopefully that is only an issue during debugging.
| context('Test Student team access', () => { | ||
| it('Should test student access to their new teams created in this test', () => { | ||
| [STUDENT_1, STUDENT_2, STUDENT_3].forEach((user) => { | ||
| cy.login(user); | ||
| cy.visit(['sample', 'gradeable', GRADEABLE, 'team']); | ||
| cy.get('[data-testid="your-team-header"]').should('exist'); | ||
| }); | ||
| }); | ||
| }); | ||
|
|
||
| context('Test Instructor team management, delete teams', () => { | ||
| it('Should successfully test the deletion of teams', () => { | ||
| cy.login('instructor'); | ||
| cy.visit(['sample', 'gradeable', GRADEABLE, 'team']); | ||
| cy.on('window:confirm', () => true); | ||
|
|
||
| cy.get('[data-testid="delete-all-teams"]').click(); | ||
|
|
||
| cy.get('[data-testid="popup-message"]') | ||
| .invoke('text') | ||
| .should('equal', 'Successfully deleted 2 teams. Skipped 36 teams with submissions. Skipped 0 teams with instructor-level users.'); | ||
|
|
||
| cy.get('[data-testid="manage-teams-message"]', { timeout: 5000 }) | ||
| .should('have.text', 'There are currently 36 existing teams for this gradeable. There are currently 3 students not yet on a team and 101 students on existing teams for this gradeable.'); | ||
| }); | ||
| }); |
There was a problem hiding this comment.
Instead of different "context", these could be different "it" in the same "context" as the first set.
There was a problem hiding this comment.
I ended up just making one it and putting them in there, and then we also don't need a context any more. Hopefully that is okay.
|
@IDzyre Thank you for the review. I have pushed a commit to address your requested changes, hopefully the structure of the test looks good now. |
|
|
||
| // Verify the buttons for management of teams exist | ||
| cy.get('[data-testid="create-teams-from-registration-subsections"]') | ||
| .should('be.visible') |
There was a problem hiding this comment.
While not strictly necessary here, since if the element isn't visible, it shouldn't be able to be retreived by cy.get, I think this is fine since it is an assertion.
| cyAssertRegistration(STUDENT_1, 'NULL'); | ||
| cyAssertRegistration(STUDENT_2, 'NULL'); | ||
| cyAssertRegistration(STUDENT_3, 'NULL'); |
There was a problem hiding this comment.
I don't think you should assert anything in the before, since it is the setup. If you run half of the test, then stop and rerun it because you fixed something, this will fail. The before should be to set the state that the tests expect, even if they were in an unexpected state before .
There was a problem hiding this comment.
Alright, that makes sense. I've just pushed a commit to remove the assertions both from the before() and from the after().
| // ========================================== | ||
| // Test Instructor creation of teams | ||
| // ========================================== | ||
| cy.login('instructor'); |
There was a problem hiding this comment.
Since the instructor is already logged in, this isn't really necessary.
There was a problem hiding this comment.
Thanks for pointing that out, I've just updated with a commit to remove it!
IDzyre
left a comment
There was a problem hiding this comment.
Tests look better. There are a couple of things that are redundant, but won't hurt anything or cause significant delay in test time (maybe + seconds at the most).
|
There are errors about excessive/duplicate queries so we cannot merge this PR without either addressing that or making an exception. |
@bmcutler thank you for pointing that out, I updated the PR to ignore the warnings on the 3 functions being tested since I believe we had previously discussed that in this case it was okay to ignore the warnings. Hopefully once tests pass it should be ready to go now. |
Why is this Change Important & Necessary?
In #12909 I added some features for instructors to manage teams for their class. These features include: creating teams from subsections, creating single-student teams, and deleting all teams (without submissions). However, I did not add Cypress e2e testing for these features.
What is the New Behavior?
Cypress e2e testing has been added for the manage teams features. Creating teams from subsections and single student teams are tested for the instructor. It will also test that these teams have actually been created for their users. Then, it will test deleting these teams.
What steps should a reviewer take to reproduce or test the bug or new feature?
Submitty guidelines I followed here:
https://submitty.org/developer/testing/cypress
Automated Testing & Documentation
It sure is :)
Other information
This is not a breaking change.
Luckily, this gradeable (grading team homework pdf) only starts off with teams with submissions, so the test is free to make and delete teams without disturbing the initial state of the gradeable (as long as it makes it to cleanup.)