Add Selenium and a basic CI script#8
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a first pass at browser-based (Selenium) tests and a GitHub Actions workflow to run tests on PRs, along with small UI/controller tweaks intended to support those tests.
Changes:
- Introduces new Selenium-based UI tests for group creation.
- Adds a GitHub Actions workflow to run unit tests (and Selenium tests).
- Modifies the index template to add DOM ids for student cells, and changes controller validation behavior around “extra” students.
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 7 comments.
| File | Description |
|---|---|
tests/selenium_tests.py |
Adds Selenium tests and a (currently incomplete) page-object helper. |
app/templates/index.html |
Adds id attributes to student <td> elements for Selenium selectors. |
app/controllers.py |
Comments out validation logic for students beyond the selected group size. |
.github/workflows/python-app.yml |
Adds a CI workflow to install deps and run unittest suites. |
Comments suppressed due to low confidence (1)
tests/selenium_tests.py:84
CreateGroupPageis used as a fluent API in the test, but it is incomplete (set_group_membersis missing, and there are no helpers forstudent3/student4). Either flesh out the page object to cover the form fields used by the tests, or remove it and keep the tests using directdriver.find_elementcalls consistently.
class CreateGroupPage:
def __init__(self, driver):
self.driver = driver
def set_student1(self, student_id):
self.driver.find_element(By.ID, "student1").send_keys(student_id)
return self
def set_student2(self, student_id):
self.driver.find_element(By.ID, "student2").send_keys(student_id)
return self
def submit_form(self):
self.driver.find_element(By.ID, "submitBtn").click()
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @@ -1,5 +1,6 @@ | |||
|
|
|||
| import multiprocessing | |||
| import time | |||
Comment on lines
+41
to
+44
| def test_group_creation(self): | ||
| page = CreateGroupPage(self.driver).set_group_members("3").set_student1("12345678").set_student2("87654321") | ||
|
|
||
| self.driver.get(localHost) |
Comment on lines
+62
to
+69
| def test_invalid_group_creation(self): | ||
| self.driver.find_element(By.ID, "groupMembers").send_keys("4") | ||
| self.driver.find_element(By.ID, "student1").send_keys("12345678") | ||
| self.driver.find_element(By.ID, "student2").send_keys("87654321") | ||
| self.driver.find_element(By.ID, "student3").send_keys("11223344") | ||
|
|
||
| self.driver.find_element(By.ID, "submitBtn").click() | ||
|
|
Comment on lines
+47
to
+50
| <td id="{{group.student1}}">{{group.student1}}</td> | ||
| <td id="{{group.student2}}">{{group.student2}}</td> | ||
| <td id="{{group.student3}}">{{group.student3}}</td> | ||
| <td id="{{group.student4}}">{{group.student4}}</td> |
Comment on lines
49
to
54
| def check_valid_student(expected_number, student_number, student_id: Optional[str]): | ||
| # print(expected_number, student_number, student_id, student_id is not None or student_id != '') | ||
| if student_number > expected_number: | ||
| if student_id is not None: | ||
| raise ValueError(f"Student {student_number} should not be provided for a group of {expected_number} members.") | ||
| # if student_id is not None or student_id != '': | ||
| # raise ValueError(f"Student {student_number} should not be provided for a group of {expected_number} members.") | ||
| return |
Comment on lines
49
to
54
| def check_valid_student(expected_number, student_number, student_id: Optional[str]): | ||
| # print(expected_number, student_number, student_id, student_id is not None or student_id != '') | ||
| if student_number > expected_number: | ||
| if student_id is not None: | ||
| raise ValueError(f"Student {student_number} should not be provided for a group of {expected_number} members.") | ||
| # if student_id is not None or student_id != '': | ||
| # raise ValueError(f"Student {student_number} should not be provided for a group of {expected_number} members.") | ||
| return |
Comment on lines
+21
to
+23
| pip install -r requirements.txt | ||
|
|
||
| - name: Run tests |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.