diff --git a/src/tests/frontend/specs/import_then_timeslider.js b/src/tests/frontend/specs/import_then_timeslider.js new file mode 100644 index 000000000..99603ac92 --- /dev/null +++ b/src/tests/frontend/specs/import_then_timeslider.js @@ -0,0 +1,70 @@ +'use strict'; + +describe('import then timeslider', function () { + beforeEach(async function () { + await helper.aNewPad(); + }); + + const getinnertext = () => { + const inner = helper.padInner$; + let newtext = ''; + inner('div').each((line, el) => { + newtext += `${el.innerHTML}\n`; + }); + console.log(newtext); + return newtext; + }; + + const importrequest = (data, importurl, type) => { + let error; + const result = $.ajax({ + url: importurl, + type: 'post', + processData: false, + async: false, + contentType: 'multipart/form-data; boundary=boundary', + accepts: { + text: 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', + }, + data: [ + 'Content-Type: multipart/form-data; boundary=--boundary', + '', + '--boundary', + `Content-Disposition: form-data; name="file"; filename="import.${type}"`, + 'Content-Type: text/plain', + '', + data, + '', + '--boundary', + ].join('\r\n'), + error(res) { + error = res; + }, + }); + expect(error).to.be(undefined); + return result; + }; + + it('import a pad with indents from html', async function () { + const importurl = `${helper.padChrome$.window.location.href}/import`; + const html = '
Richard C. Hay is a business owner, teacher, designer, and publisher. He taught business and technical writing courses at the University of Wisconsin—Milwaukee, where he also completed his Masters’ of Arts and presented at many regional and national conferences. For the past fifteen years, he has owned a successful design, programming, and social services firm and, for the past six years, has served as publisher of the peer reviewed Writing Lab Newsletter. He also sits on the boards of two non-profits, including holding the position of President for Quest Ensemble.
'; + const inner$ = helper.padInner$; + + const textElement = inner$('div'); + textElement.sendkeys('{selectall}'); // select all + textElement.sendkeys('{del}'); // clear the pad text + importrequest(html, importurl, 'html'); + await helper.waitForPromise(() => getinnertext() === '