Skip to content

Commit

Permalink
[#11947] Format error toasts (#12509)
Browse files Browse the repository at this point in the history
* fix: format error toasts

* fix: css for line breaks

* fix: change formatting for certain toast messages

* fix: lint errors

* fix: add wait time

* fix: close toast after verification

* fix: lint errors

* fix: formatted status message

* fix: add whitespace to status message

* fix: remove extra inverted commas

---------

Co-authored-by: Jason Qiu <jason_qiu@hotmail.com>
  • Loading branch information
domoberzin and jasonqiu212 committed Jul 13, 2023
1 parent 930c2b1 commit 09106ad
Show file tree
Hide file tree
Showing 11 changed files with 25 additions and 18 deletions.
1 change: 0 additions & 1 deletion src/e2e/java/teammates/e2e/cases/BaseE2ETestCase.java
Original file line number Diff line number Diff line change
Expand Up @@ -363,5 +363,4 @@ protected boolean doPutDocuments(DataBundle testData) {
return false;
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ public void testAll() {
.build();

editPage.addInstructor(newInstructor);
editPage.verifyStatusMessage("\"The instructor " + newInstructor.getName() + " has been added successfully. "
editPage.verifyStatusMessage("The instructor " + newInstructor.getName() + " has been added successfully. "
+ "An email containing how to 'join' this course will be sent to " + newInstructor.getEmail()
+ " in a few minutes.\"");
+ " in a few minutes.");
editPage.verifyInstructorDetails(newInstructor);
verifyPresentInDatabase(newInstructor);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,9 @@ public void testAll() {

homePage.verifyStatusMessage("Reminder e-mails have been sent out to those students"
+ " and instructors. Please allow up to 1 hour for all the notification emails to be sent out.");

verifyEmailSent(studentToEmail.getEmail(), "TEAMMATES: Feedback session reminder"
+ " [Course: " + course.getName() + "][Feedback Session: "
+ feedbackSessionOpen.getFeedbackSessionName() + "]");

______TS("resend results link");
homePage.resendResultsLink(courseIndex, sessionIndex, studentToEmail);

Expand Down
9 changes: 9 additions & 0 deletions src/e2e/java/teammates/e2e/pageobjects/AppPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,7 @@ void scrollElementToCenter(WebElement element) {
*/
public void verifyStatusMessage(String expectedMessage) {
verifyStatusMessageWithLinks(expectedMessage, new String[] {});
closeToast();
}

/**
Expand Down Expand Up @@ -667,6 +668,14 @@ public void run() {
}
}

/**
* Closes toast message.
*/
public void closeToast() {
WebElement toastCloseButton = waitForElementPresence(By.className("btn-close"));
click(toastCloseButton);
}

/**
* Switches to the new browser window just opened.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public JsonResult execute() throws InvalidHttpRequestBodyException {
FeedbackQuestionDetails questionDetails = attributes.getQuestionDetailsCopy();
List<String> questionDetailsErrors = questionDetails.validateQuestionDetails();
if (!questionDetailsErrors.isEmpty()) {
throw new InvalidHttpRequestBodyException(questionDetailsErrors.toString());
throw new InvalidHttpRequestBodyException(String.join("\n", questionDetailsErrors));
}

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ public JsonResult execute() throws InvalidHttpRequestBodyException, InvalidOpera
.validateResponsesDetails(responseDetails, numRecipients);

if (!questionSpecificErrors.isEmpty()) {
throw new InvalidHttpRequestBodyException(questionSpecificErrors.toString());
throw new InvalidHttpRequestBodyException(String.join("\n", questionSpecificErrors));
}

List<String> recipients = submitRequest.getRecipients();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public JsonResult execute() throws InvalidHttpRequestBodyException {
List<String> questionDetailsErrors = questionDetails.validateQuestionDetails();

if (!questionDetailsErrors.isEmpty()) {
throw new InvalidHttpRequestBodyException(questionDetailsErrors.toString());
throw new InvalidHttpRequestBodyException(String.join("\n", questionDetailsErrors));
}

try {
Expand Down
1 change: 1 addition & 0 deletions src/web/app/components/toast/toast.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
.toast {
max-width: 100%;
width: inherit;
white-space: break-spaces;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -499,8 +499,8 @@ export class InstructorCourseEditPageComponent implements OnInit {
newDetailPanels.originalPanel = JSON.parse(JSON.stringify(newDetailPanels.editPanel));

this.instructorDetailPanels.push(newDetailPanels);
this.statusMessageService.showSuccessToast(`"The instructor ${resp.name} has been added successfully.
An email containing how to 'join' this course will be sent to ${resp.email} in a few minutes."`);
this.statusMessageService.showSuccessToast(`The instructor ${resp.name} has been added successfully. `
+ `An email containing how to 'join' this course will be sent to ${resp.email} in a few minutes.`);

this.updatePrivilegeForInstructor(newDetailPanels.originalInstructor, newDetailPanels.editPanel.permission);

Expand Down Expand Up @@ -779,8 +779,8 @@ export class InstructorCourseEditPageComponent implements OnInit {
this.statusMessageService.showErrorToast(err.error.message);
},
complete: () => {
this.statusMessageService.showSuccessToast(`The selected instructor(s) have been added successfully.
An email containing how to 'join' this course will be sent to them in a few minutes.`);
this.statusMessageService.showSuccessToast('The selected instructor(s) have been added successfully. '
+ 'An email containing how to \'join\' this course will be sent to them in a few minutes.');
},
});
}
Expand All @@ -801,8 +801,8 @@ export class InstructorCourseEditPageComponent implements OnInit {
const emailSet: Set<string> = new Set();
for (const instructor of allInstructorsAfterCopy) {
if (emailSet.has(instructor.email)) {
this.statusMessageService.showErrorToast(`An instructor with email address ${instructor.email}
already exists in the course and/or you have selected more than one instructor with this email address.`);
this.statusMessageService.showErrorToast(`An instructor with email address ${instructor.email} already `
+ 'exists in the course and/or you have selected more than one instructor with this email address.');
return false;
}
emailSet.add(instructor.email);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,8 @@ export class InstructorCoursesPageComponent implements OnInit {
next: (courseArchive: CourseArchive) => {
if (courseArchive.isArchived) {
this.changeModelFromActiveToArchived(courseId);
this.statusMessageService.showSuccessToast(`The course ${courseId} has been archived.
It will not appear on the home page anymore.`);
this.statusMessageService.showSuccessToast(`The course ${courseId} has been archived. `
+ 'It will not appear on the home page anymore.');
} else {
this.changeModelFromArchivedToActive(courseId);
this.statusMessageService.showSuccessToast('The course has been unarchived.');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,8 @@ export class InstructorHomePageComponent extends InstructorSessionModalPageCompo
this.courseTabModels = this.courseTabModels.filter((model: CourseTabModel) => {
return model.course.courseId !== courseId;
});
this.statusMessageService.showSuccessToast(`The course ${courseArchive.courseId} has been archived.
You can retrieve it from the Courses page.`);
this.statusMessageService.showSuccessToast(`The course ${courseArchive.courseId} has been archived. `
+ 'You can retrieve it from the Courses page.');
},
error: (resp: ErrorMessageOutput) => {
this.statusMessageService.showErrorToast(resp.error.message);
Expand Down

0 comments on commit 09106ad

Please sign in to comment.