-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…11749) * Add notification banner E2E test * Remove unnecessary new line
- Loading branch information
1 parent
7d4873e
commit 87ae891
Showing
12 changed files
with
225 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
src/e2e/java/teammates/e2e/cases/NotificationBannerE2ETest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package teammates.e2e.cases; | ||
|
||
import java.time.Instant; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import org.testng.annotations.Test; | ||
|
||
import teammates.common.datatransfer.attributes.AccountAttributes; | ||
import teammates.common.datatransfer.attributes.NotificationAttributes; | ||
import teammates.common.util.AppUrl; | ||
import teammates.common.util.Const; | ||
import teammates.e2e.pageobjects.StudentHomePage; | ||
|
||
/** | ||
* SUT: The reusable notification banner, which can be displayed across many pages. | ||
* {@link Const.WebPageURIs#STUDENT_HOME_PAGE} is used to test the behaviour of the banner in this case, | ||
* {@link Const.WebPageURIs#STUDENT_PROFILE_PAGE}, {@link Const.WebPageURIs#STUDENT_NOTIFICATIONS_PAGE} | ||
*/ | ||
public class NotificationBannerE2ETest extends BaseE2ETestCase { | ||
@Override | ||
protected void prepareTestData() { | ||
testData = loadDataBundle("/NotificationBannerE2ETest.json"); | ||
removeAndRestoreDataBundle(testData); | ||
} | ||
|
||
@Test | ||
@Override | ||
protected void testAll() { | ||
AccountAttributes account = testData.accounts.get("NotifBanner.student"); | ||
NotificationAttributes notification = testData.notifications.get("notification1"); | ||
AppUrl studentHomePageUrl = createFrontendUrl(Const.WebPageURIs.STUDENT_HOME_PAGE); | ||
StudentHomePage studentHomePage = loginToPage(studentHomePageUrl, StudentHomePage.class, | ||
account.getGoogleId()); | ||
|
||
______TS("verify active notification with correct information is shown"); | ||
assertTrue(studentHomePage.isBannerVisible()); | ||
studentHomePage.verifyBannerContent(notification); | ||
|
||
______TS("close notification"); | ||
// After user closes a notification banner, it should not appear till user refreshes page | ||
studentHomePage.clickCloseNotificationBannerButton(); | ||
assertFalse(studentHomePage.isBannerVisible()); | ||
studentHomePage.reloadPage(); | ||
assertTrue(studentHomePage.isBannerVisible()); | ||
|
||
______TS("mark notification as read"); | ||
studentHomePage.reloadPage(); | ||
assertTrue(studentHomePage.isBannerVisible()); | ||
|
||
studentHomePage.clickMarkAsReadButton(); | ||
studentHomePage.verifyStatusMessage("Notification marked as read."); | ||
assertFalse(studentHomePage.isBannerVisible()); | ||
|
||
Map<String, Instant> readNotifications = new HashMap<>(); | ||
readNotifications.put(notification.getNotificationId(), notification.getEndTime()); | ||
|
||
account.setReadNotifications(readNotifications); | ||
verifyPresentInDatabase(account); | ||
|
||
______TS("delete test notifications from database"); | ||
for (NotificationAttributes n : testData.notifications.values()) { | ||
BACKDOOR.deleteNotification(n.getNotificationId()); | ||
verifyAbsentInDatabase(n); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
{ | ||
"accounts": { | ||
"NotifBanner.instructor": { | ||
"googleId": "tm.e2e.NotifBanner.instructor", | ||
"name": "Teammates Test Instructor", | ||
"email": "[email protected]", | ||
"readNotifications": {} | ||
}, | ||
"NotifBanner.student": { | ||
"googleId": "tm.e2e.NotifBanner.student", | ||
"name": "Teammates Test Student", | ||
"email": "[email protected]", | ||
"readNotifications": {} | ||
} | ||
}, | ||
"courses": { | ||
"typicalCourse1": { | ||
"id": "tm.e2e.NotifBanner.course1", | ||
"name": "Typical Course 1", | ||
"institute": "TEAMMATES Test Institute 1", | ||
"timeZone": "Africa/Johannesburg" | ||
} | ||
}, | ||
"instructors": { | ||
"teammates.test.CS2104": { | ||
"googleId": "tm.e2e.NotifBanner.instructor", | ||
"courseId": "tm.e2e.NotifBanner.CS2104", | ||
"name": "Teammates Test Instructor", | ||
"email": "[email protected]", | ||
"role": "Co-owner", | ||
"isDisplayedToStudents": true, | ||
"displayedName": "Instructor", | ||
"privileges": { | ||
"courseLevel": { | ||
"canViewStudentInSections": true, | ||
"canSubmitSessionInSections": true, | ||
"canModifySessionCommentsInSections": true, | ||
"canModifyCourse": true, | ||
"canViewSessionInSections": true, | ||
"canModifySession": true, | ||
"canModifyStudent": true, | ||
"canModifyInstructor": true | ||
}, | ||
"sectionLevel": {}, | ||
"sessionLevel": {} | ||
} | ||
} | ||
}, | ||
"students": { | ||
"SNotifications.student": { | ||
"googleId": "tm.e2e.NotifBanner.student", | ||
"email": "[email protected]", | ||
"course": "tm.e2e.NotifBanner.course1", | ||
"name": "Amy Betsy</option></td></div>'\"", | ||
"comments": "This student's name is Amy Betsy</option></td></div>'\"", | ||
"team": "Team 1</td></div>'\"", | ||
"section": "None" | ||
} | ||
}, | ||
"notifications": { | ||
"notification1": { | ||
"notificationId": "notification1", | ||
"startTime": "2011-01-01T00:00:00Z", | ||
"endTime": "2099-01-01T00:00:00Z", | ||
"createdAt": "2011-01-01T00:00:00Z", | ||
"updatedAt": "2011-01-01T00:00:00Z", | ||
"style": "DANGER", | ||
"targetUser": "GENERAL", | ||
"title": "A deprecation note", | ||
"message": "<p>Deprecation happens in three minutes</p>", | ||
"shown": false | ||
}, | ||
"notification2": { | ||
"notificationId": "notification2", | ||
"startTime": "2011-01-01T00:00:00Z", | ||
"endTime": "2099-01-01T00:00:00Z", | ||
"createdAt": "2011-01-01T00:00:00Z", | ||
"updatedAt": "2011-01-01T00:00:00Z", | ||
"style": "INFO", | ||
"targetUser": "STUDENT", | ||
"title": "New Update", | ||
"message": "<p>Information on new update</p>", | ||
"shown": false | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters