2016-04-28 16:52:27 +02:00
|
|
|
(function (root, factory) {
|
|
|
|
define([
|
2017-07-11 10:41:11 +02:00
|
|
|
"jquery.noconflict",
|
2017-02-24 16:11:57 +01:00
|
|
|
"converse-core",
|
2016-04-28 16:52:27 +02:00
|
|
|
"mock",
|
|
|
|
"test_utils",
|
|
|
|
"utils",
|
|
|
|
"transcripts"
|
|
|
|
], factory
|
|
|
|
);
|
2017-07-11 10:41:11 +02:00
|
|
|
} (this, function ($, converse, mock, test_utils, utils, transcripts) {
|
2016-12-20 10:30:20 +01:00
|
|
|
var Strophe = converse.env.Strophe;
|
|
|
|
var _ = converse.env._;
|
2016-04-28 16:52:27 +02:00
|
|
|
var IGNORED_TAGS = [
|
|
|
|
'stream:features',
|
|
|
|
'auth',
|
|
|
|
'challenge',
|
|
|
|
'success',
|
|
|
|
'stream:features',
|
|
|
|
'response'
|
|
|
|
];
|
|
|
|
|
|
|
|
function traverseElement (el, _stanza) {
|
|
|
|
if (typeof _stanza !== 'undefined') {
|
|
|
|
if (el.nodeType === 3) {
|
|
|
|
_stanza.t(el.nodeValue);
|
|
|
|
return _stanza;
|
|
|
|
} else {
|
|
|
|
_stanza = _stanza.c(el.nodeName.toLowerCase(), getAttributes(el));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
_stanza = new Strophe.Builder(
|
|
|
|
el.nodeName.toLowerCase(),
|
|
|
|
getAttributes(el)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
_.each(el.childNodes, _.partial(traverseElement, _, _stanza));
|
|
|
|
return _stanza.up();
|
|
|
|
}
|
|
|
|
|
|
|
|
function getAttributes (el) {
|
|
|
|
var attributes = {};
|
|
|
|
_.each(el.attributes, function (att) {
|
|
|
|
attributes[att.nodeName] = att.nodeValue;
|
|
|
|
});
|
|
|
|
return attributes;
|
|
|
|
}
|
|
|
|
|
|
|
|
return describe("Transcripts of chat logs", function () {
|
2017-02-24 16:11:57 +01:00
|
|
|
|
|
|
|
it("can be used to replay conversations", mock.initConverse(function (_converse) {
|
|
|
|
/*
|
2017-02-28 05:49:01 +01:00
|
|
|
test_utils.openAndEnterChatRoom(_converse, "dummy", 'rooms.localhost', 'jc');
|
|
|
|
test_utils.openAndEnterChatRoom(_converse, "prosody", 'conference.prosody.im', 'jc');
|
2017-02-24 16:11:57 +01:00
|
|
|
*/
|
2017-02-28 05:49:01 +01:00
|
|
|
test_utils.openAndEnterChatRoom(_converse, "discuss", 'conference.conversejs.org', 'jc');
|
2016-12-20 10:30:20 +01:00
|
|
|
spyOn(_converse, 'areDesktopNotificationsEnabled').andReturn(true);
|
2016-04-28 16:52:27 +02:00
|
|
|
_.each(transcripts, function (transcript) {
|
|
|
|
var text = transcript();
|
|
|
|
var xml = Strophe.xmlHtmlNode(text);
|
|
|
|
$(xml).children('log').children('body').each(function (i, el) {
|
|
|
|
$(el).children().each(function (i, el) {
|
|
|
|
if (el.nodeType === 3) {
|
|
|
|
return; // Ignore text
|
|
|
|
}
|
2017-01-26 15:49:02 +01:00
|
|
|
if (_.includes(IGNORED_TAGS, el.nodeName.toLowerCase())) {
|
2016-04-28 16:52:27 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
var _stanza = traverseElement(el);
|
2016-12-20 10:30:20 +01:00
|
|
|
_converse.connection._dataRecv(test_utils.createRequest(_stanza));
|
2016-04-28 16:52:27 +02:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2017-02-24 16:11:57 +01:00
|
|
|
}));
|
2016-04-28 16:52:27 +02:00
|
|
|
});
|
|
|
|
}));
|