Commit f34cc63d authored by JC Brand's avatar JC Brand

Log out before running test

To avoid one test which times out, causing subsequent tests to not be
run (and therefore also time out).
parent 831e59c1
......@@ -57,8 +57,13 @@
async function (done, _converse) {
spyOn(Strophe.Connection.prototype, 'connect');
await u.waitUntil(() => _.get(_converse.chatboxviews.get('controlbox'), 'registerpanel'));
const toggle = document.querySelector(".toggle-controlbox");
toggle.click();
const cbview = _converse.api.controlbox.get();
await u.waitUntil(() => u.isVisible(cbview.el));
const registerview = cbview.registerpanel;
spyOn(registerview, 'onProviderChosen').and.callThrough();
registerview.delegateEvents(); // We need to rebind all events otherwise our spy won't be called
......@@ -191,13 +196,14 @@
registerview.el.querySelector('input[name=email]').value = 'test@email.local';
spyOn(_converse.connection, 'send');
registerview.el.querySelector('input[type=submit]').click();
expect(_converse.connection.send).toHaveBeenCalled();
stanza = _converse.connection.send.calls.argsFor(0)[0].tree();
expect(stanza.querySelector('query').childNodes.length).toBe(3);
expect(stanza.querySelector('query').firstElementChild.tagName).toBe('username');
delete _converse.connection;
done();
}));
......@@ -276,6 +282,8 @@
'</query>'+
'</iq>'
);
delete _converse.connection;
done();
}));
......
......@@ -46,20 +46,22 @@
await test_utils.waitForRoster(_converse, 'current', 1);
IQ_stanzas.pop();
const disco_iq = IQ_stanzas.pop();
expect(Strophe.serialize(disco_iq)).toBe(
const expected_IQs = disco_iq => ([
`<iq from="romeo@montague.lit" id="${disco_iq.getAttribute('id')}" to="romeo@montague.lit" type="get" xmlns="jabber:client">`+
`<pubsub xmlns="http://jabber.org/protocol/pubsub"><items node="eu.siacs.conversations.axolotl.devicelist"/></pubsub></iq>`);
`<pubsub xmlns="http://jabber.org/protocol/pubsub"><items node="eu.siacs.conversations.axolotl.devicelist"/></pubsub></iq>`,
iq = IQ_stanzas.pop();
expect(Strophe.serialize(iq)).toBe(
`<iq from="romeo@montague.lit/orchard" id="${iq.getAttribute('id')}" to="romeo@montague.lit" type="get" xmlns="jabber:client">`+
`<query xmlns="http://jabber.org/protocol/disco#info"/></iq>`);
`<query xmlns="http://jabber.org/protocol/disco#info"/></iq>`,
iq = IQ_stanzas.pop();
expect(Strophe.serialize(iq)).toBe(
`<iq from="romeo@montague.lit/orchard" id="${iq.getAttribute('id')}" to="montague.lit" type="get" xmlns="jabber:client">`+
`<query xmlns="http://jabber.org/protocol/disco#info"/></iq>`);
`<query xmlns="http://jabber.org/protocol/disco#info"/></iq>`]);
const disco_iq = IQ_stanzas.pop();
expect(expected_IQs(disco_iq).includes(Strophe.serialize(disco_iq))).toBe(true);
iq = IQ_stanzas.pop();
expect(expected_IQs(disco_iq).includes(Strophe.serialize(disco_iq))).toBe(true);
iq = IQ_stanzas.pop();
expect(expected_IQs(disco_iq).includes(Strophe.serialize(disco_iq))).toBe(true);
expect(sent_stanzas.filter(s => (s.nodeName === 'r')).length).toBe(2);
expect(_converse.session.get('unacked_stanzas').length).toBe(5);
......
......@@ -319,25 +319,23 @@
}
return async done => {
const _converse = await initConverse(settings);
async function _done () {
if (_converse.api.connection.connected()) {
await _converse.api.user.logout();
}
const el = document.querySelector('#conversejs');
if (el) {
el.parentElement.removeChild(el);
}
document.title = "Converse Tests";
done();
if (_converse && _converse.api.connection.connected()) {
await _converse.api.user.logout();
}
const el = document.querySelector('#conversejs');
if (el) {
el.parentElement.removeChild(el);
}
document.title = "Converse Tests";
await initConverse(settings);
await Promise.all((promise_names || []).map(_converse.api.waitUntil));
try {
await func(_done, _converse);
await func(done, _converse);
} catch(e) {
console.error(e);
fail(e);
await _done();
await done();
}
}
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment