From 00ac5503d9f9855eaa6bbf622b9a75c0758c5889 Mon Sep 17 00:00:00 2001 From: Jeremy Ruston Date: Mon, 6 May 2024 21:56:35 +0100 Subject: [PATCH] Extend testcase default template so that the display format can be chosen It is selected by setting the variable "displayFormat" --- core/ui/TestCaseTemplate.tid | 22 +++++++++++-------- core/ui/TestCases/DefaultTemplate.tid | 6 ++++- .../testcases/DataWidget/ImportCompound.tid | 9 +++----- .../testcases/DataWidget/ImportedFilter.tid | 9 +++----- .../testcases/DataWidget/ImportedTiddler.tid | 9 +++----- .../testcases/DataWidget/SimpleTiddler.tid | 9 +++----- .../tiddlers/widgets/TestCaseWidget.tid | 12 +++++++++- 7 files changed, 41 insertions(+), 35 deletions(-) diff --git a/core/ui/TestCaseTemplate.tid b/core/ui/TestCaseTemplate.tid index 4e958ee45..74b6ab27d 100644 --- a/core/ui/TestCaseTemplate.tid +++ b/core/ui/TestCaseTemplate.tid @@ -1,14 +1,18 @@ title: $:/core/ui/TestCaseTemplate \parameters (hideIfPass:"no") -<$let linkTarget="yes"> -<$testcase - testOutput="Output" - testExpectedResult="ExpectedResult" - testActions="Actions" - testHideIfPass=<> +\whitespace trim +<$let + linkTarget="yes" + displayFormat={{!!display-format}} > -<$data $compound-tiddler=<>/> -<$data title="Description" text={{!!description}}/> - + <$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 f604e3f78..7a7042e82 100644 --- a/core/ui/TestCases/DefaultTemplate.tid +++ b/core/ui/TestCases/DefaultTemplate.tid @@ -38,7 +38,11 @@ title: $:/core/ui/testcases/DefaultTemplate
- <$transclude $tiddler="Output" $mode="block"/> + <%if [!match[]else[wikitext]match[plaintext]] %> +
<$view tiddler="Output" format="plainwikified" mode="block"/>
+ <%else%> + <$transclude $tiddler="Output" $mode="block"/> + <%endif%>
diff --git a/editions/tw5.com/tiddlers/testcases/DataWidget/ImportCompound.tid b/editions/tw5.com/tiddlers/testcases/DataWidget/ImportCompound.tid index b7f80629c..c79c91b40 100644 --- a/editions/tw5.com/tiddlers/testcases/DataWidget/ImportCompound.tid +++ b/editions/tw5.com/tiddlers/testcases/DataWidget/ImportCompound.tid @@ -2,12 +2,11 @@ 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 @@ -20,13 +19,11 @@ 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 +]

\ 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 index 024fbaaba..3b12bbfcd 100644 --- a/editions/tw5.com/tiddlers/testcases/DataWidget/ImportedFilter.tid +++ b/editions/tw5.com/tiddlers/testcases/DataWidget/ImportedFilter.tid @@ -2,12 +2,11 @@ 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 @@ -32,8 +31,7 @@ text: Today is Sunday + title: ExpectedResult -

-[
+

[ { "title": "Day: Thursday", "text": "Today is Thursday", @@ -44,5 +42,4 @@ title: ExpectedResult "text": "Today is Tuesday", "custom": "Beta" } -] -

\ No newline at end of file +]

\ 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 index 88be0a4a7..e7ddeb83b 100644 --- a/editions/tw5.com/tiddlers/testcases/DataWidget/ImportedTiddler.tid +++ b/editions/tw5.com/tiddlers/testcases/DataWidget/ImportedTiddler.tid @@ -2,12 +2,11 @@ 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 @@ -16,13 +15,11 @@ 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 +]

\ 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 index cc7a64585..ada31f811 100644 --- a/editions/tw5.com/tiddlers/testcases/DataWidget/SimpleTiddler.tid +++ b/editions/tw5.com/tiddlers/testcases/DataWidget/SimpleTiddler.tid @@ -2,20 +2,17 @@ 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 +]

\ 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 faf488c4b..2369ed500 100644 --- a/editions/tw5.com/tiddlers/widgets/TestCaseWidget.tid +++ b/editions/tw5.com/tiddlers/widgets/TestCaseWidget.tid @@ -29,6 +29,8 @@ If the test fails, a red cross is shown, and there is a display of the differenc 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: @@ -57,7 +59,15 @@ The payload tiddlers are the tiddler values that are loaded into the subwiki tha ! Testcase Templates -The <<.attr template>> attribute defaults to $:/core/ui/testcases/DefaultTemplate but can be used to specify a custom template for special purposes. The provided template $:/core/ui/testcases/RawJSONTemplate can be used for debugging purposes to display all of the payload widgets in JSON. +The <<.attr template>> attribute defaults to $:/core/ui/testcases/DefaultTemplate + +The default template uses several variables that can be set by the user: + +|!Variable |!Description | +|<<.var linkTarget>> |Causes the testcase description to be rendered as a link to the current tiddler | +|<<.var displayFormat>> |Defaults to "wikitext", can also be "plaintext" to force plain text display | + +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. ! Testcase Template Variables