/*global mock, converse */ const { dayjs } = converse.env; const u = converse.env.utils; // See: https://xmpp.org/rfcs/rfc3921.html describe("MUC Mention Notfications", function () { it("may be received from a MUC in which the user is not currently present", mock.initConverse([], { 'allow_bookmarks': false, // Hack to get the rooms list to render 'muc_subscribe_to_rai': true, 'view_mode': 'fullscreen'}, async function (done, _converse) { const { api } = _converse; expect(_converse.session.get('rai_enabled_domains')).toBe(undefined); const muc_jid = 'lounge@montague.lit'; const nick = 'romeo'; const muc_creation_promise = await api.rooms.open(muc_jid, {nick, 'hidden': true}, false); await mock.getRoomFeatures(_converse, muc_jid, []); await mock.receiveOwnMUCPresence(_converse, muc_jid, nick); await muc_creation_promise; const model = _converse.chatboxes.get(muc_jid); await u.waitUntil(() => (model.session.get('connection_status') === converse.ROOMSTATUS.ENTERED)); expect(model.get('hidden')).toBe(true); await u.waitUntil(() => model.session.get('connection_status') === converse.ROOMSTATUS.DISCONNECTED); const room_el = await u.waitUntil(() => document.querySelector("converse-rooms-list .available-chatroom")); expect(Array.from(room_el.classList).includes('unread-msgs')).toBeFalsy(); const base_time = new Date(); let message = u.toStanza(` Romeo, wherefore art though Romeo `); _converse.connection._dataRecv(mock.createRequest(message)); expect(Array.from(room_el.classList).includes('unread-msgs')).toBeTruthy(); expect(room_el.querySelector('.msgs-indicator')?.textContent.trim()).toBe('1'); message = u.toStanza(` Romeo, wherefore art though Romeo `); _converse.connection._dataRecv(mock.createRequest(message)); expect(Array.from(room_el.classList).includes('unread-msgs')).toBeTruthy(); expect(room_el.querySelector('.msgs-indicator')?.textContent.trim()).toBe('2'); done(); })); });