2020-02-12 07:31:25 +01:00
|
|
|
zrequire('rows');
|
2018-07-16 20:50:57 +02:00
|
|
|
zrequire('lightbox');
|
|
|
|
|
2020-02-10 23:21:06 +01:00
|
|
|
set_global('message_store', {});
|
2018-07-16 20:50:57 +02:00
|
|
|
set_global('Image', class Image {});
|
|
|
|
set_global('overlays', {
|
|
|
|
close_overlay: () => {},
|
|
|
|
close_active: () => {},
|
|
|
|
open_overlay: () => {},
|
|
|
|
});
|
|
|
|
set_global('popovers', {
|
|
|
|
hide_all: () => {},
|
|
|
|
});
|
2019-05-21 17:36:39 +02:00
|
|
|
|
2020-04-02 15:13:23 +02:00
|
|
|
rows.is_draft_row = () => false;
|
|
|
|
|
2019-05-21 17:36:39 +02:00
|
|
|
set_global('$', global.make_zjquery());
|
2018-07-16 20:50:57 +02:00
|
|
|
|
|
|
|
run_test('pan_and_zoom', () => {
|
2019-05-21 17:36:39 +02:00
|
|
|
$.clear_all_elements();
|
|
|
|
|
2020-02-10 23:21:06 +01:00
|
|
|
const img = $.create('img-stub');
|
|
|
|
const link = $.create('link-stub');
|
|
|
|
const msg = $.create('msg-stub');
|
|
|
|
|
|
|
|
$(img).closest = () => [];
|
2020-02-10 17:59:40 +01:00
|
|
|
|
2020-02-10 23:21:06 +01:00
|
|
|
img.set_parent(link);
|
|
|
|
link.closest = () => msg;
|
2020-02-10 17:59:40 +01:00
|
|
|
msg.attr("zid", "1234");
|
2020-04-02 15:07:30 +02:00
|
|
|
img.attr("src", "example");
|
2020-02-10 23:21:06 +01:00
|
|
|
|
|
|
|
let fetched_zid;
|
|
|
|
|
|
|
|
message_store.get = (zid) => {
|
|
|
|
fetched_zid = zid;
|
|
|
|
return 'message-stub';
|
|
|
|
};
|
2019-05-21 17:36:39 +02:00
|
|
|
|
|
|
|
// Used by render_lightbox_list_images
|
|
|
|
$.stub_selector('.focused_table .message_inline_image img', []);
|
|
|
|
|
|
|
|
lightbox.open(img);
|
2020-02-10 23:21:06 +01:00
|
|
|
|
|
|
|
assert.equal(fetched_zid, 1234);
|
2018-07-16 20:50:57 +02:00
|
|
|
});
|
2019-05-21 17:36:39 +02:00
|
|
|
|
2020-02-10 23:21:06 +01:00
|
|
|
run_test('youtube', () => {
|
2019-05-21 17:36:39 +02:00
|
|
|
$.clear_all_elements();
|
|
|
|
|
2020-02-10 23:21:06 +01:00
|
|
|
const href = 'https://youtube.com/some-random-clip';
|
|
|
|
const img = $.create('img-stub');
|
|
|
|
const link = $.create('link-stub');
|
|
|
|
const msg = $.create('msg-stub');
|
|
|
|
|
2020-02-21 17:29:23 +01:00
|
|
|
msg.attr("zid", "4321");
|
|
|
|
|
2020-02-10 23:21:06 +01:00
|
|
|
$(img).attr('src', href);
|
|
|
|
|
|
|
|
$(img).closest = (sel) => {
|
|
|
|
if (sel === '.youtube-video') {
|
|
|
|
// We just need a nonempty array to
|
|
|
|
// set is_youtube_video to true.
|
|
|
|
return ['whatever'];
|
|
|
|
}
|
|
|
|
return [];
|
|
|
|
};
|
|
|
|
|
|
|
|
img.set_parent(link);
|
|
|
|
link.closest = () => msg;
|
|
|
|
link.attr('href', href);
|
2019-05-21 17:36:39 +02:00
|
|
|
|
|
|
|
// Used by render_lightbox_list_images
|
|
|
|
$.stub_selector('.focused_table .message_inline_image img', []);
|
|
|
|
|
|
|
|
lightbox.open(img);
|
2020-02-10 23:21:06 +01:00
|
|
|
assert.equal($('.image-actions .open').attr('href'), href);
|
2019-05-21 17:36:39 +02:00
|
|
|
});
|