mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/MinervaNeue
synced 2024-11-17 11:13:34 +00:00
5593b23aa8
Replace all occurrences of `M.require( 'mobile.startup/pathToModule' )` with `M.require( 'mobile.startup' ).pathToModule`. Where multiple requires existed, add an intermediate variable, `var mobile = M.require( 'mobile.startup' )`, and dot off that. This changes improves the consistency of MinervaNeue which currently contains a mix of require styles and eliminates any deprecated requires. Bug: T208915 Change-Id: If14f280672d914d07275197100b12421bb217b67
57 lines
1.5 KiB
JavaScript
57 lines
1.5 KiB
JavaScript
( function ( M ) {
|
|
|
|
var AB = M.require( 'skins.minerva.scripts/AB' ),
|
|
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.4 ) &&
|
|
( userBuckets.unsampled / maxUsers < 0.6 ),
|
|
true, 'test unsampled group is about 50% (' + userBuckets.unsampled / 10 + '%)' );
|
|
|
|
assert.strictEqual(
|
|
( userBuckets.control / maxUsers > 0.2 ) &&
|
|
( userBuckets.control / maxUsers < 0.3 ),
|
|
true, 'test control group is about 25% (' + userBuckets.control / 10 + '%)' );
|
|
|
|
assert.strictEqual(
|
|
( userBuckets.treatment / maxUsers > 0.2 ) &&
|
|
( userBuckets.treatment / maxUsers < 0.3 ),
|
|
true, 'test new treatment group is about 25% (' + userBuckets.treatment / 10 + '%)' );
|
|
} );
|
|
|
|
}( mw.mobileFrontend ) );
|