1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-09-21 11:49:44 +00:00

Make testcase default template more modular (#8514)

* make testcase default template more modular

* exclude state/popup/export from tabList

* fix state in linkcatcherActions

* use "explicitState" instead of "state" for tabs macro

* clean testcase-tablist code

* remove unwanted tiddler

* remove redundant parameters from export-filter
This commit is contained in:
Mario Pietsch 2024-08-18 23:35:36 +02:00 committed by GitHub
parent ec651539a6
commit c51a233627
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 130 additions and 80 deletions

View File

@ -2,23 +2,25 @@ title: $:/core/ui/testcases/DefaultTemplate
code-body: yes code-body: yes
\whitespace trim \whitespace trim
\function tf.state() [<qualify "$:/state/testcase">]
\procedure linkcatcherActions() \procedure linkcatcherActions()
<%if [<navigateTo>has[title]] %> <%if [<navigateTo>has[title]] %>
<$qualify title=<<state>> name="qualifiedState"> <$action-setfield $tiddler=<<tf.state>> text=<<navigateTo>>/>
<$action-setfield $tiddler=<<qualifiedState>> text=<<navigateTo>>/>
</$qualify>
<%endif%> <%endif%>
\end \end
<$let \procedure testcase-header()
state={{{ [<qualify "$:/state/testcase">] }}} <div class="tc-test-case-header">
>
<div class="tc-test-case-wrapper">
<div class="tc-test-case-header">
<h2> <h2>
<$genesis $type={{{ [<linkTarget>!match[]then[$link]else[span]] }}} to=<<testcaseTiddler>>> <$genesis $type={{{ [<linkTarget>!match[]then[$link]else[span]] }}} 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]] %>
{{$:/core/images/done-button}} {{$:/core/images/done-button}}
<%else%> <%else%>
@ -29,20 +31,27 @@ code-body: yes
<$view tiddler="Description" mode="inline"/> <$view tiddler="Description" mode="inline"/>
</$genesis> </$genesis>
<span class="tc-test-case-toolbar"> <span class="tc-test-case-toolbar">
<$button popup=`$(state)$-more` <<testcase-toolbar>>
</span>
</h2>
</div>
\end
\procedure testcase-toolbar()
<$button popup=`$(tf.state)$-more`
tooltip={{$:/language/Buttons/More/Hint}} tooltip={{$:/language/Buttons/More/Hint}}
aria-label={{$:/language/Buttons/More/Caption}} aria-label={{$:/language/Buttons/More/Caption}}
class="tc-btn-invisible" class="tc-btn-invisible"
selectedClass="tc-selected" selectedClass="tc-selected"
> >
{{$:/core/images/down-arrow}} {{$:/core/images/down-arrow}}
</$button> </$button>
<$let <$let
tv-config-toolbar-icons="yes" tv-config-toolbar-icons="yes"
tv-config-toolbar-text="yes" tv-config-toolbar-text="yes"
tv-config-toolbar-class="tc-btn-invisible" tv-config-toolbar-class="tc-btn-invisible"
> >
<$reveal state=`$(state)$-more` type="popup" position="belowleft" animate="yes"> <$reveal state=`$(tf.state)$-more` type="popup" position="belowleft" animate="yes">
<div class="tc-drop-down"> <div class="tc-drop-down">
<$list filter="[all[shadows+tiddlers]tag[$:/tags/TestCase/Actions]!has[draft.of]]" <$list filter="[all[shadows+tiddlers]tag[$:/tags/TestCase/Actions]!has[draft.of]]"
variable="listItem" variable="listItem"
@ -51,42 +60,83 @@ code-body: yes
</$list> </$list>
</div> </div>
</$reveal> </$reveal>
</$let> </$let>
</span> \end
</h2>
</div> \procedure testcase-narrative()
<%if [[Narrative]is[tiddler]] %> <div class="tc-test-case-narrative">
<div class="tc-test-case-narrative">
<$transclude $tiddler="Narrative" $mode="block"/> <$transclude $tiddler="Narrative" $mode="block"/>
</div> </div>
<%endif%> \end
<%if [<testResult>match[fail]] %>
<div class="tc-test-case-result-fail"> \procedure testcase-fail()
<div class="tc-test-case-result-fail">
<div class="tc-test-case-result-fail-header"> <div class="tc-test-case-result-fail-header">
TEST FAILED TEST FAILED
</div> </div>
<div class="tc-test-case-result-fail-body"> <div class="tc-test-case-result-fail-body">
<$diff-text source=<<expectedHTML>> dest=<<outputHTML>>/> <$diff-text source=<<expectedHTML>> dest=<<outputHTML>>/>
</div> </div>
</div> </div>
<%endif%> \end
<div class="tc-test-case-panes">
<div class="tc-test-case-source"> \procedure testcase-output-wikified()
<$macrocall $name="tabs" tabsList="[all[tiddlers]sort[]] -[prefix<state>] -Description -Narrative -Output Output +[putfirst[]] -[has[plugin-type]]" state=<<state>> default="Output" template="$:/core/ui/testcases/DefaultTemplate/SourceTabs"/> <$linkcatcher actions=<<linkcatcherActions>>>
</div>
<div class="tc-test-case-divider">
</div>
<div class="tc-test-case-output">
<%if [<displayFormat>!match[]else[wikitext]match[plaintext]] %>
<pre><$view tiddler="Output" format="plainwikified" mode="block"/></pre>
<%else%>
<$linkcatcher actions=<<linkcatcherActions>>>
<$tiddler tiddler="Output"> <$tiddler tiddler="Output">
<$transclude $tiddler="Output" $mode="block"/> <$transclude $tiddler="Output" $mode="block"/>
</$tiddler> </$tiddler>
</$linkcatcher> </$linkcatcher>
\end
\procedure testcase-output()
<div class="tc-test-case-output">
<%if [<displayFormat>!match[]else[wikitext]match[plaintext]] %>
<pre><$view tiddler="Output" format="plainwikified" mode="block"/></pre>
<%else%>
<<testcase-output-wikified>>
<%endif%> <%endif%>
</div> </div>
</div> \end
</div>
</$let> \procedure testcase-tabsList()
[all[tiddlers]sort[]] Output +[putfirst[]]
-Description
-Narrative
-[has[plugin-type]]
-[prefix<tf.state>]
-[prefix[$:/state/popup/export]]
\end
\procedure testcase-source()
<div class="tc-test-case-source">
<$macrocall $name="tabs"
tabsList=<<testcase-tabsList>>
explicitState=<<tf.state>>
default="Output"
template="$:/core/ui/testcases/DefaultTemplate/SourceTabs"
/>
</div>
\end
\procedure testcase-panes()
<div class="tc-test-case-panes">
<<testcase-source>>
<div class="tc-test-case-divider"></div>
<<testcase-output>>
</div>
\end
\procedure testcase-body()
<div class="tc-test-case-wrapper">
<<testcase-header>>
<%if [[Narrative]is[tiddler]] %>
<<testcase-narrative>>
<%endif%>
<%if [<testResult>match[fail]] %>
<<testcase-fail>>
<%endif%>
<<testcase-panes>>
</div>
\end
<<testcase-body>>

View File

@ -1,4 +1,4 @@
title: $:/core/ui/testcases/actions/Export title: $:/core/ui/testcases/actions/Export
tags: $:/tags/TestCase/Actions tags: $:/tags/TestCase/Actions
<$macrocall $name="exportButton" exportFilter="[all[tiddlers]sort[]] -[prefix[$:/state/]] -Description -Narrative -ExpectedResult -Output Output +[putfirst[]] -[has[plugin-type]]" lingoBase="$:/language/Buttons/ExportTiddlers/"/> <$macrocall $name="exportButton" exportFilter="[all[tiddlers]sort[]] -[prefix[$:/state/]] -Description -Narrative -ExpectedResult -[has[plugin-type]]" lingoBase="$:/language/Buttons/ExportTiddlers/"/>