New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add <$testcase> widget #7817
base: master
Are you sure you want to change the base?
Add <$testcase> widget #7817
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Looks good. Will need to run some tests. |
Thanks @pmario I've pushed an update to fix those issues |
Thanks @CodaCodr I've just pushed a fix. |
confirmed. |
The testcase widget shares the same rendering context as the main wiki and so CSS and other globla DOM properties are shared. In such cases the innerwiki widget can be used to create an entirely separate embedded wiki. The purpose of the testcase widget is to be a lighter weight and more performant version of the innerwiki widget. It wouldn't be practical to use the innerwiki widget for hundreds of documentation examples; each of those iframes would overwhelm a mobile device. The documentation needs to clarify the limitations and constraints of the testcase widget. |
|<<.attr $compound-tiddler>> |Optional title of a tiddler containing payload tiddlers in `text/vnd.tiddlywiki-multiple` format (see below) | | ||
|//any attribute<br>not starting<br>with $// |Field values to be assigned to the payload tiddler(s) | | ||
|
||
The data widget is not rendered when used within the <<.wlink TestCaseWidget>> widget or the [[Innerwiki Plugin]] but for ease of testing, when used elsewhere it renders a JSON representation of the payload tiddlers. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when used elsewhere it renders a JSON representation of the payload tiddlers
I'm not able to get this behavior to work. Outside of the testcase widget, I find the data widget to render empty.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @btheado I had replaced that feature of the data widget with the ability for the testcase widget to display its payload in JSON via a special template. I've pushed an update with the docs in 0db4c44 that explains how to do that. I've also added the JSON output feature back to the data widget in 1d89c79 with tests in 0db4c44
The content of the `<$testcase>` widget is not displayed but instead is scanned for <<.wlink DataWidget>> widgets that define the payload tiddlers to be included in the test case. The `$:/core` plugin is automatically included in the payload. | ||
|
||
|!Attribute |!Description | | ||
|<<.attr template>> |Optional title of the template used to display the testcase (defaults to $:/core/ui/testcases/DefaultTemplate). Note that custom templates will need to be explicitly added to the payload | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mention the other core provided template $:/core/ui/testcases/RawJSONTemplate
as being useful for troubleshooting $data
widgets?
</div> | ||
<div class="tc-testcase-divider"> | ||
</div> | ||
<div class="tc-testcase-output"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be useful to add a linkcatcher widget here and select the tab corresponding to the clicked link?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. Works great!
Thanks to @btheado for the suggestion
@Jermolene, nice improvements! I like that test case tiddler titles are links to open the tiddler separately. Very useful. I also like the new Narrative feature. The test case tiddlers and test case widget seem like a really good replacement for the Being able to easily copy the text of the example is useful. In addition or instead, maybe an easy way to get the json for all the tiddlers in the test case widget? Tagging @AnthonyMuscio as I've seen him advocate for more use of "copy to clipboard" in the past. |
Originally I was thinking all the uses of For example, at https://tiddlywiki5-git-testcase-widget-jermolenes-projects.vercel.app/#%24%3A%2Feditions%2Ftw5.com%2Fwikitext-macros Change this
to this
|
I'm seeing some strange rendering behavior regarding With the following test case tiddler, the test case is passing. It must be finding However, visibly I see it rendered as
Here is a json attachement of the tiddler: TestCases_TestCaseTiddler_currentTiddler.json Edit: I see the same issue (not surprisingly) by directly using the testcase widget
|
Thanks @btheado
Yes, although given that these examples only have a single payload tiddler perhaps it would be nicer to use a more streamlined template.
Great idea, I agree. We should have both a "copy to clipboard" button on each source tiddler, and a way to drag and drop the tiddlers to another wiki (or the host wiki), and to save the JSON directly.
Yes, that's an excellent idea. We should still aim to convert the usages to test case tiddlers so that we can specify ExpectedResult, and hence run them as tests.
Ouch, I will investigate. I'm not surprised to see this kind of wrinkle; the testcase widget mixes widgets from different wikis in a way that hasn't been tested before. |
There are still many examples for which the default template is very instructive. Whenever an example such as the RevealWidget creates a tiddler, a new tab appears. For a learner, that makes it easy to see what changes are happening.
But even this approach requires caution. There are many examples which depend on tiddlers in the main wiki. For example (just a partial list):
|
Fixes problem reported by @btheado in #7817 (comment)
Thanks @btheado this is now fixed in eb4e9d8
Yes, that's very true.
Good point. My instinct is to merge this quite soon, and then we can tackle updating the examples gradually. One advantage of the structure introduced in this PR is that the testcases are part of the tw5.com wiki, and can thus be updated directly to tiddlywiki.com because they are part of the documentation. |
This PR adds a new
<$testcase>
widget to try to solve a problem with the examples that we feature in the documentation. The existing macros are workable for simple, self-contained examples, but can be extremely hard to follow in cases where the examples are also using additional tiddlers. The<$testcase>
widget solves that problem by displaying interactive examples that show the output together with a tabbed display of the constituent tiddlers that produce it:Try out the Vercel preview
The testcase widget is essentially a lightweight version of the existing
<$innerwiki>
plugin. It constructs an entirely separate wiki store object, fills it with the required tiddlers, and then renders a template that by default provides the tabbed view of the source tiddlers alongside the output.The example above was generated with:
The
<$data>
widget that originated in the<$innerwiki>
plugin is moved into the core and extended with support for reading tiddlers from "compound tiddlers", which are the special format used by the test suite for embedding multiple tiddlers within a single tiddler. Here is an example.Our test cases are a useful form of documentation. The ultimate goal of this work is to be able to include our wikitext tests suite within the main documentation of TiddlyWiki. Advanced users wondering how
\function
works could dig down into potentially dozens of test cases to explore the behaviour of edge cases.Progress:
<$testcase>
widgetThis PR was cherry picked from #7406.