mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/MinervaNeue
synced 2024-11-17 03:08:12 +00:00
72df451bd3
Help with readability by using module.exports and require rather than the MobileFrontend provided mw.mobileFrontend module manager (and avoid adopting webpack at this time) Replace usages of mw.mobileFrontend.require with local require and module.exports (compatible with RL or Node implementation) Changes: * Notifications modules are merged into skins.minerva.scripts and initialised via a client side check. * new file overlayManager for exporting an overlayManager singleton rather than being hidden inside resources/skins.minerva.scripts/init.js * All M.define/M.requires swapped out for require where possible The `define` method is now forbidden in the repo. Bug: T212944 Change-Id: I44790dd3fc6fe42bb502d79c39c4081c223bf2b1
57 lines
1.6 KiB
JavaScript
57 lines
1.6 KiB
JavaScript
( function ( M ) {
|
|
|
|
var AB = require( '../../../resources/skins.minerva.scripts/AB.js' ),
|
|
util = M.require( 'mobile.startup' ).util,
|
|
defaultConfig = {
|
|
testName: 'WME.MinervaABTest',
|
|
samplingRate: 0.5,
|
|
sessionId: mw.user.generateRandomSessionId()
|
|
};
|
|
|
|
QUnit.module( 'Minerva AB-test' );
|
|
|
|
QUnit.test( 'Bucketing test', function ( assert ) {
|
|
var userBuckets = {
|
|
unsampled: 0,
|
|
control: 0,
|
|
treatment: 0
|
|
},
|
|
maxUsers = 1000,
|
|
bucketingTest,
|
|
config,
|
|
i;
|
|
|
|
for ( i = 0; i < maxUsers; i++ ) {
|
|
config = util.extend( {}, defaultConfig, {
|
|
sessionId: mw.user.generateRandomSessionId()
|
|
} );
|
|
bucketingTest = new AB( config );
|
|
if ( bucketingTest.isControl() ) {
|
|
++userBuckets.control;
|
|
} else if ( bucketingTest.isTreatment() ) {
|
|
++userBuckets.treatment;
|
|
} else if ( !bucketingTest.isSampled() ) {
|
|
++userBuckets.unsampled;
|
|
} else {
|
|
throw new Error( 'Unknown bucket!' );
|
|
}
|
|
}
|
|
|
|
assert.strictEqual(
|
|
( userBuckets.unsampled / maxUsers > 0.3 ) &&
|
|
( userBuckets.unsampled / maxUsers < 0.7 ),
|
|
true, 'test unsampled group is about 50% (' + userBuckets.unsampled / 10 + '%)' );
|
|
|
|
assert.strictEqual(
|
|
( userBuckets.control / maxUsers > 0.1 ) &&
|
|
( userBuckets.control / maxUsers < 0.4 ),
|
|
true, 'test control group is about 25% (' + userBuckets.control / 10 + '%)' );
|
|
|
|
assert.strictEqual(
|
|
( userBuckets.treatment / maxUsers > 0.1 ) &&
|
|
( userBuckets.treatment / maxUsers < 0.4 ),
|
|
true, 'test new treatment group is about 25% (' + userBuckets.treatment / 10 + '%)' );
|
|
} );
|
|
|
|
}( mw.mobileFrontend ) );
|