From 44aa38be7648df2e9378779150107cc2d5066b67 Mon Sep 17 00:00:00 2001 From: Lan Hui Date: Sat, 28 Sep 2024 09:46:52 +0800 Subject: [PATCH] Add a new regression test: test_student_can_join_course --- lrr_database.sql | 4 ++-- test/SeleniumHui/test_lrr.py | 30 +++++++++++++++++++++++++----- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/lrr_database.sql b/lrr_database.sql index efce39d..ae9266f 100644 --- a/lrr_database.sql +++ b/lrr_database.sql @@ -61,7 +61,7 @@ CREATE TABLE `courses_table` ( INSERT INTO `courses_table` (`Course_ID`, `Course_Name`, `Academic_Year`, `Faculty`, `Lecturer_User_ID`, `TA_User_ID`, `Course_Code`, `URL`, `Verify_New_Members`) VALUES (10, 'Software Engineering', '2018', 'Computing', 8, 0, 'CSC1234', 'CSC12342018', '1'), -(11, 'Project Management', '2019', 'Computing', 8, 0, 'P.M2019', 'P.M20192019', '0'), +(11, 'Project Management', '2024', 'Computing', 8, 0, 'CSC1111', 'CSC11112024', '0'), (12, 'Ashly Course Testing', '2020', 'Testing', 8, 0, 'Teecloudy', 'Teecloudy2020', '1'); -- -------------------------------------------------------- @@ -287,7 +287,7 @@ CREATE TABLE `users_table` ( INSERT INTO `users_table` (`User_ID`, `Email`, `Password`, `HashPassword`, `Full_Name`, `UserType`, `Student_ID`, `Passport_Number`, `Status`) VALUES (3, 'admin@qq.com', '$2y$10$8GCG6lTo1LFRD3bOkAyKYeOMOrFSBUgrTxaPLS5ynWN1bYDHf89pO', '', 'Kamal', 'Admin', '0', NULL, 'Active'), (8, 'lanhui@qq.com', '$2y$10$8GCG6lTo1LFRD3bOkAyKYeOMOrFSBUgrTxaPLS5ynWN1bYDHf89pO', '', 'Lanhui', 'Lecturer', NULL, '123', 'Active'), -(9, 'mohamed@qq.com', '123', '', 'Mohamed', 'Student', '201825800050', 'P00581929', 'Active'), +(9, 'mohamed@qq.com', '$2y$10$8GCG6lTo1LFRD3bOkAyKYeOMOrFSBUgrTxaPLS5ynWN1bYDHf89pO', '', 'Mohamed', 'Student', '201825800050', 'P00581929', 'Active'), (10, 'mark@qq.com', '123', '', 'Mark ', 'TA', NULL, '123', 'Active'), (11, 'john@qq.com', '123', '', 'John', 'TA', NULL, '123', 'Active'), (12, 'mehdi@qq.com', '123', '', 'El-mehdi Houzi', 'Student', '201825800054', 'LJ7951632', 'Active'), diff --git a/test/SeleniumHui/test_lrr.py b/test/SeleniumHui/test_lrr.py index 36c77cd..4a17d91 100644 --- a/test/SeleniumHui/test_lrr.py +++ b/test/SeleniumHui/test_lrr.py @@ -67,7 +67,7 @@ def test_lecturer_can_post_assignment(driver, url, restore_database): driver.maximize_window() login(driver, url, 'lanhui@qq.com', '123') - # Create an assignment called Take-home quiz 1 for course (P.M2019) - Project Management + # Create an assignment called Take-home quiz 1 for course (CSC1111) - Project Management elems = driver.find_elements(By.CLASS_NAME, 'btn-default') elems[1].click() elem = driver.find_element(By.NAME, 'deadlinedate') @@ -192,10 +192,30 @@ def test_student_with_invalid_student_number_cannot_sign_up(driver, url, restore driver.quit() -@pytest.mark.skip() -def test_student_can_join_course(): - # Student can join CSC1001 Advanced Software Engineering - assert True +def test_student_can_join_course(driver, url, restore_database): + # Student can join (CSC1111) - Project Management + login(driver, url, '201825800050', '123') + driver.maximize_window() + + # Search for CSC1111 + elem = driver.find_element(By.NAME, 'search') + elem.send_keys('CSC1111') + elem = driver.find_element(By.CLASS_NAME, 'btn-primary') + elem.click() + elems = driver.find_elements(By.CLASS_NAME, 'btn-default') + assert 'CSC1111' in elems[0].text + + # Join + elem = driver.find_element(By.CLASS_NAME, 'btn-success') # find the green Join button + elem.click() + + # Log out, then log in to check the course-joining status + logout(driver) + login(driver, url, '201825800050', '123') + elems = driver.find_elements(By.CLASS_NAME, 'btn-default') + assert 'CSC1111' in elems[0].text + assert 'Project Management' in elems[0].text + assert 'Joined' in elems[0].text @pytest.mark.skip()