This should solve issue #169: The test now completes with the insertion of a random anchor (menu-driven) and some text, the export is then checked to contain <a name="..." id="..."> as expected, then cleans up.

paul
pull/1/head
Paul Libbrecht 6 years ago
parent 372f1dfeb4
commit 0dc1500784

@ -165,8 +165,10 @@ define([
var getHTML = function (inner) { var getHTML = function (inner) {
return ('<!DOCTYPE html>\n' + '<html>\n' + return ('<!DOCTYPE html>\n' + '<html>\n' +
' <head><meta charset="utf-8"></head>\n <body>' + ' <head><meta charset="utf-8"></head>\n <body>' +
inner.innerHTML.replace(/<img[^>]*class="cke_anchor"[^>]*data-cke-realelement="([^"]*)"[^>]*>/, inner.innerHTML.replace(/<img[^>]*class="cke_anchor"[^>]*data-cke-realelement="([^"]*)"[^>]*>/g,
function(match,realElt){ return unescape(realElt); }) + function(match,realElt){
//console.log("returning realElt \"" + unescape(realElt)+ "\".");
return unescape(realElt); }) +
' </body>\n</html>' ' </body>\n</html>'
); );
}; };
@ -764,12 +766,22 @@ define([
// -------- anchor test: make sure the exported anchor contains <a name="..."> ------- // -------- anchor test: make sure the exported anchor contains <a name="..."> -------
console.log('---- anchor test: make sure the exported anchor contains <a name="..."> -----.'); console.log('---- anchor test: make sure the exported anchor contains <a name="..."> -----.');
// TODO: cleanup fixme, too much ---, and removed tests
// TODO: any other unwanted changes (sframe-app?)?
// TODO: upgrade to latest of master, create branch
// TODO: any way to make sure that content contains anchors? Seems to need selenium-driven clicks and inputs
function tryAndTestExport() { function tryAndTestExport() {
// window.setContent("This goes before the anchor"); console.log("Starting tryAndTestExport.");
editor.on( 'dialogShow', function( evt ) {
console.log("Anchor dialog detected.");
var dialog = evt.data;
$(dialog.parts.contents.$).find("input").val('xx-' + Math.round(Math.random()*1000));
dialog.click(CKEDITOR.dialog.okButton(editor).id);
} );
var existingText = editor.getData();
editor.insertText("A bit of text");
console.log("Launching anchor command.");
editor.execCommand(editor.ui.get('Anchor').command);
console.log("Anchor command launched.");
var waitH = window.setInterval(function() {
console.log("Waited 2s for the dialog to appear");
var anchors = CKEDITOR.plugins["link"].getEditorAnchors(editor); var anchors = CKEDITOR.plugins["link"].getEditorAnchors(editor);
if(!anchors || anchors.length===0) { if(!anchors || anchors.length===0) {
test.fail("No anchors found. Please adjust document"); test.fail("No anchors found. Please adjust document");
@ -786,15 +798,33 @@ define([
console.log("Found " + expected + " " + found + "."); console.log("Found " + expected + " " + found + ".");
allFound = allFound && found; allFound = allFound && found;
} }
console.log("Finished anchor test.");
if(allFound) {test.pass();} console.log("Cleaning up.");
else if(allFound) {
{test.fail("Not all expected a elements found.");} // clean-up
editor.execCommand('undo');
editor.execCommand('undo');
var nint = window.setInterval(function(){
console.log("Waiting for undo to yield same result.")
if(existingText === editor.getData()) {
window.clearInterval(nint);
test.pass();
}
}, 500);
} else
{
test.fail("Not all expected a elements found for document at " + window.top.location + ".");
} }
}
window.clearInterval(waitH);
},2000);
} }
var intervalHandle = window.setInterval(function() { var intervalHandle = window.setInterval(function() {
if(editor.status==="ready") { if(editor.status==="ready") {
window.clearInterval(intervalHandle); window.clearInterval(intervalHandle);
console.log("Editor is ready.");
tryAndTestExport(); tryAndTestExport();
} else { } else {
console.log("Waiting for editor to be ready."); console.log("Waiting for editor to be ready.");

Loading…
Cancel
Save