Skip to content
Permalink
master
Switch branches/tags
Go to file
 
 
Cannot retrieve contributors at this time
/****************
* Testing Framework for Unit Testing
* @Author: Gregor Fellenz, http://www.publishingx.de
* @Author: Roland Dreger
* Usage:
//[at]include ../idsTest.jsx
idsTest.insertBlock("Testing idsLog");
idsTest.assertEquals("Message", true, "somethingToTest");
idsTest.htmlReport();
*/
var idsTest = function () {
// Private
var version = "2021-04-27--1.2";
var meta = {
name: "",
version: "",
testScript: "",
testScriptVersion: ""
}
var testResults = [];
var consoleLog = true;
var writeTextFile = function (htmlFile, string) {
htmlFile.encoding = "UTF-8";
htmlFile.open("w");
htmlFile.write(string);
htmlFile.close();
return true;
};
var readTextFile = function (file, encoding) {
if (file.constructor.name == "File" && file.exists) {
try {
if (encoding != undefined) file.encoding = encoding;
else file.encoding = "UTF-8";
file.open("r");
var res = file.read();
file.close();
return res;
} catch (e) {
return e
}
}
else {
throw Error("This is not a File");
}
};
var preflightDocument = function (dok, preflightProfileFile) {
var preflightResult = { status: "fail", message: "Could not run", items: [] };
if (!preflightProfileFile.exists) {
preflightResult.message = "Die Datei [" + preflightProfileFile + "] für das Preflight Profile existiert nicht!";
return preflightResult;
}
var preflightProfileName = preflightProfileFile.name.replace(/\.idpp$/, "");
var preflightProfile;
var updatePreflightProfile = preflightProfileFile.modified.getTime();
if ((app.extractLabel("px:updatePreflightProfileTime") * 1) < updatePreflightProfile) {
preflightProfile = app.preflightProfiles.itemByName(preflightProfileName);
if (preflightProfile.isValid) {
preflightProfile.remove();
}
app.loadPreflightProfile(preflightProfileFile);
app.insertLabel("px:updatePreflightProfileTime", updatePreflightProfile + "");
}
preflightProfile = app.preflightProfiles.itemByName(preflightProfileName);
if (!preflightProfile.isValid) {
preflightResult.message = "Das Preflight Profil [" + preflightProfileName + "] konnte nicht geladen werden. Es wurde kein Preflight ausgeführt!";
return preflightResult;
}
// Preflight
var preflightProcess = app.preflightProcesses.add(dok, preflightProfile);
preflightProcess.waitForProcess();
preflightProcess.waitForProcess();
if (preflightProcess.processResults.indexOf("None") == 0) {
preflightResult.status = "pass";
preflightResult.message = "Preflight mit Profil [" + preflightProfileName + "] bestanden";
preflightResult.items = [];
}
else {
var results = preflightProcess.aggregatedResults;
preflightResult.status = "fail";
preflightResult.message = "Preflight mit Profil [" + preflightProfileName + "] nicht bestanden";
preflightResult.items = results;
}
preflightProcess.remove();
return preflightResult;
};
var cleanInDesignString = function (object) {
if (object.hasOwnProperty("parentStory")) {
var string = object.parentStory.contents;
}
else if (object.hasOwnProperty("baseline")) {
var string = object.contents;
}
else if (object.constructor.name == "String") {
var string = object;
}
else {
var string = object.toString();
}
string = string.replace(/[\u0003\u0007\u0016\u0008]/g, ''); // <control> Character können raus
string = string.replace(/[\uFEFF\u0EFF]/g, ''); // InDesign Spezialzeichen entfernen
return string;
};
// API
return {
/**
* Assert two Parameters are equal
* @param {String} message
* @param {Any} expected
* @param {Any} actual
* @returns {Boolean} Result of assertion
*/
assertEquals: function (message, expected, actual) {
message = message + " <em>Wertevergleich <span class='code'>assertEquals</span></em>";
try {
if (expected === actual) {
testResults.push({ failed: false, message: message, result: "Expected: <strong>" + expected + "</strong> Actual: <strong>" + actual + "</strong>" });
return true;
}
else {
testResults.push({ failed: true, message: message, result: "Expected: <strong>" + expected + "</strong> Actual: <strong>" + actual + "</strong>" });
if (consoleLog) $.writeln("Test: " + message + "\nExpected: " + expected + "\nActual: " + actual + "\n\n");
return false;
}
}
catch (e) {
testResults.push({ failed: true, message: message, result: "Error: " + e + " Line " + e.line });
return false;
}
},
/**
* Assert two strings as equal
* @param {String} message
* @param {String} expected
* @param {String|Object} actual
* @param {Boolean} clean Defaults to false, try to obtain string from InDesign object and clean all control characters
* @returns {Boolean} Result of assertion
*/
assertString: function (message, expected, actual, clean) {
message = message + " <em>Stringvergleich <span class='code'>assertString</span></em>";
try {
if (clean) {
actual = cleanInDesignString(actual);
}
if (expected === actual) {
testResults.push({ failed: false, message: message, result: "Expected: <strong>" + expected + "</strong> Actual: <strong>" + actual + "</strong>" });
return true;
}
else {
testResults.push({ failed: true, message: message, result: "Expected: <strong>" + expected + "</strong> Actual: <strong>" + actual + "</strong>" });
if (consoleLog) $.writeln("Test: " + message + "\nExpected: " + expected + "\nActual: " + actual + "\n\n");
return false;
}
}
catch (e) {
testResults.push({ failed: true, message: message, result: "Error: " + e + " Line " + e.line });
return false;
}
},
/**
* Assert a Regular expression matches a String
* @param {String} message
* @param {RegExp} regex
* @param {String} actual
* @param {Boolean} clean Defaults to false, try to obtain string from InDesign object and clean all control characters
* @returns {Boolean} Result of assertion
*/
assertRegEx: function (message, regex, actual, clean) {
message = message + " <em>Regex Test <span class='code'>assertRegEx</span></em>";
try {
if (clean) {
actual = cleanInDesignString(actual);
}
if (actual.match(regex)) {
testResults.push({ failed: false, message: message, result: "regex: " + regex });
return true;
}
else {
testResults.push({ failed: true, message: message, result: "regex: " + regex });
if (consoleLog) $.writeln("Test: " + message + "\nExpected: " + expected + "\nActual: " + actual + "\n\n");
return false;
}
}
catch (e) {
testResults.push({ failed: true, message: message, result: "Error: " + e + " Line " + e.line });
return false;
}
},
/**
* Asserts a String can be found in a Text file
* @param {String} message
* @param {String} searchValue
* @param {File} file
* @param {String} encoding
* @returns {Boolean} Result of assertion
*/
assertStringInFile: function (message, searchValue, file, encoding) {
message = message + " <em>String in Datei <span class='code'>assertStringInFile</span></em>" + " <span class='hint'><a target='_blank' rel='noopener noreferrer' href='file:///" + file.fsName + "'>" + decodeURI(file.name) + "</a></span>";
try {
if (!file.exists) {
testResults.push({ failed: true, message: message, result: "File does not exist" });
return false;
}
var string = readTextFile(file, encoding);
if (string.indexOf(searchValue) > -1) {
testResults.push({ failed: false, message: message, result: "searchValue: <strong>" + searchValue + "</strong>" });
return true;
}
else {
testResults.push({ failed: true, message: message, result: "searchValue: <strong>" + searchValue + "</strong>" });
if (consoleLog) $.writeln("Test: " + message + "\nExpected: " + expected + "\nActual: " + actual + "\n\n")
return false;
}
}
catch (e) {
testResults.push({ failed: true, message: message, result: "Error: " + e + " Line " + e.line });
return false;
}
},
/**
* Asserts a String cannot be found in a Text file
* @param {String} message
* @param {String} searchValue
* @param {File} file
* @param {String} encoding
* @returns {Boolean} Result of assertion
*/
assertStringNotInFile: function (message, searchValue, file, encoding) {
message = message + " <em>String nicht in Datei <span class='code'>assertStringNotInFile</span></em>" + " <span class='hint'><a target='_blank' rel='noopener noreferrer' href='file:///" + file.fsName + "'>" + decodeURI(file.name) + "</a></span>";
try {
if (!file.exists) {
testResults.push({ failed: true, message: message, result: "File does not exist" });
return false;
}
var string = readTextFile(file, encoding);
if (string.indexOf(searchValue) == -1) {
testResults.push({ failed: false, message: message, result: "searchValue: <strong>" + searchValue + "</strong>" });
return true;
}
else {
testResults.push({ failed: true, message: message, result: "searchValue: <strong>" + searchValue + "</strong>" });
if (consoleLog) $.writeln("Test: " + message + "\nExpected: " + expected + "\nActual: " + actual + "\n\n");
return false;
}
}
catch (e) {
testResults.push({ failed: true, message: message, result: "Error: " + e + " Line " + e.line });
return false;
}
},
/**
* Asserts a Regular Expression matches the contents of a Text file
* @param {String} message
* @param {String} regex
* @param {File} file
* @param {String} encoding
* @returns {Boolean} Result of assertion
*/
assertRegExInFile: function (message, regex, file, encoding) {
message = message + " <em>RegEx in Datei <span class='code'>assertRegExInFile</span></em>" + " <span class='hint'><a target='_blank' rel='noopener noreferrer' href='file:///" + file.fsName + "'>" + decodeURI(file.name) + "</a></span>";
try {
if (!file.exists) {
testResults.push({ failed: true, message: message, result: "File does not exist" });
return false;
}
var string = readTextFile(file, encoding);
if (string.match(regex) != null) {
testResults.push({ failed: false, message: message, result: "RegEx: " + regex + " Found: " + string.match(regex).join("<br/>") });
if (consoleLog) $.writeln("Test: " + message + "\nFound: " + string.match(regex) + "\n\n");
return false;
}
else {
testResults.push({ failed: true, message: message, result: "RegEx: <strong>" + regex + "</strong>" });
return false;
}
}
catch (e) {
testResults.push({ failed: true, message: message, result: "Error: " + e + " Line " + e.line });
return false;
}
},
/**
* Asserts a Regular Expression does not match the contents of a Text file
* @param {String} message
* @param {String} regex
* @param {File} file
* @param {String} encoding
* @returns {Boolean} Result of assertion
*/
assertRegExNotInFile: function (message, regex, file, encoding) {
message = message + " <em>RegEx nicht in Datei <span class='code'>assertRegExNotInFile</span></em>" + " <span class='hint'><a target='_blank' rel='noopener noreferrer' href='file:///" + file.fsName + "'>" + decodeURI(file.name) + "</a></span>";
try {
if (!file.exists) {
testResults.push({ failed: true, message: message, result: "File does not exist" });
return false;
}
var string = readTextFile(file, encoding);
if (string.match(regex) == null) {
testResults.push({ failed: false, message: message, result: "RegEx: <strong>" + regex + "</strong>" });
return true;
}
else {
testResults.push({ failed: true, message: message, result: "RegEx: " + regex + " Found: " + string.match(regex).join("<br/>") });
if (consoleLog) $.writeln("Test: " + message + "\nFound: " + string.match(regex) + "\n\n")
return false;
}
}
catch (e) {
testResults.push({ failed: true, message: message, result: "Error: " + e + " Line " + e.line });
return false;
}
},
/**
* Assert that an expected number of GREP matches can be found in the document
* @param {String} message
* @param {FindGrepPreference|String} find
* @param {Document} dok
* @param {Number} expectedLength
* @param {Boolean} includeMaster
* @returns {Boolean|Array} Result of assertion. If true, the the results of fingGrep()
*/
assertGREPInDoc: function (message, find, dok, expectedLength, includeMaster) {
message = message + " <em>GREP-Suche <span class='code'>assertGREPInDoc</span></em>";
try {
if (includeMaster == undefined) {
includeMaster = false;
}
// Save Options
var saveFindGrepOptions = {};
saveFindGrepOptions.includeFootnotes = app.findChangeGrepOptions.includeFootnotes;
saveFindGrepOptions.includeHiddenLayers = app.findChangeGrepOptions.includeHiddenLayers;
saveFindGrepOptions.includeLockedLayersForFind = app.findChangeGrepOptions.includeLockedLayersForFind;
saveFindGrepOptions.includeLockedStoriesForFind = app.findChangeGrepOptions.includeLockedStoriesForFind;
saveFindGrepOptions.includeMasterPages = app.findChangeGrepOptions.includeMasterPages;
if (app.findChangeGrepOptions.hasOwnProperty("searchBackwards")) saveFindGrepOptions.searchBackwards = app.findChangeGrepOptions.searchBackwards;
// Set Options
app.findChangeGrepOptions.includeFootnotes = true;
app.findChangeGrepOptions.includeHiddenLayers = true;
app.findChangeGrepOptions.includeLockedLayersForFind = false;
app.findChangeGrepOptions.includeLockedStoriesForFind = false;
app.findChangeGrepOptions.includeMasterPages = includeMaster;
if (app.findChangeGrepOptions.hasOwnProperty("searchBackwards")) app.findChangeGrepOptions.searchBackwards = false;
// Reset Dialog
app.findGrepPreferences = NothingEnum.nothing;
try {
// Find Change operation
if (find.constructor.name == "String") {
app.findGrepPreferences.findWhat = find;
}
else {
app.findGrepPreferences.properties = find;
}
var results = null;
results = dok.findGrep(true);
}
catch (e) {
throw e;
}
finally {
// Reset Dialog
app.findGrepPreferences = NothingEnum.nothing;
// Reset Options
app.findChangeGrepOptions.includeFootnotes = saveFindGrepOptions.includeFootnotes;
app.findChangeGrepOptions.includeHiddenLayers = saveFindGrepOptions.includeHiddenLayers;
app.findChangeGrepOptions.includeLockedLayersForFind = saveFindGrepOptions.includeLockedLayersForFind;
app.findChangeGrepOptions.includeLockedStoriesForFind = saveFindGrepOptions.includeLockedStoriesForFind;
app.findChangeGrepOptions.includeMasterPages = saveFindGrepOptions.includeMasterPages;
if (app.findChangeGrepOptions.hasOwnProperty("searchBackwards")) app.findChangeGrepOptions.searchBackwards = saveFindGrepOptions.searchBackwards;
}
if (results.length == expectedLength) {
testResults.push({ failed: false, message: message, result: "GREP: " + find.toSource() + " expected: " + expectedLength + " actual: " + results.length + " search results" });
return results;
}
else {
testResults.push({ failed: true, message: message, result: "GREP: " + find.toSource() + " expected: " + expectedLength + " actual: " + results.length + " search results" });
if (consoleLog) $.writeln("Test: " + message + "\nGREP: " + find.toSource() + " expected: " + expectedLength + " actual: " + results.length + " search results" + "\n\n")
return false;
}
}
catch (e) {
testResults.push({ failed: true, message: message, result: "Error: " + e + " Line " + e.line });
return false;
}
},
/**
* Assert that an expected number of objects can be found in the document
* @param {String} message
* @param {ObjectTypes} objectType ObjectTypes.ALL_FRAMES_TYPE, ObjectTypes.GRAPHIC_FRAMES_TYPE, ObjectTypes.TEXT_FRAMES_TYPE, ObjectTypes.UNASSIGNED_FRAMES_TYPE
* @param {FindObjectPreference} findObjectPreferences
* @param {Document} dok
* @param {Number} expectedLength
* @param {Boolean} includeMaster
* @returns {Boolean|Array} Result of assertion. If true, the the results of findObject()
*/
assertObjectInDoc: function (message, objectType, findObjectPreferences, dok, expectedLength, includeMaster) {
message = message + " <em>Objekt-Suche <span class='code'>assertObjectInDoc</span></em>";
try {
if (includeMaster == undefined) {
includeMaster = false;
}
// Save Options
var saveFindObjectOptions = {};
saveFindObjectOptions.includeFootnotes = app.findChangeObjectOptions.includeFootnotes;
saveFindObjectOptions.includeHiddenLayers = app.findChangeObjectOptions.includeHiddenLayers;
saveFindObjectOptions.includeLockedLayersForFind = app.findChangeObjectOptions.includeLockedLayersForFind;
saveFindObjectOptions.includeLockedStoriesForFind = app.findChangeObjectOptions.includeLockedStoriesForFind;
saveFindObjectOptions.includeMasterPages = app.findChangeObjectOptions.includeMasterPages;
saveFindObjectOptions.objectType = app.findChangeObjectOptions.objectType;
// Set Options
app.findChangeObjectOptions.includeFootnotes = true;
app.findChangeObjectOptions.includeHiddenLayers = true;
app.findChangeObjectOptions.includeLockedLayersForFind = false;
app.findChangeObjectOptions.includeLockedStoriesForFind = false;
app.findChangeObjectOptions.includeMasterPages = includeMaster;
app.findChangeObjectOptions.objectType = objectType;
app.findObjectPreferences = NothingEnum.NOTHING;
app.findObjectPreferences.properties = findObjectPreferences;
var results = dok.findObject();
app.findObjectPreferences = NothingEnum.NOTHING;
// Reset Options
app.findChangeObjectOptions.includeFootnotes = saveFindObjectOptions.includeFootnotes;
app.findChangeObjectOptions.includeHiddenLayers = saveFindObjectOptions.includeHiddenLayers;
app.findChangeObjectOptions.includeLockedLayersForFind = saveFindObjectOptions.includeLockedLayersForFind;
app.findChangeObjectOptions.includeLockedStoriesForFind = saveFindObjectOptions.includeLockedStoriesForFind;
app.findChangeObjectOptions.includeMasterPages = saveFindObjectOptions.includeMasterPages;
app.findChangeObjectOptions.objectType = saveFindObjectOptions.objectType;
if (results.length == expectedLength) {
testResults.push({ failed: false, message: message, result: "Object: " + findObjectPreferences.toSource() + " expected: " + expectedLength + " actual: " + results.length + " search results" });
return results;
}
else {
testResults.push({ failed: true, message: message, result: "Object: " + findObjectPreferences.toSource() + " expected: " + expectedLength + " actual: " + results.length + " search results" });
if (consoleLog) $.writeln("Test: " + message + "\nObject: " + findObjectPreferences.toSource() + " expected: " + expectedLength + " actual: " + results.length + " search results" + "\n\n")
return false;
}
}
catch (e) {
testResults.push({ failed: true, message: message, result: "Error: " + e + " Line " + e.line });
return false;
}
},
/**
* Assert that an expected number of tables identified by a tablestyle can be found in the document
* @param {String} message
* @param {TableStyle} tableStyle - Tabellenformat der gesuchten Tabelle
* @param {Document} dok
* @param {Number} expectedLength - Erwartete Anzahl an Tabellen
* @param {Boolean} includeMaster
* @returns {Boolean|Array} Result of assertion. If true, an Array with found tables
*/
assertTablesInDoc: function (message, tableStyle, dok, expectedLength, includeMaster) {
message = message + " <em>Tabellen-Suche <span class='code'>assertTableInDoc</span></em>";
try {
if (includeMaster == undefined) {
includeMaster = false;
}
var findTextPreferences = {
findWhat: "<0016>"
};
// Save Options
var saveFindTextOptions = {};
saveFindTextOptions.caseSensitive = app.findChangeTextOptions.caseSensitive;
saveFindTextOptions.wholeWord = app.findChangeTextOptions.wholeWord;
saveFindTextOptions.includeFootnotes = app.findChangeTextOptions.includeFootnotes;
saveFindTextOptions.includeHiddenLayers = app.findChangeTextOptions.includeHiddenLayers;
saveFindTextOptions.includeLockedLayersForFind = app.findChangeTextOptions.includeLockedLayersForFind;
saveFindTextOptions.includeLockedStoriesForFind = app.findChangeTextOptions.includeLockedStoriesForFind;
saveFindTextOptions.includeMasterPages = app.findChangeTextOptions.includeMasterPages;
if (app.findChangeTextOptions.hasOwnProperty("searchBackwards")) { saveFindTextOptions.searchBackwards = app.findChangeTextOptions.searchBackwards; }
// Set Options
app.findChangeTextOptions.caseSensitive = false;
app.findChangeTextOptions.wholeWord = false;
app.findChangeTextOptions.includeFootnotes = true;
app.findChangeTextOptions.includeHiddenLayers = true;
app.findChangeTextOptions.includeLockedLayersForFind = false;
app.findChangeTextOptions.includeLockedStoriesForFind = false;
app.findChangeTextOptions.includeMasterPages = includeMaster;
if (app.findChangeTextOptions.hasOwnProperty("searchBackwards")) { app.findChangeTextOptions.searchBackwards = false; }
app.findTextPreferences = NothingEnum.NOTHING;
app.findTextPreferences.properties = findTextPreferences;
var results = dok.findText();
// Reset Options
app.findChangeTextOptions.caseSensitive = saveFindTextOptions.caseSensitive;
app.findChangeTextOptions.wholeWord = saveFindTextOptions.wholeWord;
app.findChangeTextOptions.includeFootnotes = saveFindTextOptions.includeFootnotes;
app.findChangeTextOptions.includeHiddenLayers = saveFindTextOptions.includeHiddenLayers;
app.findChangeTextOptions.includeLockedLayersForFind = saveFindTextOptions.includeLockedLayersForFind;
app.findChangeTextOptions.includeLockedStoriesForFind = saveFindTextOptions.includeLockedStoriesForFind;
app.findChangeTextOptions.includeMasterPages = saveFindTextOptions.includeMasterPages;
if (app.findChangeTextOptions.hasOwnProperty("searchBackwards")) app.findChangeTextOptions.searchBackwards = saveFindTextOptions.searchBackwards;
var returnTables = [];
for (var i = results.length - 1; i >= 0; i--) {
var curTableChar = results[i];
if (!curTableChar || !curTableChar.isValid) {
continue;
}
var curTable = curTableChar.tables[0];
if (!curTable.isValid) {
continue;
}
if (curTable.appliedTableStyle === tableStyle) {
returnTables.push(curTable);
}
else {
results.splice(i, 1);
}
}
if (results.length == expectedLength) {
testResults.push({ failed: false, message: message, result: "Table: " + findTextPreferences.toSource() + " with " + results.length + " hits." });
return returnTables;
}
else {
testResults.push({ failed: true, message: message, result: "Table: " + findTextPreferences.toSource() + "; Tabellenformat: " + tableStyle.name });
if (consoleLog) $.writeln("Test: " + message + "\nExpected: " + expectedLength + "\nActual: " + results.length + "\n\n");
return false;
}
}
catch (e) {
testResults.push({ failed: true, message: message, result: "Error: " + e + " Line " + e.line });
return false;
}
},
/**
* Assert that InDesign Preflight Pass
* @param {String} message
* @param {File} preflightProfileFile
* @param {Document} dok
* @returns {Boolean} Result of assertion
*/
assertPreflightPass: function (message, preflightProfileFile, dok) {
message = message + " <em>Preflight bestanden <span class='code'>assertPreflightPass</span></em>";
try {
var preflightResultObj = preflightDocument(dok, preflightProfileFile);
var preflightStatus = preflightResultObj.status;
var preflightMessage = preflightResultObj.message;
var preflightArray = preflightResultObj.items;
var preflightMessageString = "<strong>Preflight Message:</strong> " + preflightMessage;
var preflightResultString = "<strong>Preflight Result:</strong> " + preflightArray.toSource();
if (preflightStatus === 'pass') {
testResults.push({ failed: false, message: message, result: preflightMessageString });
return true;
}
else {
testResults.push({ failed: true, message: message, result: preflightMessageString + "; " + preflightResultString });
if (consoleLog) $.writeln("Test: " + message + "\nPreflight Message: " + preflightMessage + "\nPreflight result: " + preflightResultString + "\n\n");
return false;
}
}
catch (e) {
testResults.push({ failed: true, message: message, result: "Error: " + e + " Line " + e.line });
return false;
}
},
/**
* Assert that InDesign Preflight Fail for a specific reason
* @param {String} message
* @param {File} preflightProfileFile
* @param {Document} dok
* @param {String} expectedPageName Page name (optional) (preflight panel –> main section -> last expanded row)
* @param {String} expectedProblem Problem (optional) (preflight panel –> info section -> problem)
* @param {String} expectedDesc Description (optional) (preflight panel –> main section -> last expanded row)
* @returns {Boolean} Result of assertion
*/
assertPreflightFail: function (message, preflightProfileFile, dok, expectedPageName, expectedProblem, expectedDesc) {
message = message + " <em>Preflight nicht bestanden <span class='code'>assertPreflightFail</span></em>";
try {
var preflightResultObj = preflightDocument(dok, preflightProfileFile);
var preflightStatus = preflightResultObj.status;
var preflightMessage = preflightResultObj.message;
var preflightArray = preflightResultObj.items;
expectedPageName = expectedPageName && expectedPageName.toString() || "";
expectedProblem = expectedProblem && expectedProblem.toString() || "";
expectedDesc = expectedDesc && expectedDesc.toString() || "";
var escapeCharsRegExp = new RegExp("([.*+?()[\\]{}\\^$|\\~\\\\])", "g");
expectedProblem = expectedProblem.replace(escapeCharsRegExp, "\\$1");
var expectedProblemRegExp = new RegExp(expectedProblem, "ig");
var testPassed = false;
if (preflightStatus === 'fail') {
if (preflightArray.length > 2) {
var resultArray = preflightArray[2];
for (var i = 0; i < resultArray.length; i++) {
var id = resultArray[i][0];
var desc = resultArray[i][1];
var pageName = resultArray[i][2];
var problem = resultArray[i][3];
if (
(expectedPageName === "" || pageName === expectedPageName) &&
(expectedProblem === "" || expectedProblemRegExp.test(problem)) &&
(expectedDesc === "" || desc === expectedDesc)
) {
testPassed = true;
break;
}
}
}
}
var preflightMessageString = "";
if (expectedProblem) {
preflightMessageString += "<strong>Expected Problem:</strong> " + expectedProblem + "; ";
}
if (expectedPageName) {
preflightMessageString += "<strong>Expected Page:</strong> " + expectedPageName + "; ";
}
if (expectedDesc) {
preflightMessageString += "<strong>Expected Description:</strong> " + expectedDesc + "; ";
}
preflightMessageString += "<strong>Preflight Message:</strong> " + preflightMessage;
var preflightResultString = "<strong>Preflight Result:</strong> " + preflightArray.toSource();
if (!testPassed) {
testResults.push({ failed: true, message: message, result: preflightMessageString + "; " + preflightResultString });
if (consoleLog) $.writeln("Test: " + message + "\nPreflight Message: " + preflightMessageString + "\nPreflight result: " + preflightResultString + "\n\n");
return true;
}
else {
testResults.push({ failed: false, message: message, result: preflightMessageString + "; " + preflightResultString });
return false;
}
}
catch (e) {
testResults.push({ failed: true, message: message, result: "Error: " + e + " Line " + e.line });
return false;
}
},
/**
* Set the Meta-Data for the test run
* @param {Object} testSuiteMeta
*/
setMeta: function (testSuiteMeta) {
testSuiteMeta = testSuiteMeta;
},
/**
* Write failed test to console $.writeln()
* @param {Boolean} value
*/
logToConsole: function (value) {
consoleLog = value;
},
/**
* Inserts an info Block into the test result list
* @param {String} message
* @param {String} info
*/
insertBlock: function (message, info) {
testResults.push({ failed: "block", "message": message, "result": info });
},
/**
* Writes a HTML Test Report to a file
* @param {File} htmlFile
*/
htmlReport: function (htmlFile) {
var htmlString = '<html><head><meta charset="utf-8"><title>Testresults</title><style>' +
'body { font-family: Calibri, Candara, Segoe, Segoe UI, Optima, Arial, sans-serif; }' +
// '.infoBlock { background-color: #ccc; padding: 6px; margin: 6px 0 6px 0 } '+
'table { margin: 12px 0 12px 0 } ' +
'.meta td { background-color: #eee; font-size: 12px; padding: 2px 4px 2px 2px; width: 14em; min-width: 14em; max-width: 14em; word-break: break-all; } ' +
// 'thead tr th:first-child, tbody tr td:first-child { background-color: #eee; width: 14em; min-width: 14em; max-width: 14em; word-break: break-all; }' +
'.overview { width: 100px; min-width: 100%; max-width: 100%; } ' +
'.overview td { height: 30px; } ' +
'td.passed { background-color: #339933; } ' +
'td.failed { background-color: #cc0000; } ' +
'h3.passed { color: #339933; background-color: none} ' +
'h3.failed { color: #cc0000; background-color: none} ' +
'.togglePassed { color: #339933; background: transparent; border: 1px solid #339933; border-radius: 0px; padding: 3px; margin-left: 6px }' +
'.testName { background-color: #aaa; padding: 6px; margin: 24px 0 6px 0 } ' +
'.testPassed { background-color: #b3ffc6; padding: 6px; margin: 6px 0; } ' +
'.testFailed { background-color: #eb4747; padding: 6px; margin: 6px 0; } ' +
'.infoBlock h1 { font-size: 28px; font-style: normal; font-variant: normal; font-weight: 700; line-height: 26.4px; margin: 0 0 20px 0 } ' +
'h1 { font-size: 22px; font-style: normal; font-variant: normal; font-weight: 700; line-height: 26.4px; margin: 0 0 6px 0 } ' +
'h3 { font-size: 18px; font-style: normal; font-variant: normal; font-weight: 700; line-height: 15.4px; margin: 0 0 6px 0 } ' +
'.infoBlock h3 { margin: 0 0 8px 0 } ' +
'p { font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; line-height: 20px; margin: 0} ' +
'.hint { font-size: 14px; color: #737373; font-weight: normal; } ' +
'em { font-size: 14px; color: #444; } ' +
// '.code { font-family: monospace; font-size: 12px; font-style: normal; font-variant: normal; font-weight: 400;} ' +
'.code { display:none } ' +
'.testName .hint { color: #000; } ' +
'.hide { display: none; } ' +
'#providedBy { float: right; }' +
'</style></head><body>' +
'<div id="providedBy"><p><a href="https://www.publishingx.de/"><img class="logo" width="150px" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAA1IAAADlCAYAAABZAcZXAAAACXBIWXMAAFxGAABcRgEUlENBAAAgAElEQVR42u3dv6szy5ng8fsn6E/QP7CgbFPhcINF6YIDZcaZksWpMExoEDhxsIEuEzhZY4ET32BMB57oMiBu5BuNmOAmnkB4YWEj7Vv37fNenT7d5+hHdXdV9afhm4zHr3Wqqrufb1c9z/PV5XL5CgAAAABwOwYBAAAAAIgUAAAAABApAAAAACBSAAAAAECkAAAAAIBIAQAAAACIFAAAAAAQKQAAAAAgUgAAAABApAAAAACASAEAAAAAiBQAAAAAECkAAAAAIFIAAAAAQKQAAACA0ph9YtlgblxGZd7nnBhgAAAA4LEgffOJwyfOl/ev0yf2n1jXwmX8+mFVj/Px8vFV1fO3IFIAAABA/6zrIPyZa2+3KqrQ7m+Q2feu4yOSa/ABAACA2wTqdIl77e1QPXWUcht5Ps71vzkjUgAAAMBzLN87KvZ//9//ufzbv//L5Q/f/vbymz//8vLrP/38C//8r/90+ea7ry//8Z/ffxS8L4zzXSzem5Mw3mHcw/hfz0cgzFOYrzBvHxzFXBEpAAAA4LEdj11XpB2C8SBO/+1//Zeb+B9f/9fL7/7yq8vf//EDmXpeot4c4wvjGsTpF7//2c1zEsTqr9//8aM8qhmRAgAAAJ7c8QiB9z3BehtBqFp2RMjUbXJ7bu4IBoF6Zj6C5Iadqo5dqs55MSEAAADABzsef/vh26cFqhm8txz5O8qZepeqKVH/83//92hzEuY37DR2XGsiBQAAANwoUTF2PO6Uqb15aGXTp0Q1j/x17E6tiRQAAADwwbGxIDl9BesvhH+/JWhfmY83gvvqCrLT57x0SO6rY34mBgAAAPjcWPeVRIVgus9g/TpnqiVgn5uTL4J7uh6cUJFviHl55/glkQIAAAAun0ucvzo2NpREvdCSm1OZlx/ZNwV3yHnpkKkNkQIAAAAaRQz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qRKQAIgUAAJCySB0S+3sWEf6mytoAkSJSAAAAfcZIgXlJ+VGpySFApAAAAMoUqUMif8sy0t+zsTZApIgUAADAezHSMZJ8rEf+O8KRvnOkv0XPJBApIgUAAPBujHSIJB+B3SdmI/wNm4h/w8m6AJEiUgAAAB/FSNuIEnKpd4W2fedNBWELu2AxKvSJ+UCkiBQAAMAjR+IuPXGspWr1rFjV4rSs/72qx988ty5ApIgUAADALXHSuUcxaduxqq441HJ0zfV/fhzwt+2tBxApIgUAAHBrnLQbUFZS5Ww3CkSKSAEAANwTJ82JlJLnIFJECgAA4H6Z2k9YojTgBZEiUgAAAA8XczhPUKKOY5RsB4gUAABAOTK1JFEAkSJSAAAA98vUeiISVZEoECkiBQAAQKZuZ2eeQaSIFAAAQB8yFRr1ngoTqPD3LM0vQKQAAAD6LkCxK6RH1NqcAkQKAABgSKGa1+XRzxnuQBEogEgBAACMvkMV8qcOictT2EVbmDMggkgBAAAgulStwsfmugLeeURxCmK3IU8AkQIAAMj1COCylpptfRywqjk9KUsv/862/veXypcDRAoAAMAOFzECiBQAAAAAECkAAAAAIFIAAAAAQKQAAAAAAEQKAAAAAIgUAAAAABApAAAAACBSAAAAAECkAAAAAABECgAAAACIFAAAAAAQKQAAAAAgUgAAAABApAAAAACASAEAAAAAiBQAAAAAECkAAAAAIFIAAAAAkB3/HxVL5She4LYJAAAAAElFTkSuQmCC"/></a></p></div>' +
'<div class="infoBlock"><h1>Testergebnis für ' + testSuiteMeta.name + '</h1>' +
'<table class="meta"><tbody>';
htmlString += '<tr><td class="key">Version der Testsuite</td> <td class="value">' + testSuiteMeta.version + '</td></tr>';
htmlString += '<tr><td class="key">Getestetes Skript</td> <td class="value">' + testSuiteMeta.testScript + '</td></tr>';
htmlString += '<tr><td class="key">Version ' + testSuiteMeta.testScript + '</td> <td class="value">' + testSuiteMeta.testScriptVersion + '</td></tr>';
// 'Start und Run Information ... Platform, Datum, Tests. Auswertnung... '
var date = new Date();
date = date.getFullYear() + "-" + pad(date.getMonth() + 1, 2) + "-" + pad(date.getDate(), 2) + " " + pad(date.getHours(), 2) + "-" + pad(date.getMinutes(), 2) + "-" + pad(date.getSeconds(), 2);
htmlString += '<tr><td class="key">Datum</td> <td class="value">' + date + '</td></tr>';
htmlString += '<tr><td class="key">Plattform</td> <td class="value">' + File.fs + '</td></tr>';
var appVersion = 'InDesign ' + app.version;
if (app.hasOwnProperty("activeDocument")) {
appVersion += ' (Desktop)';
}
else { // Server
appVersion += ' (Server)';
}
htmlString += '<tr><td class="key">InDesign-Version</td> <td class="value">' + appVersion + '</td></tr>';
htmlString += '<tr><td class="key">DOM-Version</td> <td class="value">' + app.scriptPreferences.version + '</td></tr>';
htmlString += '</tbody></table>'
var failedCounter = 0;
var passedCounter = 0;
for (var i = 0; i < testResults.length; i++) {
var result = testResults[i];
if (result.failed === "block") {
}
else if (result.failed) {
failedCounter++
}
else {
passedCounter++
}
}
var percentPassed = passedCounter / (failedCounter + passedCounter) * 100;
var percentFailed = failedCounter / (failedCounter + passedCounter) * 100;
htmlString += '<table class="overview"><tbody><tr>';
if (percentFailed > 0 && percentPassed > 0) {
htmlString += '<td class="failed" width="' + percentFailed + '%"></td>';
htmlString += '<td class="passed" width="' + percentPassed + '%"></td>';
}
else if (percentFailed == 0) {
htmlString += '<td class="passed" width="' + percentPassed + '%"></td>';
}
else if (percentPassed == 0) {
htmlString += '<td class="failed" width="' + percentFailed + '%"></td>';
}
htmlString += '</tr></tbody></table>';
htmlString += '<h3 class="failed">Tests fehlgeschlagen: ' + failedCounter + '</h3>';
htmlString += '<h3 class="passed">Tests bestanden: ' + passedCounter + ' ';
htmlString += '<button class="togglePassed" onclick="toggleView()">Toggle display</button></h3>';
htmlString += '</div>';
for (var i = 0; i < testResults.length; i++) {
var result = testResults[i];
if (result.failed === "block") {
htmlString += '<div class="testName"><h1>' + result.message + '</h1>' +
'<p>' + result.result + '</p></div>';
}
else if (result.failed) {
htmlString += '<div class="testFailed"><h3>' + result.message + '</h3>' +
'<p>' + result.result + '</p></div>';
}
else {
htmlString += '<div class="testPassed"><h3>' + result.message + '</h3>' +
'<p>' + result.result + '</p></div>';
}
}
// var divs = document.querySelectorAll('div'), i;
htmlString += '<script>';
htmlString += 'function toggleView() { var nodes = document.querySelectorAll(".testPassed"); if (!nodes) return;';
htmlString += ' for (i = 0; i < nodes.length; ++i) { nodes[i].classList.toggle("hide"); } }';
htmlString += '</script>';
htmlString += '</body></html>';
writeTextFile(htmlFile, htmlString);
htmlFile.execute();
}
};
}();