Commit graph

714 commits

Author SHA1 Message Date
jenkins-bot 0cfd298d18 Merge "Fix and test page name splitting code in template dialog" 2021-09-13 12:23:17 +00:00
jenkins-bot bb22a6e4bb Merge "Add tests for ve.ui.MWParameterPage class" 2021-09-13 11:45:00 +00:00
Gergő Tisza 986e5ab4d2
MWInternalLinkAnnotation: Make test work with both fragment modes
Avoid breaking the test if $wgFragmentMode has html5 first.

Bug: T186267
Bug: T290464
Change-Id: I0c846173c06698eb039ed289ad202fd3539e61a9
2021-09-11 17:41:22 -07:00
Thiemo Kreuz 22757fa901 Fix and test page name splitting code in template dialog
In JavaScript .split() behaves different, compared to PHP. In
PHP the last element contains the rest of the string. In
JavaScript the rest of the string is discarded. The limit acts
as if the array is truncated. That's why we can reduce the
number in

  'foo/bar'.split( '/', 1 )[ 0 ]

to 1, as we are only interested in the element "foo".

The same code in the other class is currently not covered by a
test. But changing it accordingly should be obviously fine now.

Change-Id: I20c27d480ddb1799df9eb1e5bc119b724e80653d
2021-09-11 17:40:39 +00:00
Thiemo Kreuz 3b59d7ce0d Add tests for ve.ui.MWParameterPage class
Change-Id: Ie09ef4745c006822cc66e845cb16f54d62fa3b7e
2021-09-11 17:39:17 +00:00
Thiemo Kreuz 3f97610e6e Add tests for .containsValuableData() methods
Bug: T272355
Bug: T290554
Change-Id: Icebf7139ed64cdad49522f7b082d1925a9a4a21b
2021-09-10 15:38:28 +00:00
Andrew Kostka 4c0666fd19 Don't allow users to add parameters that contain forbidden chars
Bug: T285869
Change-Id: I1011949c2724939f3cec1e1a2ae1c821c33eff84
2021-09-09 11:43:49 +02:00
Andrew Kostka 075ca72fe8 Add input validation to the add parameter page
Bug: T285869
Change-Id: Iebb982e95aa19bd61fcda915981d505cc243c4b2
2021-09-09 11:42:53 +02:00
Thiemo Kreuz 7edb3a82b8 Rename ambiguous onParameterInput event handler
This is split from patch Iebb982e to make it easier to review.

The name is rather ambiguous. Does "input" refer to the input
element? Is it triggered for every key press, i.e. when the
input changes? Or when it's submitted?

Change-Id: Iddbe3bfb9faf3561d8d71b96ffae507799827a95
2021-09-07 09:04:33 +02:00
jenkins-bot 836ab09a79 Merge "Rename and document select/focus events in template dialog" 2021-09-03 09:38:21 +00:00
jenkins-bot 52ed6367f9 Merge "Mark link to non-existing template page red" 2021-09-02 10:25:54 +00:00
Thiemo Kreuz a395e76653 Mark link to non-existing template page red
Bug: T272487
Change-Id: I15b377feda3a4e3b4570986668dfaa066afd70e9
2021-09-02 10:02:57 +00:00
jenkins-bot 6bb4b13f41 Merge "Remove unused event listener from …ParameterSelectWidget" 2021-09-02 09:56:49 +00:00
Thiemo Kreuz 06cf00f4c6 Rename and document select/focus events in template dialog
I tried hard to come up with the best possible names. Some of the
criteria I used:
* Longer and more unique is better. This makes it much easier to
  e.g. search for the event name.
* The term "part" should only be used for top-level parts. While
  template parameters have a unique id, they are not a subclass
  of …TransclusionPartModel and therefor not "parts".
* BookletLayout manages "pages" via "page names".
  * The page names of top-level parts are identical with the part
    id, see ve.ui.MWTemplateDialog.getPageFromPart.
  * The page names of parameters are identical with the parameter
    model id, see ve.ui.MWTemplateDialog.onAddParameter.

Some code knows parameter ids, but not what pages are. Other code
knows page names, but not what parameters are. The transition
currently happens in the …OutlineContainerWidget. We might want
to move this point up to the …TemplateDialog. But I would argue
this is good enough for now and can be changed later, if needed.

Bug: T285323
Change-Id: Iab2805b3203988db400b67c8d00e48905fdc53dc
2021-09-01 16:23:59 +00:00
Thiemo Kreuz 9dbbc06273 Fix …TemplateSpecModel reporting missing pages as documented
The code in .cacheTemplateDataApiResponse() where the `specCache`
is filled skips missing pages. .setTemplateData() is never called.
While we could – in theory – check the `missing` flag (as done in
patchset 1), this flag never makes it to the spec.

Rather simple solution: Mark everything as undocumented, as long
as .setTemplateData() is not called.

This affects only missing pages. .setTemplateData() is called in
all other situations.

Bug: T272487
Bug: T276574
Bug: T290136
Change-Id: I7045e84f2f2ba5aa4591c94ea495b0249e6c40d6
2021-09-01 14:59:03 +02:00
Thiemo Kreuz b7efea5559 Remove unused event listener from …ParameterSelectWidget
We forgot to remove this in I319896a. The individual
…TransclusionOutlineParameterWidgets don't fire this event any
more. Instead this is done by the …SelectWidget.

Bug: T285323
Change-Id: I2c29e45127464785ffdc32d73b52188fcbefb7bf
2021-09-01 11:58:36 +00:00
jenkins-bot 49eaab5139 Merge "Add tests for ve.ui.MWTransclusionOutlineParameterSelectWidget" 2021-08-31 12:04:02 +00:00
jenkins-bot ef486588ce Merge "Add tests for new ve.ui.MWAddParameterPage" 2021-08-31 10:55:16 +00:00
Thiemo Kreuz 5ffaa3e313 Add tests for ve.ui.MWTransclusionOutlineParameterSelectWidget
Note this covers both the outer SelectWidget as well as most of
the functionality of the item class. This is because the outer
widget manages everything. The items are mostly dumb containers
for a `.selected` bool flag.

Bug: T289560
Change-Id: I6bffda3b74a4bca26032e2602563d64f7bf9bf40
2021-08-30 19:48:42 +00:00
Thiemo Kreuz 926913cad6 Add/simplify assertions in transclusion outline related code
Bug: T289560
Change-Id: Ia76e13582a182c8184b3e8642c5c03bf3d674a24
2021-08-30 14:58:50 +00:00
Thiemo Kreuz e9bd350f68 Add tests for new ve.ui.MWAddParameterPage
The class was added via Ic5dcd36 just a few days ago.

Bug: T289560
Change-Id: I3f729fb6c5d7c28a221d88294d5547809f10a17d
2021-08-30 13:02:52 +00:00
jenkins-bot 62a390d39f Merge "Add rather complex QUnit tests for transclusion outline code" 2021-08-30 10:48:22 +00:00
jenkins-bot fdea0c5357 Merge "More test cases for more complex template dialog functionality" 2021-08-30 08:54:19 +00:00
Thiemo Kreuz 115441b5d8 Add rather complex QUnit tests for transclusion outline code
These are more integration tests than actual "unit" tests. What
the tested code does depends a lot on e.g. how the model and
spec classes behave, and even on some events. Which is good. We
want to cover all of this with tests. The only question is: Is
there a good way to make these tests easier to read, while they
still cover the same code?

Bug: T289560
Change-Id: I8c681f161c272d143a07ca4d0080b4089b48bcb6
2021-08-28 12:34:36 +00:00
Thiemo Kreuz 1f19d85ea8 More test cases for more complex template dialog functionality
Contains:
* Full test coverage (I believe) for the filter functionality in
  …OutlineTemplateWidget.

Also some TODOs for missing tests I believe are critical.

Bug: T289560
Change-Id: I2ac5add8e189d501d3558bbd4854cb92155bcb96
2021-08-28 14:02:57 +02:00
Thiemo Kreuz 55beccbb79 Tests for some trivial but critical template model methods
Not only do we want to make sure getUniquePartId() always starts
at 0 and increments correctly, it should return a number (and
not e.g. "part_0").

I realize the getTitle() test is also testing functionality from
mw.libs.ve.… (can be found in the file ve.utils.parsoid.js).
This is intentional. What we care about at this point is not a
library but the very specific functionality of a very specific
method we use quite a lot in code we touch.

Bug: T289560
Change-Id: I43c1d00dacf27a68b16f62ecca4adda22f437391
2021-08-27 12:49:06 +00:00
jenkins-bot e778057389 Merge "Remove not needed boilerplate from QUnit tests" 2021-08-27 10:56:08 +00:00
jenkins-bot f2b94e10b6 Merge "More test cases for MWTransclusionOutlineContainerWidget" 2021-08-27 10:00:04 +00:00
jenkins-bot 4dd435f3af Merge "More meaningful assertions for all outline part widgets" 2021-08-27 09:59:21 +00:00
jenkins-bot bdb3a783c9 Merge "Add basic QUnit tests for all transclusion outline classes" 2021-08-27 09:59:16 +00:00
Thiemo Kreuz a0e613d8fc Remove not needed boilerplate from QUnit tests
These tests obviously don't need this extra environment.
They run just fine (and faster) without.

Bug: T289560
Change-Id: Ib186a07cd556f741e0440ffa54ae6aaaf626adcd
2021-08-25 12:01:14 +00:00
Thiemo Kreuz 9392282bf2 More test cases for MWTransclusionOutlineContainerWidget
This also fixes a mistake in the class where we forgot to
disconnect event handlers when an element is removed from
the list. This doesn't have much of a consequence, as the
event flow is only in one direction, from the destroyed
element up. This is not possible any more.

Bug: T289560
Change-Id: I0bcc1d68c50b8cbdb033ef6692b34e2fc94e8d85
2021-08-24 15:46:46 +00:00
Thiemo Kreuz e56b4e82f5 Add test for ve.ui.MWParameterCheckboxInputWidget
This is not a file we created recently, but one we care about.
This is also a nice start to get in the mood to write tests.

Bug: T289560
Change-Id: I6475b00508cfa9188ab0d78c2bfd31bab8aed6ed
2021-08-24 15:44:43 +00:00
Thiemo Kreuz 352e7795ca More meaningful assertions for all outline part widgets
Bug: T289560
Change-Id: I81f882d6e6793198371ff9ff3e1e5bbbec98e0d9
2021-08-24 13:17:16 +02:00
Thiemo Kreuz f6953d4096 Add basic QUnit tests for all transclusion outline classes
This is just the smallest possible boilerplate to get the first
trivial test running. More test cases will be added in the
following patches.

Bug: T289560
Change-Id: I3a4e49a7b9761db00b211e933386bad71d4f0942
2021-08-24 11:31:14 +02:00
Thiemo Kreuz 4f9426d61a Rename …ParameterCheckboxLayout now that it's an actual Widget
This is a direct follow-up for Idc5e048.

Bug: T285323
Change-Id: Ia03d594386a9a59a4819bf78c7d2edcd465dfd52
2021-08-20 09:56:40 +02:00
WMDE-Fisch 9aaeac3318 Add getters for un-/documented parameters
Will be needed to figure out when the new UI to add parameters should
be visible.

Bug: T272487
Change-Id: I97d2429b7845905784ef18e9d41cd5e6f85bbd01
2021-08-19 07:00:30 +00:00
jenkins-bot 5c9bfe6a33 Merge "Make checkbox element in the sidebar an actual widget" 2021-08-16 12:36:40 +00:00
Thiemo Kreuz b264a9c381 Add isDocumented() feature to ve.dm.MWTemplateSpecModel
Bug: T272487
Change-Id: I39c612358cc0238c515c8eb28aa1b40418a10cef
2021-08-13 12:47:28 +02:00
Thiemo Kreuz d1f87646df Make checkbox element in the sidebar an actual widget
This should not have any effect on how the thing looks and
behaves.
* All elements in the sidebar should be reachable with the tab
  key, including disabled elements.
* Enter jumps to the corresponding paremeter in the content
  area on the right. But enter doesn't change the checkbox
  state.
* Space canges the checkbox.

The class will be renamed in the next patch.

Bug: T285323
Change-Id: Idc5e04828ece0ba77a65e4c839cd3ffccc3b6733
2021-08-11 09:12:00 +02:00
Thiemo Kreuz (WMDE) 8d9b4526c6 Revert "Hide deprecated parameters if they don't have a value"
This reverts commit 0d4dee341b.

Reason for revert: This made it entirely impossible to add a
deprecated parameter, even if done intentionally. Needs more tests.

Bug: T274551
Change-Id: I7389bad0845cd1ce78f9d7ef71592cb1ce2a063e
2021-08-03 08:24:24 +00:00
Andrew Kostka 0d4dee341b Hide deprecated parameters if they don't have a value
Bug: T274551
Change-Id: I6bfceae2579a5bcedae9da7eb5326fe8f60ea7c0
2021-07-22 12:24:57 +02:00
jenkins-bot c2bc8c7e26 Merge "Move code that belongs to the template specification" 2021-07-08 08:46:40 +00:00
jenkins-bot e70ca5bd42 Merge "Add missing test case with template parameter placeholder" 2021-07-08 08:33:15 +00:00
Svantje Lilienthal ee98622076 Change style for adding an "Unknown field" in the parameter search
Bug: T286236
Change-Id: Ibb3df034c9b423dd4130d8242bd7bf0dc742ee2f
2021-07-08 09:20:25 +02:00
Thiemo Kreuz 3cd91100a9 Move code that belongs to the template specification
Separation of concerns:
* The template model knows which parameters are currently used,
  but doesn't know what's documented.
* The spec knows what's documented, but doesn't know what's
  currently used.

Change-Id: I97cac00d6775a17a07059d0e8a7a116adc6080b3
2021-07-07 16:45:35 +02:00
Thiemo Kreuz 9624f61701 Add missing test case with template parameter placeholder
There are some methods that behave different when a parameter
placeholder (where the parameter name is "") is present. Some
skip placeholders, some don't. This is critical to cover
before we make further changes to this class.

What I also do in this patch:
* Use shorter variable names to make the code easier to read.
* Don't reuse the `transclusionData` variable but use a copy
  of the expected value. This makes the assertions much
  easier to understand.
* Bring every test in the same "setup" → "execute" → "assert"
  order.

Change-Id: I41a691c56bc509b132dc719ff820ae1ade4ccc3a
2021-07-07 15:53:40 +02:00
jenkins-bot de71ebc9de Merge "Simplify ve.dm.MWTemplateModel.hasParameter() a lot" 2021-07-06 08:23:15 +00:00
jenkins-bot 4a5f811c82 Merge "Keep template parameter position when resolving aliases" 2021-07-05 11:44:19 +00:00
Thiemo Kreuz fbb7d211d0 Simplify ve.dm.MWTemplateModel.hasParameter() a lot
A lot of the checks are redundant. The first check still is
redundant because the later two cover everything as well. But
I left it for performance reasons.

Additionally:
* There was no test for the method.
* This patch also updates a few pieces of documentation in the
  same class.

Change-Id: I10f2944a844cc070bdc08dec6719929b383e34fa
2021-07-05 11:58:42 +02:00