Skip to content
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

Support live server tests with Selenium #2077

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

hansegucker
Copy link
Collaborator

Close #1854

Copy link
Member

@niklasmohrin niklasmohrin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very cool, I feel that there are some parts that could be cleaned up or need some more explanation otherwise:

deployment/provision_vagrant_vm.sh Outdated Show resolved Hide resolved
evap/evaluation/tests/tools.py Outdated Show resolved Hide resolved
evap/evaluation/tests/tools.py Outdated Show resolved Hide resolved
evap/evaluation/tests/tools.py Show resolved Hide resolved
@niklasmohrin
Copy link
Member

Manager group was not present, but only if all tests are run. We found that django will first run django.test.TestCase instances, then django.test.TransactionTestCase and then unittest.TestCase. After the first, the database is cleared. If only running the live server test, the database is still there when running the test.

Link dump if we try to debug this again:

We concluded that we want to migrate an empty database, dump it, and use that dump as a fixture in the live server test - at least for now, to continue working on this.

@hansegucker
Copy link
Collaborator Author

hansegucker commented Apr 15, 2024

@Kakadus @niklasmohrin @richardebeling Finally, the last test has been migrated and I'm ready for a final review. 🥳

@hansegucker hansegucker force-pushed the live-server-tests branch 2 times, most recently from 6f8cb5d to 88d3f6e Compare April 22, 2024 18:44
Copy link
Member

@richardebeling richardebeling left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not yet fully reviewed, will have to look through most of the ported tests still, but generally this is looking very nice. Thanks!

evap/results/tests/test_live.py Outdated Show resolved Hide resolved
evap/staff/tests/test_live.py Outdated Show resolved Hide resolved
evap/student/tests/test_live.py Outdated Show resolved Hide resolved
evap/student/tests/test_live.py Outdated Show resolved Hide resolved
@niklasmohrin
Copy link
Member

Getting chromium or firefox should be a lot easier now that we have nix, we can work something out together some time if you want :)

@Kakadus Kakadus force-pushed the live-server-tests branch 5 times, most recently from d182ee9 to a88cdfa Compare December 2, 2024 21:29
@Kakadus Kakadus mentioned this pull request Dec 9, 2024
@Kakadus
Copy link
Collaborator

Kakadus commented Dec 9, 2024

Heey, there is a green check now! 🎉

@hansegucker do you want to take over and resolve the open threads? If not, I can also finish this : )

Things I fixed:

  • we no longer supported django.contrib.auth.backends.ModelBackend, I switched to our evap.evaluation.auth.RequestAuthUserBackend (since Make natural key of userprofile unique #2249)
  • increased window size so that all elements should be visible now
  • compile scss&ts before testing the frontend
  • separate firefox into a separate nix shell / CI job

@Kakadus Kakadus self-assigned this Jan 13, 2025
Copy link
Member

@richardebeling richardebeling left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good! I especially like the changes to package.json and package-lock.json.

Haven't re-checked yet whether all ported tests assert the same things as the old tests, will need to re-do that in a final review.

Comment on lines +42 to +43
if not self.tags and not self.exclude_tags:
self.exclude_tags = {"live-server"}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If someone uses the SkipLiveServerTestsRunner and passes tags or exclude_tags here, it doesn't skip live server tests anymore. I'd either expect us to just add "live-server" to exclude_tags, or at least assert that neither tags or exclude_tags was set (if we never expect this to happen). The current approach of continuing but with behavior that doesn't match the class name, to me, is just a trap we set.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think adding --tags live-server to start the live servers is reasonable. To mitigate the other stuff, I think this is most intuitive

Suggested change
if not self.tags and not self.exclude_tags:
self.exclude_tags = {"live-server"}
if "live-server" not in self.tags:
self.exclude_tags.add("live-server")

Copy link
Collaborator

@Kakadus Kakadus Jan 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe also a constant for the "live-server" tag?

browser = "firefox"
selenium_hub = None
headless = True
window_size = (1920, 3080)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3080 intended? Or should it be 1080?

Copy link
Collaborator

@Kakadus Kakadus Jan 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, the height should be large enough so that there is no scrolling needed. Maybe worth a comment?

evap/evaluation/tests/tools.py Outdated Show resolved Hide resolved
evap/staff/tests/test_live.py Outdated Show resolved Hide resolved
Comment on lines 39 to 33
role=Contribution.Role.EDITOR,
textanswer_visibility=Contribution.TextAnswerVisibility.GENERAL_TEXTANSWERS,
role=Contribution.Role.CONTRIBUTOR,
textanswer_visibility=Contribution.TextAnswerVisibility.OWN_TEXTANSWERS,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed this so that the values selected in the UI are not already selected. I found out this was intended to be a test for #1769 but I could not find there that this is required for this

@Kakadus
Copy link
Collaborator

Kakadus commented Jan 20, 2025

I'm going to rebase this and sort the changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Use LiveServerTestCase for frontend tests
4 participants