1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-06-27 15:53:14 +00:00

Merge branch 'master' into geospatial-plugin

This commit is contained in:
Jeremy Ruston 2024-05-29 14:12:03 +01:00
commit e8782b7936
32 changed files with 449 additions and 130 deletions

View File

@ -1,6 +1,3 @@
title: $:/boot/boot.css
type: text/css
/* /*
Basic styles used before we boot up the parsing engine Basic styles used before we boot up the parsing engine
*/ */

View File

@ -142,15 +142,15 @@ $tw.utils.each = function(object,callback) {
var next,f,length; var next,f,length;
if(object) { if(object) {
if(Object.prototype.toString.call(object) == "[object Array]") { if(Object.prototype.toString.call(object) == "[object Array]") {
for (f=0, length=object.length; f<length; f++) { for(f=0, length=object.length; f<length; f++) {
next = callback(object[f],f,object); next = callback(object[f],f,object);
if(next === false) { if(next === false) {
break; break;
} }
} }
} else { } else {
var keys = Object.keys(object); var keys = Object.keys(object);
for (f=0, length=keys.length; f<length; f++) { for(f=0, length=keys.length; f<length; f++) {
var key = keys[f]; var key = keys[f];
next = callback(object[key],key,object); next = callback(object[key],key,object);
if(next === false) { if(next === false) {
@ -275,7 +275,7 @@ Extend an object with the properties from a list of source objects
$tw.utils.extend = function(object /*, sourceObjectList */) { $tw.utils.extend = function(object /*, sourceObjectList */) {
$tw.utils.each(Array.prototype.slice.call(arguments,1),function(source) { $tw.utils.each(Array.prototype.slice.call(arguments,1),function(source) {
if(source) { if(source) {
for (var p in source) { for(var p in source) {
object[p] = source[p]; object[p] = source[p];
} }
} }
@ -289,7 +289,7 @@ Fill in any null or undefined properties of an object with the properties from a
$tw.utils.deepDefaults = function(object /*, sourceObjectList */) { $tw.utils.deepDefaults = function(object /*, sourceObjectList */) {
$tw.utils.each(Array.prototype.slice.call(arguments,1),function(source) { $tw.utils.each(Array.prototype.slice.call(arguments,1),function(source) {
if(source) { if(source) {
for (var p in source) { for(var p in source) {
if(object[p] === null || object[p] === undefined) { if(object[p] === null || object[p] === undefined) {
object[p] = source[p]; object[p] = source[p];
} }
@ -893,8 +893,8 @@ $tw.modules.execute = function(moduleName,moduleRoot) {
} else { } else {
/* /*
CommonJS optional require.main property: CommonJS optional require.main property:
In a browser we offer a fake main module which points back to the boot function In a browser we offer a fake main module which points back to the boot function
(Theoretically, this may allow TW to eventually load itself as a module in the browser) (Theoretically, this may allow TW to eventually load itself as a module in the browser)
*/ */
Object.defineProperty(sandbox.require, "main", { Object.defineProperty(sandbox.require, "main", {
value: (typeof(require) !== "undefined") ? require.main : {TiddlyWiki: _boot}, value: (typeof(require) !== "undefined") ? require.main : {TiddlyWiki: _boot},
@ -936,9 +936,9 @@ $tw.modules.execute = function(moduleName,moduleRoot) {
moduleInfo.exports = moduleInfo.definition; moduleInfo.exports = moduleInfo.definition;
} }
} catch(e) { } catch(e) {
if (e instanceof SyntaxError) { if(e instanceof SyntaxError) {
var line = e.lineNumber || e.line; // Firefox || Safari var line = e.lineNumber || e.line; // Firefox || Safari
if (typeof(line) != "undefined" && line !== null) { if(typeof(line) != "undefined" && line !== null) {
$tw.utils.error("Syntax error in boot module " + name + ":" + line + ":\n" + e.stack); $tw.utils.error("Syntax error in boot module " + name + ":" + line + ":\n" + e.stack);
} else if(!$tw.browser) { } else if(!$tw.browser) {
// this is the only way to get node.js to display the line at which the syntax error appeared, // this is the only way to get node.js to display the line at which the syntax error appeared,
@ -1533,7 +1533,7 @@ Define all modules stored in ordinary tiddlers
$tw.Wiki.prototype.defineTiddlerModules = function() { $tw.Wiki.prototype.defineTiddlerModules = function() {
this.each(function(tiddler,title) { this.each(function(tiddler,title) {
if(tiddler.hasField("module-type")) { if(tiddler.hasField("module-type")) {
switch (tiddler.fields.type) { switch(tiddler.fields.type) {
case "application/javascript": case "application/javascript":
// We only define modules that haven't already been defined, because in the browser modules in system tiddlers are defined in inline script // We only define modules that haven't already been defined, because in the browser modules in system tiddlers are defined in inline script
if(!$tw.utils.hop($tw.modules.titles,tiddler.fields.title)) { if(!$tw.utils.hop($tw.modules.titles,tiddler.fields.title)) {
@ -2043,7 +2043,7 @@ $tw.loadTiddlersFromSpecification = function(filepath,excludeRegExp) {
arrayOfFiles = arrayOfFiles || []; arrayOfFiles = arrayOfFiles || [];
var files = fs.readdirSync(dirPath); var files = fs.readdirSync(dirPath);
files.forEach(function(file) { files.forEach(function(file) {
if (recurse && fs.statSync(dirPath + path.sep + file).isDirectory()) { if(recurse && fs.statSync(dirPath + path.sep + file).isDirectory()) {
arrayOfFiles = getAllFiles(dirPath + path.sep + file, recurse, arrayOfFiles); arrayOfFiles = getAllFiles(dirPath + path.sep + file, recurse, arrayOfFiles);
} else if(fs.statSync(dirPath + path.sep + file).isFile()){ } else if(fs.statSync(dirPath + path.sep + file).isFile()){
arrayOfFiles.push(path.join(dirPath, path.sep, file)); arrayOfFiles.push(path.join(dirPath, path.sep, file));
@ -2188,13 +2188,16 @@ Returns an array of search paths
*/ */
$tw.getLibraryItemSearchPaths = function(libraryPath,envVar) { $tw.getLibraryItemSearchPaths = function(libraryPath,envVar) {
var pluginPaths = [path.resolve($tw.boot.corePath,libraryPath)], var pluginPaths = [path.resolve($tw.boot.corePath,libraryPath)],
env;
if(envVar) {
env = process.env[envVar]; env = process.env[envVar];
if(env) { if(env) {
env.split(path.delimiter).map(function(item) { env.split(path.delimiter).map(function(item) {
if(item) { if(item) {
pluginPaths.push(item); pluginPaths.push(item);
} }
}); });
}
} }
return pluginPaths; return pluginPaths;
}; };
@ -2280,7 +2283,7 @@ $tw.loadWikiTiddlers = function(wikiPath,options) {
} }
$tw.wiki.addTiddlers(tiddlerFile.tiddlers); $tw.wiki.addTiddlers(tiddlerFile.tiddlers);
}); });
if ($tw.boot.wikiPath == wikiPath) { if($tw.boot.wikiPath == wikiPath) {
// Save the original tiddler file locations if requested // Save the original tiddler file locations if requested
var output = {}, relativePath, fileInfo; var output = {}, relativePath, fileInfo;
for(var title in $tw.boot.files) { for(var title in $tw.boot.files) {
@ -2634,14 +2637,14 @@ $tw.boot.doesTaskMatchPlatform = function(taskModule) {
var platforms = taskModule.platforms; var platforms = taskModule.platforms;
if(platforms) { if(platforms) {
for(var t=0; t<platforms.length; t++) { for(var t=0; t<platforms.length; t++) {
switch (platforms[t]) { switch(platforms[t]) {
case "browser": case "browser":
if ($tw.browser) { if($tw.browser) {
return true; return true;
} }
break; break;
case "node": case "node":
if ($tw.node) { if($tw.node) {
return true; return true;
} }
break; break;
@ -2724,7 +2727,7 @@ Invoke the hook by key
$tw.hooks.invokeHook = function(hookName /*, value,... */) { $tw.hooks.invokeHook = function(hookName /*, value,... */) {
var args = Array.prototype.slice.call(arguments,1); var args = Array.prototype.slice.call(arguments,1);
if($tw.utils.hop($tw.hooks.names,hookName)) { if($tw.utils.hop($tw.hooks.names,hookName)) {
for (var i = 0; i < $tw.hooks.names[hookName].length; i++) { for(var i = 0; i < $tw.hooks.names[hookName].length; i++) {
args[0] = $tw.hooks.names[hookName][i].apply(null,args); args[0] = $tw.hooks.names[hookName][i].apply(null,args);
} }
} }

View File

@ -1,3 +0,0 @@
title: $:/library/sjcl.js
type: application/javascript
library: yes

35
boot/tiddlywiki.files Normal file
View File

@ -0,0 +1,35 @@
{
"tiddlers": [
{
"file": "sjcl.js",
"fields": {
"title": "$:/library/sjcl.js",
"type": "application/javascript",
"library": "yes"
},
"prefix": "(function(define) {\n",
"suffix": "\n})(function (_,defined){window.sjcl = defined()})\n"
},
{
"file": "boot.js",
"fields": {
"title": "$:/boot/boot.js",
"type": "application/javascript"
}
},
{
"file": "bootprefix.js",
"fields": {
"title": "$:/boot/bootprefix.js",
"type": "application/javascript"
}
},
{
"file": "boot.css",
"fields": {
"title": "$:/boot/boot.css",
"type": "text/css"
}
}
]
}

View File

@ -70,6 +70,9 @@ BackSubIndexer.prototype.rebuild = function() {
* Get things that is being referenced in the text, e.g. tiddler names in the link syntax. * Get things that is being referenced in the text, e.g. tiddler names in the link syntax.
*/ */
BackSubIndexer.prototype._getTarget = function(tiddler) { BackSubIndexer.prototype._getTarget = function(tiddler) {
if(this.wiki.isBinaryTiddler(tiddler.fields.text)) {
return [];
}
var parser = this.wiki.parseText(tiddler.fields.type, tiddler.fields.text, {}); var parser = this.wiki.parseText(tiddler.fields.type, tiddler.fields.text, {});
if(parser) { if(parser) {
return this.wiki[this.extractor](parser.tree); return this.wiki[this.extractor](parser.tree);

View File

@ -0,0 +1,23 @@
/*\
title: $:/core/modules/utils/errors.js
type: application/javascript
module-type: utils
Custom errors for TiddlyWiki.
\*/
(function(){
function TranscludeRecursionError() {
Error.apply(this,arguments);
this.signatures = Object.create(null);
};
/* Maximum permitted depth of the widget tree for recursion detection */
TranscludeRecursionError.MAX_WIDGET_TREE_DEPTH = 1000;
TranscludeRecursionError.prototype = Object.create(Error);
exports.TranscludeRecursionError = TranscludeRecursionError;
})();

View File

@ -42,7 +42,7 @@ var TW_TextNode = function(text) {
this.textContent = text + ""; this.textContent = text + "";
}; };
Object.setPrototypeOf(TW_TextNode,TW_Node.prototype); Object.setPrototypeOf(TW_TextNode.prototype,TW_Node.prototype);
Object.defineProperty(TW_TextNode.prototype, "nodeType", { Object.defineProperty(TW_TextNode.prototype, "nodeType", {
get: function() { get: function() {
@ -67,7 +67,7 @@ var TW_Element = function(tag,namespace) {
this.namespaceURI = namespace || "http://www.w3.org/1999/xhtml"; this.namespaceURI = namespace || "http://www.w3.org/1999/xhtml";
}; };
Object.setPrototypeOf(TW_Element,TW_Node.prototype); Object.setPrototypeOf(TW_Element.prototype,TW_Node.prototype);
Object.defineProperty(TW_Element.prototype, "style", { Object.defineProperty(TW_Element.prototype, "style", {
get: function() { get: function() {

View File

@ -14,8 +14,12 @@ Utilities for working with the TiddlyWiki repository file structure
/* /*
Get an object containing all the plugins as a hashmap by title of the JSON representation of the plugin Get an object containing all the plugins as a hashmap by title of the JSON representation of the plugin
Options:
ignoreEnvironmentVariables: defaults to false
*/ */
exports.getAllPlugins = function() { exports.getAllPlugins = function(options) {
options = options || {};
var fs = require("fs"), var fs = require("fs"),
path = require("path"), path = require("path"),
tiddlers = {}; tiddlers = {};
@ -39,9 +43,9 @@ exports.getAllPlugins = function() {
} }
} }
}; };
$tw.utils.each($tw.getLibraryItemSearchPaths($tw.config.pluginsPath,$tw.config.pluginsEnvVar),collectPublisherPlugins); $tw.utils.each($tw.getLibraryItemSearchPaths($tw.config.pluginsPath,options.ignoreEnvironmentVariables ? undefined : $tw.config.pluginsEnvVar),collectPublisherPlugins);
$tw.utils.each($tw.getLibraryItemSearchPaths($tw.config.themesPath,$tw.config.themesEnvVar),collectPublisherPlugins); $tw.utils.each($tw.getLibraryItemSearchPaths($tw.config.themesPath,options.ignoreEnvironmentVariables ? undefined : $tw.config.themesEnvVar),collectPublisherPlugins);
$tw.utils.each($tw.getLibraryItemSearchPaths($tw.config.languagesPath,$tw.config.languagesEnvVar),collectPlugins); $tw.utils.each($tw.getLibraryItemSearchPaths($tw.config.languagesPath,options.ignoreEnvironmentVariables ? undefined : $tw.config.languagesEnvVar),collectPlugins);
return tiddlers; return tiddlers;
}; };

View File

@ -825,7 +825,7 @@ options.length .. number of characters returned defaults to 64
*/ */
exports.sha256 = function(str, options) { exports.sha256 = function(str, options) {
options = options || {} options = options || {}
return sjcl.codec.hex.fromBits(sjcl.hash.sha256.hash(str)).substr(0,options.length || 64); return $tw.sjcl.codec.hex.fromBits($tw.sjcl.hash.sha256.hash(str)).substr(0,options.length || 64);
} }
/* /*

View File

@ -77,8 +77,13 @@ TestCaseWidget.prototype.render = function(parent,nextSibling) {
this.setVariable("transclusion",$tw.utils.hashString(jsonPayload)); this.setVariable("transclusion",$tw.utils.hashString(jsonPayload));
// Generate a `payloadTiddlers` variable that contains the payload in JSON format // Generate a `payloadTiddlers` variable that contains the payload in JSON format
this.setVariable("payloadTiddlers",jsonPayload); this.setVariable("payloadTiddlers",jsonPayload);
// Only run the tests if the testcase output and expected results were specified, and those tiddlers actually exist in the wiki
var shouldRunTests = false;
if(this.testcaseTestOutput && this.testcaseWiki.tiddlerExists(this.testcaseTestOutput) && this.testcaseTestExpectedResult && this.testcaseWiki.tiddlerExists(this.testcaseTestExpectedResult)) {
shouldRunTests = true;
}
// Render the test rendering if required // Render the test rendering if required
if(this.testcaseTestOutput && this.testcaseTestExpectedResult) { if(shouldRunTests) {
var testcaseOutputContainer = $tw.fakeDocument.createElement("div"); var testcaseOutputContainer = $tw.fakeDocument.createElement("div");
var testcaseOutputWidget = this.testcaseWiki.makeTranscludeWidget(this.testcaseTestOutput,{ var testcaseOutputWidget = this.testcaseWiki.makeTranscludeWidget(this.testcaseTestOutput,{
document: $tw.fakeDocument, document: $tw.fakeDocument,
@ -101,7 +106,7 @@ TestCaseWidget.prototype.render = function(parent,nextSibling) {
var testResult = "", var testResult = "",
outputHTML = "", outputHTML = "",
expectedHTML = ""; expectedHTML = "";
if(this.testcaseTestOutput && this.testcaseTestExpectedResult) { if(shouldRunTests) {
outputHTML = testcaseOutputContainer.children[0].innerHTML; outputHTML = testcaseOutputContainer.children[0].innerHTML;
expectedHTML = this.testcaseWiki.getTiddlerText(this.testcaseTestExpectedResult); expectedHTML = this.testcaseWiki.getTiddlerText(this.testcaseTestExpectedResult);
if(outputHTML === expectedHTML) { if(outputHTML === expectedHTML) {
@ -115,7 +120,7 @@ TestCaseWidget.prototype.render = function(parent,nextSibling) {
this.setVariable("currentTiddler",this.testcaseTestOutput); this.setVariable("currentTiddler",this.testcaseTestOutput);
} }
// Don't display anything if testHideIfPass is "yes" and the tests have passed // Don't display anything if testHideIfPass is "yes" and the tests have passed
if(this.testcaseHideIfPass === "yes" && testResult === "pass") { if(this.testcaseHideIfPass === "yes" && testResult !== "fail") {
return; return;
} }
// Render the page root template of the subwiki // Render the page root template of the subwiki

View File

@ -30,7 +30,30 @@ TranscludeWidget.prototype.render = function(parent,nextSibling) {
this.parentDomNode = parent; this.parentDomNode = parent;
this.computeAttributes(); this.computeAttributes();
this.execute(); this.execute();
this.renderChildren(parent,nextSibling); try {
this.renderChildren(parent,nextSibling);
} catch(error) {
if(error instanceof $tw.utils.TranscludeRecursionError) {
// We were infinite looping.
// We need to try and abort as much of the loop as we can, so we will keep "throwing" upward until we find a transclusion that has a different signature.
// Hopefully that will land us just outside where the loop began. That's where we want to issue an error.
// Rendering widgets beneath this point may result in a freezing browser if they explode exponentially.
var transcludeSignature = this.getVariable("transclusion");
if(this.getAncestorCount() > $tw.utils.TranscludeRecursionError.MAX_WIDGET_TREE_DEPTH - 50) {
// For the first fifty transcludes we climb up, we simply collect signatures.
// We're assuming that those first 50 will likely include all transcludes involved in the loop.
error.signatures[transcludeSignature] = true;
} else if(!error.signatures[transcludeSignature]) {
// Now that we're past the first 50, let's look for the first signature that wasn't in the loop. That'll be where we print the error and resume rendering.
this.children = [this.makeChildWidget({type: "error", attributes: {
"$message": {type: "string", value: $tw.language.getString("Error/RecursiveTransclusion")}
}})];
this.renderChildren(parent,nextSibling);
return;
}
}
throw error;
}
}; };
/* /*

View File

@ -12,9 +12,6 @@ Widget base class
/*global $tw: false */ /*global $tw: false */
"use strict"; "use strict";
/* Maximum permitted depth of the widget tree for recursion detection */
var MAX_WIDGET_TREE_DEPTH = 1000;
/* /*
Create a widget object for a parse tree node Create a widget object for a parse tree node
parseTreeNode: reference to the parse tree node to be rendered parseTreeNode: reference to the parse tree node to be rendered
@ -166,6 +163,8 @@ Widget.prototype.getVariableInfo = function(name,options) {
}); });
resultList = this.wiki.filterTiddlers(value,this.makeFakeWidgetWithVariables(variables),options.source); resultList = this.wiki.filterTiddlers(value,this.makeFakeWidgetWithVariables(variables),options.source);
value = resultList[0] || ""; value = resultList[0] || "";
} else {
params = variable.params;
} }
return { return {
text: value, text: value,
@ -494,10 +493,8 @@ Widget.prototype.makeChildWidgets = function(parseTreeNodes,options) {
this.children = []; this.children = [];
var self = this; var self = this;
// Check for too much recursion // Check for too much recursion
if(this.getAncestorCount() > MAX_WIDGET_TREE_DEPTH) { if(this.getAncestorCount() > $tw.utils.TranscludeRecursionError.MAX_WIDGET_TREE_DEPTH) {
this.children.push(this.makeChildWidget({type: "error", attributes: { throw new $tw.utils.TranscludeRecursionError();
"$message": {type: "string", value: $tw.language.getString("Error/RecursiveTransclusion")}
}}));
} else { } else {
// Create set variable widgets for each variable // Create set variable widgets for each variable
$tw.utils.each(options.variables,function(value,name) { $tw.utils.each(options.variables,function(value,name) {

View File

@ -5,6 +5,7 @@ title: $:/core/ui/TestCaseTemplate
<$let <$let
linkTarget="yes" linkTarget="yes"
displayFormat={{!!display-format}} displayFormat={{!!display-format}}
testcaseTiddler=<<currentTiddler>>
> >
<$testcase <$testcase
testOutput="Output" testOutput="Output"

View File

@ -15,7 +15,7 @@ title: $:/core/ui/testcases/DefaultTemplate
<div class="tc-test-case-wrapper"> <div class="tc-test-case-wrapper">
<div class="tc-test-case-header"> <div class="tc-test-case-header">
<h2> <h2>
<$genesis $type={{{ [<linkTarget>!match[]then[$link]else[div]] }}}> <$genesis $type={{{ [<linkTarget>!match[]then[$link]else[div]] }}} to=<<testcaseTiddler>>>
<%if [<testResult>!match[]] %> <%if [<testResult>!match[]] %>
<span class={{{ tc-test-case-result-icon [<testResult>!match[fail]then[tc-test-case-result-icon-pass]] [<testResult>match[fail]then[tc-test-case-result-icon-fail]] +[join[ ]] }}}> <span class={{{ tc-test-case-result-icon [<testResult>!match[fail]then[tc-test-case-result-icon-pass]] [<testResult>match[fail]then[tc-test-case-result-icon-fail]] +[join[ ]] }}}>
<%if [<testResult>!match[fail]] %> <%if [<testResult>!match[fail]] %>
@ -55,7 +55,9 @@ title: $:/core/ui/testcases/DefaultTemplate
<pre><$view tiddler="Output" format="plainwikified" mode="block"/></pre> <pre><$view tiddler="Output" format="plainwikified" mode="block"/></pre>
<%else%> <%else%>
<$linkcatcher actions=<<linkcatcherActions>>> <$linkcatcher actions=<<linkcatcherActions>>>
<$transclude $tiddler="Output" $mode="block"/> <$tiddler tiddler="Output">
<$transclude $tiddler="Output" $mode="block"/>
</$tiddler>
</$linkcatcher> </$linkcatcher>
<%endif%> <%endif%>
</div> </div>

View File

@ -1,6 +1,6 @@
caption: {{$:/language/OfficialPluginLibrary}}
tags: $:/tags/PluginLibrary
title: $:/config/OfficialPluginLibrary title: $:/config/OfficialPluginLibrary
url: https://tiddlywiki5-git-plugin-stability-badges-jermolenes-projects.vercel.app/library/v5.3.3/index.html tags: $:/tags/PluginLibrary
url: https://tiddlywiki.com/library/v5.3.4/index.html
caption: {{$:/language/OfficialPluginLibrary}}
Plugin library for https://tiddlywiki5-git-plugin-stability-badges-jermolenes-projects.vercel.app {{$:/language/OfficialPluginLibrary/Hint}}

View File

@ -1,6 +1,6 @@
caption: 5.3.4 caption: 5.3.4
created: 20231223102229103 created: 20240529100240232
modified: 20231223102229103 modified: 20240529100240232
tags: ReleaseNotes tags: ReleaseNotes
title: Release 5.3.4 title: Release 5.3.4
type: text/vnd.tiddlywiki type: text/vnd.tiddlywiki
@ -10,6 +10,8 @@ description: Under development
! Major Improvements ! Major Improvements
!! Tour Plugin
<<.link-badge-added "https://github.com/Jermolene/TiddlyWiki5/pull/7734">> several new features that together allow interactive learning tours to be created and presented in TiddlyWiki. <<.link-badge-added "https://github.com/Jermolene/TiddlyWiki5/pull/7734">> several new features that together allow interactive learning tours to be created and presented in TiddlyWiki.
The demo TiddlyWiki interactive tour can be seen at https://tiddlywiki.com/prerelease/tour The demo TiddlyWiki interactive tour can be seen at https://tiddlywiki.com/prerelease/tour
@ -20,6 +22,20 @@ The new features include:
* The new Confetti Plugin that allows animated bursts of confetti to be displayed * The new Confetti Plugin that allows animated bursts of confetti to be displayed
* Improvements to the Dynannotate Plugin to add the ability to highlight screen elements using an animated spotlight effect * Improvements to the Dynannotate Plugin to add the ability to highlight screen elements using an animated spotlight effect
!! <<.wlink TestCaseWidget>> Widget
<<.link-badge-added "https://github.com/Jermolene/TiddlyWiki5/pull/7817">> new <<.wlink TestCaseWidget>> widget that is intended to solve a problem with the examples that we feature in the documentation. The existing macros are workable for simple, self-contained examples, but can be hard to follow in cases where the examples use additional tiddlers. The <<.wlink TestCaseWidget>> widget displays complete, self-contained interactive examples showing the output together with a tabbed display of the constituent tiddlers that produce it:
<<testcase "TestCases/TestCaseWidget/TwoPlusTwo">>
The payload tiddlers for a test case are specified with the <<.wlink DataWidget>> widget. Test cases are run as an independent, self-contained nested wiki in a similar way to the [[Innerwiki Plugin]], but are much more lightweight. The disadvantage is that test cases are rendered as part of the main page, and so any styling changes will leak out to the rest of the page.
Test cases can also specify the raw HTML of the expected result which causes them to be executed as tests, with success or failure indicated by an icon:
<<testcase "TestCases/TestCaseWidget/FailingTest">>
The easiest way to use the <<.wlink TestCaseWidget>> is by creating TestCaseTiddlers using the new CompoundTiddlers format. There are also many test cases to view in the TiddlyWiki test edition at https://tiddlywiki.com/prerelease/test.html
! Translation improvements ! Translation improvements
Improvements to the following translations: Improvements to the following translations:
@ -30,7 +46,7 @@ Improvements to the following translations:
! Plugin Improvements ! Plugin Improvements
* * <<.link-badge-added "https://github.com/Jermolene/TiddlyWiki5/pull/8198">> badges to the core plugins to indicate their [[stability level|Plugin Stability]] from "deprecated", "experimental", "stable" and "legacy". These badges are shown in the plugin library and in the control panel
! Widget Improvements ! Widget Improvements
@ -46,11 +62,13 @@ Improvements to the following translations:
! Hackability Improvements ! Hackability Improvements
* <<.link-badge-improved "https://github.com/Jermolene/TiddlyWiki5/pull/7882">> infinite recursion handling using a custom exception
* <<.link-badge-added "https://github.com/Jermolene/TiddlyWiki5/pull/7966">> button to the JavaScript error popup allowing tiddlers to be saved to a local JSON file * <<.link-badge-added "https://github.com/Jermolene/TiddlyWiki5/pull/7966">> button to the JavaScript error popup allowing tiddlers to be saved to a local JSON file
* <<.link-badge-updated "https://github.com/Jermolene/TiddlyWiki5/issues/8120">> to latest version of modern-normalize 2.0.0 * <<.link-badge-updated "https://github.com/Jermolene/TiddlyWiki5/issues/8120">> to latest version of modern-normalize 2.0.0
! Bug Fixes ! Bug Fixes
* <<.link-badge-fixed "https://github.com/Jermolene/TiddlyWiki5/pull/8186">> nested [[Block Quotes in WikiText]]
* <<.link-badge-fixed "https://github.com/Jermolene/TiddlyWiki5/pull/7933">> TiddlyWikiClassic build process * <<.link-badge-fixed "https://github.com/Jermolene/TiddlyWiki5/pull/7933">> TiddlyWikiClassic build process
* <<.link-badge-fixed "https://github.com/Jermolene/TiddlyWiki5/pull/7935">> LinkWidget not refreshing when the `to` attribute changes * <<.link-badge-fixed "https://github.com/Jermolene/TiddlyWiki5/pull/7935">> LinkWidget not refreshing when the `to` attribute changes
* <<.link-badge-fixed "https://github.com/Jermolene/TiddlyWiki5/issues/3460">> parsing bug with empty procedures/macros * <<.link-badge-fixed "https://github.com/Jermolene/TiddlyWiki5/issues/3460">> parsing bug with empty procedures/macros
@ -79,7 +97,8 @@ Improvements to the following translations:
! Developer Improvements ! Developer Improvements
* * <<.link-badge-fixed "https://github.com/Jermolene/TiddlyWiki5/pull/8195">> issue with fakedom TW_Node inheritence
* <<.link-badge-fixed "https://github.com/Jermolene/TiddlyWiki5/pull/8099">> SJCL library creating variables in global scope
! Infrastructure Improvements ! Infrastructure Improvements
@ -114,5 +133,6 @@ rmunn
saqimtiaz saqimtiaz
sarna sarna
Telumire Telumire
twMat
yaisog yaisog
""">> """>>

View File

@ -1,6 +1,6 @@
caption: {{$:/language/OfficialPluginLibrary}}
tags: $:/tags/PluginLibrary
title: $:/config/OfficialPluginLibrary title: $:/config/OfficialPluginLibrary
url: https://tiddlywiki5-git-plugin-stability-badges-jermolenes-projects.vercel.app/library/v5.3.3/index.html tags: $:/tags/PluginLibrary
url: https://tiddlywiki.com/prerelease/library/v5.3.4/index.html
caption: {{$:/language/OfficialPluginLibrary}} (Prerelease)
Plugin library for https://tiddlywiki5-git-plugin-stability-badges-jermolenes-projects.vercel.app The prerelease version of the official ~TiddlyWiki plugin library at tiddlywiki.com. Plugins, themes and language packs are maintained by the core team.

View File

@ -7,7 +7,8 @@ title: Output
\whitespace trim \whitespace trim
<$transclude $tiddler="Output"/> <$transclude $tiddler="Output"/>
+ +
title: ExpectedResult title: ExpectedResult
<p><span class="tc-error">Recursive transclusion error in transclude widget</span></p> <span class="tc-error">Recursive transclusion error in transclude widget</span>

View File

@ -12,6 +12,24 @@ Tests the backlinks mechanism.
"use strict"; "use strict";
describe('Backlinks tests', function() { describe('Backlinks tests', function() {
function setupWiki(wikiOptions) {
wikiOptions = wikiOptions || {};
// Create a wiki
var wiki = new $tw.Wiki(wikiOptions);
wiki.addIndexersToWiki();
wiki.addTiddler({
title: 'TestIncoming',
text: '',
});
wiki.addTiddler({
title: 'TestOutgoing',
text: 'A link to [[TestIncoming]]',
});
return wiki;
}
describe('a tiddler with no links to it', function() { describe('a tiddler with no links to it', function() {
var wiki = new $tw.Wiki(); var wiki = new $tw.Wiki();
@ -25,15 +43,7 @@ describe('Backlinks tests', function() {
}); });
describe('A tiddler added to the wiki with a link to it', function() { describe('A tiddler added to the wiki with a link to it', function() {
var wiki = new $tw.Wiki(); var wiki = setupWiki();
wiki.addTiddler({
title: 'TestIncoming',
text: ''});
wiki.addTiddler({
title: 'TestOutgoing',
text: 'A link to [[TestIncoming]]'});
it('should have a backlink', function() { it('should have a backlink', function() {
expect(wiki.filterTiddlers('TestIncoming +[backlinks[]]').join(',')).toBe('TestOutgoing'); expect(wiki.filterTiddlers('TestIncoming +[backlinks[]]').join(',')).toBe('TestOutgoing');
@ -42,15 +52,7 @@ describe('Backlinks tests', function() {
describe('A tiddler that has a link added to it later', function() { describe('A tiddler that has a link added to it later', function() {
it('should have an additional backlink', function() { it('should have an additional backlink', function() {
var wiki = new $tw.Wiki(); var wiki = setupWiki();
wiki.addTiddler({
title: 'TestIncoming',
text: ''});
wiki.addTiddler({
title: 'TestOutgoing',
text: 'A link to [[TestIncoming]]'});
wiki.addTiddler({ wiki.addTiddler({
title: 'TestOutgoing2', title: 'TestOutgoing2',
@ -67,15 +69,7 @@ describe('Backlinks tests', function() {
}); });
describe('A tiddler that has a link remove from it later', function() { describe('A tiddler that has a link remove from it later', function() {
var wiki = new $tw.Wiki(); var wiki = setupWiki();
wiki.addTiddler({
title: 'TestIncoming',
text: ''});
wiki.addTiddler({
title: 'TestOutgoing',
text: 'A link to [[TestIncoming]]'});
it('should have one fewer backlink', function() { it('should have one fewer backlink', function() {
expect(wiki.filterTiddlers('TestIncoming +[backlinks[]]').join(',')).toBe('TestOutgoing'); expect(wiki.filterTiddlers('TestIncoming +[backlinks[]]').join(',')).toBe('TestOutgoing');
@ -89,15 +83,7 @@ describe('Backlinks tests', function() {
}); });
describe('A tiddler linking to another that gets renamed', function() { describe('A tiddler linking to another that gets renamed', function() {
var wiki = new $tw.Wiki(); var wiki = setupWiki();
wiki.addTiddler({
title: 'TestIncoming',
text: ''});
wiki.addTiddler({
title: 'TestOutgoing',
text: 'A link to [[TestIncoming]]'});
it('should have its name changed in the backlinks', function() { it('should have its name changed in the backlinks', function() {
expect(wiki.filterTiddlers('TestIncoming +[backlinks[]]').join(',')).toBe('TestOutgoing'); expect(wiki.filterTiddlers('TestIncoming +[backlinks[]]').join(',')).toBe('TestOutgoing');
@ -109,15 +95,7 @@ describe('Backlinks tests', function() {
}); });
describe('A tiddler linking to another that gets deleted', function() { describe('A tiddler linking to another that gets deleted', function() {
var wiki = new $tw.Wiki(); var wiki = setupWiki();
wiki.addTiddler({
title: 'TestIncoming',
text: ''});
wiki.addTiddler({
title: 'TestOutgoing',
text: 'A link to [[TestIncoming]]'});
it('should be removed from backlinks', function() { it('should be removed from backlinks', function() {
expect(wiki.filterTiddlers('TestIncoming +[backlinks[]]').join(',')).toBe('TestOutgoing'); expect(wiki.filterTiddlers('TestIncoming +[backlinks[]]').join(',')).toBe('TestOutgoing');
@ -127,6 +105,41 @@ describe('Backlinks tests', function() {
expect(wiki.filterTiddlers('TestIncoming +[backlinks[]]').join(',')).toBe(''); expect(wiki.filterTiddlers('TestIncoming +[backlinks[]]').join(',')).toBe('');
}); });
}); });
describe('Binary tiddlers should not be parsed', function() {
var wiki = setupWiki();
wiki.addTiddler({
title: 'TestDoc.doc',
text: 'A link to [[TestOutgoing]]',
type: 'application/msword'
});
wiki.addTiddler({
title: 'TestExcel.xls',
text: 'A link to [[TestOutgoing]]',
type: 'application/excel'
});
wiki.addTiddler({
title: 'TestOutgoing',
text: 'Some links to [[TestDoc.doc]] and [[TestExcel.xls]].'
});
it('should ignore office files', function() {
expect(wiki.getIndexer("BackIndexer").subIndexers.link._getTarget(wiki.getTiddler('TestExcel.xls'))).toEqual([]);
expect(wiki.filterTiddlers('[all[]] +[backlinks[]]').join(',')).toBe('TestOutgoing');
// make it tw5 tiddler
wiki.addTiddler({
title: 'TestExcel.xls',
text: 'A link to [[TestOutgoing]]'
});
expect(wiki.filterTiddlers('[all[]] +[backlinks[]]').join(',')).toBe('TestOutgoing,TestExcel.xls');
});
});
}); });
})(); })();

View File

@ -0,0 +1,27 @@
/*\
title: test-fakedom.js
type: application/javascript
tags: [[$:/tags/test-spec]]
Tests the fakedom that Tiddlywiki occasionally uses.
\*/
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
describe("fakedom tests", function() {
it("properly assigns nodeType based on DOM standards", function() {
// According to MDN, ELEMENT_NODE == 1 && TEXT_NODE == 3
// There are others, but currently they're not implemented in fakedom
expect($tw.fakeDocument.createElement("div").nodeType).toBe(1);
expect($tw.fakeDocument.createElement("div").ELEMENT_NODE).toBe(1);
expect($tw.fakeDocument.createTextNode("text").nodeType).toBe(3);
expect($tw.fakeDocument.createTextNode("text").TEXT_NODE).toBe(3);
});
});
})();

View File

@ -17,7 +17,7 @@ if($tw.node) {
describe("Plugin tests", function() { describe("Plugin tests", function() {
// Get all the plugins as a hashmap by title of a JSON string with the plugin content // Get all the plugins as a hashmap by title of a JSON string with the plugin content
var tiddlers = $tw.utils.getAllPlugins(); var tiddlers = $tw.utils.getAllPlugins({ignoreEnvironmentVariables: true});
// console.log(JSON.stringify(Object.keys(tiddlers),null,4)); // console.log(JSON.stringify(Object.keys(tiddlers),null,4));
describe("every plugin should have the required standard fields", function() { describe("every plugin should have the required standard fields", function() {
var titles = Object.keys(tiddlers); var titles = Object.keys(tiddlers);

View File

@ -0,0 +1,95 @@
/*\
title: test-widget-getVariableInfo.js
type: application/javascript
tags: [[$:/tags/test-spec]]
Tests the wikitext rendering pipeline end-to-end. We also need tests that individually test parsers, rendertreenodes etc., but this gets us started.
\*/
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
describe("Widget module", function() {
var widget = require("$:/core/modules/widgets/widget.js");
function createWidgetNode(parseTreeNode,wiki) {
return new widget.widget(parseTreeNode,{
wiki: wiki,
document: $tw.fakeDocument
});
}
function parseText(text,wiki,options) {
var parser = wiki.parseText("text/vnd.tiddlywiki",text,options);
return parser ? {type: "widget", children: parser.tree} : undefined;
}
function renderWidgetNode(widgetNode) {
$tw.fakeDocument.setSequenceNumber(0);
var wrapper = $tw.fakeDocument.createElement("div");
widgetNode.render(wrapper,null);
// console.log(require("util").inspect(wrapper,{depth: 8}));
return wrapper;
}
function refreshWidgetNode(widgetNode,wrapper,changes) {
var changedTiddlers = {};
if(changes) {
$tw.utils.each(changes,function(title) {
changedTiddlers[title] = true;
});
}
widgetNode.refresh(changedTiddlers,wrapper,null);
// console.log(require("util").inspect(wrapper,{depth: 8}));
}
it("should make sure that getVariableInfo returns all expected parameters", function() {
var wiki = new $tw.Wiki();
wiki.addTiddlers([
{title: "A", text: "\\define macro(a:aa) aaa"},
{title: "B", text: "\\function fn(f:ff) fff\n\\function x() [<fn>]"},
{title: "C", text: "\\procedure proc(p:pp) ppp"},
{title: "D", text: "\\widget $my.widget(w:ww) www"}
]);
var text = "\\import A B C D\n\n<$let abc=def>";
var widgetNode = createWidgetNode(parseText(text,wiki),wiki);
// Render the widget node to the DOM
renderWidgetNode(widgetNode);
var childNode = widgetNode;
while(childNode.children.length > 0) {
childNode = childNode.children[0];
}
expect(childNode.getVariableInfo("macro",{allowSelfAssigned:true}).params).toEqual([{name:"a",value:"aa"}]);
// function params
expect(childNode.getVariableInfo("fn", {allowSelfAssigned:true}).params).toEqual([{name:"f",value:"ff"}]);
// functions have a text and a value
expect(childNode.getVariableInfo("x", {allowSelfAssigned:true}).text).toBe("fff");
expect(childNode.getVariableInfo("x", {allowSelfAssigned:true}).srcVariable.value).toBe("[<fn>]");
// procedures and widgets failed prior to v5.3.4
expect(childNode.getVariableInfo("proc", {allowSelfAssigned:true}).params).toEqual([{name:"p",default:"pp"}]);
expect(childNode.getVariableInfo("$my.widget", {allowSelfAssigned:true}).params).toEqual([{name:"w",default:"ww"}]);
// no params expected
expect(childNode.getVariableInfo("abc", {allowSelfAssigned:true})).toEqual({text:"def"});
// debugger; Find code in browser
// Find values to be compated to
// console.log("macro", childNode.getVariableInfo("macro",{allowSelfAssigned:true}));
// console.log("function", childNode.getVariableInfo("fn",{allowSelfAssigned:true}));
// console.log("function x", childNode.getVariableInfo("x",{allowSelfAssigned:true}));
// console.log("procedure", childNode.getVariableInfo("proc",{allowSelfAssigned:true}));
// console.log("widget", childNode.getVariableInfo("$my.widget",{allowSelfAssigned:true}));
// console.log("let", childNode.getVariableInfo("abc",{allowSelfAssigned:true}));
});
});
})();

View File

@ -160,6 +160,47 @@ describe("Widget module", function() {
expect(wrapper.innerHTML).toBe("<span class=\"tc-error\">Recursive transclusion error in transclude widget</span>"); expect(wrapper.innerHTML).toBe("<span class=\"tc-error\">Recursive transclusion error in transclude widget</span>");
}); });
it("should handle single-tiddler recursion with branching nodes", function() {
var wiki = new $tw.Wiki();
// Add a tiddler
wiki.addTiddlers([
{title: "TiddlerOne", text: "<$tiddler tiddler='TiddlerOne'><$transclude /> <$transclude /></$tiddler>"},
]);
// Test parse tree
var parseTreeNode = {type: "widget", children: [
{type: "transclude", attributes: {
"tiddler": {type: "string", value: "TiddlerOne"}
}}
]};
// Construct the widget node
var widgetNode = createWidgetNode(parseTreeNode,wiki);
// Render the widget node to the DOM
var wrapper = renderWidgetNode(widgetNode);
// Test the rendering
expect(wrapper.innerHTML).toBe("<span class=\"tc-error\">Recursive transclusion error in transclude widget</span> <span class=\"tc-error\">Recursive transclusion error in transclude widget</span>");
});
it("should handle many-tiddler recursion with branching nodes", function() {
var wiki = new $tw.Wiki();
// Add a tiddler
wiki.addTiddlers([
{title: "TiddlerOne", text: "<$transclude tiddler='TiddlerTwo'/> <$transclude tiddler='TiddlerTwo'/>"},
{title: "TiddlerTwo", text: "<$transclude tiddler='TiddlerOne'/>"}
]);
// Test parse tree
var parseTreeNode = {type: "widget", children: [
{type: "transclude", attributes: {
"tiddler": {type: "string", value: "TiddlerOne"}
}}
]};
// Construct the widget node
var widgetNode = createWidgetNode(parseTreeNode,wiki);
// Render the widget node to the DOM
var wrapper = renderWidgetNode(widgetNode);
// Test the rendering
expect(wrapper.innerHTML).toBe("<span class=\"tc-error\">Recursive transclusion error in transclude widget</span>");
});
it("should deal with SVG elements", function() { it("should deal with SVG elements", function() {
var wiki = new $tw.Wiki(); var wiki = new $tw.Wiki();
// Construct the widget node // Construct the widget node

View File

@ -23,5 +23,4 @@ Some payload tiddlers are set aside for special purposes:
|''Narrative'' |Narrative description of the test, intended to explain the purpose and operation of the test | |''Narrative'' |Narrative description of the test, intended to explain the purpose and operation of the test |
|''Output'' |The tiddler that produces the test output | |''Output'' |The tiddler that produces the test output |
|''~ExpectedResult'' |HTML of expected result of rendering the ''Output'' tiddler | |''~ExpectedResult'' |HTML of expected result of rendering the ''Output'' tiddler |
|''Description'' |Set to the text of the <<.field description>> field |

View File

@ -5,7 +5,7 @@ description: An example of a failing test
title: Narrative title: Narrative
This test case intentionally fails to show how failures are displayed. This test case intentionally fails (in order to show how failures are displayed)
+ +
title: Output title: Output

View File

@ -0,0 +1,12 @@
title: TestCases/TestCaseWidget/NoExpectedResults
type: text/vnd.tiddlywiki-multiple
tags: [[$:/tags/wiki-test-spec]]
description: A testcase that does not specify expected results
title: Narrative
This testcase will display without the pass/fail icons because it does not include an `ExpectedResults` tiddler, and so will only be rendered, and not be executed as a test
+
title: Output
This is the output

View File

@ -0,0 +1,18 @@
title: TestCases/TestCaseWidget/TwoPlusTwo
type: text/vnd.tiddlywiki-multiple
tags: [[$:/tags/wiki-test-spec-failing]]
description: A testcase to calculate 2+2
title: Narrative
This test case shows an elaborate way to calculate 2+2 involving multiple tiddlers
+
title: Output
The sum is <$text text={{{ [{FirstNumber}add{SecondNumber}] }}}/>
+
title: FirstNumber
text: 2
+
title: SecondNumber
text: 2

View File

@ -1,6 +1,6 @@
caption: action-listops caption: action-listops
created: 20141025120850184 created: 20141025120850184
modified: 20230805103548113 modified: 20240509135041526
myfield: myfield:
tags: ActionWidgets Widgets tags: ActionWidgets Widgets
title: ActionListopsWidget title: ActionListopsWidget
@ -35,10 +35,12 @@ The above widget will toggle the presence of the element <<.value "List Item">>
Similarly, if an element is to always be removed when it is present, the `-` / `:except` [[filter run prefix|Filter Expression]] can be used. Both of the following yield the same result: Similarly, if an element is to always be removed when it is present, the `-` / `:except` [[filter run prefix|Filter Expression]] can be used. Both of the following yield the same result:
``` ```
<$action-listops $subfilter="-[[List Item]]"/> <$action-listops $subfilter="-[[ListItem]]"/>
<$action-listops $subfilter="+[remove[List Item]]"/> <$action-listops $subfilter="+[remove[ListItem]]"/>
``` ```
<<.infoBox """Note that the parameter of the [[remove Operator]] is a [[Title List]]. To remove one or more titles containing spaces the individual titles must be wrapped in double square brackets, usually via a soft [[Filter Parameter]]. See //Filtered List Variable Assignment// in the [[SetWidget]] documentation to learn more.""">>
Without any prefixes, the filter run output is simply [[dominantly appended|Dominant Append]] to the list. Without any prefixes, the filter run output is simply [[dominantly appended|Dominant Append]] to the list.
See also the [[Examples|ActionListopsWidget (Examples)]]. See also the [[Examples|ActionListopsWidget (Examples)]].

View File

@ -75,7 +75,7 @@ The test case wiki will inherit variables that are visible to the <<.wid testcas
A custom template can be specified for special purposes. For example, the provided template $:/core/ui/testcases/RawJSONTemplate just displays the payload tiddlers in JSON, which can be used for debugging purposes. A custom template can be specified for special purposes. For example, the provided template $:/core/ui/testcases/RawJSONTemplate just displays the payload tiddlers in JSON, which can be used for debugging purposes.
! Test Czase Template Variables ! Test Case Template Variables
The <<.wid testcase>> widget makes the following variables available within the rendered template: The <<.wid testcase>> widget makes the following variables available within the rendered template:

View File

@ -30,6 +30,7 @@ name: 具可读性的插件条目的名称
parent-plugin: 对于一个插件,指定其为哪个插件的子插件 parent-plugin: 对于一个插件,指定其为哪个插件的子插件
plugin-priority: 插件条目的优先级数值 plugin-priority: 插件条目的优先级数值
plugin-type: 插件条目的类型 plugin-type: 插件条目的类型
stability: 插件的开发状态:已弃用、实验性、稳定或旧版
released: TiddlyWiki 的发布日期 released: TiddlyWiki 的发布日期
revision: 条目存放于服务器中的修订版本 revision: 条目存放于服务器中的修订版本
source: 条目的网址 source: 条目的网址

View File

@ -30,6 +30,7 @@ name: 具可讀性的套件條目的名稱
parent-plugin: 對於一個插件,指定其為哪個插件的子插件 parent-plugin: 對於一個插件,指定其為哪個插件的子插件
plugin-priority: 套件條目的優先級數值 plugin-priority: 套件條目的優先級數值
plugin-type: 套件條目的類型 plugin-type: 套件條目的類型
stability: 插件的開發狀態:已棄用、實驗性、穩定或舊版
released: TiddlyWiki 的釋出日期 released: TiddlyWiki 的釋出日期
revision: 條目存放於伺服器中的修訂版本 revision: 條目存放於伺服器中的修訂版本
source: 條目的網址 source: 條目的網址

View File

@ -34,23 +34,22 @@ describe("Wiki-based tests", function() {
if(!wiki.tiddlerExists("Output")) { if(!wiki.tiddlerExists("Output")) {
throw "Missing 'Output' tiddler"; throw "Missing 'Output' tiddler";
} }
if(!wiki.tiddlerExists("ExpectedResult")) { if(wiki.tiddlerExists("ExpectedResult")) {
throw "Missing 'ExpectedResult' tiddler"; // Construct the widget node
var text = "{{Output}}\n\n";
var widgetNode = createWidgetNode(parseText(text,wiki),wiki);
// Render the widget node to the DOM
var wrapper = renderWidgetNode(widgetNode);
// Clear changes queue
wiki.clearTiddlerEventQueue();
// Run the actions if provided
if(wiki.tiddlerExists("Actions")) {
widgetNode.invokeActionString(wiki.getTiddlerText("Actions"));
refreshWidgetNode(widgetNode,wrapper);
}
// Test the rendering
expect(wrapper.innerHTML).toBe(wiki.getTiddlerText("ExpectedResult"));
} }
// Construct the widget node
var text = "{{Output}}\n\n";
var widgetNode = createWidgetNode(parseText(text,wiki),wiki);
// Render the widget node to the DOM
var wrapper = renderWidgetNode(widgetNode);
// Clear changes queue
wiki.clearTiddlerEventQueue();
// Run the actions if provided
if(wiki.tiddlerExists("Actions")) {
widgetNode.invokeActionString(wiki.getTiddlerText("Actions"));
refreshWidgetNode(widgetNode,wrapper);
}
// Test the rendering
expect(wrapper.innerHTML).toBe(wiki.getTiddlerText("ExpectedResult"));
}); });
}); });