diff --git a/core/language/en-GB/ControlPanel.multids b/core/language/en-GB/ControlPanel.multids index d8321edbf..73c287654 100644 --- a/core/language/en-GB/ControlPanel.multids +++ b/core/language/en-GB/ControlPanel.multids @@ -206,6 +206,12 @@ Stylesheets/Caption: Stylesheets Stylesheets/Expand/Caption: Expand All Stylesheets/Hint: This is the rendered CSS of the current stylesheet tiddlers tagged with <> Stylesheets/Restore/Caption: Restore +TestCases/Caption: Test Cases +TestCases/Hint: Test cases are self contained examples for testing and learning +TestCases/All/Caption: All Test Cases +TestCases/All/Hint: All Test Cases +TestCases/Failed/Caption: Failed Test Cases +TestCases/Failed/Hint: Just Failed Test Cases Theme/Caption: Theme Theme/Prompt: Current theme: TiddlerFields/Caption: Tiddler Fields diff --git a/core/language/en-GB/Docs/PaletteColours.multids b/core/language/en-GB/Docs/PaletteColours.multids index 98addbf85..636d2d3b1 100644 --- a/core/language/en-GB/Docs/PaletteColours.multids +++ b/core/language/en-GB/Docs/PaletteColours.multids @@ -65,6 +65,9 @@ sidebar-tab-foreground-selected: Sidebar tab foreground for selected tabs sidebar-tab-foreground: Sidebar tab foreground sidebar-tiddler-link-foreground-hover: Sidebar tiddler link foreground hover sidebar-tiddler-link-foreground: Sidebar tiddler link foreground +testcase-accent-level-1: Testcase accent colour with no nesting +testcase-accent-level-2: Testcase accent colour with 2nd level nesting +testcase-accent-level-3: Testcase accent colour with 3rd level nesting or higher site-title-foreground: Site title foreground static-alert-foreground: Static alert foreground tab-background-selected: Tab background for selected tabs diff --git a/core/modules/widgets/data.js b/core/modules/widgets/data.js index 2cc5da9a3..78c6bff34 100644 --- a/core/modules/widgets/data.js +++ b/core/modules/widgets/data.js @@ -31,7 +31,10 @@ DataWidget.prototype.render = function(parent,nextSibling) { this.parentDomNode = parent; this.computeAttributes(); this.execute(); - this.renderChildren(parent,nextSibling); + var jsonPayload = JSON.stringify(this.readDataTiddlerValues(),null,4); + var textNode = this.document.createTextNode(jsonPayload); + parent.insertBefore(textNode,nextSibling); + this.domNodes.push(textNode); }; /* @@ -61,7 +64,10 @@ DataWidget.prototype.readDataTiddlerValues = function() { if(this.hasAttribute("$tiddler")) { title = this.getAttribute("$tiddler"); if(title) { - tiddlers.push(this.wiki.getTiddler(title)); + var tiddler = this.wiki.getTiddler(title); + if(tiddler) { + tiddlers.push(tiddler); + } } } if(this.hasAttribute("$filter")) { diff --git a/core/modules/widgets/testcase.js b/core/modules/widgets/testcase.js index 1ebb1b7c1..fe80f2b63 100644 --- a/core/modules/widgets/testcase.js +++ b/core/modules/widgets/testcase.js @@ -79,8 +79,52 @@ TestCaseWidget.prototype.render = function(parent,nextSibling) { this.setVariable("transclusion",$tw.utils.hashString(jsonPayload)); // Generate a `payloadTiddlers` variable that contains the payload in JSON format this.setVariable("payloadTiddlers",jsonPayload); + // Render the test rendering if required + if(this.testcaseTestOutput && this.testcaseTestExpectedResult) { + var testcaseOutputContainer = $tw.fakeDocument.createElement("div"); + var testcaseOutputWidget = this.testcaseWiki.makeTranscludeWidget(this.testcaseTestOutput,{ + document: $tw.fakeDocument, + parseAsInline: false, + parentWidget: this, + variables: { + currentTiddler: this.testcaseTestOutput + } + }); + testcaseOutputWidget.render(testcaseOutputContainer); + } + // Clear changes queue + this.testcaseWiki.clearTiddlerEventQueue(); + // Run the actions if provided + if(this.testcaseWiki.tiddlerExists(this.testcaseTestActions)) { + testcaseOutputWidget.invokeActionString(this.testcaseWiki.getTiddlerText(this.testcaseTestActions)); + testcaseOutputWidget.refresh(this.testcaseWiki.changedTiddlers,testcaseOutputContainer); + } + // Set up the test result variables + var testResult = "", + outputHTML = "", + expectedHTML = ""; + if(this.testcaseTestOutput && this.testcaseTestExpectedResult) { + outputHTML = testcaseOutputContainer.children[0].innerHTML; + expectedHTML = this.testcaseWiki.getTiddlerText(this.testcaseTestExpectedResult); + if(outputHTML === expectedHTML) { + testResult = "pass"; + } else { + testResult = "fail"; + } + this.setVariable("outputHTML",outputHTML); + this.setVariable("expectedHTML",expectedHTML); + this.setVariable("testResult",testResult); + } + // Don't display anything if testHideIfPass is "yes" and the tests have passed + if(this.testcaseHideIfPass === "yes" && testResult === "pass") { + return; + } // Render the page root template of the subwiki - var rootWidget = this.testcaseWiki.makeTranscludeWidget(this.testcaseTemplate,{document: this.document, parseAsInline: false, parentWidget: this}); + var rootWidget = this.testcaseWiki.makeTranscludeWidget(this.testcaseTemplate,{ + document: this.document, + parseAsInline: false, + parentWidget: this + }); rootWidget.render(domNode); // Trap changes in the wiki and refresh the rendering this.testcaseWiki.addEventListener("change",function(changes) { @@ -93,6 +137,10 @@ Compute the internal state of the widget */ TestCaseWidget.prototype.execute = function() { this.testcaseTemplate = this.getAttribute("template","$:/core/ui/testcases/DefaultTemplate"); + this.testcaseTestOutput = this.getAttribute("testOutput"); + this.testcaseTestActions = this.getAttribute("testActions"); + this.testcaseTestExpectedResult = this.getAttribute("testExpectedResult"); + this.testcaseHideIfPass = this.getAttribute("testHideIfPass"); }; /* diff --git a/core/palettes/Vanilla.tid b/core/palettes/Vanilla.tid index 4c660e912..c7c800046 100644 --- a/core/palettes/Vanilla.tid +++ b/core/palettes/Vanilla.tid @@ -95,6 +95,9 @@ table-footer-background: #a8a8a8 table-header-background: #f0f0f0 tag-background: #ec6 tag-foreground: #ffffff +testcase-accent-level-1: #84C5E6 +testcase-accent-level-2: #E3B740 +testcase-accent-level-3: #5FD564 tiddler-background: <> tiddler-border: <> tiddler-controls-foreground-hover: #888888 diff --git a/core/ui/ControlPanel/TestCases.tid b/core/ui/ControlPanel/TestCases.tid new file mode 100644 index 000000000..401e14113 --- /dev/null +++ b/core/ui/ControlPanel/TestCases.tid @@ -0,0 +1,10 @@ +title: $:/core/ui/ControlPanel/TestCases +tags: $:/tags/ControlPanel/Advanced +caption: {{$:/language/ControlPanel/TestCases/Caption}} + +\whitespace trim +{{$:/language/ControlPanel/TestCases/Hint}} + +
+<$macrocall $name="tabs" tabsList="[all[shadows+tiddlers]tag[$:/tags/ControlPanel/TestCases]!has[draft.of]]" default="$:/core/ui/ControlPanel/TestCases/All"/> +
diff --git a/core/ui/ControlPanel/TestCasesAll.tid b/core/ui/ControlPanel/TestCasesAll.tid new file mode 100644 index 000000000..571fb93c2 --- /dev/null +++ b/core/ui/ControlPanel/TestCasesAll.tid @@ -0,0 +1,24 @@ +title: $:/core/ui/ControlPanel/TestCases/All +tags: $:/tags/ControlPanel/TestCases +caption: {{$:/language/ControlPanel/TestCases/All/Caption}} + +\define lingo-base() $:/language/ControlPanel/ +<> + +<$list filter="[all[tiddlers+shadows]tag[$:/tags/wiki-test-spec]type[text/vnd.tiddlywiki-multiple]] [all[tiddlers+shadows]tag[$:/tags/wiki-test-spec-failing]type[text/vnd.tiddlywiki-multiple]]"> + +

+ +<$link> + +<$text text=<>/> + + + +

+ +<$transclude + $tiddler="$:/core/ui/TestCaseTemplate" +/> + + diff --git a/core/ui/ControlPanel/TestCasesFailed.tid b/core/ui/ControlPanel/TestCasesFailed.tid new file mode 100644 index 000000000..4ab2d062d --- /dev/null +++ b/core/ui/ControlPanel/TestCasesFailed.tid @@ -0,0 +1,15 @@ +title: $:/core/ui/ControlPanel/TestCases/Failed +tags: $:/tags/ControlPanel/TestCases +caption: {{$:/language/ControlPanel/TestCases/Failed/Caption}} + +\define lingo-base() $:/language/ControlPanel/ +<> + +<$list filter="[all[tiddlers+shadows]tag[$:/tags/wiki-test-spec]type[text/vnd.tiddlywiki-multiple]] [all[tiddlers+shadows]tag[$:/tags/wiki-test-spec-failing]type[text/vnd.tiddlywiki-multiple]]"> + +<$transclude + $tiddler="$:/core/ui/TestCaseTemplate" + hideIfPass="yes" +/> + + diff --git a/core/ui/TestCaseTemplate.tid b/core/ui/TestCaseTemplate.tid new file mode 100644 index 000000000..74b6ab27d --- /dev/null +++ b/core/ui/TestCaseTemplate.tid @@ -0,0 +1,18 @@ +title: $:/core/ui/TestCaseTemplate + +\parameters (hideIfPass:"no") +\whitespace trim +<$let + linkTarget="yes" + displayFormat={{!!display-format}} +> + <$testcase + testOutput="Output" + testExpectedResult="ExpectedResult" + testActions="Actions" + testHideIfPass=<> + > + <$data $compound-tiddler=<>/> + <$data title="Description" text={{!!description}}/> + + diff --git a/core/ui/TestCases/DefaultTemplate.tid b/core/ui/TestCases/DefaultTemplate.tid index 595162092..7a7042e82 100644 --- a/core/ui/TestCases/DefaultTemplate.tid +++ b/core/ui/TestCases/DefaultTemplate.tid @@ -4,19 +4,46 @@ title: $:/core/ui/testcases/DefaultTemplate <$let state={{{ [] }}} > -
-
-

<$transclude tiddler="Description" mode="inline"/>

-
-
-
-<$macrocall $name="tabs" tabsList="[all[tiddlers]sort[]] -[prefix] -Description -ExpectedResult -Output Output +[putfirst[]] -[has[plugin-type]]" state=<> default="Output" template="$:/core/ui/testcases/DefaultTemplate/Source"/> -
-
-
-
-<$transclude tiddler="Output"/> -
-
-
+
+
+

+ <$genesis $type={{{ [!match[]then[$link]else[div]] }}}> + <%if [!match[]] %> + !match[fail]then[tc-testcase-result-icon-pass]] [match[fail]then[tc-testcase-result-icon-fail]] +[join[ ]] }}}> + <%if [!match[fail]] %> + {{$:/core/images/done-button}} + <%else%> + {{$:/core/images/close-button}} + <%endif%> + + <%endif%> + <$view tiddler="Description" mode="inline"/> + +

+
+ <%if [match[fail]] %> +
+
+ TEST FAILED +
+
+ <$diff-text source=<> dest=<>/> +
+
+ <%endif%> +
+
+ <$macrocall $name="tabs" tabsList="[all[tiddlers]sort[]] -[prefix] -Description -ExpectedResult -Output Output +[putfirst[]] -[has[plugin-type]]" state=<> default="Output" template="$:/core/ui/testcases/DefaultTemplate/Source"/> +
+
+
+
+ <%if [!match[]else[wikitext]match[plaintext]] %> +
<$view tiddler="Output" format="plainwikified" mode="block"/>
+ <%else%> + <$transclude $tiddler="Output" $mode="block"/> + <%endif%> +
+
+
diff --git a/core/ui/TestCases/DefaultTemplateSource.tid b/core/ui/TestCases/DefaultTemplateSource.tid index fcee5268d..f6bda6171 100644 --- a/core/ui/TestCases/DefaultTemplateSource.tid +++ b/core/ui/TestCases/DefaultTemplateSource.tid @@ -1,5 +1,7 @@ title: $:/core/ui/testcases/DefaultTemplate/Source +\whitespace trim +\procedure body() <$list filter="[fields[]] -text +[limit[1]]" variable="ignore"> @@ -17,3 +19,6 @@ title: $:/core/ui/testcases/DefaultTemplate/Source
<$edit class="tc-edit-texteditor" tiddler=<>/> +\end + +<$transclude $variable="body" $mode="inline"/> diff --git a/core/wiki/config/ViewTemplateBodyFilters.multids b/core/wiki/config/ViewTemplateBodyFilters.multids index ff9fe7250..bafbfc92f 100644 --- a/core/wiki/config/ViewTemplateBodyFilters.multids +++ b/core/wiki/config/ViewTemplateBodyFilters.multids @@ -1,6 +1,7 @@ title: $:/config/ViewTemplateBodyFilters/ tags: $:/tags/ViewTemplateBodyFilter +testcase: [tag[$:/tags/wiki-test-spec]type[text/vnd.tiddlywiki-multiple]then[$:/core/ui/TestCaseTemplate]] stylesheet: [tag[$:/tags/Stylesheet]then[$:/core/ui/ViewTemplate/body/rendered-plain-text]] core-ui-tags: [tag[$:/tags/PageTemplate]] [tag[$:/tags/EditTemplate]] [tag[$:/tags/ViewTemplate]] [tag[$:/tags/KeyboardShortcut]] [tag[$:/tags/ImportPreview]] [tag[$:/tags/EditPreview]][tag[$:/tags/EditorToolbar]] [tag[$:/tags/Actions]] :then[[$:/core/ui/ViewTemplate/body/code]] system: [prefix[$:/boot/]] [prefix[$:/config/]] [prefix[$:/core/macros]] [prefix[$:/core/save/]] [prefix[$:/core/templates/]] [prefix[$:/info/]] [prefix[$:/language/]] [prefix[$:/languages/]] [prefix[$:/snippets/]] [prefix[$:/state/]] [prefix[$:/status/]] [prefix[$:/info/]] [prefix[$:/temp/]] +[!is[image]limit[1]then[$:/core/ui/ViewTemplate/body/code]] diff --git a/core/wiki/macros/testcase.tid b/core/wiki/macros/testcase.tid new file mode 100644 index 000000000..a04cb540d --- /dev/null +++ b/core/wiki/macros/testcase.tid @@ -0,0 +1,10 @@ +title: $:/core/macros/testcase +tags: $:/tags/Macro $:/tags/Global + +\whitespace trim + +\procedure testcase(tiddler) +<$tiddler tiddler=<>> +<$transclude $tiddler="$:/core/ui/TestCaseTemplate"> + +\end diff --git a/core/wiki/tags/ViewTemplateBodyFilter.tid b/core/wiki/tags/ViewTemplateBodyFilter.tid index 7b9fb7fd8..0143c1f88 100644 --- a/core/wiki/tags/ViewTemplateBodyFilter.tid +++ b/core/wiki/tags/ViewTemplateBodyFilter.tid @@ -1,2 +1,2 @@ title: $:/tags/ViewTemplateBodyFilter -list: $:/config/ViewTemplateBodyFilters/hide-body $:/config/ViewTemplateBodyFilters/code-body $:/config/ViewTemplateBodyFilters/stylesheet $:/config/ViewTemplateBodyFilters/core-ui-advanced-search $:/config/ViewTemplateBodyFilters/core-ui-tags $:/config/ViewTemplateBodyFilters/system $:/config/ViewTemplateBodyFilters/import $:/config/ViewTemplateBodyFilters/plugin $:/config/ViewTemplateBodyFilters/default \ No newline at end of file +list: $:/config/ViewTemplateBodyFilters/testcase $:/config/ViewTemplateBodyFilters/hide-body $:/config/ViewTemplateBodyFilters/code-body $:/config/ViewTemplateBodyFilters/stylesheet $:/config/ViewTemplateBodyFilters/core-ui-advanced-search $:/config/ViewTemplateBodyFilters/core-ui-tags $:/config/ViewTemplateBodyFilters/system $:/config/ViewTemplateBodyFilters/import $:/config/ViewTemplateBodyFilters/plugin $:/config/ViewTemplateBodyFilters/default \ No newline at end of file diff --git a/editions/prerelease/tiddlywiki.info b/editions/prerelease/tiddlywiki.info index 11c65b2e4..4f4c8d499 100644 --- a/editions/prerelease/tiddlywiki.info +++ b/editions/prerelease/tiddlywiki.info @@ -17,6 +17,7 @@ "tiddlywiki/jszip", "tiddlywiki/geospatial", "tiddlywiki/xlsx-utils", + "tiddlywiki/innerwiki", "tiddlywiki/confetti", "tiddlywiki/dynannotate", "tiddlywiki/tour" diff --git a/editions/test/tiddlers/HelloThere.tid b/editions/test/tiddlers/HelloThere.tid index d41f45fe2..74ea616e5 100644 --- a/editions/test/tiddlers/HelloThere.tid +++ b/editions/test/tiddlers/HelloThere.tid @@ -3,3 +3,7 @@ title: HelloThere This is TiddlyWiki's browser-based test runner for version <>. See the bottom of this page for the test results. https://tiddlywiki.com/ + +! Test Cases + +{{$:/core/ui/ControlPanel/TestCases}} diff --git a/editions/test/tiddlers/tests/from-tw5.com/tiddlywiki.files b/editions/test/tiddlers/tests/from-tw5.com/tiddlywiki.files new file mode 100644 index 000000000..c8ce1656e --- /dev/null +++ b/editions/test/tiddlers/tests/from-tw5.com/tiddlywiki.files @@ -0,0 +1,5 @@ +{ + "directories": [ + "../../../../tw5.com/tiddlers/testcases" + ] +} \ No newline at end of file diff --git a/editions/tw5.com/tiddlers/concepts/TestCaseTiddlers.tid b/editions/tw5.com/tiddlers/concepts/TestCaseTiddlers.tid new file mode 100644 index 000000000..019ed934f --- /dev/null +++ b/editions/tw5.com/tiddlers/concepts/TestCaseTiddlers.tid @@ -0,0 +1,13 @@ +title: TestCaseTiddlers + + + +Behind the scenes, the templates used to view TestCaseTiddlers use the <<.wlink TestCaseWidget>> widget. + +! Testcase Conventions + +The following conventions are used for testcase tiddlers: + +* `Description` contains a brief description of the test (rendered in inline mode) +* `Output` contains the tiddler text to be rendered. It can also reference other tiddlers +* `ExpectedResult` contains the HTML that should match the rendering of the tiddler `Output` diff --git a/editions/tw5.com/tiddlers/testcases/DataWidget/ImportCompound.tid b/editions/tw5.com/tiddlers/testcases/DataWidget/ImportCompound.tid new file mode 100644 index 000000000..c79c91b40 --- /dev/null +++ b/editions/tw5.com/tiddlers/testcases/DataWidget/ImportCompound.tid @@ -0,0 +1,29 @@ +title: TestCases/DataWidget/ImportCompound +type: text/vnd.tiddlywiki-multiple +tags: [[$:/tags/wiki-test-spec]] +description: Importing a compound payload tiddler and adding custom fields +display-format: plaintext + +title: Output + +<$data $compound-tiddler="Compound" custom="Alpha"/> ++ +title: Compound +type: text/vnd.tiddlywiki-multiple +tags: [[$:/tags/wiki-test-spec]] + +title: Payload Tiddler +tags: Alpha Beta Gamma + +This is a payload tiddler from a compound tiddler ++ +title: ExpectedResult + +

[ + { + "title": "Payload Tiddler", + "tags": "Alpha Beta Gamma", + "text": "This is a payload tiddler from a compound tiddler", + "custom": "Alpha" + } +]

\ No newline at end of file diff --git a/editions/tw5.com/tiddlers/testcases/DataWidget/ImportedFilter.tid b/editions/tw5.com/tiddlers/testcases/DataWidget/ImportedFilter.tid new file mode 100644 index 000000000..3b12bbfcd --- /dev/null +++ b/editions/tw5.com/tiddlers/testcases/DataWidget/ImportedFilter.tid @@ -0,0 +1,45 @@ +title: TestCases/DataWidget/ImportedFilter +type: text/vnd.tiddlywiki-multiple +tags: [[$:/tags/wiki-test-spec]] +description: Imported filter definition +display-format: plaintext + +title: Output + +<$data $filter="[prefix[Day: T]]" custom="Beta"/> ++ +title: Day: Monday +text: Today is Monday ++ +title: Day: Tuesday +text: Today is Tuesday ++ +title: Day: Wednesday +text: Today is Wednesday ++ +title: Day: Thursday +text: Today is Thursday ++ +title: Day: Friday +text: Today is Friday ++ +title: Day: Saturday +text: Today is Saturday ++ +title: Day: Sunday +text: Today is Sunday ++ +title: ExpectedResult + +

[ + { + "title": "Day: Thursday", + "text": "Today is Thursday", + "custom": "Beta" + }, + { + "title": "Day: Tuesday", + "text": "Today is Tuesday", + "custom": "Beta" + } +]

\ No newline at end of file diff --git a/editions/tw5.com/tiddlers/testcases/DataWidget/ImportedTiddler.tid b/editions/tw5.com/tiddlers/testcases/DataWidget/ImportedTiddler.tid new file mode 100644 index 000000000..e7ddeb83b --- /dev/null +++ b/editions/tw5.com/tiddlers/testcases/DataWidget/ImportedTiddler.tid @@ -0,0 +1,25 @@ +title: TestCases/DataWidget/ImportedTiddler +type: text/vnd.tiddlywiki-multiple +tags: [[$:/tags/wiki-test-spec]] +description: Imported tiddler definition +display-format: plaintext + +title: Output + +<$data $tiddler="HelloThere" custom="Alpha"/> ++ +title: HelloThere +modifier: JoeBloggs + +This is the HelloThere tiddler ++ +title: ExpectedResult + +

[ + { + "title": "HelloThere", + "modifier": "JoeBloggs", + "text": "This is the HelloThere tiddler", + "custom": "Alpha" + } +]

\ No newline at end of file diff --git a/editions/tw5.com/tiddlers/testcases/DataWidget/SimpleTiddler.tid b/editions/tw5.com/tiddlers/testcases/DataWidget/SimpleTiddler.tid new file mode 100644 index 000000000..ada31f811 --- /dev/null +++ b/editions/tw5.com/tiddlers/testcases/DataWidget/SimpleTiddler.tid @@ -0,0 +1,18 @@ +title: TestCases/DataWidget/SimpleTiddler +type: text/vnd.tiddlywiki-multiple +tags: [[$:/tags/wiki-test-spec]] +description: Simple tiddler definition +display-format: plaintext + +title: Output + +<$data title="Epsilon" text="Theta"/> ++ +title: ExpectedResult + +

[ + { + "title": "Epsilon", + "text": "Theta" + } +]

\ No newline at end of file diff --git a/editions/tw5.com/tiddlers/testcases/TestCaseWidget/FailingTest.tid b/editions/tw5.com/tiddlers/testcases/TestCaseWidget/FailingTest.tid new file mode 100644 index 000000000..942c2e752 --- /dev/null +++ b/editions/tw5.com/tiddlers/testcases/TestCaseWidget/FailingTest.tid @@ -0,0 +1,11 @@ +title: TestCases/TestCaseWidget/FailingTest +type: text/vnd.tiddlywiki-multiple +tags: [[$:/tags/wiki-test-spec-failing]] +description: An example of a failing test + +title: Output + +The sum is <$text text={{{ [[2]add[2]] }}}/>. ++ +title: ExpectedResult +text:

The sum is not 8.

diff --git a/editions/tw5.com/tiddlers/testcases/TranscludeWidget/SimpleTransclusion.tid b/editions/tw5.com/tiddlers/testcases/TranscludeWidget/SimpleTransclusion.tid new file mode 100644 index 000000000..7bd92f13e --- /dev/null +++ b/editions/tw5.com/tiddlers/testcases/TranscludeWidget/SimpleTransclusion.tid @@ -0,0 +1,19 @@ +title: TestCases/TranscludeWidget/SimpleTransclusion +type: text/vnd.tiddlywiki-multiple +tags: [[$:/tags/wiki-test-spec]] +description: Simple transclusion + +title: Output + +Good morning, my name is {{Name}} and I live in {{Address}} ++ +title: Name + +Robert Rabbit ++ +title: Address + +14 Carrot Street, Vegetabletown ++ +title: ExpectedResult +text:

Good morning, my name is Robert Rabbit and I live in 14 Carrot Street, Vegetabletown

diff --git a/editions/tw5.com/tiddlers/widgets/DataWidget.tid b/editions/tw5.com/tiddlers/widgets/DataWidget.tid index 143d462d4..8a235638f 100644 --- a/editions/tw5.com/tiddlers/widgets/DataWidget.tid +++ b/editions/tw5.com/tiddlers/widgets/DataWidget.tid @@ -11,7 +11,7 @@ The data widget is used with the <<.wlink TestCaseWidget>> widget and the [[Inne ! Content and Attributes -The content of the data widget is rendered as if the data widget were not present. It supports the following attributes: +The content of the data widget is ignored. It supports the following attributes: |!Attribute |!Description | |<<.attr $tiddler>> |Optional title of a tiddler to be used as a payload tiddler (optional) | @@ -23,29 +23,25 @@ The data widget is not rendered when used within the <<.wlink TestCaseWidget>> w Without any of the attributes <<.attr $tiddler>>, <<.attr $filter>> or <<.attr $compound-tiddler>>, any attributes whose name does not start with $ are used as the field values for creating a single new tiddler. For example, here a tiddler with the title "Epsilon" and the text "Theta" is created: -``` -<$data title="Epsilon" text="Theta"/> -``` +<> If any of the attributes <<.attr $tiddler>>, <<.attr $filter>> or <<.attr $compound-tiddler>> are specified then they are used to generate base tiddlers that are then modified with the addition of fields derived from any attributes whose name does not start with $. This example, here we specify a copy of the "HelloThere" tiddler with the addition of the field "custom" set to "Alpha": -``` -<$data $tiddler="HelloThere" custom="Alpha"/> -``` +<> This example injects all image tiddlers with the addition of the field "custom" set to "Beta": -``` -<$data $filter="[is[image]]" custom="Beta"/> -``` +<> ! Compound Tiddlers Compound tiddlers provide a way to easily create multiple tiddlers from within a single tiddler. They are contained in tiddlers of type `text/vnd.tiddlywiki-multiple`. The text field consists of a series of tiddlers in the same format as `.tid` files, each separated by a line containing a single `+` character. -For example: +<> + +Here is a more complex example of the content of a compound tiddler: ``` title: First @@ -62,4 +58,4 @@ title: third tags: five six This is the third tiddler -``` \ No newline at end of file +``` diff --git a/editions/tw5.com/tiddlers/widgets/TestCaseWidget.tid b/editions/tw5.com/tiddlers/widgets/TestCaseWidget.tid index 7dfb7640e..2369ed500 100644 --- a/editions/tw5.com/tiddlers/widgets/TestCaseWidget.tid +++ b/editions/tw5.com/tiddlers/widgets/TestCaseWidget.tid @@ -7,40 +7,89 @@ type: text/vnd.tiddlywiki ! Introduction -The testcase widget creates an independent subwiki loaded with the specified payload tiddlers and then renders a specified template from within the subwiki.The default template displays a split view with the source tiddlers on the left and the rendered tiddler titled `Output` on the right. It also displays the tiddler titled `Description` as the heading. This makes it possible to run independent tests that also serve as documentation examples. +The <<.wid testcase>> widget is designed to present interactive example test cases that are useful for learning and testing. It functions by creating an independent subwiki loaded with the specified payload tiddlers and then rendering a specified template from within the subwiki. The <<.wid testcase>> widget can optionally also be used to run and verify test results within the subwiki. + +This makes it possible to run independent tests that also serve as documentation examples. + +!! Features + +Here is an example of a testcase showing the default split view with the source tiddlers on the left and the tiddler titled `Output` rendered on the right. It also displays the tiddler titled `Description` as the heading. + +<> + +The payload tiddlers listed in the tabs on the left are editable, with the results being immediately reflected in the preview pane on the right. However, if the <<.wid testcase>> widget is refreshed then the modifications are lost. + +The green tick at the top left of a testcase indicates that a test has been set up and that it passes. + +If the test fails, a red cross is shown, and there is a display of the differences between the actual results and the expected results: + +<> + +!! Usage + +The <<.wid testcase>> widget can be used directly as documented below, but it is generally easier and more flexible to create [[TestCaseTiddlers]]. These are special, self contained tiddlers that can contain multiple payload tiddlers making up a testcase. + +Note that the testcase wiki will inherit variables that are visible to the <<.wid testcase>> widget itself. + +! Limitations + +The <<.wid testcase>> widget creates a lightweight TiddlyWiki environment that is a parasite of the main wiki. Because it is not a full, independent TiddlyWiki environment, there are some important limitations: + +* Output is rendered into a DIV, and so cannot be styled independently of the host wiki +* Any changes to the wiki made interactively by the user are volatile, and are lost when the <<.wid testcase>> widget is refreshed +* Startup actions are not supported +* Only plugins available in the host wiki can be included in the testcase + +If these limitations are a problem, the [[Innerwiki Plugin]] offers the ability to embed a fully independent subwiki via an `