Extend testcase default template so that the display format can be chosen
It is selected by setting the variable "displayFormat"
This commit is contained in:
parent
43fe5e9523
commit
00ac5503d9
|
@ -1,14 +1,18 @@
|
|||
title: $:/core/ui/TestCaseTemplate
|
||||
|
||||
\parameters (hideIfPass:"no")
|
||||
<$let linkTarget="yes">
|
||||
<$testcase
|
||||
testOutput="Output"
|
||||
testExpectedResult="ExpectedResult"
|
||||
testActions="Actions"
|
||||
testHideIfPass=<<hideIfPass>>
|
||||
\whitespace trim
|
||||
<$let
|
||||
linkTarget="yes"
|
||||
displayFormat={{!!display-format}}
|
||||
>
|
||||
<$data $compound-tiddler=<<currentTiddler>>/>
|
||||
<$data title="Description" text={{!!description}}/>
|
||||
</$testcase>
|
||||
<$testcase
|
||||
testOutput="Output"
|
||||
testExpectedResult="ExpectedResult"
|
||||
testActions="Actions"
|
||||
testHideIfPass=<<hideIfPass>>
|
||||
>
|
||||
<$data $compound-tiddler=<<currentTiddler>>/>
|
||||
<$data title="Description" text={{!!description}}/>
|
||||
</$testcase>
|
||||
</$let>
|
||||
|
|
|
@ -38,7 +38,11 @@ title: $:/core/ui/testcases/DefaultTemplate
|
|||
<div class="tc-testcase-divider">
|
||||
</div>
|
||||
<div class="tc-testcase-output">
|
||||
<$transclude $tiddler="Output" $mode="block"/>
|
||||
<%if [<displayFormat>!match[]else[wikitext]match[plaintext]] %>
|
||||
<pre><$view tiddler="Output" format="plainwikified" mode="block"/></pre>
|
||||
<%else%>
|
||||
<$transclude $tiddler="Output" $mode="block"/>
|
||||
<%endif%>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -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
|
||||
|
||||
<pre>
|
||||
<$data $compound-tiddler="Compound" custom="Alpha"/>
|
||||
</pre>
|
||||
+
|
||||
title: Compound
|
||||
type: text/vnd.tiddlywiki-multiple
|
||||
|
@ -20,13 +19,11 @@ This is a payload tiddler from a compound tiddler
|
|||
+
|
||||
title: ExpectedResult
|
||||
|
||||
<p><pre>
|
||||
[
|
||||
<p>[
|
||||
{
|
||||
"title": "Payload Tiddler",
|
||||
"tags": "Alpha Beta Gamma",
|
||||
"text": "This is a payload tiddler from a compound tiddler",
|
||||
"custom": "Alpha"
|
||||
}
|
||||
]
|
||||
</pre></p>
|
||||
]</p>
|
|
@ -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
|
||||
|
||||
<pre>
|
||||
<$data $filter="[prefix[Day: T]]" custom="Beta"/>
|
||||
</pre>
|
||||
+
|
||||
title: Day: Monday
|
||||
text: Today is Monday
|
||||
|
@ -32,8 +31,7 @@ text: Today is Sunday
|
|||
+
|
||||
title: ExpectedResult
|
||||
|
||||
<p><pre>
|
||||
[
|
||||
<p>[
|
||||
{
|
||||
"title": "Day: Thursday",
|
||||
"text": "Today is Thursday",
|
||||
|
@ -44,5 +42,4 @@ title: ExpectedResult
|
|||
"text": "Today is Tuesday",
|
||||
"custom": "Beta"
|
||||
}
|
||||
]
|
||||
</pre></p>
|
||||
]</p>
|
|
@ -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
|
||||
|
||||
<pre>
|
||||
<$data $tiddler="HelloThere" custom="Alpha"/>
|
||||
</pre>
|
||||
+
|
||||
title: HelloThere
|
||||
modifier: JoeBloggs
|
||||
|
@ -16,13 +15,11 @@ This is the HelloThere tiddler
|
|||
+
|
||||
title: ExpectedResult
|
||||
|
||||
<p><pre>
|
||||
[
|
||||
<p>[
|
||||
{
|
||||
"title": "HelloThere",
|
||||
"modifier": "JoeBloggs",
|
||||
"text": "This is the HelloThere tiddler",
|
||||
"custom": "Alpha"
|
||||
}
|
||||
]
|
||||
</pre></p>
|
||||
]</p>
|
|
@ -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
|
||||
|
||||
<pre>
|
||||
<$data title="Epsilon" text="Theta"/>
|
||||
</pre>
|
||||
+
|
||||
title: ExpectedResult
|
||||
|
||||
<p><pre>
|
||||
[
|
||||
<p>[
|
||||
{
|
||||
"title": "Epsilon",
|
||||
"text": "Theta"
|
||||
}
|
||||
]
|
||||
</pre></p>
|
||||
]</p>
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue