Skip to content

Commit

Permalink
Fix failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jcbrand committed Jan 7, 2025
1 parent dc5237a commit 576fcc5
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/plugins/chatview/heading.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export default class ChatHeading extends CustomElement {
* @returns {Promise<Array.<import('./types').HeadingButtonAttributes>>}
*/
async getHeadingButtons () {
debugger;
const buttons = [
/** @type {import('./types').HeadingButtonAttributes} */
{
Expand Down
1 change: 0 additions & 1 deletion src/plugins/chatview/templates/chat-head.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export default (el) => {

const i18n_profile = __("The User's Profile Image");
const display_name = el.model.getDisplayName();
debugger;
const avatar = html`<span title="${i18n_profile}">
<converse-avatar
.model=${el.model.contact || el.model}
Expand Down
1 change: 1 addition & 0 deletions src/plugins/chatview/tests/chatbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ describe("Chatboxes", function () {
mock.initConverse(['chatBoxesFetched'], {}, async function (_converse) {

await mock.waitForRoster(_converse, 'current');
await mock.waitUntilBlocklistInitialized(_converse);
await mock.openControlBox(_converse);
const contact_jid = mock.cur_names[7].replace(/ /g,'.').toLowerCase() + '@montague.lit';
const rosterview = document.querySelector('converse-roster');
Expand Down
3 changes: 3 additions & 0 deletions src/plugins/minimize/tests/minchats.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ describe("A chat message", function () {
mock.initConverse(['chatBoxesFetched'], {'view_mode': 'overlayed'}, async function (_converse) {

await mock.waitForRoster(_converse, 'current');
await mock.waitUntilBlocklistInitialized(_converse);
const contact_name = mock.cur_names[0];
const contact_jid = contact_name.replace(/ /g,'.').toLowerCase() + '@montague.lit';
await mock.openControlBox(_converse);
Expand Down Expand Up @@ -92,6 +93,7 @@ describe("A Chatbox", function () {
mock.initConverse(['chatBoxesFetched'], {}, async function (_converse) {

await mock.waitForRoster(_converse, 'current');
await mock.waitUntilBlocklistInitialized(_converse);
await mock.openControlBox(_converse);

const contact_jid = mock.cur_names[7].replace(/ /g,'.').toLowerCase() + '@montague.lit';
Expand Down Expand Up @@ -214,6 +216,7 @@ describe("The Minimized Chats Widget", function () {
it("shows chats that have been minimized",
mock.initConverse([], {}, async function (_converse) {

await mock.waitUntilBlocklistInitialized(_converse);
await mock.waitForRoster(_converse, 'current');
await mock.openControlBox(_converse);
const minimized_chats = await u.waitUntil(() => document.querySelector("converse-minimized-chats"));
Expand Down
1 change: 1 addition & 0 deletions src/plugins/omemo/tests/omemo.js
Original file line number Diff line number Diff line change
Expand Up @@ -1109,6 +1109,7 @@ describe("The OMEMO module", function() {
it("shows OMEMO device fingerprints in the user details modal",
mock.initConverse(['chatBoxesFetched'], {}, async function (_converse) {

await mock.waitUntilBlocklistInitialized(_converse);
await mock.waitForRoster(_converse, 'current', 1);
await mock.waitUntilDiscoConfirmed(
_converse, _converse.bare_jid,
Expand Down
28 changes: 28 additions & 0 deletions src/shared/tests/mock.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,33 @@ function closeControlBox () {
u.isVisible(view) && view.querySelector(".controlbox-heading__btn.close")?.click();
}

async function waitUntilBlocklistInitialized (_converse, blocklist=[]) {
window.sessionStorage.removeItem('converse.blocklist-romeo@montague.lit-fetched');

const { api } = _converse;
await mock.waitUntilDiscoConfirmed(
_converse,
_converse.domain,
[{ 'category': 'server', 'type': 'IM' }],
['urn:xmpp:blocking']
);
const connection = api.connection.get();
const IQ_stanzas = connection.IQ_stanzas;
const sent_stanza = await u.waitUntil(() => IQ_stanzas.find((s) => s.querySelector('iq blocklist')));

connection._dataRecv(mock.createRequest(stx`
<iq xmlns="jabber:client"
to="${connection.jid}"
type="result"
id="${sent_stanza.getAttribute('id')}">
<blocklist xmlns='urn:xmpp:blocking'>
${blocklist.map((jid) => stx`<item jid='${jid}'/>`)}
</blocklist>
</iq>`));

return await api.waitUntil('blocklistInitialized');
}

async function waitUntilBookmarksReturned (
_converse,
bookmarks=[],
Expand Down Expand Up @@ -865,6 +892,7 @@ Object.assign(mock, {
view_mode,
waitForReservedNick,
waitForRoster,
waitUntilBlocklistInitialized,
waitUntilBookmarksReturned,
waitUntilDiscoConfirmed
});
Expand Down

0 comments on commit 576fcc5

Please sign in to comment.