@atlaskit/tmp-editor-statsig 1.4.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/dist/cjs/{test-runner.js → editor-experiments-test-utils.js} +4 -4
- package/dist/cjs/experiments-config.js +9 -0
- package/dist/cjs/experiments.js +7 -48
- package/dist/cjs/setup.js +53 -0
- package/dist/es2019/{test-runner.js → editor-experiments-test-utils.js} +1 -1
- package/dist/es2019/experiments-config.js +9 -0
- package/dist/es2019/experiments.js +3 -38
- package/dist/es2019/setup.js +41 -0
- package/dist/esm/{test-runner.js → editor-experiments-test-utils.js} +1 -1
- package/dist/esm/experiments-config.js +9 -0
- package/dist/esm/experiments.js +3 -42
- package/dist/esm/setup.js +45 -0
- package/dist/{types-ts4.5/test-runner.d.ts → types/editor-experiments-test-utils.d.ts} +1 -1
- package/dist/types/experiments-config.d.ts +8 -0
- package/dist/types/experiments.d.ts +1 -21
- package/dist/types/setup.d.ts +32 -0
- package/dist/{types/test-runner.d.ts → types-ts4.5/editor-experiments-test-utils.d.ts} +1 -1
- package/dist/types-ts4.5/experiments-config.d.ts +8 -0
- package/dist/types-ts4.5/experiments.d.ts +1 -21
- package/dist/types-ts4.5/setup.d.ts +32 -0
- package/editor-experiments-test-utils/package.json +14 -0
- package/package.json +3 -4
- package/setup/package.json +14 -0
- package/test-runner/package.json +0 -14
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @atlaskit/editor-statsig-tmp
|
|
2
2
|
|
|
3
|
+
## 2.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- [#136209](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/136209)
|
|
8
|
+
[`2d0d9036c143a`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/2d0d9036c143a) -
|
|
9
|
+
[ED-24790] Add support for editor experiments in gemini tests
|
|
10
|
+
|
|
11
|
+
## 1.4.1
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [#136078](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/136078)
|
|
16
|
+
[`09414d7233497`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/09414d7233497) -
|
|
17
|
+
ED-24507 Switch nested dnd FG to experiment and include padding changes"
|
|
18
|
+
|
|
3
19
|
## 1.4.0
|
|
4
20
|
|
|
5
21
|
### Minor Changes
|
|
@@ -8,7 +8,7 @@ exports.eeTest = eeTest;
|
|
|
8
8
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
9
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
10
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
11
|
-
var
|
|
11
|
+
var _setup = require("./setup");
|
|
12
12
|
var _experimentsConfig = require("./experiments-config");
|
|
13
13
|
// This is loosely based on the `ffTest` util from `@atlassian/feature-flags-test-utils` package.
|
|
14
14
|
|
|
@@ -48,10 +48,10 @@ var _experimentsConfig = require("./experiments-config");
|
|
|
48
48
|
* ```
|
|
49
49
|
*/
|
|
50
50
|
function eeTest(experimentName, cases, otherExperiments) {
|
|
51
|
-
(0,
|
|
51
|
+
(0, _setup.setupEditorExperiments)('test', {});
|
|
52
52
|
describe("eeTest: ".concat(experimentName), function () {
|
|
53
53
|
afterEach(function () {
|
|
54
|
-
(0,
|
|
54
|
+
(0, _setup.setupEditorExperiments)('test', otherExperiments !== null && otherExperiments !== void 0 ? otherExperiments : {});
|
|
55
55
|
});
|
|
56
56
|
var isBooleanExperiment = typeof _experimentsConfig.editorExperimentsConfig[experimentName].defaultValue === 'boolean';
|
|
57
57
|
if (isBooleanExperiment && Object.keys(cases).length !== 2) {
|
|
@@ -65,7 +65,7 @@ function eeTest(experimentName, cases, otherExperiments) {
|
|
|
65
65
|
case 0:
|
|
66
66
|
testCaseKey = value; // For boolean experiments, we need to convert the 'on' and 'off' cases to boolean `true` and `false` values.
|
|
67
67
|
convertedValue = isBooleanExperiment ? testCaseKey === 'true' ? true : false : testCaseKey;
|
|
68
|
-
(0,
|
|
68
|
+
(0, _setup.setupEditorExperiments)('test', (0, _defineProperty2.default)({}, experimentName, convertedValue));
|
|
69
69
|
testCase = cases[testCaseKey]; // @ts-ignore
|
|
70
70
|
_context.next = 6;
|
|
71
71
|
return Promise.resolve(testCase());
|
|
@@ -84,5 +84,14 @@ var editorExperimentsConfig = exports.editorExperimentsConfig = {
|
|
|
84
84
|
param: 'isEnabled',
|
|
85
85
|
typeGuard: isBoolean,
|
|
86
86
|
defaultValue: false
|
|
87
|
+
},
|
|
88
|
+
// Added 2024-08-30
|
|
89
|
+
'nested-dnd': {
|
|
90
|
+
productKeys: {
|
|
91
|
+
confluence: 'platform_editor_element_drag_and_drop_nested'
|
|
92
|
+
},
|
|
93
|
+
param: 'isEnabled',
|
|
94
|
+
typeGuard: isBoolean,
|
|
95
|
+
defaultValue: false
|
|
87
96
|
}
|
|
88
97
|
};
|
package/dist/cjs/experiments.js
CHANGED
|
@@ -5,52 +5,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.editorExperiment = editorExperiment;
|
|
8
|
-
exports.setupEditorExperiments = setupEditorExperiments;
|
|
9
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
11
8
|
var _featureGateJsClient = _interopRequireDefault(require("@atlaskit/feature-gate-js-client"));
|
|
12
9
|
var _experimentsConfig = require("./experiments-config");
|
|
13
|
-
|
|
14
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
15
|
-
var _overrides = {};
|
|
16
|
-
var _product;
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* This function is used to set up the editor experiments for testing purposes.
|
|
20
|
-
* It should be called before running code that depends on editor experiments.
|
|
21
|
-
*
|
|
22
|
-
* @example
|
|
23
|
-
* ```ts
|
|
24
|
-
* setupEditorExperiments('confluence', {
|
|
25
|
-
* 'experiment-name': 'value',
|
|
26
|
-
* });
|
|
27
|
-
* ```
|
|
28
|
-
*/
|
|
29
|
-
function setupEditorExperiments(product,
|
|
30
|
-
/**
|
|
31
|
-
* Overrides are used to set the value of an experiment for testing purposes.
|
|
32
|
-
* This is useful when you want to test a specific value of an experiment.
|
|
33
|
-
*/
|
|
34
|
-
overrides) {
|
|
35
|
-
if (overrides) {
|
|
36
|
-
// When setting up overrides, we want to ensure that experiments don't end up with invalid
|
|
37
|
-
// values.
|
|
38
|
-
// For production usage -- this is done via the feature flag client which takes the type
|
|
39
|
-
// and performs equivalent logic.
|
|
40
|
-
// @ts-ignore
|
|
41
|
-
overrides = Object.entries(overrides).reduce(function (acc, _ref) {
|
|
42
|
-
var _ref2 = (0, _slicedToArray2.default)(_ref, 2),
|
|
43
|
-
key = _ref2[0],
|
|
44
|
-
value = _ref2[1];
|
|
45
|
-
var config = _experimentsConfig.editorExperimentsConfig[key];
|
|
46
|
-
acc = _objectSpread(_objectSpread({}, acc), {}, (0, _defineProperty2.default)({}, key, config.typeGuard(value) ? value : config.defaultValue));
|
|
47
|
-
return acc;
|
|
48
|
-
}, {});
|
|
49
|
-
_overrides = overrides;
|
|
50
|
-
}
|
|
51
|
-
_product = product;
|
|
52
|
-
}
|
|
53
|
-
|
|
10
|
+
var _setup = require("./setup");
|
|
54
11
|
/**
|
|
55
12
|
* Check the value of an editor experiment.
|
|
56
13
|
*
|
|
@@ -99,21 +56,23 @@ function editorExperiment(experimentName, expectedExperimentValue) {
|
|
|
99
56
|
exposure: false
|
|
100
57
|
};
|
|
101
58
|
var experimentConfig = _experimentsConfig.editorExperimentsConfig[experimentName];
|
|
102
|
-
if (_overrides[experimentName] !== undefined) {
|
|
59
|
+
if (_setup._overrides[experimentName] !== undefined) {
|
|
103
60
|
// This will be hit in the case of a test setting an override
|
|
104
|
-
return _overrides[experimentName] === expectedExperimentValue;
|
|
61
|
+
return _setup._overrides[experimentName] === expectedExperimentValue;
|
|
105
62
|
}
|
|
106
|
-
if (!_product) {
|
|
63
|
+
if (!_setup._product) {
|
|
107
64
|
// This will be hit in the case of a product not having setup the editor experiment tooling
|
|
108
65
|
return experimentConfig.defaultValue === expectedExperimentValue;
|
|
109
66
|
}
|
|
110
67
|
|
|
111
68
|
// Typescript is complaining here about accessing the productKeys property
|
|
112
|
-
var experimentKey = (_experimentConfig$pro = experimentConfig.productKeys) === null || _experimentConfig$pro === void 0 ? void 0 : _experimentConfig$pro[_product];
|
|
69
|
+
var experimentKey = (_experimentConfig$pro = experimentConfig.productKeys) === null || _experimentConfig$pro === void 0 ? void 0 : _experimentConfig$pro[_setup._product];
|
|
113
70
|
if (!experimentKey) {
|
|
114
71
|
// This will be hit in the case of an experiment not being set up for the product
|
|
115
72
|
return _experimentsConfig.editorExperimentsConfig[experimentName].defaultValue === expectedExperimentValue;
|
|
116
73
|
}
|
|
74
|
+
|
|
75
|
+
// eslint-disable-next-line @atlaskit/platform/use-recommended-utils
|
|
117
76
|
var experimentValue = _featureGateJsClient.default.getExperimentValue(
|
|
118
77
|
// @ts-ignore
|
|
119
78
|
experimentKey, experimentConfig.param, experimentConfig.defaultValue, {
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports._product = exports._overrides = void 0;
|
|
8
|
+
exports.setupEditorExperiments = setupEditorExperiments;
|
|
9
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
10
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
11
|
+
var _experimentsConfig = require("./experiments-config");
|
|
12
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
13
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
14
|
+
var _overrides = exports._overrides = {};
|
|
15
|
+
var _product;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* This function is used to set up the editor experiments for testing purposes.
|
|
19
|
+
* It should be called before running code that depends on editor experiments.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```ts
|
|
23
|
+
* setupEditorExperiments('confluence', {
|
|
24
|
+
* 'experiment-name': 'value',
|
|
25
|
+
* });
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
function setupEditorExperiments(product,
|
|
29
|
+
/**
|
|
30
|
+
* Overrides are used to set the value of an experiment for testing purposes.
|
|
31
|
+
* This is useful when you want to test a specific value of an experiment.
|
|
32
|
+
*/
|
|
33
|
+
overrides) {
|
|
34
|
+
if (overrides) {
|
|
35
|
+
// When setting up overrides, we want to ensure that experiments don't end up with invalid
|
|
36
|
+
// values.
|
|
37
|
+
// For production usage -- this is done via the feature flag client which takes the type
|
|
38
|
+
// and performs equivalent logic.
|
|
39
|
+
// @ts-ignore
|
|
40
|
+
overrides = Object.entries(overrides).reduce(function (acc, _ref) {
|
|
41
|
+
var _ref2 = (0, _slicedToArray2.default)(_ref, 2),
|
|
42
|
+
key = _ref2[0],
|
|
43
|
+
value = _ref2[1];
|
|
44
|
+
var config = _experimentsConfig.editorExperimentsConfig[key];
|
|
45
|
+
if (config) {
|
|
46
|
+
acc = _objectSpread(_objectSpread({}, acc), {}, (0, _defineProperty2.default)({}, key, config.typeGuard(value) ? value : config.defaultValue));
|
|
47
|
+
}
|
|
48
|
+
return acc;
|
|
49
|
+
}, {});
|
|
50
|
+
exports._overrides = _overrides = overrides;
|
|
51
|
+
}
|
|
52
|
+
exports._product = _product = product;
|
|
53
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// This is loosely based on the `ffTest` util from `@atlassian/feature-flags-test-utils` package.
|
|
2
2
|
|
|
3
|
-
import { setupEditorExperiments } from './
|
|
3
|
+
import { setupEditorExperiments } from './setup';
|
|
4
4
|
import { editorExperimentsConfig } from './experiments-config';
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -78,5 +78,14 @@ export const editorExperimentsConfig = {
|
|
|
78
78
|
param: 'isEnabled',
|
|
79
79
|
typeGuard: isBoolean,
|
|
80
80
|
defaultValue: false
|
|
81
|
+
},
|
|
82
|
+
// Added 2024-08-30
|
|
83
|
+
'nested-dnd': {
|
|
84
|
+
productKeys: {
|
|
85
|
+
confluence: 'platform_editor_element_drag_and_drop_nested'
|
|
86
|
+
},
|
|
87
|
+
param: 'isEnabled',
|
|
88
|
+
typeGuard: isBoolean,
|
|
89
|
+
defaultValue: false
|
|
81
90
|
}
|
|
82
91
|
};
|
|
@@ -1,43 +1,6 @@
|
|
|
1
1
|
import FeatureGates from '@atlaskit/feature-gate-js-client';
|
|
2
2
|
import { editorExperimentsConfig } from './experiments-config';
|
|
3
|
-
|
|
4
|
-
let _product;
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* This function is used to set up the editor experiments for testing purposes.
|
|
8
|
-
* It should be called before running code that depends on editor experiments.
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* ```ts
|
|
12
|
-
* setupEditorExperiments('confluence', {
|
|
13
|
-
* 'experiment-name': 'value',
|
|
14
|
-
* });
|
|
15
|
-
* ```
|
|
16
|
-
*/
|
|
17
|
-
export function setupEditorExperiments(product,
|
|
18
|
-
/**
|
|
19
|
-
* Overrides are used to set the value of an experiment for testing purposes.
|
|
20
|
-
* This is useful when you want to test a specific value of an experiment.
|
|
21
|
-
*/
|
|
22
|
-
overrides) {
|
|
23
|
-
if (overrides) {
|
|
24
|
-
// When setting up overrides, we want to ensure that experiments don't end up with invalid
|
|
25
|
-
// values.
|
|
26
|
-
// For production usage -- this is done via the feature flag client which takes the type
|
|
27
|
-
// and performs equivalent logic.
|
|
28
|
-
// @ts-ignore
|
|
29
|
-
overrides = Object.entries(overrides).reduce((acc, [key, value]) => {
|
|
30
|
-
const config = editorExperimentsConfig[key];
|
|
31
|
-
acc = {
|
|
32
|
-
...acc,
|
|
33
|
-
[key]: config.typeGuard(value) ? value : config.defaultValue
|
|
34
|
-
};
|
|
35
|
-
return acc;
|
|
36
|
-
}, {});
|
|
37
|
-
_overrides = overrides;
|
|
38
|
-
}
|
|
39
|
-
_product = product;
|
|
40
|
-
}
|
|
3
|
+
import { _overrides, _product } from './setup';
|
|
41
4
|
|
|
42
5
|
/**
|
|
43
6
|
* Check the value of an editor experiment.
|
|
@@ -101,6 +64,8 @@ export function editorExperiment(experimentName, expectedExperimentValue, option
|
|
|
101
64
|
// This will be hit in the case of an experiment not being set up for the product
|
|
102
65
|
return editorExperimentsConfig[experimentName].defaultValue === expectedExperimentValue;
|
|
103
66
|
}
|
|
67
|
+
|
|
68
|
+
// eslint-disable-next-line @atlaskit/platform/use-recommended-utils
|
|
104
69
|
const experimentValue = FeatureGates.getExperimentValue(
|
|
105
70
|
// @ts-ignore
|
|
106
71
|
experimentKey, experimentConfig.param, experimentConfig.defaultValue, {
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { editorExperimentsConfig } from './experiments-config';
|
|
2
|
+
export let _overrides = {};
|
|
3
|
+
export let _product;
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* This function is used to set up the editor experiments for testing purposes.
|
|
7
|
+
* It should be called before running code that depends on editor experiments.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* setupEditorExperiments('confluence', {
|
|
12
|
+
* 'experiment-name': 'value',
|
|
13
|
+
* });
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export function setupEditorExperiments(product,
|
|
17
|
+
/**
|
|
18
|
+
* Overrides are used to set the value of an experiment for testing purposes.
|
|
19
|
+
* This is useful when you want to test a specific value of an experiment.
|
|
20
|
+
*/
|
|
21
|
+
overrides) {
|
|
22
|
+
if (overrides) {
|
|
23
|
+
// When setting up overrides, we want to ensure that experiments don't end up with invalid
|
|
24
|
+
// values.
|
|
25
|
+
// For production usage -- this is done via the feature flag client which takes the type
|
|
26
|
+
// and performs equivalent logic.
|
|
27
|
+
// @ts-ignore
|
|
28
|
+
overrides = Object.entries(overrides).reduce((acc, [key, value]) => {
|
|
29
|
+
const config = editorExperimentsConfig[key];
|
|
30
|
+
if (config) {
|
|
31
|
+
acc = {
|
|
32
|
+
...acc,
|
|
33
|
+
[key]: config.typeGuard(value) ? value : config.defaultValue
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
return acc;
|
|
37
|
+
}, {});
|
|
38
|
+
_overrides = overrides;
|
|
39
|
+
}
|
|
40
|
+
_product = product;
|
|
41
|
+
}
|
|
@@ -3,7 +3,7 @@ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
|
3
3
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
4
4
|
// This is loosely based on the `ffTest` util from `@atlassian/feature-flags-test-utils` package.
|
|
5
5
|
|
|
6
|
-
import { setupEditorExperiments } from './
|
|
6
|
+
import { setupEditorExperiments } from './setup';
|
|
7
7
|
import { editorExperimentsConfig } from './experiments-config';
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -78,5 +78,14 @@ export var editorExperimentsConfig = {
|
|
|
78
78
|
param: 'isEnabled',
|
|
79
79
|
typeGuard: isBoolean,
|
|
80
80
|
defaultValue: false
|
|
81
|
+
},
|
|
82
|
+
// Added 2024-08-30
|
|
83
|
+
'nested-dnd': {
|
|
84
|
+
productKeys: {
|
|
85
|
+
confluence: 'platform_editor_element_drag_and_drop_nested'
|
|
86
|
+
},
|
|
87
|
+
param: 'isEnabled',
|
|
88
|
+
typeGuard: isBoolean,
|
|
89
|
+
defaultValue: false
|
|
81
90
|
}
|
|
82
91
|
};
|
package/dist/esm/experiments.js
CHANGED
|
@@ -1,47 +1,6 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
4
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
5
1
|
import FeatureGates from '@atlaskit/feature-gate-js-client';
|
|
6
2
|
import { editorExperimentsConfig } from './experiments-config';
|
|
7
|
-
|
|
8
|
-
var _product;
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* This function is used to set up the editor experiments for testing purposes.
|
|
12
|
-
* It should be called before running code that depends on editor experiments.
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
* ```ts
|
|
16
|
-
* setupEditorExperiments('confluence', {
|
|
17
|
-
* 'experiment-name': 'value',
|
|
18
|
-
* });
|
|
19
|
-
* ```
|
|
20
|
-
*/
|
|
21
|
-
export function setupEditorExperiments(product,
|
|
22
|
-
/**
|
|
23
|
-
* Overrides are used to set the value of an experiment for testing purposes.
|
|
24
|
-
* This is useful when you want to test a specific value of an experiment.
|
|
25
|
-
*/
|
|
26
|
-
overrides) {
|
|
27
|
-
if (overrides) {
|
|
28
|
-
// When setting up overrides, we want to ensure that experiments don't end up with invalid
|
|
29
|
-
// values.
|
|
30
|
-
// For production usage -- this is done via the feature flag client which takes the type
|
|
31
|
-
// and performs equivalent logic.
|
|
32
|
-
// @ts-ignore
|
|
33
|
-
overrides = Object.entries(overrides).reduce(function (acc, _ref) {
|
|
34
|
-
var _ref2 = _slicedToArray(_ref, 2),
|
|
35
|
-
key = _ref2[0],
|
|
36
|
-
value = _ref2[1];
|
|
37
|
-
var config = editorExperimentsConfig[key];
|
|
38
|
-
acc = _objectSpread(_objectSpread({}, acc), {}, _defineProperty({}, key, config.typeGuard(value) ? value : config.defaultValue));
|
|
39
|
-
return acc;
|
|
40
|
-
}, {});
|
|
41
|
-
_overrides = overrides;
|
|
42
|
-
}
|
|
43
|
-
_product = product;
|
|
44
|
-
}
|
|
3
|
+
import { _overrides, _product } from './setup';
|
|
45
4
|
|
|
46
5
|
/**
|
|
47
6
|
* Check the value of an editor experiment.
|
|
@@ -106,6 +65,8 @@ export function editorExperiment(experimentName, expectedExperimentValue) {
|
|
|
106
65
|
// This will be hit in the case of an experiment not being set up for the product
|
|
107
66
|
return editorExperimentsConfig[experimentName].defaultValue === expectedExperimentValue;
|
|
108
67
|
}
|
|
68
|
+
|
|
69
|
+
// eslint-disable-next-line @atlaskit/platform/use-recommended-utils
|
|
109
70
|
var experimentValue = FeatureGates.getExperimentValue(
|
|
110
71
|
// @ts-ignore
|
|
111
72
|
experimentKey, experimentConfig.param, experimentConfig.defaultValue, {
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
4
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
5
|
+
import { editorExperimentsConfig } from './experiments-config';
|
|
6
|
+
export var _overrides = {};
|
|
7
|
+
export var _product;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* This function is used to set up the editor experiments for testing purposes.
|
|
11
|
+
* It should be called before running code that depends on editor experiments.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* setupEditorExperiments('confluence', {
|
|
16
|
+
* 'experiment-name': 'value',
|
|
17
|
+
* });
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export function setupEditorExperiments(product,
|
|
21
|
+
/**
|
|
22
|
+
* Overrides are used to set the value of an experiment for testing purposes.
|
|
23
|
+
* This is useful when you want to test a specific value of an experiment.
|
|
24
|
+
*/
|
|
25
|
+
overrides) {
|
|
26
|
+
if (overrides) {
|
|
27
|
+
// When setting up overrides, we want to ensure that experiments don't end up with invalid
|
|
28
|
+
// values.
|
|
29
|
+
// For production usage -- this is done via the feature flag client which takes the type
|
|
30
|
+
// and performs equivalent logic.
|
|
31
|
+
// @ts-ignore
|
|
32
|
+
overrides = Object.entries(overrides).reduce(function (acc, _ref) {
|
|
33
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
34
|
+
key = _ref2[0],
|
|
35
|
+
value = _ref2[1];
|
|
36
|
+
var config = editorExperimentsConfig[key];
|
|
37
|
+
if (config) {
|
|
38
|
+
acc = _objectSpread(_objectSpread({}, acc), {}, _defineProperty({}, key, config.typeGuard(value) ? value : config.defaultValue));
|
|
39
|
+
}
|
|
40
|
+
return acc;
|
|
41
|
+
}, {});
|
|
42
|
+
_overrides = overrides;
|
|
43
|
+
}
|
|
44
|
+
_product = product;
|
|
45
|
+
}
|
|
@@ -63,5 +63,13 @@ export declare const editorExperimentsConfig: {
|
|
|
63
63
|
typeGuard: typeof isBoolean;
|
|
64
64
|
defaultValue: boolean;
|
|
65
65
|
};
|
|
66
|
+
'nested-dnd': {
|
|
67
|
+
productKeys: {
|
|
68
|
+
confluence: string;
|
|
69
|
+
};
|
|
70
|
+
param: string;
|
|
71
|
+
typeGuard: typeof isBoolean;
|
|
72
|
+
defaultValue: boolean;
|
|
73
|
+
};
|
|
66
74
|
};
|
|
67
75
|
export {};
|
|
@@ -1,24 +1,4 @@
|
|
|
1
|
-
import { type EditorExperimentsConfig
|
|
2
|
-
export type EditorExperimentOverrides = Partial<{
|
|
3
|
-
[ExperimentName in keyof typeof editorExperimentsConfig]: (typeof editorExperimentsConfig)[ExperimentName]['defaultValue'];
|
|
4
|
-
}>;
|
|
5
|
-
/**
|
|
6
|
-
* This function is used to set up the editor experiments for testing purposes.
|
|
7
|
-
* It should be called before running code that depends on editor experiments.
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* ```ts
|
|
11
|
-
* setupEditorExperiments('confluence', {
|
|
12
|
-
* 'experiment-name': 'value',
|
|
13
|
-
* });
|
|
14
|
-
* ```
|
|
15
|
-
*/
|
|
16
|
-
export declare function setupEditorExperiments(product: 'confluence' | 'jira' | 'test',
|
|
17
|
-
/**
|
|
18
|
-
* Overrides are used to set the value of an experiment for testing purposes.
|
|
19
|
-
* This is useful when you want to test a specific value of an experiment.
|
|
20
|
-
*/
|
|
21
|
-
overrides?: EditorExperimentOverrides): void;
|
|
1
|
+
import { type EditorExperimentsConfig } from './experiments-config';
|
|
22
2
|
/**
|
|
23
3
|
* Check the value of an editor experiment.
|
|
24
4
|
*
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { editorExperimentsConfig } from './experiments-config';
|
|
2
|
+
export type EditorExperimentOverrides = Partial<{
|
|
3
|
+
[ExperimentName in keyof typeof editorExperimentsConfig]: (typeof editorExperimentsConfig)[ExperimentName]['defaultValue'];
|
|
4
|
+
}>;
|
|
5
|
+
export declare let _overrides: Partial<{
|
|
6
|
+
'example-boolean': boolean;
|
|
7
|
+
'example-multivariate': "one" | "two" | "three";
|
|
8
|
+
'test-new-experiments-package': boolean;
|
|
9
|
+
'basic-text-transformations': boolean;
|
|
10
|
+
'platform-editor-ai-condensed-floating-toobar': boolean;
|
|
11
|
+
'dnd-input-performance-optimisation': boolean;
|
|
12
|
+
'element-level-templates': boolean;
|
|
13
|
+
'nested-dnd': boolean;
|
|
14
|
+
}>;
|
|
15
|
+
export declare let _product: 'confluence' | 'jira' | 'test' | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* This function is used to set up the editor experiments for testing purposes.
|
|
18
|
+
* It should be called before running code that depends on editor experiments.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts
|
|
22
|
+
* setupEditorExperiments('confluence', {
|
|
23
|
+
* 'experiment-name': 'value',
|
|
24
|
+
* });
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare function setupEditorExperiments(product: 'confluence' | 'jira' | 'test',
|
|
28
|
+
/**
|
|
29
|
+
* Overrides are used to set the value of an experiment for testing purposes.
|
|
30
|
+
* This is useful when you want to test a specific value of an experiment.
|
|
31
|
+
*/
|
|
32
|
+
overrides?: EditorExperimentOverrides): void;
|
|
@@ -63,5 +63,13 @@ export declare const editorExperimentsConfig: {
|
|
|
63
63
|
typeGuard: typeof isBoolean;
|
|
64
64
|
defaultValue: boolean;
|
|
65
65
|
};
|
|
66
|
+
'nested-dnd': {
|
|
67
|
+
productKeys: {
|
|
68
|
+
confluence: string;
|
|
69
|
+
};
|
|
70
|
+
param: string;
|
|
71
|
+
typeGuard: typeof isBoolean;
|
|
72
|
+
defaultValue: boolean;
|
|
73
|
+
};
|
|
66
74
|
};
|
|
67
75
|
export {};
|
|
@@ -1,24 +1,4 @@
|
|
|
1
|
-
import { type EditorExperimentsConfig
|
|
2
|
-
export type EditorExperimentOverrides = Partial<{
|
|
3
|
-
[ExperimentName in keyof typeof editorExperimentsConfig]: (typeof editorExperimentsConfig)[ExperimentName]['defaultValue'];
|
|
4
|
-
}>;
|
|
5
|
-
/**
|
|
6
|
-
* This function is used to set up the editor experiments for testing purposes.
|
|
7
|
-
* It should be called before running code that depends on editor experiments.
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* ```ts
|
|
11
|
-
* setupEditorExperiments('confluence', {
|
|
12
|
-
* 'experiment-name': 'value',
|
|
13
|
-
* });
|
|
14
|
-
* ```
|
|
15
|
-
*/
|
|
16
|
-
export declare function setupEditorExperiments(product: 'confluence' | 'jira' | 'test',
|
|
17
|
-
/**
|
|
18
|
-
* Overrides are used to set the value of an experiment for testing purposes.
|
|
19
|
-
* This is useful when you want to test a specific value of an experiment.
|
|
20
|
-
*/
|
|
21
|
-
overrides?: EditorExperimentOverrides): void;
|
|
1
|
+
import { type EditorExperimentsConfig } from './experiments-config';
|
|
22
2
|
/**
|
|
23
3
|
* Check the value of an editor experiment.
|
|
24
4
|
*
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { editorExperimentsConfig } from './experiments-config';
|
|
2
|
+
export type EditorExperimentOverrides = Partial<{
|
|
3
|
+
[ExperimentName in keyof typeof editorExperimentsConfig]: (typeof editorExperimentsConfig)[ExperimentName]['defaultValue'];
|
|
4
|
+
}>;
|
|
5
|
+
export declare let _overrides: Partial<{
|
|
6
|
+
'example-boolean': boolean;
|
|
7
|
+
'example-multivariate': "one" | "two" | "three";
|
|
8
|
+
'test-new-experiments-package': boolean;
|
|
9
|
+
'basic-text-transformations': boolean;
|
|
10
|
+
'platform-editor-ai-condensed-floating-toobar': boolean;
|
|
11
|
+
'dnd-input-performance-optimisation': boolean;
|
|
12
|
+
'element-level-templates': boolean;
|
|
13
|
+
'nested-dnd': boolean;
|
|
14
|
+
}>;
|
|
15
|
+
export declare let _product: 'confluence' | 'jira' | 'test' | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* This function is used to set up the editor experiments for testing purposes.
|
|
18
|
+
* It should be called before running code that depends on editor experiments.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts
|
|
22
|
+
* setupEditorExperiments('confluence', {
|
|
23
|
+
* 'experiment-name': 'value',
|
|
24
|
+
* });
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare function setupEditorExperiments(product: 'confluence' | 'jira' | 'test',
|
|
28
|
+
/**
|
|
29
|
+
* Overrides are used to set the value of an experiment for testing purposes.
|
|
30
|
+
* This is useful when you want to test a specific value of an experiment.
|
|
31
|
+
*/
|
|
32
|
+
overrides?: EditorExperimentOverrides): void;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@atlaskit/tmp-editor-statsig/editor-experiments-test-utils",
|
|
3
|
+
"main": "../dist/cjs/editor-experiments-test-utils.js",
|
|
4
|
+
"module": "../dist/esm/editor-experiments-test-utils.js",
|
|
5
|
+
"module:es2019": "../dist/es2019/editor-experiments-test-utils.js",
|
|
6
|
+
"types": "../dist/types/editor-experiments-test-utils.d.ts",
|
|
7
|
+
"typesVersions": {
|
|
8
|
+
">=4.5 <5.4": {
|
|
9
|
+
"*": [
|
|
10
|
+
"../dist/types-ts4.5/editor-experiments-test-utils.d.ts"
|
|
11
|
+
]
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/tmp-editor-statsig",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Temp plugin to ease use of statsig feature flags until platform feature flags are available",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -9,8 +9,6 @@
|
|
|
9
9
|
},
|
|
10
10
|
"atlassian": {
|
|
11
11
|
"team": "Editor: Core Experiences",
|
|
12
|
-
"inPublicMirror": false,
|
|
13
|
-
"releaseModel": "continuous",
|
|
14
12
|
"website": {
|
|
15
13
|
"name": "EditorStatsigTmp",
|
|
16
14
|
"category": "Components"
|
|
@@ -31,9 +29,10 @@
|
|
|
31
29
|
},
|
|
32
30
|
"atlaskit:src": "src/index.ts",
|
|
33
31
|
"af:exports": {
|
|
32
|
+
"./setup": "./src/setup.ts",
|
|
34
33
|
"./experiments": "./src/experiments.ts",
|
|
35
34
|
"./experiments-config": "./src/experiments-config.ts",
|
|
36
|
-
"./test-
|
|
35
|
+
"./editor-experiments-test-utils": "./src/editor-experiments-test-utils.ts"
|
|
37
36
|
},
|
|
38
37
|
"dependencies": {
|
|
39
38
|
"@atlaskit/feature-gate-js-client": "^4.17.0",
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@atlaskit/tmp-editor-statsig/setup",
|
|
3
|
+
"main": "../dist/cjs/setup.js",
|
|
4
|
+
"module": "../dist/esm/setup.js",
|
|
5
|
+
"module:es2019": "../dist/es2019/setup.js",
|
|
6
|
+
"types": "../dist/types/setup.d.ts",
|
|
7
|
+
"typesVersions": {
|
|
8
|
+
">=4.5 <5.4": {
|
|
9
|
+
"*": [
|
|
10
|
+
"../dist/types-ts4.5/setup.d.ts"
|
|
11
|
+
]
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
package/test-runner/package.json
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@atlaskit/tmp-editor-statsig/test-runner",
|
|
3
|
-
"main": "../dist/cjs/test-runner.js",
|
|
4
|
-
"module": "../dist/esm/test-runner.js",
|
|
5
|
-
"module:es2019": "../dist/es2019/test-runner.js",
|
|
6
|
-
"types": "../dist/types/test-runner.d.ts",
|
|
7
|
-
"typesVersions": {
|
|
8
|
-
">=4.5 <5.4": {
|
|
9
|
-
"*": [
|
|
10
|
-
"../dist/types-ts4.5/test-runner.d.ts"
|
|
11
|
-
]
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
}
|