wiki.techinc.nl/tests/qunit/QUnitTestResources.php
Moriel Schottlender 85876bbc71 RCFilters: Make frontend URL follow backend rules and add 'urlversion=2'
The backend always merges the query with wiki/user defaults before
it gives us data. The frontend, though, initially assumed that the
state is given strictly by the URL parameters (especially after the
URL shorening commit). This made it so that the frontend state is
incompatible with backend state.

However, always merging frontend state with user/wiki defaults can
produce inconsistencies between URLs in the same wiki, preventing
users from sharing them -- and making it potentially break if ever
a wiki default changes.

The solution is to add 'urlversion=2' to all RCFilters-generated
URLs and have the backend recognize this parameter as 'do not
merge with defaults'.

When RCFilters frontend loads, it checks whether the parameter
exists; if it doesn't, it merges whatever it sees with the defaults
just like the backend, then it transforms the URL to represent the
correct full state, and adds 'urlversion=2' to the URL parameters,
making it consistent across accounts and through time for the
next time it will load.

This means several new behaviors over the 'short url' commit:
- Accessing Special:RecentChanges directly (no query) will result
  in one of two things:
  -- If there is a saved query that's set to default:
     The system will load that saved query "straight forward" (as
     if the user clicked that option from the menu) causing, also,
     an ajax re-request from the server (since the server does not
     yet know about saved queries or their potential for being
     the default state.)
  -- If there is no saved query default: The system will load
     user/wiki defaults (like the backend does) and then fix the
     url to represent this state fully (with parameters showing the
     actual state of the filters.
  -- Both cases will also result in adding 'urlversion=2' to
     the end result URL.
- Accessing Special:RecentChanges?urlversion=2 (without any other
  parameters) will result in loading a completely empty filter set
  in RCFilters. We assume that 'urlversion=2' does not load defaults
  even if it is the only parameter in the URL.
- Accessing Special:RecentChanges?hideX=1 (parameter set without
  urlversion=2) will result in the front end taking the requested
  parameters, merging them with user/wiki default (reproducing what
  the backend does) and then adding urlversion=2 to the URL.

In all cases except for the default-saved-query-load case, the initial
load will **not** re-request data from the backend. The backend needs
to adjust to respect urlversion=2 as well (will come in an upcoming
commit) so the state and expectation of both the front- and back-end
are the same.

This commit also factors out URL handing to a separate class (UriProcessor)
and adds unit tests for it.

Bug: T166907
Bug: T166972
Bug: T166974
Change-Id: I0eed3bc0d4fa4810b6301b535c75b6bfbc8b4a5b
2017-06-14 10:50:49 -07:00

149 lines
6.2 KiB
PHP

<?php
/* Modules registered when $wgEnableJavaScriptTest is true */
return [
/* Utilities */
'test.sinonjs' => [
'scripts' => [
'tests/qunit/suites/resources/test.sinonjs/index.js',
'resources/lib/sinonjs/sinon-1.17.3.js',
// We want tests to work in IE, but can't include this as it
// will break the placeholders in Sinon because the hack it uses
// to hijack IE globals relies on running in the global scope
// and in ResourceLoader this won't be running in the global scope.
// Including it results (among other things) in sandboxed timers
// being broken due to Date inheritance being undefined.
// 'resources/lib/sinonjs/sinon-ie-1.15.4.js',
],
'targets' => [ 'desktop', 'mobile' ],
],
'test.mediawiki.qunit.testrunner' => [
'scripts' => [
'tests/qunit/data/testrunner.js',
],
'dependencies' => [
// Test runner configures QUnit but can't have it as dependency,
// see SpecialJavaScriptTest::viewQUnit.
'jquery.getAttrs',
'mediawiki.page.ready',
'mediawiki.page.startup',
'test.sinonjs',
],
'position' => 'top',
'targets' => [ 'desktop', 'mobile' ],
],
/*
Test suites for MediaWiki core modules
These must have a dependency on test.mediawiki.qunit.testrunner!
*/
'test.mediawiki.qunit.suites' => [
'scripts' => [
'tests/qunit/suites/resources/startup.test.js',
'tests/qunit/suites/resources/jquery/jquery.accessKeyLabel.test.js',
'tests/qunit/suites/resources/jquery/jquery.autoEllipsis.test.js',
'tests/qunit/suites/resources/jquery/jquery.byteLength.test.js',
'tests/qunit/suites/resources/jquery/jquery.byteLimit.test.js',
'tests/qunit/suites/resources/jquery/jquery.color.test.js',
'tests/qunit/suites/resources/jquery/jquery.colorUtil.test.js',
'tests/qunit/suites/resources/jquery/jquery.getAttrs.test.js',
'tests/qunit/suites/resources/jquery/jquery.hidpi.test.js',
'tests/qunit/suites/resources/jquery/jquery.highlightText.test.js',
'tests/qunit/suites/resources/jquery/jquery.localize.test.js',
'tests/qunit/suites/resources/jquery/jquery.makeCollapsible.test.js',
'tests/qunit/suites/resources/jquery/jquery.mwExtension.test.js',
'tests/qunit/suites/resources/jquery/jquery.tabIndex.test.js',
'tests/qunit/suites/resources/jquery/jquery.tablesorter.test.js',
'tests/qunit/suites/resources/jquery/jquery.tablesorter.parsers.test.js',
'tests/qunit/suites/resources/jquery/jquery.textSelection.test.js',
'tests/qunit/data/mediawiki.jqueryMsg.data.js',
'tests/qunit/suites/resources/mediawiki/mediawiki.requestIdleCallback.test.js',
'tests/qunit/suites/resources/mediawiki/mediawiki.errorLogger.test.js',
'tests/qunit/suites/resources/mediawiki/mediawiki.jqueryMsg.test.js',
'tests/qunit/suites/resources/mediawiki/mediawiki.jscompat.test.js',
'tests/qunit/suites/resources/mediawiki/mediawiki.messagePoster.factory.test.js',
'tests/qunit/suites/resources/mediawiki/mediawiki.RegExp.test.js',
'tests/qunit/suites/resources/mediawiki/mediawiki.storage.test.js',
'tests/qunit/suites/resources/mediawiki/mediawiki.template.test.js',
'tests/qunit/suites/resources/mediawiki/mediawiki.template.mustache.test.js',
'tests/qunit/suites/resources/mediawiki/mediawiki.test.js',
'tests/qunit/suites/resources/mediawiki/mediawiki.loader.test.js',
'tests/qunit/suites/resources/mediawiki/mediawiki.html.test.js',
'tests/qunit/suites/resources/mediawiki/mediawiki.inspect.test.js',
'tests/qunit/suites/resources/mediawiki/mediawiki.Title.test.js',
'tests/qunit/suites/resources/mediawiki/mediawiki.toc.test.js',
'tests/qunit/suites/resources/mediawiki/mediawiki.track.test.js',
'tests/qunit/suites/resources/mediawiki/mediawiki.Uri.test.js',
'tests/qunit/suites/resources/mediawiki/mediawiki.user.test.js',
'tests/qunit/suites/resources/mediawiki/mediawiki.util.test.js',
'tests/qunit/suites/resources/mediawiki/mediawiki.viewport.test.js',
'tests/qunit/suites/resources/mediawiki.api/mediawiki.api.test.js',
'tests/qunit/suites/resources/mediawiki.api/mediawiki.api.category.test.js',
'tests/qunit/suites/resources/mediawiki.api/mediawiki.api.edit.test.js',
'tests/qunit/suites/resources/mediawiki.api/mediawiki.api.messages.test.js',
'tests/qunit/suites/resources/mediawiki.api/mediawiki.api.options.test.js',
'tests/qunit/suites/resources/mediawiki.api/mediawiki.api.parse.test.js',
'tests/qunit/suites/resources/mediawiki.api/mediawiki.api.upload.test.js',
'tests/qunit/suites/resources/mediawiki.api/mediawiki.api.watch.test.js',
'tests/qunit/suites/resources/mediawiki.api/mediawiki.ForeignApi.test.js',
'tests/qunit/suites/resources/mediawiki.special/mediawiki.special.recentchanges.test.js',
'tests/qunit/suites/resources/mediawiki.rcfilters/dm.FiltersViewModel.test.js',
'tests/qunit/suites/resources/mediawiki.rcfilters/dm.FilterItem.test.js',
'tests/qunit/suites/resources/mediawiki.rcfilters/UriProcessor.test.js',
'tests/qunit/suites/resources/mediawiki/mediawiki.language.test.js',
'tests/qunit/suites/resources/mediawiki/mediawiki.cldr.test.js',
'tests/qunit/suites/resources/mediawiki/mediawiki.cookie.test.js',
'tests/qunit/suites/resources/mediawiki/mediawiki.experiments.test.js',
],
'dependencies' => [
'jquery.accessKeyLabel',
'jquery.autoEllipsis',
'jquery.byteLength',
'jquery.byteLimit',
'jquery.color',
'jquery.colorUtil',
'jquery.getAttrs',
'jquery.hidpi',
'jquery.highlightText',
'jquery.localize',
'jquery.makeCollapsible',
'jquery.mwExtension',
'jquery.tabIndex',
'jquery.tablesorter',
'jquery.textSelection',
'mediawiki.api',
'mediawiki.api.category',
'mediawiki.api.messages',
'mediawiki.api.options',
'mediawiki.api.parse',
'mediawiki.api.upload',
'mediawiki.api.watch',
'mediawiki.ForeignApi.core',
'mediawiki.jqueryMsg',
'mediawiki.messagePoster',
'mediawiki.RegExp',
'mediawiki.storage',
'mediawiki.Title',
'mediawiki.toc',
'mediawiki.Uri',
'mediawiki.user',
'mediawiki.template.mustache',
'mediawiki.template',
'mediawiki.util',
'mediawiki.viewport',
'mediawiki.special.recentchanges',
'mediawiki.rcfilters.filters.dm',
'mediawiki.language',
'mediawiki.cldr',
'mediawiki.cookie',
'mediawiki.experiments',
'mediawiki.inspect',
'test.mediawiki.qunit.testrunner',
],
]
];