1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-07-05 19:53:17 +00:00

Testcase UI enhancements (#8292)

* Include the ExpectedResults in the displayed tabs

* Lighted testcase background

* Add testcase toolbar with export and import options

* Further styling tweaks
This commit is contained in:
Jeremy Ruston 2024-06-26 10:23:54 +01:00 committed by GitHub
parent f15b6a26da
commit 18152aa7c8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 87 additions and 9 deletions

View File

@ -104,6 +104,8 @@ ShowSideBar/Caption: show sidebar
ShowSideBar/Hint: Show sidebar ShowSideBar/Hint: Show sidebar
TagManager/Caption: tag manager TagManager/Caption: tag manager
TagManager/Hint: Open tag manager TagManager/Hint: Open tag manager
TestCaseImport/Caption: import tiddlers
TestCaseImport/Hint: Import tiddlers
Timestamp/Caption: timestamps Timestamp/Caption: timestamps
Timestamp/Hint: Choose whether modifications update timestamps Timestamp/Hint: Choose whether modifications update timestamps
Timestamp/On/Caption: timestamps are on Timestamp/On/Caption: timestamps are on

View File

@ -95,6 +95,7 @@ function SaverHandler(options) {
if($tw.browser) { if($tw.browser) {
$tw.rootWidget.addEventListener("tm-save-wiki",function(event) { $tw.rootWidget.addEventListener("tm-save-wiki",function(event) {
self.saveWiki({ self.saveWiki({
wiki: event.widget.wiki,
template: event.param, template: event.param,
downloadType: "text/plain", downloadType: "text/plain",
variables: event.paramObject variables: event.paramObject
@ -102,6 +103,7 @@ function SaverHandler(options) {
}); });
$tw.rootWidget.addEventListener("tm-download-file",function(event) { $tw.rootWidget.addEventListener("tm-download-file",function(event) {
self.saveWiki({ self.saveWiki({
wiki: event.widget.wiki,
method: "download", method: "download",
template: event.param, template: event.param,
downloadType: "text/plain", downloadType: "text/plain",
@ -147,20 +149,22 @@ Save the wiki contents. Options are:
method: "save", "autosave" or "download" method: "save", "autosave" or "download"
template: the tiddler containing the template to save template: the tiddler containing the template to save
downloadType: the content type for the saved file downloadType: the content type for the saved file
wiki: optional wiki, overriding the default wiki specified in the constructor
*/ */
SaverHandler.prototype.saveWiki = function(options) { SaverHandler.prototype.saveWiki = function(options) {
options = options || {}; options = options || {};
var self = this, var self = this,
wiki = options.wiki || this.wiki,
method = options.method || "save"; method = options.method || "save";
// Ignore autosave if disabled // Ignore autosave if disabled
if(method === "autosave" && ($tw.config.disableAutoSave || this.wiki.getTiddlerText(this.titleAutoSave,"yes") !== "yes")) { if(method === "autosave" && ($tw.config.disableAutoSave || wiki.getTiddlerText(this.titleAutoSave,"yes") !== "yes")) {
return false; return false;
} }
var variables = options.variables || {}, var variables = options.variables || {},
template = (options.template || template = (options.template ||
this.wiki.getTiddlerText("$:/config/SaveWikiButton/Template","$:/core/save/all")).trim(), wiki.getTiddlerText("$:/config/SaveWikiButton/Template","$:/core/save/all")).trim(),
downloadType = options.downloadType || "text/plain", downloadType = options.downloadType || "text/plain",
text = this.wiki.renderTiddler(downloadType,template,options), text = wiki.renderTiddler(downloadType,template,options),
callback = function(err) { callback = function(err) {
if(err) { if(err) {
alert($tw.language.getString("Error/WhileSaving") + ":\n\n" + err); alert($tw.language.getString("Error/WhileSaving") + ":\n\n" + err);

View File

@ -99,7 +99,7 @@ table-footer-background: #a8a8a8
table-header-background: #f0f0f0 table-header-background: #f0f0f0
tag-background: #ec6 tag-background: #ec6
tag-foreground: #ffffff tag-foreground: #ffffff
testcase-accent-level-1: #84C5E6 testcase-accent-level-1: #c1eaff
testcase-accent-level-2: #E3B740 testcase-accent-level-2: #E3B740
testcase-accent-level-3: #5FD564 testcase-accent-level-3: #5FD564
tiddler-background: <<colour background>> tiddler-background: <<colour background>>

View File

@ -27,6 +27,31 @@ title: $:/core/ui/testcases/DefaultTemplate
<%endif%> <%endif%>
<$view tiddler="Description" mode="inline"/> <$view tiddler="Description" mode="inline"/>
</$genesis> </$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> </h2>
</div> </div>
<%if [[Narrative]is[tiddler]] %> <%if [[Narrative]is[tiddler]] %>
@ -46,7 +71,7 @@ title: $:/core/ui/testcases/DefaultTemplate
<%endif%> <%endif%>
<div class="tc-test-case-panes"> <div class="tc-test-case-panes">
<div class="tc-test-case-source"> <div class="tc-test-case-source">
<$macrocall $name="tabs" tabsList="[all[tiddlers]sort[]] -[prefix<state>] -Description -Narrative -ExpectedResult -Output Output +[putfirst[]] -[has[plugin-type]]" state=<<state>> default="Output" template="$:/core/ui/testcases/DefaultTemplate/SourceTabs"/> <$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"/>
</div> </div>
<div class="tc-test-case-divider"> <div class="tc-test-case-divider">
</div> </div>

View File

@ -19,6 +19,9 @@ title: $:/core/ui/testcases/DefaultTemplate/SourceTabs
</table> </table>
</$list> </$list>
<$edit class="tc-edit-texteditor" tiddler=<<currentTab>>/> <$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 \end
<$transclude $variable="body" $mode="inline"/> <$transclude $variable="body" $mode="inline"/>

View File

@ -0,0 +1,4 @@
title: $:/core/ui/testcases/actions/Export
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/"/>

View File

@ -0,0 +1,11 @@
title: $:/core/ui/testcases/actions/Import
tags: $:/tags/TestCase/Actions
\whitespace trim
<$button tooltip={{$:/language/Buttons/TestCaseImport/Hint}} aria-label={{$:/language/Buttons/TestCaseImport/Caption}} class=<<tv-config-toolbar-class>>>
<$action-sendmessage $message="tm-import-tiddlers" $param=<<payloadTiddlers>>/>
{{$:/core/images/permalink-button}}
<span class="tc-btn-text">
<$text text={{$:/language/Buttons/TestCaseImport/Caption}}/>
</span>
</$button>

View File

@ -0,0 +1,2 @@
title: $:/tags/TestCase/Actions
list:

View File

@ -5,7 +5,7 @@ description: An example of a failing test
title: Narrative title: Narrative
This test case intentionally fails (in order to show how failures are displayed) This test case intentionally fails (in order to show how failures are displayed). The expected result is set to <code><$text text={{ExpectedResult}}/></code>, but the result computes to <code><$wikify name="html" text={{Output}} mode="block" output="html"><$text text=<<html>>/></$wikify></code>
+ +
title: Output title: Output

View File

@ -3297,7 +3297,7 @@ span.tc-translink > a:first-child {
display: inline-block; display: inline-block;
line-height: 0; line-height: 0;
border-radius: 1em; border-radius: 1em;
vertical-align: bottom; vertical-align: text-bottom;
margin-right: 0.25em; margin-right: 0.25em;
} }
@ -3314,6 +3314,12 @@ span.tc-translink > a:first-child {
height: 0.5em; height: 0.5em;
} }
.tc-test-case-header > h2 {
background: <<colour background>>;
border-radius: 4px;
padding: 0.25em;
}
.tc-test-case-header > h2, .tc-test-case-header > h2,
.tc-test-case-source > pre { .tc-test-case-source > pre {
margin: 0; margin: 0;
@ -3323,6 +3329,18 @@ span.tc-translink > a:first-child {
font-style: normal; font-style: normal;
} }
.tc-test-case-toolbar {
float: right;
}
.tc-test-case-toolbar svg {
fill: <<colour tiddler-controls-foreground>>;
}
.tc-test-case-toolbar .tc-drop-down {
font-size: 0.8em;
}
.tc-test-case-result-fail { .tc-test-case-result-fail {
border: 1px solid <<colour foreground>>; border: 1px solid <<colour foreground>>;
background-color: <<colour background>>; background-color: <<colour background>>;
@ -3366,10 +3384,14 @@ span.tc-translink > a:first-child {
} }
.tc-test-case-source .tc-tab-content { .tc-test-case-source .tc-tab-content {
background: <<colour background>>; background: inherit;
margin: 0; margin: 0;
} }
.tc-test-case-source .tc-tab-content .tc-field-table {
background: <<colour background>>;
}
.tc-test-case-source .tc-field-table { .tc-test-case-source .tc-field-table {
width: 100%; width: 100%;
} }
@ -3390,11 +3412,16 @@ span.tc-translink > a:first-child {
padding-top: 0; padding-top: 0;
} }
.tc-test-case-footer-toolbar {
display: flex;
justify-content: flex-end;
}
.tc-test-case-output { .tc-test-case-output {
box-shadow: inset 2px 2px 10px 0px <<colour muted-foreground>>; box-shadow: inset 2px 2px 10px 0px <<colour muted-foreground>>;
background: <<colour background>>; background: <<colour background>>;
border-radius: 4px; border-radius: 4px;
border: 1px solid <<colour foreground>>; border: 1px solid <<colour muted-foreground>>;
flex: 1 0 49%; flex: 1 0 49%;
min-width: 250px; min-width: 250px;
padding: 0.25em 1em; padding: 0.25em 1em;