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

[#13066] Combine Admin Add Account Request Flow into Instructor Account Request Flow #13124

Open
wants to merge 29 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
0b29350
Change admin add account flow to use instructor request flow
Andy-W-Developer May 29, 2024
13f7add
Remove old flow results table
Andy-W-Developer May 30, 2024
4f24c5e
Remove old flow functions
Andy-W-Developer May 30, 2024
880278f
Remove old flow variables
Andy-W-Developer May 30, 2024
86ecbaf
Remove old flow tests
Andy-W-Developer May 30, 2024
b97b637
Change tests to new instructor request flow
Andy-W-Developer May 30, 2024
105cb50
Fix formatting inconsistencies
Andy-W-Developer Jun 1, 2024
1132790
Add missing expects
Andy-W-Developer Jun 2, 2024
63fb244
Add test for fetchAccountRequests
Andy-W-Developer Jun 2, 2024
b81a48f
Change sample strings to shorter strings
Andy-W-Developer Jun 2, 2024
0223006
Merge branch 'master' of github.com:TEAMMATES/teammates into combine-…
Andy-W-Developer Jun 18, 2024
49f4ce1
Update AdminHomePageE2ETest
Andy-W-Developer Jun 25, 2024
0de6816
Update SQL AdminHomePageE2ETest
Andy-W-Developer Jun 25, 2024
c481da4
Remove deprecated E2E test functions
Andy-W-Developer Jun 25, 2024
35471f2
Merge branch 'master' into combine-account-requests
Andy-W-Developer Jul 3, 2024
3e6daf8
Merge branch 'master' into combine-account-requests
mingyuanc Jul 30, 2024
1030c7e
Merge branch 'master' into combine-account-requests
Andy-W-Developer Aug 3, 2024
2dc547f
Replace getToastTextContent with verifyStatusMessage
Andy-W-Developer Aug 4, 2024
9e15d2f
Fix inconsistent whitespacing
Andy-W-Developer Aug 4, 2024
66d4a0e
Add error handling to batch requests
Andy-W-Developer Aug 4, 2024
7862935
Add negative test case for invalid single line email
Andy-W-Developer Aug 6, 2024
28e5c97
Fix mismatching logic between sql and non sql test
Andy-W-Developer Aug 6, 2024
7a954f7
Fix linting
Andy-W-Developer Aug 6, 2024
3cbf5a0
Fix api being called multiple times
Andy-W-Developer Aug 15, 2024
7d5feca
Fix loop array being changed inside loop
Andy-W-Developer Aug 28, 2024
0fa111b
Change validateAndAddInstructorDetails() return from void to Promise<…
Andy-W-Developer Aug 28, 2024
a2f3b4f
Add string checks before request creation
Andy-W-Developer Aug 28, 2024
266a37e
Fix break used instead of continue in for loop
Andy-W-Developer Aug 28, 2024
3351df8
Add mock implementation for createAccountRequest
Andy-W-Developer Aug 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 12 additions & 13 deletions src/e2e/java/teammates/e2e/cases/AdminHomePageE2ETest.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,25 @@ public void testAll() {
AdminHomePage homePage = loginAdminToPage(url, AdminHomePage.class);

______TS("Test adding instructors with both valid and invalid details");

String name = "AHPUiT Instrúctör WithPlusInEmail";
String email = "[email protected]";
String institute = "TEAMMATES Test Institute 1";

homePage.queueInstructorForAdding(name, email, institute);

String singleLineDetails = "Instructor With Invalid Email | invalidemail | TEAMMATES Test Institute 1";

homePage.queueInstructorForAdding(singleLineDetails);

homePage.addAllInstructors();

String successMessage = homePage.getMessageForInstructor(0);
assertTrue(successMessage.contains(
"Instructor \"AHPUiT Instrúctör WithPlusInEmail\" has been successfully created"));

String failureMessage = homePage.getMessageForInstructor(1);
Copy link
Contributor

Choose a reason for hiding this comment

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

Try not to remove this negative test case

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've added back an error toast for when a single line request has an invalid email under validateAndAddInstructorDetails, it works when I add a request manually but when running the e2e test, no toast is shown.
A toast made by the approve account button - under the account request table still works, any ideas why on this is happening?
https://github.com/user-attachments/assets/c985d4dd-5a51-4ca0-90e1-67ee7e48197a
I've tried rerunning the e2e tests after deleting all the postgres data and remaking all docker containers.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The issue was user error, I forgot to build the front-end files after editing.
I've added back in the negative test case with a updated error message.

assertTrue(failureMessage.contains(
"\"invalidemail\" is not acceptable to TEAMMATES as a/an email because it is not in the correct format."));
homePage.verifyStatusMessage("\"invalidemail\" is not acceptable to TEAMMATES as a/an email because it is not "
+ "in the correct format. An email address contains some text followed by one '@' sign followed by some "
+ "more text, and should end with a top level domain address like .com. It cannot be longer than 254 "
+ "characters, cannot be empty and cannot contain spaces.");

______TS("Verify that newly added instructor appears in account request table");
homePage.verifyInstructorInAccountRequestTable(name, email, institute);

______TS("Test approving a valid account request");
homePage.clickApproveAccountRequestButton(name, email, institute);
homePage.verifyStatusMessage("Account request was successfully approved. Email has been sent to "
+ "[email protected].");
}

}
24 changes: 8 additions & 16 deletions src/e2e/java/teammates/e2e/cases/sql/AdminHomePageE2ETest.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,33 +23,25 @@ public void testAll() {
AdminHomePage homePage = loginAdminToPage(url, AdminHomePage.class);

______TS("Test adding instructors with both valid and invalid details");

String name = "AHPUiT Instrúctör WithPlusInEmail";
String email = "[email protected]";
String institute = "TEAMMATES Test Institute 1";

homePage.queueInstructorForAdding(name, email, institute);

String singleLineDetails = "Instructor With Invalid Email | invalidemail | TEAMMATES Test Institute 1";

homePage.queueInstructorForAdding(singleLineDetails);

homePage.addAllInstructors();
Copy link
Contributor

Choose a reason for hiding this comment

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

As part of our migration to SQL, please keep the E2E tests the same as its non-SQL counterpart as much as possible. The logic here does not represent the same logic in src/e2e/java/teammates/e2e/cases/AdminHomePageE2ETest.java

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Both tests use the same logic now, the page reload was removed because fetchAccountRequests() makes it unnecessary.


String successMessage = homePage.getMessageForInstructor(0);
assertTrue(successMessage.contains(
"Instructor \"AHPUiT Instrúctör WithPlusInEmail\" has been successfully created"));

String failureMessage = homePage.getMessageForInstructor(1);
assertTrue(failureMessage.contains(
"\"invalidemail\" is not acceptable to TEAMMATES as a/an email because it is not in the correct format."));

homePage.reloadPage();
homePage.verifyStatusMessage("\"invalidemail\" is not acceptable to TEAMMATES as a/an email because it is not "
+ "in the correct format. An email address contains some text followed by one '@' sign followed by some "
+ "more text, and should end with a top level domain address like .com. It cannot be longer than 254 "
+ "characters, cannot be empty and cannot contain spaces.");

______TS("Verify that newly added instructor appears in account request table");

homePage.verifyInstructorInAccountRequestTable(name, email, institute);

______TS("Test approving a valid account request");
homePage.clickApproveAccountRequestButton(name, email, institute);
homePage.verifyStatusMessage("Account request was successfully approved. Email has been sent to "
+ "[email protected].");
}

}
23 changes: 7 additions & 16 deletions src/e2e/java/teammates/e2e/pageobjects/AdminHomePage.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ public class AdminHomePage extends AppPage {
@FindBy (id = "add-instructor-single-line")
private WebElement submitButtonDetailsSingleLineForm;

@FindBy (id = "add-all-instructors")
private WebElement addAllInstructorsButton;

public AdminHomePage(Browser browser) {
super(browser);
}
Expand Down Expand Up @@ -69,19 +66,13 @@ public void queueInstructorForAdding(String instructorDetails) {
click(submitButtonDetailsSingleLineForm);
}

public void addAllInstructors() {
click(addAllInstructorsButton);
waitForElementToBeClickable(addAllInstructorsButton);
}

public String getMessageForInstructor(int i) {
By by = By.id("message-instructor-" + i);
waitForElementVisibility(by);
WebElement element = browser.driver.findElement(by);
if (element == null) {
return null;
}
return element.getText();
public void clickApproveAccountRequestButton(String name, String email, String institute) {
WebElement accountRequestRow = getAccountRequestRow(name, email, institute);
waitForElementPresence(By.cssSelector("[id^='approve-account-request-']"));
WebElement approveButton = accountRequestRow.findElement(By.cssSelector("[id^='approve-account-request-']"));
waitForElementToBeClickable(approveButton);
approveButton.click();
waitForPageToLoad();
}

public void clickMoreInfoButtonForRegisteredInstructor(int i) {
Expand Down
Loading
Loading