2018-07-16 20:50:57 +02:00
|
|
|
zrequire('lightbox');
|
|
|
|
|
|
|
|
set_global('blueslip', global.make_zblueslip());
|
|
|
|
set_global('message_store', {
|
|
|
|
get: () => ({}),
|
|
|
|
});
|
|
|
|
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
|
|
|
|
|
|
|
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();
|
|
|
|
|
2019-11-02 00:06:25 +01:00
|
|
|
const img = '<img src="./image.png" data-src-fullsize="./original.png">';
|
|
|
|
const link = '<a href="https://zulip.com"></a>';
|
|
|
|
const msg = '<div [zid]></div>';
|
2019-05-21 17:36:39 +02:00
|
|
|
$(img).set_parent($(link));
|
|
|
|
$(link).set_parent($(msg));
|
|
|
|
|
|
|
|
// Used by render_lightbox_list_images
|
|
|
|
$.stub_selector('.focused_table .message_inline_image img', []);
|
|
|
|
|
|
|
|
lightbox.open(img);
|
2018-07-16 20:50:57 +02:00
|
|
|
assert.equal(blueslip.get_test_logs('error').length, 0);
|
|
|
|
lightbox.open('<img src="./image.png">');
|
|
|
|
assert.equal(blueslip.get_test_logs('error').length, 0);
|
|
|
|
});
|
2019-05-21 17:36:39 +02:00
|
|
|
|
|
|
|
run_test('open_url', () => {
|
|
|
|
$.clear_all_elements();
|
|
|
|
|
2019-11-02 00:06:25 +01:00
|
|
|
const url = 'https://youtube.com/1234';
|
|
|
|
const img = '<img></img>';
|
2019-05-21 17:36:39 +02:00
|
|
|
$(img).attr('src', "https://youtube.com/image.png");
|
2019-11-02 00:06:25 +01:00
|
|
|
const link = '<a></a>';
|
2019-05-21 17:36:39 +02:00
|
|
|
$(link).attr('href', url);
|
2019-11-02 00:06:25 +01:00
|
|
|
const div = '<div class="youtube-video"></div>';
|
|
|
|
const msg = '<div [zid]></div>';
|
2019-05-21 17:36:39 +02:00
|
|
|
$(img).set_parent($(link));
|
|
|
|
$(link).set_parent($(div));
|
|
|
|
$(div).set_parent($(msg));
|
|
|
|
|
|
|
|
// Used by render_lightbox_list_images
|
|
|
|
$.stub_selector('.focused_table .message_inline_image img', []);
|
|
|
|
|
|
|
|
lightbox.open(img);
|
|
|
|
assert.equal($('.image-actions .open').attr('href'), url);
|
|
|
|
assert.equal(blueslip.get_test_logs('error').length, 0);
|
|
|
|
});
|