@atlaskit/media-test-helpers 31.0.0 → 32.1.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.
Files changed (72) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/cjs/authProvider.js +25 -27
  3. package/dist/cjs/await-error.js +17 -19
  4. package/dist/cjs/docs-content-tabs.js +1 -0
  5. package/dist/cjs/fakeMediaClient.js +0 -5
  6. package/dist/cjs/fileStateFactory/{createFileState.js → factory/createFileState.js} +8 -15
  7. package/dist/cjs/fileStateFactory/{factory.js → factory/factory.js} +34 -25
  8. package/dist/cjs/fileStateFactory/factory/index.js +38 -0
  9. package/dist/cjs/fileStateFactory/fileSimulation/fileSimulation.js +89 -0
  10. package/dist/cjs/fileStateFactory/fileSimulation/index.js +79 -0
  11. package/dist/cjs/fileStateFactory/fileSimulation/simulations.js +399 -0
  12. package/dist/cjs/fileStateFactory/index.js +76 -4
  13. package/dist/cjs/getAuthFromContextProvider.js +21 -23
  14. package/dist/cjs/index.js +72 -0
  15. package/dist/cjs/mediaPickerAuthProvider.js +22 -24
  16. package/dist/cjs/mocks/database/collection-item.js +5 -0
  17. package/dist/cjs/mocks/database/index.js +6 -0
  18. package/dist/cjs/mocks/routers/api-router.js +92 -98
  19. package/dist/cjs/story-list.js +1 -1
  20. package/dist/cjs/utils/logging.js +4 -4
  21. package/dist/cjs/version.json +1 -1
  22. package/dist/cjs/waitUntil.js +19 -21
  23. package/dist/es2019/fakeMediaClient.js +0 -5
  24. package/dist/es2019/fileStateFactory/{createFileState.js → factory/createFileState.js} +8 -17
  25. package/dist/es2019/fileStateFactory/{factory.js → factory/factory.js} +12 -2
  26. package/dist/es2019/fileStateFactory/factory/index.js +3 -0
  27. package/dist/es2019/fileStateFactory/fileSimulation/fileSimulation.js +63 -0
  28. package/dist/es2019/fileStateFactory/fileSimulation/index.js +2 -0
  29. package/dist/es2019/fileStateFactory/fileSimulation/simulations.js +148 -0
  30. package/dist/es2019/fileStateFactory/index.js +4 -2
  31. package/dist/es2019/index.js +5 -1
  32. package/dist/es2019/mocks/database/collection-item.js +1 -0
  33. package/dist/es2019/mocks/database/index.js +1 -1
  34. package/dist/es2019/mocks/routers/api-router.js +3 -3
  35. package/dist/es2019/utils/logging.js +3 -3
  36. package/dist/es2019/version.json +1 -1
  37. package/dist/esm/authProvider.js +25 -27
  38. package/dist/esm/await-error.js +17 -19
  39. package/dist/esm/fakeMediaClient.js +0 -5
  40. package/dist/esm/fileStateFactory/{createFileState.js → factory/createFileState.js} +8 -15
  41. package/dist/esm/fileStateFactory/{factory.js → factory/factory.js} +34 -25
  42. package/dist/esm/fileStateFactory/factory/index.js +3 -0
  43. package/dist/esm/fileStateFactory/fileSimulation/fileSimulation.js +81 -0
  44. package/dist/esm/fileStateFactory/fileSimulation/index.js +2 -0
  45. package/dist/esm/fileStateFactory/fileSimulation/simulations.js +382 -0
  46. package/dist/esm/fileStateFactory/index.js +4 -2
  47. package/dist/esm/getAuthFromContextProvider.js +21 -23
  48. package/dist/esm/index.js +5 -1
  49. package/dist/esm/mediaPickerAuthProvider.js +22 -24
  50. package/dist/esm/mocks/database/collection-item.js +3 -0
  51. package/dist/esm/mocks/database/index.js +1 -1
  52. package/dist/esm/mocks/routers/api-router.js +93 -99
  53. package/dist/esm/utils/logging.js +3 -3
  54. package/dist/esm/version.json +1 -1
  55. package/dist/esm/waitUntil.js +19 -21
  56. package/dist/types/fileStateFactory/{factory.d.ts → factory/factory.d.ts} +3 -0
  57. package/dist/types/fileStateFactory/factory/index.d.ts +4 -0
  58. package/dist/types/fileStateFactory/fileSimulation/fileSimulation.d.ts +18 -0
  59. package/dist/types/fileStateFactory/fileSimulation/index.d.ts +4 -0
  60. package/dist/types/fileStateFactory/fileSimulation/simulations.d.ts +35 -0
  61. package/dist/types/fileStateFactory/index.d.ts +7 -3
  62. package/dist/types/index.d.ts +2 -2
  63. package/dist/types/mocks/database/collection-item.d.ts +13 -1
  64. package/dist/types/mocks/database/collection.d.ts +4 -1
  65. package/dist/types/mocks/database/index.d.ts +2 -2
  66. package/package.json +4 -3
  67. package/report.api.md +90 -0
  68. /package/dist/cjs/fileStateFactory/{helpers.js → factory/helpers.js} +0 -0
  69. /package/dist/es2019/fileStateFactory/{helpers.js → factory/helpers.js} +0 -0
  70. /package/dist/esm/fileStateFactory/{helpers.js → factory/helpers.js} +0 -0
  71. /package/dist/types/fileStateFactory/{createFileState.d.ts → factory/createFileState.d.ts} +0 -0
  72. /package/dist/types/fileStateFactory/{helpers.d.ts → factory/helpers.d.ts} +0 -0
@@ -15,8 +15,8 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
15
15
  // eslint-disable-line no-console
16
16
  import { Router, KakapoResponse } from 'kakapo';
17
17
  import uuid from 'uuid/v4';
18
- import { getMediaTypeFromMimeType, isMediaCollectionItemFullDetails } from '@atlaskit/media-client';
19
- import { createCollection, createCollectionItem, createEmptyCollectionItem } from '../database';
18
+ import { getMediaTypeFromMimeType } from '@atlaskit/media-client';
19
+ import { createCollection, createCollectionItem, createEmptyCollectionItem, isMediaItemDetails } from '../database';
20
20
  import { vrVideoDetails } from '../../exampleMediaItems';
21
21
  import { defaultBaseUrl } from '../../mediaClientProvider';
22
22
  import { createUpload } from '../database/upload';
@@ -167,48 +167,46 @@ export function createApiRouter(isSlowServer, urlsReturnErrorsTo) {
167
167
  var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref5, database) {
168
168
  var params, fileId, record, defaultDimensions, dimensions;
169
169
  return _regeneratorRuntime.wrap(function _callee$(_context) {
170
- while (1) {
171
- switch (_context.prev = _context.next) {
172
- case 0:
173
- params = _ref5.params;
174
- fileId = params.fileId;
175
- record = database.findOne('collectionItem', {
176
- id: fileId
170
+ while (1) switch (_context.prev = _context.next) {
171
+ case 0:
172
+ params = _ref5.params;
173
+ fileId = params.fileId;
174
+ record = database.findOne('collectionItem', {
175
+ id: fileId
176
+ });
177
+ defaultDimensions = {
178
+ height: 4096,
179
+ width: 4096
180
+ };
181
+ dimensions = Promise.resolve(defaultDimensions);
182
+ if (record && record.data.blob && !isSvgFile(record)) {
183
+ dimensions = new Promise(function (resolve) {
184
+ var image = new Image();
185
+ image.src = URL.createObjectURL(record.data.blob);
186
+ image.onload = function () {
187
+ return resolve({
188
+ height: image.height,
189
+ width: image.width
190
+ });
191
+ };
177
192
  });
178
- defaultDimensions = {
179
- height: 4096,
180
- width: 4096
181
- };
182
- dimensions = Promise.resolve(defaultDimensions);
183
- if (record && record.data.blob && !isSvgFile(record)) {
184
- dimensions = new Promise(function (resolve) {
185
- var image = new Image();
186
- image.src = URL.createObjectURL(record.data.blob);
187
- image.onload = function () {
188
- return resolve({
189
- height: image.height,
190
- width: image.width
191
- });
192
- };
193
- });
194
- }
195
- _context.t0 = {};
196
- _context.next = 9;
197
- return dimensions;
198
- case 9:
199
- _context.t1 = _context.sent;
200
- _context.t2 = {
201
- pending: false,
202
- preview: _context.t0,
203
- original: _context.t1
204
- };
205
- return _context.abrupt("return", {
206
- metadata: _context.t2
207
- });
208
- case 12:
209
- case "end":
210
- return _context.stop();
211
- }
193
+ }
194
+ _context.t0 = {};
195
+ _context.next = 9;
196
+ return dimensions;
197
+ case 9:
198
+ _context.t1 = _context.sent;
199
+ _context.t2 = {
200
+ pending: false,
201
+ preview: _context.t0,
202
+ original: _context.t1
203
+ };
204
+ return _context.abrupt("return", {
205
+ metadata: _context.t2
206
+ });
207
+ case 12:
208
+ case "end":
209
+ return _context.stop();
212
210
  }
213
211
  }, _callee);
214
212
  }));
@@ -251,25 +249,23 @@ export function createApiRouter(isSlowServer, urlsReturnErrorsTo) {
251
249
  function _awaitUpload() {
252
250
  _awaitUpload = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(resolver) {
253
251
  return _regeneratorRuntime.wrap(function _callee3$(_context3) {
254
- while (1) {
255
- switch (_context3.prev = _context3.next) {
256
- case 0:
257
- return _context3.abrupt("return", new Promise(function (resolve) {
258
- if (window.mediaMockControlsBackdoor.shouldWaitUpload) {
259
- setTimeout(function () {
260
- return awaitUpload(resolver || resolve);
261
- }, 10);
262
- return;
263
- }
264
- if (resolver && !window.mediaMockControlsBackdoor.shouldWaitUpload) {
265
- resolver();
266
- }
267
- resolve();
268
- }));
269
- case 1:
270
- case "end":
271
- return _context3.stop();
272
- }
252
+ while (1) switch (_context3.prev = _context3.next) {
253
+ case 0:
254
+ return _context3.abrupt("return", new Promise(function (resolve) {
255
+ if (window.mediaMockControlsBackdoor.shouldWaitUpload) {
256
+ setTimeout(function () {
257
+ return awaitUpload(resolver || resolve);
258
+ }, 10);
259
+ return;
260
+ }
261
+ if (resolver && !window.mediaMockControlsBackdoor.shouldWaitUpload) {
262
+ resolver();
263
+ }
264
+ resolve();
265
+ }));
266
+ case 1:
267
+ case "end":
268
+ return _context3.stop();
273
269
  }
274
270
  }, _callee3);
275
271
  }));
@@ -279,42 +275,40 @@ export function createApiRouter(isSlowServer, urlsReturnErrorsTo) {
279
275
  var _ref10 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(_ref9, database) {
280
276
  var body, _JSON$parse2, chunks, allChunks, existingChunks, nonExistingChunks;
281
277
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
282
- while (1) {
283
- switch (_context2.prev = _context2.next) {
284
- case 0:
285
- body = _ref9.body;
286
- _JSON$parse2 = JSON.parse(body), chunks = _JSON$parse2.chunks;
287
- allChunks = database.all('chunk');
288
- existingChunks = [];
289
- nonExistingChunks = [];
290
- allChunks.forEach(function (_ref11) {
291
- var id = _ref11.data.id;
292
- if (chunks.indexOf(id) > -1) {
293
- existingChunks.push(id);
294
- } else {
295
- nonExistingChunks.push(id);
296
- }
297
- });
298
- _context2.next = 8;
299
- return awaitUpload();
300
- case 8:
301
- return _context2.abrupt("return", {
302
- data: {
303
- results: [].concat(_toConsumableArray(existingChunks.map(function () {
304
- return {
305
- exists: true
306
- };
307
- })), _toConsumableArray(nonExistingChunks.map(function () {
308
- return {
309
- exists: false
310
- };
311
- })))
312
- }
313
- });
314
- case 9:
315
- case "end":
316
- return _context2.stop();
317
- }
278
+ while (1) switch (_context2.prev = _context2.next) {
279
+ case 0:
280
+ body = _ref9.body;
281
+ _JSON$parse2 = JSON.parse(body), chunks = _JSON$parse2.chunks;
282
+ allChunks = database.all('chunk');
283
+ existingChunks = [];
284
+ nonExistingChunks = [];
285
+ allChunks.forEach(function (_ref11) {
286
+ var id = _ref11.data.id;
287
+ if (chunks.indexOf(id) > -1) {
288
+ existingChunks.push(id);
289
+ } else {
290
+ nonExistingChunks.push(id);
291
+ }
292
+ });
293
+ _context2.next = 8;
294
+ return awaitUpload();
295
+ case 8:
296
+ return _context2.abrupt("return", {
297
+ data: {
298
+ results: [].concat(_toConsumableArray(existingChunks.map(function () {
299
+ return {
300
+ exists: true
301
+ };
302
+ })), _toConsumableArray(nonExistingChunks.map(function () {
303
+ return {
304
+ exists: false
305
+ };
306
+ })))
307
+ }
308
+ });
309
+ case 9:
310
+ case "end":
311
+ return _context2.stop();
318
312
  }
319
313
  }, _callee2);
320
314
  }));
@@ -510,7 +504,7 @@ export function createApiRouter(isSlowServer, urlsReturnErrorsTo) {
510
504
  id = _sourceRecord$data.id,
511
505
  details = _sourceRecord$data.details,
512
506
  blob = _sourceRecord$data.blob;
513
- var _ref19 = isMediaCollectionItemFullDetails(details) ? details : {},
507
+ var _ref19 = isMediaItemDetails(details) ? details : {},
514
508
  _ref19$name = _ref19.name,
515
509
  name = _ref19$name === void 0 ? getFakeFileName(extension) : _ref19$name,
516
510
  _ref19$size = _ref19.size,
@@ -1,8 +1,8 @@
1
- export var WsDirection;
2
- (function (WsDirection) {
1
+ export var WsDirection = /*#__PURE__*/function (WsDirection) {
3
2
  WsDirection["Upstream"] = "UP";
4
3
  WsDirection["Downstream"] = "DOWN";
5
- })(WsDirection || (WsDirection = {}));
4
+ return WsDirection;
5
+ }({});
6
6
  export function logRequest(params) {
7
7
  var path = params.path,
8
8
  method = params.method,
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "name": "@atlaskit/media-test-helpers",
3
- "version": "31.0.0"
3
+ "version": "32.1.0"
4
4
  }
@@ -9,29 +9,27 @@ function _waitUntil() {
9
9
  maxRetries,
10
10
  _args = arguments;
11
11
  return _regeneratorRuntime.wrap(function _callee$(_context) {
12
- while (1) {
13
- switch (_context.prev = _context.next) {
14
- case 0:
15
- timeout = _args.length > 1 && _args[1] !== undefined ? _args[1] : 100;
16
- maxRetries = _args.length > 2 && _args[2] !== undefined ? _args[2] : 10;
17
- return _context.abrupt("return", new Promise(function (resolve, reject) {
18
- var check = function check(retry) {
19
- if (retry > 0) {
20
- if (predicate()) {
21
- resolve();
22
- } else {
23
- window.setTimeout(check, timeout, retry - 1);
24
- }
12
+ while (1) switch (_context.prev = _context.next) {
13
+ case 0:
14
+ timeout = _args.length > 1 && _args[1] !== undefined ? _args[1] : 100;
15
+ maxRetries = _args.length > 2 && _args[2] !== undefined ? _args[2] : 10;
16
+ return _context.abrupt("return", new Promise(function (resolve, reject) {
17
+ var check = function check(retry) {
18
+ if (retry > 0) {
19
+ if (predicate()) {
20
+ resolve();
25
21
  } else {
26
- reject('timed out');
22
+ window.setTimeout(check, timeout, retry - 1);
27
23
  }
28
- };
29
- check(maxRetries);
30
- }));
31
- case 3:
32
- case "end":
33
- return _context.stop();
34
- }
24
+ } else {
25
+ reject('timed out');
26
+ }
27
+ };
28
+ check(maxRetries);
29
+ }));
30
+ case 3:
31
+ case "end":
32
+ return _context.stop();
35
33
  }
36
34
  }, _callee);
37
35
  }));
@@ -5,12 +5,15 @@ import { MediaFeatureFlags } from '@atlaskit/media-common';
5
5
  import { CreateFileStateOptions, FileStateStatus } from './createFileState';
6
6
  export declare type MediaClientMockOptions = {
7
7
  getImageDelay?: number;
8
+ hasPreview?: boolean;
8
9
  };
9
10
  export declare class MediaClientMock extends MediaClient {
10
11
  private observable;
11
12
  private options;
13
+ private hasPreview;
12
14
  constructor(observable: ReplaySubject<FileState>, mediaClientConfig: MediaClientConfig, featureFlags?: MediaFeatureFlags, options?: MediaClientMockOptions);
13
15
  updateObserbable: (newObservable: ReplaySubject<FileState>) => void;
16
+ setHasPreview: (hasPreview: boolean) => void;
14
17
  getImage: () => Promise<Blob>;
15
18
  private mockFileFetcher;
16
19
  }
@@ -0,0 +1,4 @@
1
+ export { FileStateFactory, MediaClientMock } from './factory';
2
+ export { createIdentifier, createFileDetails } from './helpers';
3
+ export { createFileState } from './createFileState';
4
+ export type { FileStateFactoryOptions, MediaClientMockOptions, } from './factory';
@@ -0,0 +1,18 @@
1
+ import { MediaType, FileState, FileIdentifier } from '@atlaskit/media-client';
2
+ import { FileStateFactory, MediaClientMockOptions } from '../factory';
3
+ export declare type SimulationSettings = {
4
+ mediaType?: MediaType;
5
+ mediaClientMockOptions?: MediaClientMockOptions;
6
+ };
7
+ export declare type SimulationUtils = {
8
+ updateIdentifier: (newMediaType?: MediaType) => void;
9
+ };
10
+ export declare type Simulation = (fileStateFactory: FileStateFactory, utils: SimulationUtils) => void;
11
+ export declare const useRunSimulation: (simulation: Simulation, simulationSettings?: SimulationSettings) => {
12
+ identifier: FileIdentifier;
13
+ fileStateFactory: FileStateFactory;
14
+ fileState: FileState | {
15
+ status: string;
16
+ } | undefined;
17
+ updateIdentifier: (newMediaType?: MediaType | undefined) => void;
18
+ };
@@ -0,0 +1,4 @@
1
+ export type { Simulation, SimulationUtils, SimulationSettings, } from './fileSimulation';
2
+ export { useRunSimulation } from './fileSimulation';
3
+ export { simulateProcessed, simulateProcessing, simulateImmediateFailProcessing, simulateUpload, simulateError, simulateErrorState, simulateManyProcessed, simulateEmptyDetails, simulateUpdateFileId, simulateAlwaysLoading, simulateAlwaysProcessing, } from './simulations';
4
+ export type { SimulationFactory, StandardSimulation } from './simulations';
@@ -0,0 +1,35 @@
1
+ import { Simulation } from './fileSimulation';
2
+ export declare type StandardSimulation = {
3
+ simulation: Simulation;
4
+ description: string;
5
+ };
6
+ export interface SimulationFactory<T extends any[] = []> {
7
+ (...args: T): StandardSimulation;
8
+ }
9
+ /**
10
+ * Normal File Flow
11
+ */
12
+ export declare const simulateProcessed: SimulationFactory<[
13
+ withRemotePreview?: boolean
14
+ ]>;
15
+ export declare const simulateProcessing: SimulationFactory<[
16
+ suceeded?: boolean,
17
+ withRemotePreview?: boolean
18
+ ]>;
19
+ export declare const simulateImmediateFailProcessing: SimulationFactory;
20
+ export declare const simulateUpload: SimulationFactory<[
21
+ withLocalPreview?: boolean,
22
+ suceeded?: boolean
23
+ ]>;
24
+ export declare const simulateErrorState: SimulationFactory;
25
+ export declare const simulateError: SimulationFactory;
26
+ /**
27
+ * Rare Cases
28
+ */
29
+ export declare const simulateManyProcessed: SimulationFactory<[
30
+ withRemotePreview?: boolean
31
+ ]>;
32
+ export declare const simulateEmptyDetails: SimulationFactory;
33
+ export declare const simulateUpdateFileId: SimulationFactory;
34
+ export declare const simulateAlwaysLoading: SimulationFactory;
35
+ export declare const simulateAlwaysProcessing: SimulationFactory;
@@ -1,4 +1,8 @@
1
1
  export { FileStateFactory, MediaClientMock } from './factory';
2
- export { createIdentifier, createFileDetails } from './helpers';
3
- export { createFileState } from './createFileState';
4
- export type { FileStateFactoryOptions, MediaClientMockOptions, } from './factory';
2
+ export { createIdentifier, createFileDetails } from './factory';
3
+ export { createFileState } from './factory/createFileState';
4
+ export type { FileStateFactoryOptions, MediaClientMockOptions, } from './factory/factory';
5
+ export type { Simulation, SimulationUtils, SimulationSettings, } from './fileSimulation';
6
+ export { useRunSimulation } from './fileSimulation';
7
+ export { simulateProcessed, simulateProcessing, simulateImmediateFailProcessing, simulateUpload, simulateError, simulateErrorState, simulateManyProcessed, simulateEmptyDetails, simulateUpdateFileId, simulateAlwaysLoading, simulateAlwaysProcessing, } from './fileSimulation';
8
+ export type { SimulationFactory, StandardSimulation } from './fileSimulation';
@@ -43,6 +43,6 @@ export { dataURItoBlob } from './mockData/utils';
43
43
  export { mapDataUriToBlob } from './utils/index';
44
44
  export { createPollingMaxAttemptsError, createRateLimitedError, createMediaStoreError, } from './mediaClientErrors';
45
45
  export { default as FeatureFlagsWrapper } from './featureFlagsWrapper';
46
- export { FileStateFactory, MediaClientMock, createIdentifier, createFileDetails, createFileState, } from './fileStateFactory';
47
- export type { FileStateFactoryOptions, MediaClientMockOptions, } from './fileStateFactory';
46
+ export { FileStateFactory, MediaClientMock, createIdentifier, createFileDetails, createFileState, useRunSimulation, simulateProcessed, simulateProcessing, simulateImmediateFailProcessing, simulateUpload, simulateError, simulateErrorState, simulateManyProcessed, simulateEmptyDetails, simulateUpdateFileId, simulateAlwaysLoading, simulateAlwaysProcessing, } from './fileStateFactory';
47
+ export type { FileStateFactoryOptions, MediaClientMockOptions, Simulation, SimulationUtils, SimulationSettings, SimulationFactory, StandardSimulation, } from './fileStateFactory';
48
48
  export { DocsContentTabs } from './docs-content-tabs';
@@ -1,4 +1,15 @@
1
- import { MediaType, MediaCollectionItem, MediaFileProcessingStatus } from '@atlaskit/media-client';
1
+ import { MediaType, MediaItemDetails, MediaFileProcessingStatus } from '@atlaskit/media-client';
2
+ export declare type MediaItemMinimalDetails = {
3
+ readonly name: string;
4
+ readonly size: number;
5
+ };
6
+ declare type MediaCollectionItem = {
7
+ readonly id: string;
8
+ readonly insertedAt: number;
9
+ readonly occurrenceKey: string;
10
+ readonly details: MediaItemDetails | MediaItemMinimalDetails;
11
+ };
12
+ export declare const isMediaItemDetails: (mediaCollectionItem: MediaItemDetails | MediaItemMinimalDetails) => mediaCollectionItem is MediaItemDetails;
2
13
  export declare type CollectionItem = MediaCollectionItem & {
3
14
  readonly collectionName?: string;
4
15
  readonly blob?: Blob;
@@ -15,3 +26,4 @@ export declare type CreateCollectionItemOptions = {
15
26
  };
16
27
  export declare function createEmptyCollectionItem({ id, collectionName, occurrenceKey, }: CreateCollectionItemOptions): CollectionItem;
17
28
  export declare function createCollectionItem({ name, mediaType, mimeType, collectionName, occurrenceKey, blob, id, processingStatus, }?: CreateCollectionItemOptions): CollectionItem;
29
+ export {};
@@ -1,2 +1,5 @@
1
- import { MediaCollection } from '@atlaskit/media-client';
1
+ export declare type MediaCollection = {
2
+ readonly name: string;
3
+ readonly createdAt: number;
4
+ };
2
5
  export declare function createCollection(name?: string): MediaCollection;
@@ -1,12 +1,12 @@
1
1
  import { Database } from 'kakapo';
2
2
  import { ClientBasedAuth } from '@atlaskit/media-core';
3
- import { MediaCollection } from '@atlaskit/media-client';
3
+ import { MediaCollection } from './collection';
4
4
  import { CollectionItem } from './collection-item';
5
5
  import { Upload } from './upload';
6
6
  import { Chunk } from './chunk';
7
7
  import { MockCollections } from '../media-mock';
8
8
  export { createCollection } from './collection';
9
- export { createCollectionItem, createEmptyCollectionItem, } from './collection-item';
9
+ export { createCollectionItem, createEmptyCollectionItem, isMediaItemDetails, } from './collection-item';
10
10
  export type { CollectionItem, CreateCollectionItemOptions, } from './collection-item';
11
11
  export declare const tenantAuth: ClientBasedAuth;
12
12
  export declare const userAuth: ClientBasedAuth;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/media-test-helpers",
3
- "version": "31.0.0",
3
+ "version": "32.1.0",
4
4
  "description": "Collection of test helpers used in media component stories and specs",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -23,9 +23,8 @@
23
23
  "@atlaskit/checkbox": "^12.4.0",
24
24
  "@atlaskit/icon": "^21.11.0",
25
25
  "@atlaskit/locale": "^2.1.0",
26
- "@atlaskit/media-client": "^20.2.0",
26
+ "@atlaskit/media-client": "^21.1.0",
27
27
  "@atlaskit/media-common": "^4.0.0",
28
- "@atlaskit/media-core": "^34.0.0",
29
28
  "@atlaskit/media-ui": "^22.3.0",
30
29
  "@atlaskit/popup": "^1.5.0",
31
30
  "@atlaskit/tabs": "^13.3.0",
@@ -47,9 +46,11 @@
47
46
  "xhr-mock": "^2.4.0"
48
47
  },
49
48
  "peerDependencies": {
49
+ "@atlaskit/media-core": "^34.0.2",
50
50
  "react": "^16.8.0"
51
51
  },
52
52
  "devDependencies": {
53
+ "@atlaskit/media-core": "^34.0.0",
53
54
  "@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
54
55
  "react-dom": "^16.8.0",
55
56
  "typescript": "4.5.5"
package/report.api.md CHANGED
@@ -529,12 +529,15 @@ export class MediaClientMock extends MediaClient {
529
529
  // (undocumented)
530
530
  getImage: () => Promise<Blob>;
531
531
  // (undocumented)
532
+ setHasPreview: (hasPreview: boolean) => void;
533
+ // (undocumented)
532
534
  updateObserbable: (newObservable: ReplaySubject<FileState>) => void;
533
535
  }
534
536
 
535
537
  // @public (undocumented)
536
538
  export type MediaClientMockOptions = {
537
539
  getImageDelay?: number;
540
+ hasPreview?: boolean;
538
541
  };
539
542
 
540
543
  // @public (undocumented)
@@ -869,6 +872,70 @@ export const shallowWithIntlContext: <
869
872
  },
870
873
  ) => ShallowWrapper<P & WrappedComponentProps<'intl'>, S, C>;
871
874
 
875
+ // @public (undocumented)
876
+ export const simulateAlwaysLoading: SimulationFactory;
877
+
878
+ // @public (undocumented)
879
+ export const simulateAlwaysProcessing: SimulationFactory;
880
+
881
+ // @public (undocumented)
882
+ export const simulateEmptyDetails: SimulationFactory;
883
+
884
+ // @public (undocumented)
885
+ export const simulateError: SimulationFactory;
886
+
887
+ // @public (undocumented)
888
+ export const simulateErrorState: SimulationFactory;
889
+
890
+ // @public (undocumented)
891
+ export const simulateImmediateFailProcessing: SimulationFactory;
892
+
893
+ // @public
894
+ export const simulateManyProcessed: SimulationFactory<
895
+ [withRemotePreview?: boolean]
896
+ >;
897
+
898
+ // @public
899
+ export const simulateProcessed: SimulationFactory<
900
+ [withRemotePreview?: boolean]
901
+ >;
902
+
903
+ // @public (undocumented)
904
+ export const simulateProcessing: SimulationFactory<
905
+ [suceeded?: boolean, withRemotePreview?: boolean]
906
+ >;
907
+
908
+ // @public (undocumented)
909
+ export const simulateUpdateFileId: SimulationFactory;
910
+
911
+ // @public (undocumented)
912
+ export const simulateUpload: SimulationFactory<
913
+ [withLocalPreview?: boolean, suceeded?: boolean]
914
+ >;
915
+
916
+ // @public (undocumented)
917
+ export type Simulation = (
918
+ fileStateFactory: FileStateFactory,
919
+ utils: SimulationUtils,
920
+ ) => void;
921
+
922
+ // @public (undocumented)
923
+ export interface SimulationFactory<T extends any[] = []> {
924
+ // (undocumented)
925
+ (...args: T): StandardSimulation;
926
+ }
927
+
928
+ // @public (undocumented)
929
+ export type SimulationSettings = {
930
+ mediaType?: MediaType;
931
+ mediaClientMockOptions?: MediaClientMockOptions;
932
+ };
933
+
934
+ // @public (undocumented)
935
+ export type SimulationUtils = {
936
+ updateIdentifier: (newMediaType?: MediaType) => void;
937
+ };
938
+
872
939
  // @public (undocumented)
873
940
  export const sleep: (time?: number) => Promise<unknown>;
874
941
 
@@ -883,6 +950,12 @@ export const smallImageFileId: FileIdentifier;
883
950
  export const smallTransparentImage =
884
951
  'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAABkCAYAAAD0ZHJ6AAALZUlEQVRogcWbf6wdRRXHP+d609Ta1PpCmqapdzd3tcFKDGAFExErFsWm8QeJIUERJA1KUBrkj0JMwx+AhkRjohgloEYEQVAhVQEpkR9BSlpSSWmQYPdm70vTNKS2r01T68vLPf4xs7uzs7v33rf3PTjJzezOnJn97tmZ82vmCg0pCsIWsBLlSoQPK7QE/grsAw7F/aTp0AVqN+2ocLvAdcBZKIgAynXAKWAb8KuFAChNOkWd8CIV/iawTC1aJB9MYU6U64H74ulkIoCteYMLwpUI9wosw+BCpPimAm0V7kL4wETomgAEPq7K2ai5UQXUlkWQU8CXJsTXaA4uTS80n3vmnvwabNuENG8JKjyHcARKnxVR55ObxjNvO8BeP5lBeVkFVIwUs2u3zrDvnxRgUzVzKJOevVAciebL+XTD8TNqskgQ4d/umkjBFeqUWeDYBNiAhgCBJ0Q5rVpexUq2eO5GSN4pgAcRrhIYgF0Y2EViF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kn/fliW1obBB4FqKL5dmyN6qe/BYczDuJwdQPoFwocBNwIXAN0X4qgOulqJO2BJz1DQ7I11IOMFjdX3nE780pqgTbkTYhdJ2owPMv3W+AjxjnYgSTWyLx6TVOAd1bTlAeCruJ08M6/j2ABR2Ancg/AP4FMp/Mcmnv4zq+n85L/b+qxcVDgAAAABJRU5ErkJggg==';
885
952
 
953
+ // @public (undocumented)
954
+ export type StandardSimulation = {
955
+ simulation: Simulation;
956
+ description: string;
957
+ };
958
+
886
959
  // @public (undocumented)
887
960
  export class StoryBookAuthProvider {
888
961
  // (undocumented)
@@ -954,6 +1027,22 @@ export const unmockFileReader: () => any;
954
1027
  // @public (undocumented)
955
1028
  export const unMockLoadImage: () => void;
956
1029
 
1030
+ // @public (undocumented)
1031
+ export const useRunSimulation: (
1032
+ simulation: Simulation,
1033
+ simulationSettings?: SimulationSettings,
1034
+ ) => {
1035
+ identifier: FileIdentifier;
1036
+ fileStateFactory: FileStateFactory;
1037
+ fileState:
1038
+ | FileState
1039
+ | undefined
1040
+ | {
1041
+ status: string;
1042
+ };
1043
+ updateIdentifier: (newMediaType?: MediaType | undefined) => void;
1044
+ };
1045
+
957
1046
  // @public (undocumented)
958
1047
  export const verticalImageFileId: FileIdentifier;
959
1048
 
@@ -1040,6 +1129,7 @@ export const zipJiraArchiveFileId: FileIdentifier;
1040
1129
 
1041
1130
  ```json
1042
1131
  {
1132
+ "@atlaskit/media-core": "^34.0.2",
1043
1133
  "react": "^16.8.0"
1044
1134
  }
1045
1135
  ```