@atlaskit/media-test-helpers 30.1.0 → 30.1.2

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.
Files changed (168) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cjs/I18nWrapper.js +8 -24
  3. package/dist/cjs/MockGlobalImage.js +0 -16
  4. package/dist/cjs/authProvider.js +0 -18
  5. package/dist/cjs/await-error.js +0 -10
  6. package/dist/cjs/clipboardEventMocks.js +6 -39
  7. package/dist/cjs/createMouseEvent.js +4 -8
  8. package/dist/cjs/createTouchEvent.js +0 -2
  9. package/dist/cjs/docs-content-tabs.js +1 -14
  10. package/dist/cjs/example-mediaFeatureFlags.js +0 -7
  11. package/dist/cjs/exampleMediaItems.js +6 -7
  12. package/dist/cjs/fakeI18n.js +2 -4
  13. package/dist/cjs/fakeMediaClient.js +5 -18
  14. package/dist/cjs/featureFlagsWrapper/dropdown.js +12 -46
  15. package/dist/cjs/featureFlagsWrapper/helpers.js +0 -14
  16. package/dist/cjs/featureFlagsWrapper/index.js +5 -19
  17. package/dist/cjs/fileReader.js +0 -28
  18. package/dist/cjs/fileStateFactory/createFileState.js +9 -27
  19. package/dist/cjs/fileStateFactory/factory.js +7 -44
  20. package/dist/cjs/fileStateFactory/helpers.js +10 -23
  21. package/dist/cjs/fileStateFactory/index.js +0 -3
  22. package/dist/cjs/flushPromises.js +0 -2
  23. package/dist/cjs/getAuthFromContextProvider.js +0 -9
  24. package/dist/cjs/getJest.js +3 -5
  25. package/dist/cjs/globalEventEmitterListeners.js +0 -8
  26. package/dist/cjs/images.js +0 -6
  27. package/dist/cjs/index.js +0 -42
  28. package/dist/cjs/jestHelpers.js +0 -20
  29. package/dist/cjs/keyboardEventWithKeyCode.js +0 -18
  30. package/dist/cjs/mediaClientErrors.js +0 -11
  31. package/dist/cjs/mediaClientProvider.js +1 -17
  32. package/dist/cjs/mediaPickerAuthProvider.js +5 -21
  33. package/dist/cjs/mockCanvas.js +0 -4
  34. package/dist/cjs/mockData/handlers/copyWithToken.js +0 -14
  35. package/dist/cjs/mockData/handlers/getFile.js +0 -8
  36. package/dist/cjs/mockData/handlers/getFileImage.js +0 -9
  37. package/dist/cjs/mockData/handlers/index.js +0 -5
  38. package/dist/cjs/mockData/handlers/tenantAuth.js +0 -6
  39. package/dist/cjs/mockData/handlers/userCollectionFetch.js +0 -11
  40. package/dist/cjs/mockData/index.js +0 -9
  41. package/dist/cjs/mockData/matchers.js +0 -11
  42. package/dist/cjs/mockData/utils.js +10 -10
  43. package/dist/cjs/mockLoadImage.js +2 -14
  44. package/dist/cjs/mocks/database/chunk.js +0 -3
  45. package/dist/cjs/mocks/database/collection-item.js +14 -23
  46. package/dist/cjs/mocks/database/collection.js +0 -2
  47. package/dist/cjs/mocks/database/index.js +5 -23
  48. package/dist/cjs/mocks/database/upload.js +0 -6
  49. package/dist/cjs/mocks/fileAndDirectoriesUtils.js +12 -20
  50. package/dist/cjs/mocks/media-mock.js +14 -45
  51. package/dist/cjs/mocks/routers/api-router.js +78 -162
  52. package/dist/cjs/mocks/routers/index.js +0 -2
  53. package/dist/cjs/mocks/routers/media-playground-router.js +0 -3
  54. package/dist/cjs/mocks/websockets/index.js +0 -1
  55. package/dist/cjs/mocks/websockets/messages.js +0 -9
  56. package/dist/cjs/mocks/websockets/remote-upload-server.js +19 -45
  57. package/dist/cjs/mountWithIntlContext.js +9 -27
  58. package/dist/cjs/nextTick.js +0 -4
  59. package/dist/cjs/renderWithIntl.js +0 -6
  60. package/dist/cjs/story-list.js +8 -28
  61. package/dist/cjs/story-styles.js +0 -6
  62. package/dist/cjs/styled.js +1 -9
  63. package/dist/cjs/timeoutPromise.js +0 -1
  64. package/dist/cjs/ufoLogger.js +0 -7
  65. package/dist/cjs/utils/index.js +2 -11
  66. package/dist/cjs/utils/logging.js +11 -12
  67. package/dist/cjs/utils/mockData.js +5 -19
  68. package/dist/cjs/version.json +1 -1
  69. package/dist/cjs/waitUntil.js +2 -10
  70. package/dist/es2019/I18nWrapper.js +2 -4
  71. package/dist/es2019/MockGlobalImage.js +0 -3
  72. package/dist/es2019/authProvider.js +2 -5
  73. package/dist/es2019/clipboardEventMocks.js +12 -26
  74. package/dist/es2019/createMouseEvent.js +0 -2
  75. package/dist/es2019/docs-content-tabs.js +1 -3
  76. package/dist/es2019/example-mediaFeatureFlags.js +3 -2
  77. package/dist/es2019/exampleMediaItems.js +8 -3
  78. package/dist/es2019/fakeI18n.js +2 -1
  79. package/dist/es2019/fakeMediaClient.js +0 -1
  80. package/dist/es2019/featureFlagsWrapper/dropdown.js +0 -10
  81. package/dist/es2019/featureFlagsWrapper/helpers.js +2 -1
  82. package/dist/es2019/featureFlagsWrapper/index.js +2 -7
  83. package/dist/es2019/fileReader.js +0 -17
  84. package/dist/es2019/fileStateFactory/createFileState.js +6 -14
  85. package/dist/es2019/fileStateFactory/factory.js +4 -15
  86. package/dist/es2019/fileStateFactory/helpers.js +2 -7
  87. package/dist/es2019/getJest.js +3 -6
  88. package/dist/es2019/globalEventEmitterListeners.js +0 -3
  89. package/dist/es2019/images.js +2 -1
  90. package/dist/es2019/keyboardEventWithKeyCode.js +0 -5
  91. package/dist/es2019/mediaClientErrors.js +2 -1
  92. package/dist/es2019/mediaClientProvider.js +1 -1
  93. package/dist/es2019/mediaPickerAuthProvider.js +2 -5
  94. package/dist/es2019/mockData/handlers/copyWithToken.js +0 -2
  95. package/dist/es2019/mockData/handlers/getFile.js +0 -3
  96. package/dist/es2019/mockData/handlers/getFileImage.js +0 -3
  97. package/dist/es2019/mockData/handlers/tenantAuth.js +0 -2
  98. package/dist/es2019/mockData/handlers/userCollectionFetch.js +0 -2
  99. package/dist/es2019/mockData/index.js +0 -2
  100. package/dist/es2019/mockData/utils.js +10 -6
  101. package/dist/es2019/mockLoadImage.js +4 -2
  102. package/dist/es2019/mocks/database/index.js +0 -2
  103. package/dist/es2019/mocks/fileAndDirectoriesUtils.js +20 -14
  104. package/dist/es2019/mocks/media-mock.js +4 -16
  105. package/dist/es2019/mocks/routers/api-router.js +13 -45
  106. package/dist/es2019/mocks/websockets/remote-upload-server.js +11 -14
  107. package/dist/es2019/mountWithIntlContext.js +4 -4
  108. package/dist/es2019/story-list.js +4 -6
  109. package/dist/es2019/styled.js +2 -3
  110. package/dist/es2019/ufoLogger.js +0 -1
  111. package/dist/es2019/utils/index.js +0 -2
  112. package/dist/es2019/utils/logging.js +4 -4
  113. package/dist/es2019/utils/mockData.js +5 -3
  114. package/dist/es2019/version.json +1 -1
  115. package/dist/es2019/waitUntil.js +0 -1
  116. package/dist/esm/I18nWrapper.js +8 -12
  117. package/dist/esm/MockGlobalImage.js +0 -10
  118. package/dist/esm/authProvider.js +0 -10
  119. package/dist/esm/await-error.js +0 -6
  120. package/dist/esm/clipboardEventMocks.js +15 -39
  121. package/dist/esm/createMouseEvent.js +4 -6
  122. package/dist/esm/docs-content-tabs.js +2 -5
  123. package/dist/esm/example-mediaFeatureFlags.js +0 -3
  124. package/dist/esm/exampleMediaItems.js +8 -3
  125. package/dist/esm/fakeI18n.js +2 -1
  126. package/dist/esm/fakeMediaClient.js +5 -8
  127. package/dist/esm/featureFlagsWrapper/dropdown.js +12 -30
  128. package/dist/esm/featureFlagsWrapper/helpers.js +0 -3
  129. package/dist/esm/featureFlagsWrapper/index.js +5 -12
  130. package/dist/esm/fileReader.js +0 -28
  131. package/dist/esm/fileStateFactory/createFileState.js +9 -22
  132. package/dist/esm/fileStateFactory/factory.js +7 -41
  133. package/dist/esm/fileStateFactory/helpers.js +10 -18
  134. package/dist/esm/getAuthFromContextProvider.js +0 -3
  135. package/dist/esm/getJest.js +3 -3
  136. package/dist/esm/globalEventEmitterListeners.js +0 -3
  137. package/dist/esm/images.js +2 -1
  138. package/dist/esm/jestHelpers.js +0 -2
  139. package/dist/esm/keyboardEventWithKeyCode.js +0 -10
  140. package/dist/esm/mediaClientErrors.js +0 -3
  141. package/dist/esm/mediaClientProvider.js +1 -1
  142. package/dist/esm/mediaPickerAuthProvider.js +5 -12
  143. package/dist/esm/mockData/handlers/copyWithToken.js +0 -4
  144. package/dist/esm/mockData/handlers/getFile.js +0 -3
  145. package/dist/esm/mockData/handlers/getFileImage.js +0 -3
  146. package/dist/esm/mockData/handlers/tenantAuth.js +0 -2
  147. package/dist/esm/mockData/handlers/userCollectionFetch.js +0 -5
  148. package/dist/esm/mockData/index.js +0 -2
  149. package/dist/esm/mockData/utils.js +10 -6
  150. package/dist/esm/mockLoadImage.js +2 -4
  151. package/dist/esm/mocks/database/collection-item.js +14 -15
  152. package/dist/esm/mocks/database/index.js +5 -7
  153. package/dist/esm/mocks/fileAndDirectoriesUtils.js +12 -13
  154. package/dist/esm/mocks/media-mock.js +14 -26
  155. package/dist/esm/mocks/routers/api-router.js +78 -144
  156. package/dist/esm/mocks/websockets/remote-upload-server.js +19 -24
  157. package/dist/esm/mountWithIntlContext.js +9 -17
  158. package/dist/esm/story-list.js +8 -17
  159. package/dist/esm/story-styles.js +0 -2
  160. package/dist/esm/styled.js +1 -4
  161. package/dist/esm/ufoLogger.js +0 -4
  162. package/dist/esm/utils/index.js +2 -5
  163. package/dist/esm/utils/logging.js +11 -11
  164. package/dist/esm/utils/mockData.js +5 -3
  165. package/dist/esm/version.json +1 -1
  166. package/dist/esm/waitUntil.js +2 -6
  167. package/package.json +5 -5
  168. package/report.api.md +13 -0
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "name": "@atlaskit/media-test-helpers",
3
- "version": "30.1.0"
3
+ "version": "30.1.2"
4
4
  }
@@ -1,26 +1,21 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.default = void 0;
9
8
  exports.waitUntil = waitUntil;
10
-
11
9
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
12
-
13
10
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
14
-
15
11
  function waitUntil(_x) {
16
12
  return _waitUntil.apply(this, arguments);
17
13
  }
18
-
19
14
  function _waitUntil() {
20
15
  _waitUntil = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(predicate) {
21
16
  var timeout,
22
- maxRetries,
23
- _args = arguments;
17
+ maxRetries,
18
+ _args = arguments;
24
19
  return _regenerator.default.wrap(function _callee$(_context) {
25
20
  while (1) {
26
21
  switch (_context.prev = _context.next) {
@@ -39,10 +34,8 @@ function _waitUntil() {
39
34
  reject('timed out');
40
35
  }
41
36
  };
42
-
43
37
  check(maxRetries);
44
38
  }));
45
-
46
39
  case 3:
47
40
  case "end":
48
41
  return _context.stop();
@@ -52,6 +45,5 @@ function _waitUntil() {
52
45
  }));
53
46
  return _waitUntil.apply(this, arguments);
54
47
  }
55
-
56
48
  var _default = waitUntil;
57
49
  exports.default = _default;
@@ -2,18 +2,15 @@ import React, { useState } from 'react';
2
2
  import { IntlProvider } from 'react-intl-next';
3
3
  import LocaleSelect, { defaultLocales } from '@atlaskit/locale/LocaleSelect';
4
4
  import { locales } from '@atlaskit/media-ui/locales';
5
-
6
5
  function getMessages(localeValue) {
7
6
  const lang = localeValue.substring(0, 2);
8
7
  const langWithRegion = localeValue.replace('-', '_');
9
8
  return locales[langWithRegion] || locales[lang];
10
9
  }
11
-
12
10
  const selectableLocales = defaultLocales.reduce((result, locale) => {
13
11
  if (!getMessages(locale.value)) {
14
12
  return result;
15
13
  }
16
-
17
14
  return [...result, locale];
18
15
  }, []);
19
16
  export const I18NWrapper = ({
@@ -35,7 +32,8 @@ export const I18NWrapper = ({
35
32
  locales: selectableLocales
36
33
  })), /*#__PURE__*/React.createElement(IntlProvider, {
37
34
  locale: lang,
38
- messages: messages // We need to add this key to force a re-render and refresh translations
35
+ messages: messages
36
+ // We need to add this key to force a re-render and refresh translations
39
37
  // when selected language has changed
40
38
  ,
41
39
  key: locale.value
@@ -1,14 +1,11 @@
1
1
  let globalImage = global.Image;
2
2
  let isErrorInsteadOfLoad;
3
-
4
3
  class MockImage extends global.Image {
5
4
  constructor() {
6
5
  super();
7
6
  window.setTimeout(() => this[isErrorInsteadOfLoad ? 'onerror' : 'onload']());
8
7
  }
9
-
10
8
  }
11
-
12
9
  export function enableMockGlobalImage(isError = false) {
13
10
  global.Image = MockImage;
14
11
  isErrorInsteadOfLoad = isError;
@@ -16,22 +16,19 @@ export class StoryBookAuthProvider {
16
16
  }) : undefined
17
17
  };
18
18
  const url = `${authProviderBaseURL}/token/tenant?collection=${collectionName}&environment=${environment}`;
19
- const response = fetch(url, config); // We leverage the fact, that our internal /toke/tenant API returns data in the same format as Auth
19
+ const response = fetch(url, config);
20
20
 
21
+ // We leverage the fact, that our internal /toke/tenant API returns data in the same format as Auth
21
22
  return await (await response).json();
22
23
  };
23
-
24
24
  return authContext => {
25
25
  const collectionName = authContext && authContext.collectionName || defaultCollectionName;
26
26
  const accessStr = access ? JSON.stringify(access) : '';
27
27
  const cacheKey = `${collectionName}-${accessStr}-${isAsapEnvironment}`;
28
-
29
28
  if (!cachedAuths[cacheKey]) {
30
29
  cachedAuths[cacheKey] = loadTenatAuth(collectionName);
31
30
  }
32
-
33
31
  return cachedAuths[cacheKey];
34
32
  };
35
33
  }
36
-
37
34
  }
@@ -3,30 +3,25 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
3
  // see https://github.com/tmpvar/jsdom/issues/1568
4
4
  export class ClipboardMockFile {
5
5
  msClose() {}
6
-
7
6
  msDetachStream() {}
8
-
9
7
  slice() {
10
8
  throw new Error('not implemented');
11
9
  }
12
-
13
10
  constructor(options = {
14
11
  type: '',
15
12
  name: 'some-file.png'
16
13
  }) {
17
14
  _defineProperty(this, "lastModified", 1234);
18
-
19
15
  this.type = options.type;
20
16
  this.name = options.name;
21
17
  this.size = 0;
22
18
  this.webkitRelativePath = '';
23
19
  }
24
-
25
20
  arrayBuffer() {
26
21
  return Promise.resolve(new ArrayBuffer(0));
27
- } // @ts-expect-error Property 'stream' in type 'ClipboardMockFile' is not assignable to the same property in base type 'File'.
28
-
22
+ }
29
23
 
24
+ // @ts-expect-error Property 'stream' in type 'ClipboardMockFile' is not assignable to the same property in base type 'File'.
30
25
  stream() {
31
26
  // IE11 compat
32
27
  // eslint-disable-next-line compat/compat
@@ -34,31 +29,28 @@ export class ClipboardMockFile {
34
29
  start(controller) {
35
30
  controller.close();
36
31
  }
37
-
38
32
  });
39
33
  }
40
-
41
34
  text() {
42
35
  return Promise.resolve('');
43
36
  }
37
+ }
44
38
 
45
- } // this isn't implemented by JSDOM so we've implemented it to make Typescript happy
39
+ // this isn't implemented by JSDOM so we've implemented it to make Typescript happy
46
40
  // see https://github.com/tmpvar/jsdom/issues/1568
47
-
48
41
  export class MockFileList extends Array {
49
42
  item(index) {
50
43
  return this[index];
51
44
  }
52
-
53
45
  static fromArray(files) {
54
46
  const list = new MockFileList();
55
47
  files.forEach(file => list.push(file));
56
48
  return list;
57
49
  }
50
+ }
58
51
 
59
- } // this isn't implemented by JSDOM so we've implemented it to make Typescript happy
52
+ // this isn't implemented by JSDOM so we've implemented it to make Typescript happy
60
53
  // see https://github.com/tmpvar/jsdom/issues/1568
61
-
62
54
  export class MockDataTransfer {
63
55
  constructor(files, types = [], items = [], dropEffect = 'none', effectAllowed = 'none') {
64
56
  this.files = files;
@@ -67,42 +59,36 @@ export class MockDataTransfer {
67
59
  this.dropEffect = dropEffect;
68
60
  this.effectAllowed = effectAllowed;
69
61
  }
70
-
71
62
  clearData() {
72
63
  return false;
73
64
  }
74
-
75
65
  getData() {
76
66
  return '';
77
67
  }
78
-
79
68
  setData() {
80
69
  return false;
81
70
  }
82
-
83
71
  setDragImage() {}
72
+ }
84
73
 
85
- } // this isn't implemented by JSDOM, and JSDOM .dispatchEvent() requires that event is an instanceof event,
74
+ // this isn't implemented by JSDOM, and JSDOM .dispatchEvent() requires that event is an instanceof event,
86
75
  // so we've implemented it to make Typescript happy
87
76
  // see https://github.com/tmpvar/jsdom/issues/1568
88
-
89
77
  export const getMockClipboardEvent = () => class MockClipboardEvent extends Event {
90
78
  constructor(event, files = [], types = []) {
91
79
  super(event);
92
80
  this.clipboardData = new MockDataTransfer(MockFileList.fromArray(files), types);
93
81
  }
94
-
95
82
  };
96
83
  export const MockDragEvent = () => class MockDragEvent extends MouseEvent {
97
84
  constructor(event, files = []) {
98
85
  super(event);
99
86
  this.dataTransfer = new MockDataTransfer(MockFileList.fromArray(files));
100
87
  }
101
-
102
- initDragEvent() {// noop
88
+ initDragEvent() {
89
+ // noop
103
90
  }
104
-
105
- msConvertURL() {// noop
91
+ msConvertURL() {
92
+ // noop
106
93
  }
107
-
108
94
  };
@@ -6,13 +6,11 @@ export const createMouseEvent = (name, props = {}) => {
6
6
  screenX: sx,
7
7
  screenY: sy
8
8
  } = props;
9
-
10
9
  if (document.createEvent) {
11
10
  const event = document.createEvent('MouseEvent');
12
11
  event.initMouseEvent(name, true, true, window, 0, sx || 0, sy || 0, cx || 0, cy || 0, false, false, false, false, mb || 0, null);
13
12
  return event;
14
13
  }
15
-
16
14
  return new MouseEvent(name, {
17
15
  button: mb,
18
16
  clientX: cx || 0,
@@ -1,6 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
-
3
2
  /** @jsx jsx */
3
+
4
4
  import { css, jsx } from '@emotion/react';
5
5
  import Tabs, { Tab, TabList, useTabPanel } from '@atlaskit/tabs';
6
6
  const panelStyle = css`
@@ -8,7 +8,6 @@ const panelStyle = css`
8
8
  width: 100%;
9
9
  }
10
10
  `;
11
-
12
11
  const CustomTabPanel = ({
13
12
  children
14
13
  }) => {
@@ -17,7 +16,6 @@ const CustomTabPanel = ({
17
16
  css: panelStyle
18
17
  }, context), children);
19
18
  };
20
-
21
19
  export const DocsContentTabs = ({
22
20
  tabs = []
23
21
  }) => jsx(Tabs, {
@@ -1,7 +1,8 @@
1
1
  import { defaultMediaFeatureFlags } from '@atlaskit/media-common';
2
- export const exampleMediaFeatureFlags = { ...defaultMediaFeatureFlags // add overrides to simulate what product would pass during local development
2
+ export const exampleMediaFeatureFlags = {
3
+ ...defaultMediaFeatureFlags
4
+ // add overrides to simulate what product would pass during local development
3
5
  // ** DON'T COMMIT! - TEST TO CHECK THIS EQUALS DEFAULTS WILL FAIL! **
4
6
  // you can also use `localStorage[exactFlagName] = true` to enable
5
7
  // or `delete localStorage[exactFlagName]` to disable
6
-
7
8
  };
@@ -1,7 +1,9 @@
1
1
  import { defaultCollectionName as collectionName, onlyAnimatedGifsCollectionName } from './collectionNames';
2
2
  import { videoURI } from './dataURIs/videoURI';
3
3
  import { videoPreviewURI } from './dataURIs/videoPreviewURI';
4
- const fileType = 'file'; // === FILE ===
4
+ const fileType = 'file';
5
+
6
+ // === FILE ===
5
7
 
6
8
  export const genericFileId = {
7
9
  id: '2dfcc12d-04d7-46e7-9fdf-3715ff00ba40',
@@ -173,7 +175,8 @@ export const animatedFileId = {
173
175
  id: 'af637c7a-75c3-4254-b074-d16e6ae2e04b',
174
176
  mediaItemType: fileType,
175
177
  collectionName: onlyAnimatedGifsCollectionName
176
- }; // === EXTERNAL IMAGE ===
178
+ };
179
+ // === EXTERNAL IMAGE ===
177
180
 
178
181
  export const atlassianLogoUrl = 'https://wac-cdn.atlassian.com/assets/img/favicons/atlassian/apple-touch-icon-152x152.png';
179
182
  export const externalImageIdentifier = {
@@ -252,7 +255,9 @@ export const unknownFileDetails = {
252
255
  name: 'doc_file.pdf',
253
256
  size: 2958464
254
257
  };
255
- export const genericDataURI = 'data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAZABkAAD/4QCMRXhpZgAATU0AKgAAAAgABQESAAMAAAABAAEAAAEaAAUAAAABAAAASgEbAAUAAAABAAAAUgEoAAMAAAABAAIAAIdpAAQAAAABAAAAWgAAAAAAAABkAAAAAQAAAGQAAAABAAOgAQADAAAAAQABAACgAgAEAAAAAQAAAAKgAwAEAAAAAQAAAAIAAAAA/+0AOFBob3Rvc2hvcCAzLjAAOEJJTQQEAAAAAAAAOEJJTQQlAAAAAAAQ1B2M2Y8AsgTpgAmY7PhCfv/AABEIAAIAAgMBEQACEQEDEQH/xAAfAAABBQEBAQEBAQAAAAAAAAAAAQIDBAUGBwgJCgv/xAC1EAACAQMDAgQDBQUEBAAAAX0BAgMABBEFEiExQQYTUWEHInEUMoGRoQgjQrHBFVLR8CQzYnKCCQoWFxgZGiUmJygpKjQ1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5eoOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4eLj5OXm5+jp6vHy8/T19vf4+fr/xAAfAQADAQEBAQEBAQEBAAAAAAAAAQIDBAUGBwgJCgv/xAC1EQACAQIEBAMEBwUEBAABAncAAQIDEQQFITEGEkFRB2FxEyIygQgUQpGhscEJIzNS8BVictEKFiQ04SXxFxgZGiYnKCkqNTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqCg4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2dri4+Tl5ufo6ery8/T19vf4+fr/2wBDAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQICAQECAQEBAgICAgICAgICAQICAgICAgICAgL/2wBDAQEBAQEBAQEBAQECAQEBAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgL/3QAEAAH/2gAMAwEAAhEDEQA/AP0U8M2NmPDfh8C0tgBomkgAW8OAPsFvwK/lh7s+5u+/4n//2Q=='; // === VR test ids ===
258
+ export const genericDataURI = 'data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAZABkAAD/4QCMRXhpZgAATU0AKgAAAAgABQESAAMAAAABAAEAAAEaAAUAAAABAAAASgEbAAUAAAABAAAAUgEoAAMAAAABAAIAAIdpAAQAAAABAAAAWgAAAAAAAABkAAAAAQAAAGQAAAABAAOgAQADAAAAAQABAACgAgAEAAAAAQAAAAKgAwAEAAAAAQAAAAIAAAAA/+0AOFBob3Rvc2hvcCAzLjAAOEJJTQQEAAAAAAAAOEJJTQQlAAAAAAAQ1B2M2Y8AsgTpgAmY7PhCfv/AABEIAAIAAgMBEQACEQEDEQH/xAAfAAABBQEBAQEBAQAAAAAAAAAAAQIDBAUGBwgJCgv/xAC1EAACAQMDAgQDBQUEBAAAAX0BAgMABBEFEiExQQYTUWEHInEUMoGRoQgjQrHBFVLR8CQzYnKCCQoWFxgZGiUmJygpKjQ1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5eoOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4eLj5OXm5+jp6vHy8/T19vf4+fr/xAAfAQADAQEBAQEBAQEBAAAAAAAAAQIDBAUGBwgJCgv/xAC1EQACAQIEBAMEBwUEBAABAncAAQIDEQQFITEGEkFRB2FxEyIygQgUQpGhscEJIzNS8BVictEKFiQ04SXxFxgZGiYnKCkqNTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqCg4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2dri4+Tl5ufo6ery8/T19vf4+fr/2wBDAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQICAQECAQEBAgICAgICAgICAQICAgICAgICAgL/2wBDAQEBAQEBAQEBAQECAQEBAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgL/3QAEAAH/2gAMAwEAAhEDEQA/AP0U8M2NmPDfh8C0tgBomkgAW8OAPsFvwK/lh7s+5u+/4n//2Q==';
259
+
260
+ // === VR test ids ===
256
261
 
257
262
  export const vrVideoDetails = {
258
263
  id: '0c3c64b9-65ad-4592-89d0-f838beebd81e',
@@ -1,6 +1,7 @@
1
1
  import getJest from './getJest';
2
- const jest = getJest(); // fakeIntl["..."] here to indicate those went through formatMessage and not just left as string itself
2
+ const jest = getJest();
3
3
 
4
+ // fakeIntl["..."] here to indicate those went through formatMessage and not just left as string itself
4
5
  export const fakeIntl = {
5
6
  formatMessage: jest.fn(({
6
7
  defaultMessage
@@ -30,7 +30,6 @@ export const fakeMediaClient = (config = getDefaultMediaClientConfig()) => {
30
30
  mediaClient.collection = collectionFetcher;
31
31
  mediaClient.stargate = stargateClient;
32
32
  mediaClient.config = config; // <- deprecated
33
-
34
33
  mediaClient.mediaClientConfig = config;
35
34
  mediaClient.mediaStore = mockMediaStore;
36
35
  mediaClient.mediaStore.getItems = jest.fn().mockResolvedValue({
@@ -10,18 +10,15 @@ import styled from '@emotion/styled';
10
10
  import Popup from '@atlaskit/popup';
11
11
  import { Checkbox } from '@atlaskit/checkbox';
12
12
  import { debounce } from '@atlaskit/media-common';
13
-
14
13
  const camelCaseToSentenceCase = text => {
15
14
  var result = text.replace(/([A-Z])/g, ' $1');
16
15
  return result.charAt(0).toUpperCase() + result.slice(1);
17
16
  };
18
-
19
17
  const Container = styled.div`
20
18
  display: flex;
21
19
  flex-direction: row;
22
20
  margin: 20px auto;
23
21
  `;
24
-
25
22
  const ItemWrapper = ({
26
23
  children
27
24
  }) => /*#__PURE__*/React.createElement("div", {
@@ -29,7 +26,6 @@ const ItemWrapper = ({
29
26
  padding: '10px 20px'
30
27
  }
31
28
  }, children);
32
-
33
29
  const CheckboxItem = ({
34
30
  name,
35
31
  initialValue,
@@ -44,7 +40,6 @@ const CheckboxItem = ({
44
40
  },
45
41
  name: `media-feature-flag-check-${name}`
46
42
  }));
47
-
48
43
  const TextFieldItem = ({
49
44
  name,
50
45
  value,
@@ -65,7 +60,6 @@ const TextFieldItem = ({
65
60
  type: isNumber ? 'number' : 'text'
66
61
  }));
67
62
  };
68
-
69
63
  const FeatureFlagItems = ({
70
64
  onUpdate,
71
65
  filterFlags
@@ -80,7 +74,6 @@ const FeatureFlagItems = ({
80
74
  const name = key;
81
75
  const ffType = typeof currentValue;
82
76
  const isNumber = ffType === 'number';
83
-
84
77
  switch (ffType) {
85
78
  case 'boolean':
86
79
  return /*#__PURE__*/React.createElement(CheckboxItem, {
@@ -89,7 +82,6 @@ const FeatureFlagItems = ({
89
82
  initialValue: currentValue,
90
83
  onChange: onUpdate
91
84
  });
92
-
93
85
  case 'number':
94
86
  case 'string':
95
87
  return /*#__PURE__*/React.createElement(TextFieldItem, {
@@ -102,7 +94,6 @@ const FeatureFlagItems = ({
102
94
  }
103
95
  }) : /*#__PURE__*/React.createElement(ItemWrapper, null, "No flags available"));
104
96
  };
105
-
106
97
  const MediaFeatureFlagsDropdown = ({
107
98
  onFlagChanged,
108
99
  filterFlags
@@ -140,5 +131,4 @@ const MediaFeatureFlagsDropdown = ({
140
131
  }
141
132
  })));
142
133
  };
143
-
144
134
  export default MediaFeatureFlagsDropdown;
@@ -13,6 +13,7 @@ export const clearLocalFeatureFlag = key => {
13
13
  export const clearAllLocalFeatureFlags = () => {
14
14
  mediaFeatureFlagsKeys.forEach(clearLocalFeatureFlag);
15
15
  };
16
- export const getMediaFeatureFlags = filter => mediaFeatureFlagsKeys.filter(flagKey => filter ? filter.includes(flagKey) : true).reduce((result, flagName) => ({ ...result,
16
+ export const getMediaFeatureFlags = filter => mediaFeatureFlagsKeys.filter(flagKey => filter ? filter.includes(flagKey) : true).reduce((result, flagName) => ({
17
+ ...result,
17
18
  [flagName]: getMediaFeatureFlag(flagName)
18
19
  }), {});
@@ -1,6 +1,5 @@
1
1
  import React, { useState } from 'react';
2
2
  import FeatureFlagsDropdown from './dropdown';
3
-
4
3
  const isLocalStorageSupported = () => {
5
4
  try {
6
5
  if (typeof window !== 'undefined' && !!window.localStorage) {
@@ -9,20 +8,17 @@ const isLocalStorageSupported = () => {
9
8
  return true;
10
9
  }
11
10
  } catch (e) {}
12
-
13
11
  return false;
14
12
  };
15
-
16
13
  const FeatureFlagsWrapper = ({
17
14
  children,
18
15
  filterFlags
19
16
  }) => {
20
- const [childrenKey, setChildrenKey] = useState(0); // This is a trick to force a re-render on the component's children to see the new FF values taking effect
21
-
17
+ const [childrenKey, setChildrenKey] = useState(0);
18
+ // This is a trick to force a re-render on the component's children to see the new FF values taking effect
22
19
  const onFlagChanged = () => {
23
20
  setChildrenKey(childrenKey + 1);
24
21
  };
25
-
26
22
  return isLocalStorageSupported() ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(FeatureFlagsDropdown, {
27
23
  onFlagChanged: onFlagChanged,
28
24
  filterFlags: filterFlags
@@ -30,5 +26,4 @@ const FeatureFlagsWrapper = ({
30
26
  key: childrenKey
31
27
  }, children)) : /*#__PURE__*/React.createElement(React.Fragment, null, children);
32
28
  };
33
-
34
29
  export default FeatureFlagsWrapper;
@@ -1,13 +1,10 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import getJest from './getJest';
3
3
  const jest = getJest();
4
-
5
4
  class MockFileReader {
6
5
  constructor(result = 'mockResult') {
7
6
  _defineProperty(this, "loadEvent", () => {});
8
-
9
7
  _defineProperty(this, "errorEvent", _ => {});
10
-
11
8
  _defineProperty(this, "addEventListener", jest.fn().mockImplementation((eventName, fn) => {
12
9
  if (eventName === 'load') {
13
10
  this.loadEvent = fn;
@@ -15,54 +12,40 @@ class MockFileReader {
15
12
  this.errorEvent = fn;
16
13
  }
17
14
  }));
18
-
19
15
  _defineProperty(this, "readAsDataURL", jest.fn().mockImplementation(() => {
20
16
  this.loadEvent();
21
17
  }));
22
-
23
18
  _defineProperty(this, "readAsArrayBuffer", jest.fn().mockImplementation(() => {
24
19
  this.loadEvent();
25
20
  }));
26
-
27
21
  this.result = result;
28
22
  }
29
-
30
23
  }
31
-
32
24
  const mockFileReaderError = {
33
25
  message: 'error'
34
26
  };
35
-
36
27
  class MockFileReaderWithError extends MockFileReader {
37
28
  constructor(...args) {
38
29
  super(...args);
39
-
40
30
  _defineProperty(this, "readAsDataURL", jest.fn().mockImplementation(() => {
41
31
  this.errorEvent(mockFileReaderError);
42
32
  }));
43
33
  }
44
-
45
34
  }
46
-
47
35
  const GlobalFileReader = global.FileReader;
48
36
  let FileReader;
49
-
50
37
  if (global.FileReader && typeof jest !== 'undefined') {
51
38
  FileReader = jest.spyOn(global, 'FileReader').mockImplementation(() => new GlobalFileReader());
52
39
  }
53
-
54
40
  const mockFileReader = result => {
55
41
  const fileReader = new MockFileReader(result);
56
42
  FileReader.mockImplementation(() => fileReader);
57
43
  return fileReader;
58
44
  };
59
-
60
45
  const mockFileReaderWithError = () => {
61
46
  const fileReader = new MockFileReaderWithError();
62
47
  FileReader.mockImplementation(() => fileReader);
63
48
  return fileReader;
64
49
  };
65
-
66
50
  const unmockFileReader = () => FileReader.mockImplementation(() => new GlobalFileReader());
67
-
68
51
  export { mockFileReader, mockFileReaderWithError, unmockFileReader, mockFileReaderError };
@@ -16,30 +16,26 @@ export const createFileState = (id, status, {
16
16
  fileDetails
17
17
  } = {}) => {
18
18
  const extendState = {};
19
-
20
19
  if (uploadProgress) {
21
20
  extendState.progress = uploadProgress;
22
- } // REMOTE PREVIEW
23
-
24
-
21
+ }
22
+ // REMOTE PREVIEW
25
23
  if (withRemotePreview) {
26
24
  extendState.representations = remotePreview;
27
25
  } else if (withRemotePreview === false) {
28
26
  extendState.representations = {};
29
- } // LOCAL PREVIEW
30
-
31
-
27
+ }
28
+ // LOCAL PREVIEW
32
29
  if (withLocalPreview) {
33
30
  extendState.preview = localPreview;
34
31
  } else if (withBrokenLocalPreview) {
35
32
  extendState.preview = brokenLocalPreview;
36
33
  }
37
-
38
- const base = { ...fileDetails,
34
+ const base = {
35
+ ...fileDetails,
39
36
  ...extendState,
40
37
  id
41
38
  };
42
-
43
39
  switch (status) {
44
40
  case 'uploading':
45
41
  return {
@@ -47,13 +43,11 @@ export const createFileState = (id, status, {
47
43
  progress: 0,
48
44
  ...base
49
45
  };
50
-
51
46
  case 'processing':
52
47
  return {
53
48
  status: 'processing',
54
49
  ...base
55
50
  };
56
-
57
51
  case 'processed':
58
52
  return {
59
53
  status: 'processed',
@@ -61,13 +55,11 @@ export const createFileState = (id, status, {
61
55
  artifacts: {},
62
56
  ...base
63
57
  };
64
-
65
58
  case 'failed-processing':
66
59
  return {
67
60
  status: 'failed-processing',
68
61
  ...base
69
62
  };
70
-
71
63
  case 'error':
72
64
  default:
73
65
  return {
@@ -7,11 +7,9 @@ import { sleep } from '../nextTick';
7
7
  export class MediaClientMock extends MediaClient {
8
8
  constructor(observable, mediaClientConfig, featureFlags, options = {}) {
9
9
  super(mediaClientConfig, featureFlags);
10
-
11
10
  _defineProperty(this, "updateObserbable", newObservable => {
12
11
  this.observable = newObservable;
13
12
  });
14
-
15
13
  _defineProperty(this, "getImage", async () => {
16
14
  const {
17
15
  getImageDelay = 0
@@ -19,16 +17,13 @@ export class MediaClientMock extends MediaClient {
19
17
  await sleep(getImageDelay);
20
18
  return dataURItoBlob(tallImage);
21
19
  });
22
-
23
20
  _defineProperty(this, "mockFileFetcher", () => {
24
21
  this.file.getFileState = () => this.observable;
25
22
  });
26
-
27
23
  this.observable = observable;
28
24
  this.options = options;
29
25
  this.mockFileFetcher();
30
26
  }
31
-
32
27
  }
33
28
  const mockConfig = {
34
29
  authProvider: async () => ({
@@ -37,14 +32,13 @@ const mockConfig = {
37
32
  baseUrl: 'some-url'
38
33
  })
39
34
  };
40
-
41
35
  /**
42
36
  * A fake Media Client that provides a backdoor to inject
43
37
  * simulated file states. With this class, we can test several scenarios
44
38
  * without having to recreate them all in the backend.
45
39
  */
46
40
  export class FileStateFactory {
47
- constructor(identifier, {
41
+ constructor(_identifier, {
48
42
  fileDetails: _fileDetails,
49
43
  mediaClientConfig = mockConfig,
50
44
  featureFlags,
@@ -56,7 +50,6 @@ export class FileStateFactory {
56
50
  this.observable = createMediaSubject();
57
51
  this.mediaClient.updateObserbable(this.observable);
58
52
  });
59
-
60
53
  _defineProperty(this, "subscription", {
61
54
  next: fileState => {
62
55
  this.observable.next(fileState);
@@ -65,23 +58,19 @@ export class FileStateFactory {
65
58
  this.observable.error(error);
66
59
  }
67
60
  });
68
-
69
- _defineProperty(this, "createFileState", (status, options) => createFileState(this.identifier.id, status, { ...options,
61
+ _defineProperty(this, "createFileState", (status, options) => createFileState(this.identifier.id, status, {
62
+ ...options,
70
63
  fileDetails: (options === null || options === void 0 ? void 0 : options.fileDetails) || this.fileDetails
71
64
  }));
72
-
73
65
  _defineProperty(this, "next", (status, options) => {
74
66
  this.subscription.next(this.createFileState(status, options));
75
67
  });
76
-
77
68
  _defineProperty(this, "error", error => {
78
69
  this.subscription.error(error);
79
70
  });
80
-
81
- this.identifier = identifier;
71
+ this.identifier = _identifier;
82
72
  this.fileDetails = _fileDetails || createFileDetails(this.identifier.id);
83
73
  this.observable = createMediaSubject();
84
74
  this.mediaClient = new MediaClientMock(this.observable, mediaClientConfig, featureFlags, mediaClientMockOptions);
85
75
  }
86
-
87
76
  }