2020-11-23 18:21:51 +00:00
|
|
|
describe('urls', function () {
|
|
|
|
// create a new pad before each test run
|
|
|
|
beforeEach(function (cb) {
|
2012-10-06 19:45:46 +00:00
|
|
|
helper.newPad(cb);
|
2012-11-01 23:19:59 +00:00
|
|
|
this.timeout(60000);
|
2012-10-03 20:55:23 +00:00
|
|
|
});
|
|
|
|
|
2020-11-23 18:21:51 +00:00
|
|
|
it('when you enter an url, it becomes clickable', function (done) {
|
|
|
|
const inner$ = helper.padInner$;
|
|
|
|
const chrome$ = helper.padChrome$;
|
2019-04-15 22:54:54 +00:00
|
|
|
|
2020-11-23 18:21:51 +00:00
|
|
|
// get the first text element out of the inner iframe
|
|
|
|
const firstTextElement = inner$('div').first();
|
2019-04-15 22:54:54 +00:00
|
|
|
|
2012-10-03 20:55:23 +00:00
|
|
|
// simulate key presses to delete content
|
|
|
|
firstTextElement.sendkeys('{selectall}'); // select all
|
|
|
|
firstTextElement.sendkeys('{del}'); // clear the first line
|
2019-04-15 22:54:54 +00:00
|
|
|
firstTextElement.sendkeys('https://etherpad.org'); // insert a URL
|
2013-12-05 07:41:29 +00:00
|
|
|
|
2020-11-23 18:21:51 +00:00
|
|
|
helper.waitFor(() => inner$('div').first().find('a').length === 1, 2000).done(done);
|
2012-10-03 20:55:23 +00:00
|
|
|
});
|
2012-11-21 17:52:10 +00:00
|
|
|
|
2020-11-23 18:21:51 +00:00
|
|
|
it('when you enter a url containing a !, it becomes clickable and contains the whole URL', function (done) {
|
|
|
|
const inner$ = helper.padInner$;
|
|
|
|
const chrome$ = helper.padChrome$;
|
2012-11-21 17:52:10 +00:00
|
|
|
|
2020-11-23 18:21:51 +00:00
|
|
|
// get the first text element out of the inner iframe
|
|
|
|
const firstTextElement = inner$('div').first();
|
|
|
|
const url = 'https://etherpad.org/!foo';
|
2012-11-21 17:52:10 +00:00
|
|
|
|
|
|
|
// simulate key presses to delete content
|
|
|
|
firstTextElement.sendkeys('{selectall}'); // select all
|
|
|
|
firstTextElement.sendkeys('{del}'); // clear the first line
|
|
|
|
firstTextElement.sendkeys(url); // insert a URL
|
|
|
|
|
2020-11-23 18:21:51 +00:00
|
|
|
helper.waitFor(() => {
|
|
|
|
if (inner$('div').first().find('a').length === 1) { // if it contains an A link
|
|
|
|
if (inner$('div').first().find('a')[0].href === url) {
|
2012-11-21 17:52:10 +00:00
|
|
|
return true;
|
|
|
|
}
|
2020-11-23 18:21:51 +00:00
|
|
|
}
|
2012-11-21 17:52:10 +00:00
|
|
|
}, 2000).done(done);
|
|
|
|
});
|
|
|
|
|
2020-11-23 18:21:51 +00:00
|
|
|
it('when you enter a url followed by a ], the ] is not included in the URL', function (done) {
|
|
|
|
const inner$ = helper.padInner$;
|
|
|
|
const chrome$ = helper.padChrome$;
|
2016-06-27 20:20:12 +00:00
|
|
|
|
2020-11-23 18:21:51 +00:00
|
|
|
// get the first text element out of the inner iframe
|
|
|
|
const firstTextElement = inner$('div').first();
|
|
|
|
const url = 'https://etherpad.org/';
|
2016-06-27 20:20:12 +00:00
|
|
|
|
|
|
|
// simulate key presses to delete content
|
|
|
|
firstTextElement.sendkeys('{selectall}'); // select all
|
|
|
|
firstTextElement.sendkeys('{del}'); // clear the first line
|
|
|
|
firstTextElement.sendkeys(url); // insert a URL
|
|
|
|
firstTextElement.sendkeys(']'); // put a ] after it
|
|
|
|
|
2020-11-23 18:21:51 +00:00
|
|
|
helper.waitFor(() => {
|
|
|
|
if (inner$('div').first().find('a').length === 1) { // if it contains an A link
|
|
|
|
if (inner$('div').first().find('a')[0].href === url) {
|
2016-06-27 20:20:12 +00:00
|
|
|
return true;
|
|
|
|
}
|
2020-11-23 18:21:51 +00:00
|
|
|
}
|
2016-06-27 20:20:12 +00:00
|
|
|
}, 2000).done(done);
|
|
|
|
});
|
2012-10-03 20:55:23 +00:00
|
|
|
});
|