Project Information
- Name of project: Extension:WikiUnit (working title, may change)
- Project home page: none yet
- Name of team which owns the project: none yet
- Primary contact for the project: @Evad37
- Target date for deployment: none yet
- Link to code repository: none yet (I want to check if the concept is workable, or how it could be made workable, before starting anything)
- Is this a brand-new project: yes
- Has this project ever been reviewed before: (Phab tasks, etc.) no
- Has any risk assessment (STRIDE, etc.) been performed: no
- Is there an existing RFC or has this been presented to the community: enwiki discussion, T240647, T39230 (more generally, not for this specific concept: T234661)
- Is this project tied to a team quarterly goal: no
- Does this project require its own privacy policy: no
Description of the project and how it will be used
Per T240647 (more details there):
An extension that provides unit testing capability for gadgets/scripts, using QUnit. Unit tests are defined on a script's /testcases.js subpage.
Tests are run when editing, after previewing or showing changes (action=submit) -- or perhaps a new button "Run unit tests".
To run tests, load QUnit js and css, concatenate the editor textbox content and the content of the testcases subpages (so they are within the same outer scope), and execute the resulting text as javascript.There may need to restrictions on where this can operate for security:
- MediaWiki namespace should be okay - editing is restricted to interface admins
- contentmodel:javascript pages in your userspace should be okay - editing is restricted to yourself and interface admins
- Elsewhere could be problematic. The safest way would be to just not operate on these pages... but perhaps just having a confirmation box with a "scary" message (similar to enwiki's MediaWiki:Jswarning) would be good enough, given that it's not really any worse than using importScript on your common.js
- Perhaps there should also be a note or warning that code entered into the textbox will be executed to run unit tests
Additionally, per T39230, there should be a Special page to run tests for the current saved version of a script (without needing to edit it).
Description of any sensitive data to be collected or exposed
None
Technologies employed
JavaScript and PHP
Dependencies and vendor code
QUnit, and probably mediawiki.api, mediawiki.util, and oojs
Working test environment
Proof-of-concept: WikiUnit userscript (source)
