Enable the CTA experiment on all environments (#10432)
This commit is contained in:
Родитель
ede59eb38e
Коммит
0ae08bbc56
|
@ -430,5 +430,6 @@ module.exports = {
|
|||
// See: https://github.com/mozilla/addons-frontend/pull/9125#issuecomment-580683288
|
||||
//
|
||||
// e.g., 20200204_installWarning: true,
|
||||
'20210404_download_cta_experiment': true,
|
||||
},
|
||||
};
|
||||
|
|
|
@ -46,8 +46,4 @@ module.exports = {
|
|||
extensionWorkshopUrl: 'https://extensionworkshop-dev.allizom.org',
|
||||
|
||||
enableFeatureLinkToNewBlog: true,
|
||||
|
||||
experiments: {
|
||||
'20210404_download_cta_experiment': true,
|
||||
},
|
||||
};
|
||||
|
|
|
@ -83,8 +83,4 @@ module.exports = {
|
|||
extensionWorkshopUrl: 'https://extensionworkshop-dev.allizom.org',
|
||||
|
||||
enableFeatureLinkToNewBlog: true,
|
||||
|
||||
experiments: {
|
||||
'20210404_download_cta_experiment': true,
|
||||
},
|
||||
};
|
||||
|
|
|
@ -10,4 +10,9 @@ module.exports = {
|
|||
enableRequestID: false,
|
||||
|
||||
mozillaUserId: 1337,
|
||||
|
||||
// Because tests run on the server by default and experiments are client-side
|
||||
// only, we don't want to have any active experiments. Otherwise tests try to
|
||||
// send an enrollment event, which triggers an exception.
|
||||
experiments: null,
|
||||
};
|
||||
|
|
|
@ -10,6 +10,8 @@ module.exports = {
|
|||
moduleNameMapper: {
|
||||
// Alias tests for tests to be able to import helpers.
|
||||
'^tests/(.*)$': '<rootDir>/tests/$1',
|
||||
// Alias config for tests to be able to import config files.
|
||||
'^config/(.*)$': '<rootDir>/config/$1',
|
||||
// Replaces the following formats with an empty module.
|
||||
'^.+\\.(scss|css|svg|woff|woff2|mp4|webm)$': '<rootDir>/tests/emptyModule',
|
||||
// Alias bin for bin scripts.
|
||||
|
|
|
@ -36,7 +36,7 @@ export const viewFrontendVersionHandler = ({
|
|||
};
|
||||
}, {});
|
||||
|
||||
const experiments = _config.get('experiments');
|
||||
const experiments = _config.get('experiments') || {};
|
||||
|
||||
return (req: typeof $Request, res: typeof $Response) => {
|
||||
fs.stat(version, async (error) => {
|
||||
|
|
|
@ -125,7 +125,8 @@ export const isExperimentEnabled = ({
|
|||
_config: typeof config,
|
||||
id: string,
|
||||
|}): boolean => {
|
||||
return _config.get('experiments')[id] === true;
|
||||
const experiments = _config.get('experiments') || {};
|
||||
return experiments[id] === true;
|
||||
};
|
||||
|
||||
type withExperimentInternalProps = {|
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import config from 'config';
|
||||
import { shallow } from 'enzyme';
|
||||
import * as React from 'react';
|
||||
|
||||
|
@ -11,6 +10,8 @@ import {
|
|||
getVariant,
|
||||
withExperiment,
|
||||
} from 'amo/withExperiment';
|
||||
// eslint-disable-next-line import/namespace
|
||||
import * as defaultConfig from 'config/default';
|
||||
import {
|
||||
createFakeTracking,
|
||||
fakeCookies,
|
||||
|
@ -406,6 +407,13 @@ describe(__filename, () => {
|
|||
expect(root).toHaveProp('isExperimentEnabled', false);
|
||||
});
|
||||
|
||||
it('can handle a null for experiments in the config', () => {
|
||||
const configOverrides = { experiments: null };
|
||||
|
||||
const root = render({ configOverrides });
|
||||
expect(root).toHaveProp('isExperimentEnabled', false);
|
||||
});
|
||||
|
||||
it('throws an exception for a badly formatted experimentId', () => {
|
||||
expect(() => {
|
||||
render({ experimentProps: { id: 'bad-id' } });
|
||||
|
@ -415,7 +423,8 @@ describe(__filename, () => {
|
|||
it('does not have any invalid experiment ids defined in the config', () => {
|
||||
// If this test fails it is because an experimentId does not match the
|
||||
// expected format of YYYYMMDD_ExperimentName.
|
||||
for (const experimentId of Object.keys(config.get('experiments'))) {
|
||||
// eslint-disable-next-line import/namespace
|
||||
for (const experimentId of Object.keys(defaultConfig.experiments)) {
|
||||
expect(EXPERIMENT_ID_REGEXP.test(experimentId)).toEqual(true);
|
||||
}
|
||||
});
|
||||
|
|
Загрузка…
Ссылка в новой задаче