Module talk:Template test case

Multiple automatic sandbox versions
Can we please extend the automatic addition of a  variant to all  s if there is no  ? — Christoph Päper 11:14, 20 September 2019 (UTC)

Table with many tests
For some templates, especially inline templates like frac, it makes sense to have all or most test cases in a single table with one combination of parameters per row. It would be nice if this could be handled by a single function call by passing multiple parameter sets, e.g.: 11:14, 20 September 2019 (UTC)
 * Alternatively, there should be an additional rendering mode cells. It would put the code and each result for all templates and sandbox versions into adjacent cells in a single table row, but the user would have to provide the surrounding table code (but possibly not the rows ). — Christoph Päper 10:16, 1 January 2020 (UTC)

Hyphen issue in Template:Test case nowiki
This came up when I was working on Template:Graphical timeline/testcases. At Special:Permalink/958740301 it can be observed that parameter note3-at gets a broken value. First character, hyphen, is correct, however, the first opening brace $($ of is converted into an HTML entity for some reason. This results in an error Expression error: Unrecognized punctuation character "&" somewhere deep inside the template's internals. I've added a test case to demonstrate the issue on a smaller example. —⁠andrybak (talk) 13:38, 25 May 2020 (UTC)
 * See T168759 * Pppery * it has begun... 20:45, 25 May 2020 (UTC)

Something just changed
From yesterday to today, the boxes at Template:Spoken Wikipedia/testcases changed from yellow to green, became collapsed, and introduced an error where they now don't seem to be able to embed audio files properly. I'm not sure where the edit that caused this was made, though. Does anyone know? &#123;{u&#124; Sdkb  }&#125;  talk 21:20, 9 July 2020 (UTC)
 * , user has responded to the edit request. That would explain the change from yellow to green on /testcases. Templates Spoken Wikipedia and Spoken Wikipedia/sandbox now produce the same output. Audio player is also broken for me. —⁠andrybak (talk) 22:13, 9 July 2020 (UTC)
 * I've changed the output of /sandbox, and the audio players are now fixed. Perhaps the player doesn't survive in a collapsed state? —⁠andrybak (talk) 22:17, 9 July 2020 (UTC)
 * , hmm, interesting. I just checked a few live instances, and it's not causing any problems there. &#123;{u&#124; Sdkb  }&#125;  talk 22:18, 9 July 2020 (UTC)

Audio player is broken, but video is fine. —⁠andrybak (talk) 22:18, 9 July 2020 (UTC)
 * , I suggest to move this discussion to WP:VPT. Module:Template test case is not at fault, it's wider issue. —⁠andrybak (talk) 22:23, 9 July 2020 (UTC)

How to specify page name?
I looked through the documentation, but I was unable to find a way to specify the page name (magic word PAGENAME) in a template test case. For templates that use Wikidata calls, for example, the Wikidata call checks the PAGENAME and retrieves the appropriate bit of data from the corresponding Wikidata page. Is there a way to do this? The result would be to render the template as it would appear when processed by Special:ExpandTemplates with the appropriate PAGENAME entered in the upper text field. – Jonesey95 (talk) 22:55, 23 July 2020 (UTC)
 * Partial answer, still looking for a real answer: A possible workaround is to use qid in your infobox. See Template:Ordination/testcases for an example. – Jonesey95 (talk) 01:23, 3 August 2020 (UTC)
 * I don't think this is possible. * Pppery * it has begun... 02:24, 4 August 2020 (UTC)

Paragraph break when using inline test case
This is probably something silly I am doing, but I can't figure out what. I am using inline test case in the testcase page of Template:Cite certification and from some reason I am sometimes (rarely) getting an extra paragraph break between results. I created an example: Template:Cite certification/testcases-example. I was worried that there is something wrong with the Cite certification, but as you can see from the code in the example, the paragraph break does not appear when running either the stable or the (identical) sandbox versions. Any ideas? --Muhandes (talk) 14:46, 31 December 2020 (UTC)
 * There was an invisible character (a Left-to-right mark) on your testcases example page. I copied the whole page to a text editor, told it to show the invisible characters, and deleted it. – Jonesey95 (talk) 16:51, 31 December 2020 (UTC)
 * Thanks, I must have wasted five hours of my time finding that one. I now have a good way to test it in the future. --Muhandes (talk) 19:36, 31 December 2020 (UTC)

Sandbox2, Test case2, and wrapperConfig
I'd like the ability to use a second sandbox, say, 'sandbox2', to enable simultaneous testing of different sets of changes in parallel tracks for the same template. Having browsed Module:Template test case, I believe a better method is available than the obvious brute force method of duplicating template FOO to FOO2, then FOO2/sandbox, and testcases to FOO2/testcases. Afaict the key seems to have something to do with wrapperConfig unless I'm mistaken, only I don't see how to use it, and the /doc doesn't have much to say about it.

This use case comes up occasionally in RL on complex templates that may need extended testing of some feature, while someone else desires to test another feature, or where different scenarios are being tried out. (For a RW case of the former type see Template talk:Find sources.) I get the feeling I can just create Template:Find sources/sandbox2 with my changes, and then create a "wrapper config" somewhere, and set it as param2 to the invoke.

For example, can I just duplicate Module:Template test case/config to Template:Find general sources/MySandbox2Config, edit it to set  and then in Template:Find general sources/sandbox2 invoke like this: ? Or am I misconstruing how this is supposed to work, and I should go back to the brute force method? Or something else? Pinging.

Either way, param2 of the module appears to be a config of some kind, so whether my assumptions above are right or wrong, it would be nice if someone could add a  section to Module:Template test case/doc to describe what this param is and how to use it. Mathglot (talk) 22:28, 25 December 2021 (UTC)


 * You can use a second sandbox by setting the _template1, _template2 and _template3 arguments. For example,  outputs the following:


 * The module is built so that the default value for _template1 is the base page of the current page, and the default value for _template2 is its sandbox subpage. In fact, if you are calling the module from Template:Find sources/testcases, you could omit the _template1 and _template2 arguments, and just specify Find sources/sandbox2 to get the same results. — Mr. Stradivarius  ♪ talk ♪ 01:17, 26 December 2021 (UTC)
 * As for the config file, this is not intended to be specified by users. I believe I allowed the config to be passed to the main function so that it can be more easily tested, but this ability is not currently used by Module:Template test case/testcases. I probably only used it in the console during initial development. Also, the config cannot be passed from wikitext; it needs to be passed from another Lua module. From wikitext you can only influence the contents of the first parameter (the frame object) to the function called from #invoke; you can't influence the contents of subsequent parameters. — Mr. Stradivarius  ♪ talk ♪ 01:45, 26 December 2021 (UTC)
 * Thanks, Mr. Stradivarius, this was very helpful. Mathglot (talk) 17:26, 26 December 2021 (UTC)

format=columns + inline hybrid
I've a bunch of test cases for a template that takes lots of complicated parameters, but whose output is a relatively short text. Think cite book and you're in the ballpark. I want to see the code up top in a nowiki block like or rows gives me, but I'd like to see the output arranged vertically like  gives me.

Something like:


 * Veni, vidi, vici
 * Lorem ipsum dolor sit amet

Any takers? Mr. Stradivarius? --Xover (talk) 08:45, 13 January 2023 (UTC)
 * Testcase table with _format? – Jonesey95 (talk) 22:26, 14 January 2023
 * Example:


 * How's that? You can tweak the underscore parameters to your liking. – Jonesey95 (talk) 23:34, 14 January 2023 (UTC)
 * Thanks. That's a nice option, but I kinda prefer the interface for test case nowiki for this (it's clearer, and with less faffing and things that can go wrong when converting something found in the wild into a test case). --Xover (talk) 19:33, 15 January 2023 (UTC)

Use of _before and _after
I'm trying to use the _before parameter, mostly to have something to hange templates that create superscript references, tags, and that sort of thing, so they don't appear to be isolated in space. What I'd like to see in this example, is something like this:
 * Some text to hang a tag on.

Here's my test case, using _before:



Am I doing something wrong, here? Why isn't it echoing the "before" text? Mathglot (talk) 04:29, 26 January 2023 (UTC)
 * You aren't doing anything wrong. It seems the _before (and _after) option wasn't implemented for all render (_format) methods (There's 5, which are columns, rows, inline, cells, and default - only columns and cells considered _before, and your example renders in default since nothing was specified). I've implemented the code into the other render formats, so it should start displaying now. Aidan9382 (talk) 07:10, 26 January 2023 (UTC)
 * Aidan9382 And, indeed it is! I noticed it working on one of my testcase pages, before I even saw my notification alert icon change color. Any faster, and I'd have to give you the faster-than-light barnstar ; thanks so much! (For the curious: the example above used to show nothing but tags, and no text; but since Aidan's fix, is now working properly.) Mathglot (talk) 07:21, 26 January 2023 (UTC)

Template use when there's no sandbox
@Frietjes, re this edit, should we make some change to Test case to better handle instances when it's used when there's no sandbox? &#123;{u&#124; Sdkb  }&#125;  talk 19:42, 19 May 2023 (UTC)
 * , maybe, or you could just create a sandbox version. Frietjes (talk) 19:43, 19 May 2023 (UTC)
 * True. In that case, I was just looking to see whether the template could handle a particular use case, not to make changes to it, so all I needed was the testcases page. &#123;{u&#124; Sdkb  }&#125;  talk 19:46, 19 May 2023 (UTC)
 * I always just click the "mirror" link in the template doc when the sandbox does not exist. It takes two clicks total to create a working sandbox. – Jonesey95 (talk) 15:14, 21 May 2023 (UTC)

Using syntaxhighlight when _showcode is used
I've changed the  tags to  tags when _showcode is used. Sandbox and Diff. Gonnym (talk) 18:04, 23 May 2023 (UTC)


 * Hmm. Would it make sense to have that be opt-in, at least initially, by adding a new syntaxhighlight (and/or syntax maybe) instead? Are there any weird border cases where  works, but  might break? FeRDNYC (talk) 04:00, 15 July 2023 (UTC)

Inconsistency between Test case nowiki and others
So, in most of the test case templates, you pass arguments to the test-case code preceded by underscores, and actual arguments to the template being tested are passed as usual, e.g.:

OK, great. But then here comes, where the underscore arguments don't work, and you have to use non-underscored ones:

Works
My question is, why??? If these templates are a "family", and so often used together, doesn't it make sense for to take the same set of arguments that  and all the others take? Even if it's not strictly necessary for them to be preceded by underscores? It would make converting test cases between the non-nowiki and nowiki versions a lot quicker and more convenient. Am I really the only person who finds themselves doing that pretty frequently? FeRDNYC (talk) 06:33, 15 July 2023 (UTC)


 * The technical reason for why comes down to this bit of code, in which the nowiki wrapper has its arguments done differently. The reason I think this was done in practice is because the only reason the underscores are used in the Test case version is because you have to provide the real arguments, so prefixing the options with _ prevents conflicts. Since the nowiki version just takes the parameter 1, it had no need for the underscores. Aidan9382 (talk) 06:57, 15 July 2023 (UTC)
 * *nod* I totally understand why the _-prefixed arguments are needed for the other templates, and why can do without them. But in the interests of... I don't know, consistency, harmony, whatever, it seems like   could include this logic:
 * ...So that e.g. _collapsible and collapsible are equivalent, meaning the user has the option to pass the exact same arguments as all the other templates in the group. FeRDNYC (talk) 18:44, 15 July 2023 (UTC)
 * Thats fair, I've gone ahead and implemented that here. Either option should work now. Aidan9382 (talk) 19:04, 15 July 2023 (UTC)
 * This change appears to have caused, or may have caused, an error in some test cases. The one that came to my attention is Circular reporting/testcases, where some "span title" code is being exposed. My wild guess is that a rendered equals sign in _title may be causing the problem. – Jonesey95 (talk) 21:15, 16 July 2023 (UTC)
 * This change right here shouldn't of (and hasn't) caused the issue, since this only effects how args are processed in Test case nowiki, and the normal Test case's behaviour is unchanged. I suspect that specific test case has been broken for a while. I've fixed it here and here, and it should now work fine. Aidan9382 (talk) 06:04, 17 July 2023 (UTC)
 * Strange. I wonder why that page popped into the error report right after the change, and why this Module shows in Related changes for the testcases page. It is also odd that this module appears in "Pages transcluded onto the current version of this page" when you edit the testcases page. Maybe it's a coincidence. P.S. I have modified both of the changes, since one of them caused Linter errors in other places. – Jonesey95 (talk) 12:52, 17 July 2023 (UTC)
 * It is also odd that this module appears in "Pages transcluded onto the current version of this page" when you edit the testcases page - that part makes sense, since Test case uses this module, as does Test case nowiki and a couple of the other related templates. As for why it took editing this for it to appear in an error report, even I'm not sure on that one. It definitely didn't change the behaviour, so maybe this change just caused it to purge and appear in the report. Could the report have had a recent change on what it picks up? Aidan9382 (talk) 13:00, 17 July 2023 (UTC)
 * Many, many thanks,, for putting this in place. FeRDNYC (talk) 14:52, 20 July 2023 (UTC)

Extended-confirmed-protected edit request on 17 October 2023
Please, remove the n of the word templaten in the line number 29. Nishimoto, Gilberto Kiyoshi (talk) 16:38, 17 October 2023 (UTC)
 * ✅ Aidan9382 (talk) 16:42, 17 October 2023 (UTC)