Skip to content

Commit

Permalink
[#11878] Request Page E2E (#13015)
Browse files Browse the repository at this point in the history
* Add E2E skeleton

* Fix test and lint

* Add verifyEmailSent

* fix fe tests
  • Loading branch information
dishenggg authored Apr 16, 2024
1 parent 7b05fec commit 16f7767
Show file tree
Hide file tree
Showing 8 changed files with 130 additions and 2 deletions.
52 changes: 52 additions & 0 deletions src/e2e/java/teammates/e2e/cases/sql/RequestPageE2ETest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package teammates.e2e.cases.sql;

import org.testng.annotations.Test;

import teammates.common.util.AppUrl;
import teammates.common.util.Const;
import teammates.common.util.EmailType;
import teammates.e2e.pageobjects.RequestPage;
import teammates.e2e.util.TestProperties;

/**
* SUT: {@link Const.WebPageURIs#ACCOUNT_REQUEST_PAGE}.
*/
public class RequestPageE2ETest extends BaseE2ETestCase {

@Override
protected void prepareTestData() {
// No test data needed
}

@Test
@Override
protected void testAll() {
String name = "arf-test-name";
String institution = "arf-test-institution";
String country = "arf-test-country";
String email = TestProperties.TEST_EMAIL;
String comments = "arf-test-comments";

AppUrl url = createFrontendUrl(Const.WebPageURIs.ACCOUNT_REQUEST_PAGE);
RequestPage requestPage = getNewPageInstance(url, RequestPage.class);

______TS("verify submission with comments");
requestPage.clickAmInstructorButton();
requestPage.fillForm(name, institution, country, email, comments);
requestPage.clickSubmitFormButton();
requestPage.verifySubmittedInfo(name, institution, country, email, comments);

String expectedEmailSubject = EmailType.NEW_ACCOUNT_REQUEST_ACKNOWLEDGEMENT.toString();
verifyEmailSent(email, expectedEmailSubject);

______TS("verify submission without comments");
requestPage = getNewPageInstance(url, RequestPage.class);
requestPage.clickAmInstructorButton();
requestPage.fillForm(name, institution, country, email, "");
requestPage.clickSubmitFormButton();
requestPage.verifySubmittedInfo(name, institution, country, email, "");

expectedEmailSubject = EmailType.NEW_ACCOUNT_REQUEST_ACKNOWLEDGEMENT.toString();
verifyEmailSent(email, expectedEmailSubject);
}
}
71 changes: 71 additions & 0 deletions src/e2e/java/teammates/e2e/pageobjects/RequestPage.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package teammates.e2e.pageobjects;

import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;

/**
* Page Object Model for account request form page.
*/
public class RequestPage extends AppPage {

@FindBy(id = "btn-am-instructor")
private WebElement amInstructorButton;

@FindBy(id = "name")
private WebElement nameBox;

@FindBy(id = "institution")
private WebElement institutionBox;

@FindBy(id = "country")
private WebElement countryBox;

@FindBy(id = "email")
private WebElement emailBox;

@FindBy(id = "comments")
private WebElement commentsBox;

@FindBy(id = "submit-button")
private WebElement submitButton;

public RequestPage(Browser browser) {
super(browser);
}

@Override
protected boolean containsExpectedPageContents() {
return getPageTitle().contains("Request for an Instructor Account");
}

public void clickAmInstructorButton() {
click(amInstructorButton);
waitForPageToLoad();
}

public void fillForm(String name, String institution, String country, String email, String comments) {
fillTextBox(nameBox, name);
fillTextBox(institutionBox, institution);
fillTextBox(countryBox, country);
fillTextBox(emailBox, email);
fillTextBox(commentsBox, comments);
}

public void clickSubmitFormButton() {
click(submitButton);
waitForPageToLoad();
}

public void verifySubmittedInfo(String name, String institution, String country, String email, String comments) {
WebElement table = browser.driver.findElement(By.className("table"));
String[][] expected = {
{ name },
{ institution },
{ country },
{ email },
{ comments },
};
verifyTableBodyValues(table, expected);
}
}
1 change: 1 addition & 0 deletions src/e2e/resources/testng-e2e-sql.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<class name="teammates.e2e.cases.sql.AdminSearchPageE2ETest" />
<class name="teammates.e2e.cases.sql.FeedbackRankOptionQuestionE2ETest" />
<class name="teammates.e2e.cases.sql.InstructorNotificationsPageE2ETest" />
<class name="teammates.e2e.cases.sql.RequestPageE2ETest" />
</classes>
</test>
</suite>
2 changes: 2 additions & 0 deletions src/main/java/teammates/common/util/Const.java
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,8 @@ public static class WebPageURIs {
public static final String SESSION_RESULTS_PAGE = URI_PREFIX + "/sessions/result";
public static final String SESSION_SUBMISSION_PAGE = URI_PREFIX + "/sessions/submission";
public static final String SESSIONS_LINK_RECOVERY_PAGE = FRONT_PAGE + "/help/session-links-recovery";

public static final String ACCOUNT_REQUEST_PAGE = FRONT_PAGE + "/request";
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ exports[`RequestPageComponent should render correctly before instructor declarat
</a>
<button
class="btn btn-primary ms-3"
id="btn-am-instructor"
type="button"
>
I am an instructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ exports[`InstructorRequestFormComponent should render correctly 1`] = `
<textarea
aria-invalid="false"
class="form-control ng-untouched ng-pristine ng-valid"
id="comments"
/>
</div>
<br />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
<label for="comments" id="comments-label" class="qn">
Any other comments/queries
</label>
<textarea class="form-control {{getFieldValidationClasses(comments)}}" [formControl]="comments"
<textarea class="form-control {{getFieldValidationClasses(comments)}}" id="comments" [formControl]="comments"
[attr.aria-invalid]="comments.invalid"></textarea>
</div>
<br>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ <h1 class="color-orange">
Note: <b>Students should not use this form to request for TEAMMATES accounts</b>, as students do not need accounts to use TEAMMATES. Instead, TEAMMATES will email students (who have been added to TEAMMATES by a course instructor) an access link when there is a TEAMMATES session available for them to access.
</p>
<a type="button" class="btn btn-secondary" tmRouterLink="/web/front/home">Back to home page</a>
<button type="button" class="btn btn-primary ms-3" (click)="onDeclarationButtonClicked()">I am an instructor</button>
<button id="btn-am-instructor" type="button" class="btn btn-primary ms-3" (click)="onDeclarationButtonClicked()">I am an instructor</button>
</div>
<div *ngIf="isDeclarationDone">
<tm-instructor-request-form *ngIf="!submittedFormData" (requestSubmissionEvent)="onRequestSubmitted($event)"></tm-instructor-request-form>
Expand Down

0 comments on commit 16f7767

Please sign in to comment.