@atlaskit/tmp-editor-statsig 2.1.15 → 2.2.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 CHANGED
@@ -1,5 +1,13 @@
1
1
  # @atlaskit/editor-statsig-tmp
2
2
 
3
+ ## 2.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#147660](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/147660)
8
+ [`a407a8fbc874b`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/a407a8fbc874b) -
9
+ ED-24365 Support commenting inside bodied extension content in the Renderer
10
+
3
11
  ## 2.1.15
4
12
 
5
13
  ### Patch Changes
@@ -10,6 +10,9 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
10
10
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
11
11
  var _setup = require("./setup");
12
12
  var _experimentsConfig = require("./experiments-config");
13
+ function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
14
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
15
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
13
16
  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; }
14
17
  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; } // This is loosely based on the `ffTest` util from `@atlassian/feature-flags-test-utils` package.
15
18
  /**
@@ -19,11 +22,11 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
19
22
  * ```ts
20
23
  * eeTest('example-boolean', {
21
24
  * true: () => {
22
- * expect(editorExperiment('example-boolean', true)).toBe(true);
23
- * expect(editorExperiment('example-boolean', false)).toBe(false);
25
+ * expect(editorExperiment('example-boolean', true)).toBe(true);
26
+ * expect(editorExperiment('example-boolean', false)).toBe(false);
24
27
  * },
25
28
  * false: () => {
26
- * expect(editorExperiment('example-boolean', false)).toBe(true);
29
+ * expect(editorExperiment('example-boolean', false)).toBe(true);
27
30
  * expect(editorExperiment('example-boolean', true)).toBe(false);
28
31
  * },
29
32
  * })
@@ -33,19 +36,22 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
33
36
  * ```ts
34
37
  * eeTest('example-multivariate', {
35
38
  * one: () => {
36
- * expect(editorExperiment('example-multivariate', 'one')).toBe(true);
37
- * expect(editorExperiment('example-multivariate', 'two')).toBe(false);
39
+ * expect(editorExperiment('example-multivariate', 'one')).toBe(true);
40
+ * expect(editorExperiment('example-multivariate', 'two')).toBe(false);
38
41
  * },
39
42
  * two: () => {
40
- * expect(editorExperiment('example-multivariate', 'two')).toBe(true);
41
- * expect(editorExperiment('example-multivariate', 'one')).toBe(false);
43
+ * expect(editorExperiment('example-multivariate', 'two')).toBe(true);
44
+ * expect(editorExperiment('example-multivariate', 'one')).toBe(false);
42
45
  * },
43
46
  * three: () => {
44
- * expect(editorExperiment('example-multivariate', 'three')).toBe(true);
45
- * expect(editorExperiment('example-multivariate', 'one')).toBe(false);
47
+ * expect(editorExperiment('example-multivariate', 'three')).toBe(true);
48
+ * expect(editorExperiment('example-multivariate', 'one')).toBe(false);
46
49
  * },
47
50
  * })
48
51
  * ```
52
+ *
53
+ * API based on Legacy ffTest API
54
+ * - https://hello.atlassian.net/wiki/spaces/AF/pages/2569505829/Task+Testing+your+feature+flag+in+platform+and+product#Legacy-API-lEGACY
49
55
  */
50
56
  function eeTest(experimentName, cases, otherExperiments) {
51
57
  (0, _setup.setupEditorExperiments)('test', {});
@@ -80,4 +86,75 @@ function eeTest(experimentName, cases, otherExperiments) {
80
86
  };
81
87
  }());
82
88
  });
83
- }
89
+ }
90
+
91
+ /**
92
+ * eeTest.describe() Wrapper utility for describe() that runs a test with a editor experiment overides.
93
+ *
94
+ * @example Single experiment
95
+ * ```ts
96
+ * eeTest.describe('Description of test "suite" containing nested suites and tests.', { 'example-boolean': true }, () => {
97
+ * it('should do the thing', () => {
98
+ * expect(editorExperiment('example-boolean', true)).toBe(true);
99
+ * });
100
+ * });
101
+ * ```
102
+ *
103
+ *
104
+ * @example Multiple experiment
105
+ * ```ts
106
+ * eeTest.describe('Description of test "suite" containing nested suites and tests.', { 'example-boolean': true, 'example-multivariate': 'three' }, () => {
107
+ * it('should do the thing', () => {
108
+ * expect(editorExperiment('example-boolean', true)).toBe(true);
109
+ * });
110
+ * });
111
+ * ```
112
+ *
113
+ * API based on next gen ffTest API
114
+ * - https://hello.atlassian.net/wiki/spaces/AF/pages/2569505829/Task+Testing+your+feature+flag+in+platform+and+product#Next-Generation-API-%E2%9C%A8
115
+ */
116
+ eeTest.describe = function eeTestDescribe(experimentName, describeName) {
117
+ function eeTest(value) {
118
+ var describeBody = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () {};
119
+ describe("".concat(describeName, " [").concat(value, "]"), function () {
120
+ beforeEach(function () {
121
+ (0, _setup.setupEditorExperiments)('test', (0, _defineProperty2.default)({}, experimentName, value));
122
+ });
123
+ afterEach(function () {
124
+ (0, _setup.setupEditorExperiments)('test', {});
125
+ });
126
+ describeBody();
127
+ });
128
+ (0, _setup.setupEditorExperiments)('test', {});
129
+ }
130
+ function variant(value, describeBody) {
131
+ eeTest(value, describeBody);
132
+ }
133
+ function each(describeBody) {
134
+ var possibleValues =
135
+ // @ts-ignore
136
+ _experimentsConfig.editorExperimentsConfig[experimentName].typeGuard.values;
137
+ if (possibleValues) {
138
+ var _iterator = _createForOfIteratorHelper(possibleValues),
139
+ _step;
140
+ try {
141
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
142
+ var value = _step.value;
143
+ eeTest(value, describeBody);
144
+ }
145
+ } catch (err) {
146
+ _iterator.e(err);
147
+ } finally {
148
+ _iterator.f();
149
+ }
150
+ } else {
151
+ // if there are no possible values, it's a boolean experiment
152
+ eeTest(true, describeBody);
153
+ eeTest(false, describeBody);
154
+ }
155
+ }
156
+ return {
157
+ variant: variant,
158
+ each: each
159
+ };
160
+ };
@@ -4,14 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.editorExperimentsConfig = void 0;
7
- function isBoolean(value) {
8
- return typeof value === 'boolean';
9
- }
10
- function oneOf(values) {
11
- return function (value) {
12
- return values.includes(value);
13
- };
14
- }
7
+ var _typeGuards = require("./type-guards");
15
8
  /**
16
9
  * When adding a new experiment, you need to add it here.
17
10
  * Please follow the pattern established in the examples and any
@@ -24,7 +17,7 @@ var editorExperimentsConfig = exports.editorExperimentsConfig = {
24
17
  confluence: 'confluence_editor_experiment_test_new_package_boolean'
25
18
  },
26
19
  param: 'isEnabled',
27
- typeGuard: isBoolean,
20
+ typeGuard: _typeGuards.isBoolean,
28
21
  // Note -- you need to set the type to boolean for the default value
29
22
  defaultValue: false
30
23
  },
@@ -34,7 +27,7 @@ var editorExperimentsConfig = exports.editorExperimentsConfig = {
34
27
  confluence: 'confluence_editor_experiment_test_new_package_multivariate'
35
28
  },
36
29
  param: 'variant',
37
- typeGuard: oneOf(['one', 'two', 'three']),
30
+ typeGuard: (0, _typeGuards.oneOf)(['one', 'two', 'three']),
38
31
  // Note -- you need to specify the type of the default value as the union of all possible values
39
32
  // This is used to provide type safety on consumption
40
33
  defaultValue: 'one'
@@ -46,7 +39,7 @@ var editorExperimentsConfig = exports.editorExperimentsConfig = {
46
39
  jira: 'jira_editor_experiment_test_new_package'
47
40
  },
48
41
  param: 'isEnabled',
49
- typeGuard: isBoolean,
42
+ typeGuard: _typeGuards.isBoolean,
50
43
  defaultValue: false
51
44
  },
52
45
  // Add 2024-08-14
@@ -55,7 +48,7 @@ var editorExperimentsConfig = exports.editorExperimentsConfig = {
55
48
  confluence: 'platform_editor_basic_text_transformations'
56
49
  },
57
50
  param: 'isEnabled',
58
- typeGuard: isBoolean,
51
+ typeGuard: _typeGuards.isBoolean,
59
52
  defaultValue: false
60
53
  },
61
54
  // Add 2024-08-27
@@ -65,7 +58,7 @@ var editorExperimentsConfig = exports.editorExperimentsConfig = {
65
58
  confluence: 'platform_editor_ai_command_palate_improvement'
66
59
  },
67
60
  param: 'cohort',
68
- typeGuard: oneOf(['control', 'test']),
61
+ typeGuard: (0, _typeGuards.oneOf)(['control', 'test']),
69
62
  defaultValue: 'control'
70
63
  },
71
64
  // Added 2024-08-23
@@ -74,7 +67,7 @@ var editorExperimentsConfig = exports.editorExperimentsConfig = {
74
67
  confluence: 'platform_editor_ai_condensed_floating_toobar'
75
68
  },
76
69
  param: 'cohort',
77
- typeGuard: oneOf(['control', 'dropdown', 'editor_ai_button']),
70
+ typeGuard: (0, _typeGuards.oneOf)(['control', 'dropdown', 'editor_ai_button']),
78
71
  defaultValue: 'control'
79
72
  },
80
73
  // Added 2024-08-27
@@ -83,7 +76,7 @@ var editorExperimentsConfig = exports.editorExperimentsConfig = {
83
76
  confluence: 'platform_editor_dnd_input_performance_optimisation'
84
77
  },
85
78
  param: 'isEnabled',
86
- typeGuard: isBoolean,
79
+ typeGuard: _typeGuards.isBoolean,
87
80
  defaultValue: false
88
81
  },
89
82
  // Added 2024-08-28
@@ -92,7 +85,7 @@ var editorExperimentsConfig = exports.editorExperimentsConfig = {
92
85
  confluence: 'platform_editor_element_level_templates'
93
86
  },
94
87
  param: 'isEnabled',
95
- typeGuard: isBoolean,
88
+ typeGuard: _typeGuards.isBoolean,
96
89
  defaultValue: false
97
90
  },
98
91
  // Added 2024-08-29
@@ -101,7 +94,7 @@ var editorExperimentsConfig = exports.editorExperimentsConfig = {
101
94
  confluence: 'platform_editor_add_media_from_url'
102
95
  },
103
96
  param: 'isEnabled',
104
- typeGuard: isBoolean,
97
+ typeGuard: _typeGuards.isBoolean,
105
98
  defaultValue: false
106
99
  },
107
100
  // Added 2024-08-30
@@ -110,7 +103,7 @@ var editorExperimentsConfig = exports.editorExperimentsConfig = {
110
103
  confluence: 'platform_editor_element_drag_and_drop_nested'
111
104
  },
112
105
  param: 'isEnabled',
113
- typeGuard: isBoolean,
106
+ typeGuard: _typeGuards.isBoolean,
114
107
  defaultValue: false
115
108
  },
116
109
  // Add 2024-08-27
@@ -119,7 +112,7 @@ var editorExperimentsConfig = exports.editorExperimentsConfig = {
119
112
  confluence: 'platform_editor_elements_dnd_nested_table'
120
113
  },
121
114
  param: 'isEnabled',
122
- typeGuard: isBoolean,
115
+ typeGuard: _typeGuards.isBoolean,
123
116
  defaultValue: false
124
117
  },
125
118
  // Added 2024-08-29
@@ -128,7 +121,7 @@ var editorExperimentsConfig = exports.editorExperimentsConfig = {
128
121
  confluence: 'platform_editor_insert_menu_in_right_rail'
129
122
  },
130
123
  param: 'isEnabled',
131
- typeGuard: isBoolean,
124
+ typeGuard: _typeGuards.isBoolean,
132
125
  defaultValue: false
133
126
  },
134
127
  // Added 2024-09-02
@@ -137,7 +130,7 @@ var editorExperimentsConfig = exports.editorExperimentsConfig = {
137
130
  confluence: 'platform_editor_empty_line_prompt'
138
131
  },
139
132
  param: 'isEnabled',
140
- typeGuard: isBoolean,
133
+ typeGuard: _typeGuards.isBoolean,
141
134
  defaultValue: false
142
135
  },
143
136
  // Added 2024-09-05
@@ -146,7 +139,7 @@ var editorExperimentsConfig = exports.editorExperimentsConfig = {
146
139
  confluence: 'platform_editor_support_table_in_comment_exp'
147
140
  },
148
141
  param: 'isEnabled',
149
- typeGuard: isBoolean,
142
+ typeGuard: _typeGuards.isBoolean,
150
143
  defaultValue: false
151
144
  },
152
145
  // Added 2024-09-07
@@ -155,7 +148,7 @@ var editorExperimentsConfig = exports.editorExperimentsConfig = {
155
148
  confluence: 'platform_editor_exp_lazy_node_views'
156
149
  },
157
150
  param: 'isEnabled',
158
- typeGuard: isBoolean,
151
+ typeGuard: _typeGuards.isBoolean,
159
152
  defaultValue: false
160
153
  },
161
154
  // Add 2024-09-16
@@ -165,7 +158,7 @@ var editorExperimentsConfig = exports.editorExperimentsConfig = {
165
158
  confluence: 'platform_editor_ai_ai_button_block_elements'
166
159
  },
167
160
  param: 'cohort',
168
- typeGuard: oneOf(['control', 'test']),
161
+ typeGuard: (0, _typeGuards.oneOf)(['control', 'test']),
169
162
  defaultValue: 'control'
170
163
  },
171
164
  // Added 2024-09-18
@@ -174,7 +167,7 @@ var editorExperimentsConfig = exports.editorExperimentsConfig = {
174
167
  confluence: 'platform_renderer_table_sticky_scrollbar'
175
168
  },
176
169
  param: 'isEnabled',
177
- typeGuard: isBoolean,
170
+ typeGuard: _typeGuards.isBoolean,
178
171
  defaultValue: false
179
172
  },
180
173
  // Added 2024-09-18
@@ -184,7 +177,7 @@ var editorExperimentsConfig = exports.editorExperimentsConfig = {
184
177
  confluence: 'platform_editor_nest_media_and_codeblock_in_quotes'
185
178
  },
186
179
  param: 'isEnabled',
187
- typeGuard: isBoolean,
180
+ typeGuard: _typeGuards.isBoolean,
188
181
  defaultValue: false
189
182
  },
190
183
  // Added 2024-09-18
@@ -194,7 +187,7 @@ var editorExperimentsConfig = exports.editorExperimentsConfig = {
194
187
  confluence: 'platform_editor_nest_nested_expand_in_expand'
195
188
  },
196
189
  param: 'isEnabled',
197
- typeGuard: isBoolean,
190
+ typeGuard: _typeGuards.isBoolean,
198
191
  defaultValue: false
199
192
  },
200
193
  // Added 2024-09-24
@@ -203,7 +196,7 @@ var editorExperimentsConfig = exports.editorExperimentsConfig = {
203
196
  confluence: 'platform_editor_ai_command_palette_post_ga'
204
197
  },
205
198
  param: 'cohort',
206
- typeGuard: oneOf(['control', 'test']),
199
+ typeGuard: (0, _typeGuards.oneOf)(['control', 'test']),
207
200
  defaultValue: 'control'
208
201
  },
209
202
  // Added 2024-09-26
@@ -212,7 +205,7 @@ var editorExperimentsConfig = exports.editorExperimentsConfig = {
212
205
  confluence: 'platform_editor_table_use_shared_state_hook'
213
206
  },
214
207
  param: 'isEnabled',
215
- typeGuard: isBoolean,
208
+ typeGuard: _typeGuards.isBoolean,
216
209
  defaultValue: false
217
210
  },
218
211
  // Added 2024-09-23
@@ -222,7 +215,16 @@ var editorExperimentsConfig = exports.editorExperimentsConfig = {
222
215
  confluence: 'editor_ai_-_multi_prompts'
223
216
  },
224
217
  param: 'cohort',
225
- typeGuard: oneOf(['control', 'test']),
218
+ typeGuard: (0, _typeGuards.oneOf)(['control', 'test']),
226
219
  defaultValue: 'control'
220
+ },
221
+ // Added 2024-10-01
222
+ comment_on_bodied_extensions: {
223
+ productKeys: {
224
+ confluence: 'platform_editor_comment_on_bodied_extensions'
225
+ },
226
+ param: 'isEnabled',
227
+ typeGuard: _typeGuards.isBoolean,
228
+ defaultValue: false
227
229
  }
228
230
  };
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.isBoolean = isBoolean;
7
+ exports.oneOf = oneOf;
8
+ function isBoolean(value) {
9
+ return typeof value === 'boolean';
10
+ }
11
+ function oneOf(values) {
12
+ function typeGuard(value) {
13
+ return values.includes(value);
14
+ }
15
+ /**
16
+ * This is used by test utils to get the variants when running describe.each
17
+ */
18
+ if (IS_TESTING_ENV) {
19
+ typeGuard.values = values;
20
+ }
21
+ return typeGuard;
22
+ }
23
+
24
+ // @ts-ignore
25
+
26
+ var IS_TESTING_ENV = process.env.NODE_ENV === 'test' || process.env.JEST_WORKER_ID !== undefined;
@@ -2,7 +2,6 @@
2
2
 
3
3
  import { setupEditorExperiments } from './setup';
4
4
  import { editorExperimentsConfig } from './experiments-config';
5
-
6
5
  /**
7
6
  * This is a utility function for testing editor experiments.
8
7
  *
@@ -10,11 +9,11 @@ import { editorExperimentsConfig } from './experiments-config';
10
9
  * ```ts
11
10
  * eeTest('example-boolean', {
12
11
  * true: () => {
13
- * expect(editorExperiment('example-boolean', true)).toBe(true);
14
- * expect(editorExperiment('example-boolean', false)).toBe(false);
12
+ * expect(editorExperiment('example-boolean', true)).toBe(true);
13
+ * expect(editorExperiment('example-boolean', false)).toBe(false);
15
14
  * },
16
15
  * false: () => {
17
- * expect(editorExperiment('example-boolean', false)).toBe(true);
16
+ * expect(editorExperiment('example-boolean', false)).toBe(true);
18
17
  * expect(editorExperiment('example-boolean', true)).toBe(false);
19
18
  * },
20
19
  * })
@@ -24,21 +23,24 @@ import { editorExperimentsConfig } from './experiments-config';
24
23
  * ```ts
25
24
  * eeTest('example-multivariate', {
26
25
  * one: () => {
27
- * expect(editorExperiment('example-multivariate', 'one')).toBe(true);
28
- * expect(editorExperiment('example-multivariate', 'two')).toBe(false);
26
+ * expect(editorExperiment('example-multivariate', 'one')).toBe(true);
27
+ * expect(editorExperiment('example-multivariate', 'two')).toBe(false);
29
28
  * },
30
29
  * two: () => {
31
- * expect(editorExperiment('example-multivariate', 'two')).toBe(true);
32
- * expect(editorExperiment('example-multivariate', 'one')).toBe(false);
30
+ * expect(editorExperiment('example-multivariate', 'two')).toBe(true);
31
+ * expect(editorExperiment('example-multivariate', 'one')).toBe(false);
33
32
  * },
34
33
  * three: () => {
35
- * expect(editorExperiment('example-multivariate', 'three')).toBe(true);
36
- * expect(editorExperiment('example-multivariate', 'one')).toBe(false);
34
+ * expect(editorExperiment('example-multivariate', 'three')).toBe(true);
35
+ * expect(editorExperiment('example-multivariate', 'one')).toBe(false);
37
36
  * },
38
37
  * })
39
38
  * ```
39
+ *
40
+ * API based on Legacy ffTest API
41
+ * - https://hello.atlassian.net/wiki/spaces/AF/pages/2569505829/Task+Testing+your+feature+flag+in+platform+and+product#Legacy-API-lEGACY
40
42
  */
41
- export function eeTest(experimentName, cases, otherExperiments) {
43
+ function eeTest(experimentName, cases, otherExperiments) {
42
44
  setupEditorExperiments('test', {});
43
45
  describe(`eeTest: ${experimentName}`, () => {
44
46
  afterEach(() => {
@@ -63,4 +65,68 @@ export function eeTest(experimentName, cases, otherExperiments) {
63
65
  await Promise.resolve(testCase());
64
66
  });
65
67
  });
66
- }
68
+ }
69
+
70
+ /**
71
+ * eeTest.describe() Wrapper utility for describe() that runs a test with a editor experiment overides.
72
+ *
73
+ * @example Single experiment
74
+ * ```ts
75
+ * eeTest.describe('Description of test "suite" containing nested suites and tests.', { 'example-boolean': true }, () => {
76
+ * it('should do the thing', () => {
77
+ * expect(editorExperiment('example-boolean', true)).toBe(true);
78
+ * });
79
+ * });
80
+ * ```
81
+ *
82
+ *
83
+ * @example Multiple experiment
84
+ * ```ts
85
+ * eeTest.describe('Description of test "suite" containing nested suites and tests.', { 'example-boolean': true, 'example-multivariate': 'three' }, () => {
86
+ * it('should do the thing', () => {
87
+ * expect(editorExperiment('example-boolean', true)).toBe(true);
88
+ * });
89
+ * });
90
+ * ```
91
+ *
92
+ * API based on next gen ffTest API
93
+ * - https://hello.atlassian.net/wiki/spaces/AF/pages/2569505829/Task+Testing+your+feature+flag+in+platform+and+product#Next-Generation-API-%E2%9C%A8
94
+ */
95
+ eeTest.describe = function eeTestDescribe(experimentName, describeName) {
96
+ function eeTest(value, describeBody = () => {}) {
97
+ describe(`${describeName} [${value}]`, () => {
98
+ beforeEach(() => {
99
+ setupEditorExperiments('test', {
100
+ [experimentName]: value
101
+ });
102
+ });
103
+ afterEach(() => {
104
+ setupEditorExperiments('test', {});
105
+ });
106
+ describeBody();
107
+ });
108
+ setupEditorExperiments('test', {});
109
+ }
110
+ function variant(value, describeBody) {
111
+ eeTest(value, describeBody);
112
+ }
113
+ function each(describeBody) {
114
+ let possibleValues =
115
+ // @ts-ignore
116
+ editorExperimentsConfig[experimentName].typeGuard.values;
117
+ if (possibleValues) {
118
+ for (const value of possibleValues) {
119
+ eeTest(value, describeBody);
120
+ }
121
+ } else {
122
+ // if there are no possible values, it's a boolean experiment
123
+ eeTest(true, describeBody);
124
+ eeTest(false, describeBody);
125
+ }
126
+ }
127
+ return {
128
+ variant,
129
+ each
130
+ };
131
+ };
132
+ export { eeTest };
@@ -1,11 +1,4 @@
1
- function isBoolean(value) {
2
- return typeof value === 'boolean';
3
- }
4
- function oneOf(values) {
5
- return value => {
6
- return values.includes(value);
7
- };
8
- }
1
+ import { isBoolean, oneOf } from './type-guards';
9
2
  /**
10
3
  * When adding a new experiment, you need to add it here.
11
4
  * Please follow the pattern established in the examples and any
@@ -218,5 +211,14 @@ export const editorExperimentsConfig = {
218
211
  param: 'cohort',
219
212
  typeGuard: oneOf(['control', 'test']),
220
213
  defaultValue: 'control'
214
+ },
215
+ // Added 2024-10-01
216
+ comment_on_bodied_extensions: {
217
+ productKeys: {
218
+ confluence: 'platform_editor_comment_on_bodied_extensions'
219
+ },
220
+ param: 'isEnabled',
221
+ typeGuard: isBoolean,
222
+ defaultValue: false
221
223
  }
222
224
  };
@@ -0,0 +1,19 @@
1
+ export function isBoolean(value) {
2
+ return typeof value === 'boolean';
3
+ }
4
+ export function oneOf(values) {
5
+ function typeGuard(value) {
6
+ return values.includes(value);
7
+ }
8
+ /**
9
+ * This is used by test utils to get the variants when running describe.each
10
+ */
11
+ if (IS_TESTING_ENV) {
12
+ typeGuard.values = values;
13
+ }
14
+ return typeGuard;
15
+ }
16
+
17
+ // @ts-ignore
18
+
19
+ const IS_TESTING_ENV = process.env.NODE_ENV === 'test' || process.env.JEST_WORKER_ID !== undefined;