1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2025-04-17 00:03:14 +00:00

Make testcase tab-view a story-river

This commit is contained in:
pmario 2024-08-03 16:25:37 +02:00
parent fcfb846034
commit f8ce842d26
4 changed files with 184 additions and 85 deletions

View File

@ -2,94 +2,142 @@ title: $:/core/ui/testcases/DefaultTemplate
code-body: yes
\whitespace trim
\procedure linkcatcherActions()
<$action-log/>
<%if [<navigateTo>has[title]] %>
<$qualify title=<<state>> name="qualifiedState">
<$action-setfield $tiddler=<<qualifiedState>> text=<<navigateTo>>/>
</$qualify>
<%endif%>
\function tf.state() [<qualify "$:/state/testcase">]
\procedure textcase-toolbar()
<$button popup=`$(tf.state)$-more`
tooltip={{$:/language/Buttons/More/Hint}}
aria-label={{$:/language/Buttons/More/Caption}}
class="tc-btn-invisible"
selectedClass="tc-selected"
>
{{$:/core/images/down-arrow}}
</$button>
<$let
tv-config-toolbar-icons="yes"
tv-config-toolbar-text="yes"
tv-config-toolbar-class="tc-btn-invisible"
>
<$reveal state=`$(tf.state)$-more` type="popup" position="belowleft" animate="yes">
<div class="tc-drop-down">
<$list filter="[all[shadows+tiddlers]tag[$:/tags/TestCase/Actions]!has[draft.of]]"
variable="listItem"
>
<$transclude $tiddler=<<listItem>> $mode="inline"/>
</$list>
</div>
</$reveal>
</$let>
\end
<$navigator story={{{ [<qualify $:/StoryList/>] }}} history={{{ [<qualify $:/HistoryList/>] }}}>
<$let
state={{{ [<qualify "$:/state/testcase">] }}}
>
<$linkcatcher actions=<<linkcatcherActions>>>
<div class="tc-test-case-wrapper">
<div class="tc-test-case-header">
<h2>
<$genesis $type={{{ [<linkTarget>!match[]then[$link]else[span]] }}} to=<<testcaseTiddler>>>
<%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[ ]] }}}>
<%if [<testResult>!match[fail]] %>
{{$:/core/images/done-button}}
<%else%>
{{$:/core/images/close-button}}
<%endif%>
</span>
<%endif%>
<$view tiddler="Description" mode="inline"/>
</$genesis>
<span class="tc-test-case-toolbar">
<$button popup=`$(state)$-more`
tooltip={{$:/language/Buttons/More/Hint}}
aria-label={{$:/language/Buttons/More/Caption}}
class="tc-btn-invisible"
selectedClass="tc-selected"
>
{{$:/core/images/down-arrow}}
</$button>
<$let
tv-config-toolbar-icons="yes"
tv-config-toolbar-text="yes"
tv-config-toolbar-class="tc-btn-invisible"
>
<$reveal state=`$(state)$-more` type="popup" position="belowleft" animate="yes">
<div class="tc-drop-down">
<$list filter="[all[shadows+tiddlers]tag[$:/tags/TestCase/Actions]!has[draft.of]]"
variable="listItem"
>
<$transclude $tiddler=<<listItem>> $mode="inline"/>
</$list>
</div>
</$reveal>
</$let>
</span>
</h2>
</div>
<%if [[Narrative]is[tiddler]] %>
<div class="tc-test-case-narrative">
<$transclude $tiddler="Narrative" $mode="block"/>
</div>
<%endif%>
<%if [<testResult>match[fail]] %>
<div class="tc-test-case-result-fail">
<div class="tc-test-case-result-fail-header">
TEST FAILED
</div>
<div class="tc-test-case-result-fail-body">
<$diff-text source=<<expectedHTML>> dest=<<outputHTML>>/>
</div>
</div>
<%endif%>
<div class="tc-test-case-panes">
<div class="tc-test-case-source">
<$macrocall $name="tabs" tabsList="[all[tiddlers]sort[]] Output +[putfirst[]] -[prefix<state>] -[prefix[$:/HistoryList]] -[prefix[$:/StoryList]] -Description -Narrative -[has[plugin-type]]" state=<<state>> default="Output" template="$:/core/ui/testcases/DefaultTemplate/SourceTabs"/>
</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>
\procedure testcase-header()
<div class="tc-test-case-header">
<h2>
<$genesis $type={{{ [<linkTarget>!match[]then[$link]else[span]] }}} to=<<testcaseTiddler>>>
<%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[ ]] }}}>
<%if [<testResult>!match[fail]] %>
{{$:/core/images/done-button}}
<%else%>
<$tiddler tiddler="Output">
<$transclude $tiddler="Output" $mode="block"/>
</$tiddler>
{{$:/core/images/close-button}}
<%endif%>
</span>
<%endif%>
<$view tiddler="Description" mode="inline"/>
</$genesis>
<span class="tc-test-case-toolbar">
<<textcase-toolbar>>
</span>
</h2>
</div>
\end
\procedure testcase-narrative()
<div class="tc-test-case-narrative">
<$transclude $tiddler="Narrative" $mode="block"/>
</div>
\end
\procedure testcase-fail()
<div class="tc-test-case-result-fail">
<div class="tc-test-case-result-fail-header">
TEST FAILED
</div>
<div class="tc-test-case-result-fail-body">
<$diff-text source=<<expectedHTML>> dest=<<outputHTML>>/>
</div>
</div>
\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%>
<$tiddler tiddler="Output">
<$transclude $tiddler="Output" $mode="block"/>
</$tiddler>
<%endif%>
</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%>
<div class="tc-test-case-panes">
<div class="tc-test-case-source">
<$macrocall $name="tabs" tabsList="[all[tiddlers]sort[]] -[prefix<tf.state>] -[prefix[$:/HistoryList]] -[prefix[$:/StoryList]] -[[$:/temp/testcase/draft-title]] -Description -Narrative -Output Output +[putfirst[]] -[has[plugin-type]]" state=<<tf.state>> default="Output" template="$:/core/ui/testcases/DefaultTemplate/SourceTabs"/>
<div class={{{ [[tc-tab-set]addsuffix[ ]addsuffix<__class__>] }}}>
<div class={{{ [[tc-tab-buttons]addsuffix[ ]addsuffix<__class__>] }}}>
<$list filter="[all[tiddlers]sort[]] Output +[putfirst[]] -[prefix<tf.state>] -[prefix[$:/HistoryList]] -[prefix[$:/StoryList]] -[[$:/temp/testcase/draft-title]] -Description -Narrative -[has[plugin-type]]"
variable="currentTab"
storyview="pop"
>
<$set name="save-currentTiddler"
value=<<currentTiddler>>
>
<$tiddler tiddler=<<currentTab>>>
<$button
to=<<currentTab>>
class={{{ [{$:/HistoryList!!current-tiddler}!is[blank]] :then[{$:/HistoryList!!current-tiddler}match<currentTab>then[tc-tab-selected]else[]] :else[<currentTiddler>match[Output]then[tc-tab-selected]else[]] }}}
tooltip={{{[<currentTab>get[tooltip]]}}}
role="switch"
data-tab-title=<<currentTab>>
>
<$tiddler tiddler=<<save-currentTiddler>>>
<$set name="tv-wikilinks" value="no">
<$transclude tiddler=<<buttonTemplate>> mode="inline">
<$transclude tiddler=<<currentTab>> field="caption">
<$macrocall $name="currentTab" $type="text/plain" $output="text/plain"/>
</$transclude>
</$transclude>
</$set>
</$tiddler>
</$button>
</$tiddler>
</$set>
</$list>
</div>
</div>
<div class="tc-tab-divider "></div>
<div class="tc-tab-content">
{{||$:/core/ui/testcases/DefaultTemplate/SourceTabsNEW}}
</div>
</div>
</$linkcatcher>
</$let>
<div class="tc-test-case-divider"></div>
<<testcase-output>>
</div>
</div>
\end
<$navigator story="$:/StoryList" history="$:/HistoryList">
<<testcase-body>>
</$navigator>

View File

@ -0,0 +1,50 @@
title: $:/core/ui/testcases/DefaultTemplate/SourceTabsNEW
\whitespace trim
\procedure testcaseNewTitle() $:/temp/testcase/draft-title
\procedure saveActions()
<$action-setfield $tiddler=<<currentTab>> $field="draft.title" $value={{{ [<testcaseNewTitle>get[text]] }}}/>
<$action-sendmessage $message="tm-save-tiddler" $param=<<title>> />
<$action-navigate $to=<<navTitle>> $scroll="no"/>
<$action-deletetiddler $tiddler=<<testcaseNewTitle>>/>
\end
\procedure saveButton(title, navTitle)
<$button class="tc-btn-invisible tc-test-case-save-button tc-small-gap-left" actions=<<saveActions>> disabled={{{ [<testcaseNewTitle>!has[text]then[yes]] }}}>
{{$:/core/images/done-button}}
</$button>
\end
\procedure body()
<$list filter="[<currentTab>fields[]] -text +[limit[1]]" variable="ignore" >
<table class="tc-field-table">
<tbody>
<$list filter="[<currentTab>fields[]sort[]] -text -title title +[putfirst[]]" variable="fieldName">
<tr>
<td>
<$text text=<<fieldName>>/>
</td>
<td>
<%if [<fieldName>match[draft.title]] %>
<$edit-text class="tc-edit-texteditor tc-max-width-80" tiddler=<<testcaseNewTitle>> focus="yes" tag="input"/>
<$macrocall $name="saveButton" navTitle={{{ [<currentTab>get[draft.title]] }}} title=<<currentTab>>/>
<%else%>
<$view tiddler=<<currentTab>> field=<<fieldName>>/>
<%endif%>
</td>
</tr>
</$list>
</tbody>
</table>
</$list>
<$edit class="tc-edit-texteditor" tiddler=<<currentTab>>/>
<div class="tc-test-case-footer-toolbar">
<$macrocall $name="copy-to-clipboard" src={{{ [<currentTab>get[text]] }}}/>
</div>
\end
<$let currentTab={{{ [{$:/HistoryList!!current-tiddler}!is[blank]else[Output]] }}}>
<$transclude $variable="body" $mode="inline"/>
</$let>

View File

@ -55,7 +55,7 @@ The very first toc macro is _not_ reused. So it can be used as a simple referenc
{{$:/core/images/new-here-button}}
<% endif %>
<!-- Allows the toc macros to navigate in test-case tiddlers -->
<$action-navigate $to={{{ [<tv-history-list>get[current-tiddler]] }}}/>
<!-- <$action-navigate $to={{{ [<tv-history-list>get[current-tiddler]] }}}/> -->
</$button>
\end _newChild
<% if [<tv-toc-show-new-child>match[yes]] %>

View File

@ -1,6 +1,6 @@
created: 20240730081443212
description: Simple TOC - parentField parameter
modified: 20240730115536164
modified: 20240803121600331
tags: $:/tags/wiki-test-spec
title: Examples/TOC/SimpleToc/parentField
type: text/vnd.tiddlywiki-multiple
@ -18,6 +18,7 @@ title: root
The parent-field in the ''child''-tiddlers are used to define the relation to the parent tiddler
+
title: Child-1
tooltip: child-1 tooltip
parent: root
1st 1st 1st 1st 1st