mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/MinervaNeue
synced 2024-12-19 09:11:05 +00:00
ca28efc9c7
This restores the previously reverted patchset If5b76245bf60bfa9cf977cdbf37ee0d6bb65f9d9 Changes since original: * Added Depends-On to MobileFrontend * Uses OOUI classes for page issues rather than es6 classes - ES6 classes do not support modifications to class prior to running super so MobileFrontend's View class is not compatible without significant refactors. Depends-On: I24ad75adf8519102ca356d64d99d765ab69180cc Bug: T348807 Change-Id: I4ff82af0251254c846f2caee330af5af738f6029
56 lines
1.5 KiB
JavaScript
56 lines
1.5 KiB
JavaScript
( function () {
|
|
|
|
var AB = require( '../../../resources/skins.minerva.scripts/AB.js' ),
|
|
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 = Object.assign( {}, 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 + '%)' );
|
|
} );
|
|
|
|
}() );
|