2022-01-20 03:50:59 +08:00
const { MultiUsers } = require ( "../user/multiusers" ) ;
const util = require ( './util' ) ;
const e = require ( '../core/elements' ) ;
2022-08-27 08:53:06 +08:00
const { openSettings } = require ( '../options/util' ) ;
2022-03-01 03:46:13 +08:00
const { sleep } = require ( "../core/helpers" ) ;
2022-01-20 03:50:59 +08:00
class ChatNotifications extends MultiUsers {
constructor ( browser , context ) {
super ( browser , context ) ;
}
async publicChatNotification ( ) {
await openSettings ( this . modPage ) ;
await util . enableChatPopup ( this . modPage ) ;
await util . saveSettings ( this . modPage ) ;
2022-03-01 03:46:13 +08:00
await util . waitAndClearNotification ( this . modPage ) ;
await sleep ( 1000 ) ;
2022-01-20 03:50:59 +08:00
await util . publicChatMessageToast ( this . modPage , this . userPage ) ;
await this . modPage . waitAndClick ( e . chatTitle ) ;
2024-07-31 06:49:02 +08:00
await this . modPage . hasElement ( e . smallToastMsg , 'should appear the new toast message notification' ) ;
await this . modPage . hasElement ( e . hasUnreadMessages , 'should appear the unread messages notification on the public chat button' ) ;
2022-01-20 03:50:59 +08:00
await util . checkNotificationText ( this . modPage , e . publicChatToast ) ;
}
async privateChatNotification ( ) {
await openSettings ( this . modPage ) ;
await util . enableChatPopup ( this . modPage ) ;
await util . saveSettings ( this . modPage ) ;
await util . waitAndClearNotification ( this . modPage ) ;
2022-03-01 03:46:13 +08:00
await sleep ( 2000 ) ;
2022-01-20 03:50:59 +08:00
await util . privateChatMessageToast ( this . userPage ) ;
2024-07-31 06:49:02 +08:00
await this . modPage . hasElement ( e . smallToastMsg , 'should the small toast message with the new text sent on the private chat' ) ;
await this . modPage . hasElement ( e . hasUnreadMessages , 'should the notifcation on the public chat button appear with a number of messages sent and not read' ) ;
2022-01-20 03:50:59 +08:00
await util . checkNotificationText ( this . modPage , e . privateChatToast ) ;
}
}
exports . ChatNotifications = ChatNotifications ;