From 16f776768a3b4a6e24c2b0673993e4fce1afb8a3 Mon Sep 17 00:00:00 2001 From: DS Date: Tue, 16 Apr 2024 12:55:41 +0800 Subject: [PATCH] [#11878] Request Page E2E (#13015) * Add E2E skeleton * Fix test and lint * Add verifyEmailSent * fix fe tests --- .../e2e/cases/sql/RequestPageE2ETest.java | 52 ++++++++++++++ .../e2e/pageobjects/RequestPage.java | 71 +++++++++++++++++++ src/e2e/resources/testng-e2e-sql.xml | 1 + .../java/teammates/common/util/Const.java | 2 + .../request-page.component.spec.ts.snap | 1 + ...ructor-request-form.component.spec.ts.snap | 1 + .../instructor-request-form.component.html | 2 +- .../request-page/request-page.component.html | 2 +- 8 files changed, 130 insertions(+), 2 deletions(-) create mode 100644 src/e2e/java/teammates/e2e/cases/sql/RequestPageE2ETest.java create mode 100644 src/e2e/java/teammates/e2e/pageobjects/RequestPage.java diff --git a/src/e2e/java/teammates/e2e/cases/sql/RequestPageE2ETest.java b/src/e2e/java/teammates/e2e/cases/sql/RequestPageE2ETest.java new file mode 100644 index 00000000000..4cb678a053f --- /dev/null +++ b/src/e2e/java/teammates/e2e/cases/sql/RequestPageE2ETest.java @@ -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); + } +} diff --git a/src/e2e/java/teammates/e2e/pageobjects/RequestPage.java b/src/e2e/java/teammates/e2e/pageobjects/RequestPage.java new file mode 100644 index 00000000000..05ef23a56e0 --- /dev/null +++ b/src/e2e/java/teammates/e2e/pageobjects/RequestPage.java @@ -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); + } +} diff --git a/src/e2e/resources/testng-e2e-sql.xml b/src/e2e/resources/testng-e2e-sql.xml index 61cc506ff93..40c38e4bfbf 100644 --- a/src/e2e/resources/testng-e2e-sql.xml +++ b/src/e2e/resources/testng-e2e-sql.xml @@ -15,6 +15,7 @@ + diff --git a/src/main/java/teammates/common/util/Const.java b/src/main/java/teammates/common/util/Const.java index 2152278dd7e..ee741c14c1f 100644 --- a/src/main/java/teammates/common/util/Const.java +++ b/src/main/java/teammates/common/util/Const.java @@ -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"; } /** diff --git a/src/web/app/pages-static/request-page/__snapshots__/request-page.component.spec.ts.snap b/src/web/app/pages-static/request-page/__snapshots__/request-page.component.spec.ts.snap index 3167fed5fd4..ce612779c97 100644 --- a/src/web/app/pages-static/request-page/__snapshots__/request-page.component.spec.ts.snap +++ b/src/web/app/pages-static/request-page/__snapshots__/request-page.component.spec.ts.snap @@ -159,6 +159,7 @@ exports[`RequestPageComponent should render correctly before instructor declarat +