Skip to content

Commit d7a113e

Browse files
committed
Fix transcripts code.
1 parent da1f103 commit d7a113e

File tree

3 files changed

+29
-24
lines changed

3 files changed

+29
-24
lines changed

converse-logs/converse-logs.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
define("transcripts", [
2-
"tpl!converse-logs/double_logins",
2+
"tpl!../../converse-logs/missing_messages",
33
], function () {
44
return arguments;
55
});

spec/transcripts.js

+27-22
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
(function (root, factory) {
22
define([
33
"jquery",
4+
"jasmine",
45
"converse-core",
56
"mock",
6-
"test_utils",
7+
"test-utils",
78
"utils",
89
"transcripts"
910
], factory
1011
);
11-
} (this, function ($, converse, mock, test_utils, utils, transcripts) {
12+
} (this, function ($, jasmine, converse, mock, test_utils, utils, transcripts) {
1213
var Strophe = converse.env.Strophe;
1314
var _ = converse.env._;
1415
var IGNORED_TAGS = [
@@ -48,28 +49,32 @@
4849

4950
return describe("Transcripts of chat logs", function () {
5051

51-
it("can be used to replay conversations", mock.initConverse(function (_converse) {
52-
/*
53-
test_utils.openAndEnterChatRoom(_converse, "dummy", 'rooms.localhost', 'jc');
54-
test_utils.openAndEnterChatRoom(_converse, "prosody", 'conference.prosody.im', 'jc');
55-
*/
56-
test_utils.openAndEnterChatRoom(_converse, "discuss", 'conference.conversejs.org', 'jc');
57-
spyOn(_converse, 'areDesktopNotificationsEnabled').andReturn(true);
58-
_.each(transcripts, function (transcript) {
59-
var text = transcript();
60-
var xml = Strophe.xmlHtmlNode(text);
61-
$(xml).children('log').children('body').each(function (i, el) {
62-
$(el).children().each(function (i, el) {
63-
if (el.nodeType === 3) {
64-
return; // Ignore text
65-
}
66-
if (_.includes(IGNORED_TAGS, el.nodeName.toLowerCase())) {
67-
return;
68-
}
69-
var _stanza = traverseElement(el);
70-
_converse.connection._dataRecv(test_utils.createRequest(_stanza));
52+
it("can be used to replay conversations",
53+
mock.initConverseWithPromises(
54+
null, ['rosterGroupsFetched'], {},
55+
function (done, _converse) {
56+
57+
_converse.allow_non_roster_messaging = true;
58+
59+
test_utils.openAndEnterChatRoom(_converse, 'discuss', 'conference.conversejs.org', 'dummy').then(function () {
60+
spyOn(_converse, 'areDesktopNotificationsEnabled').and.returnValue(true);
61+
_.each(transcripts, function (transcript) {
62+
var text = transcript();
63+
var xml = Strophe.xmlHtmlNode(text);
64+
_.each(xml.firstElementChild.children, function (el) {
65+
_.each(el.children, function (el) {
66+
if (el.nodeType === 3) {
67+
return; // Ignore text
68+
}
69+
if (_.includes(IGNORED_TAGS, el.nodeName.toLowerCase())) {
70+
return;
71+
}
72+
var _stanza = traverseElement(el);
73+
_converse.connection._dataRecv(test_utils.createRequest(_stanza));
74+
});
7175
});
7276
});
77+
done();
7378
});
7479
}));
7580
});

tests/runner.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ config.shim.jasmine = {
3030
require.config(config);
3131

3232
var specs = [
33-
//"spec/transcripts",
3433
"jasmine",
34+
//"spec/transcripts",
3535
"spec/profiling",
3636
"spec/utils",
3737
"spec/converse",

0 commit comments

Comments
 (0)