| 97 | }; |
| 98 | |
| 99 | export const createCollectionMedia = ( |
| 100 | collectionOrType?: Collection | MediaItemType, |
| 101 | properties: Partial<CollectionMedia> = {}, |
| 102 | ): CollectionMedia => { |
| 103 | // Check if collectionOrType is a collection-like object (has an 'id' and 'type' property) |
| 104 | const isCollection = |
| 105 | collectionOrType !== null && |
| 106 | typeof collectionOrType === 'object' && |
| 107 | 'id' in collectionOrType && |
| 108 | 'type' in collectionOrType; |
| 109 | |
| 110 | const collectionToUse = isCollection |
| 111 | ? (collectionOrType as Collection) |
| 112 | : createCollection({ type: collectionOrType as MediaItemType }); |
| 113 | |
| 114 | return Object.assign(new CollectionMedia(), { |
| 115 | id: faker.number.int(), |
| 116 | collection: collectionToUse, |
| 117 | collectionId: collectionToUse.id, |
| 118 | addDate: faker.date.past(), |
| 119 | image_path: '', |
| 120 | isManual: false, |
| 121 | includedByRule: true, |
| 122 | manualMembershipSource: |
| 123 | null as CollectionMediaManualMembershipSource | null, |
| 124 | ruleEvaluationFailed: false, |
| 125 | mediaServerId: faker.number.int().toString(), |
| 126 | tmdbId: faker.number.int(), |
| 127 | sizeBytes: null, |
| 128 | ...properties, |
| 129 | }); |
| 130 | }; |
| 131 | |
| 132 | type CollectionMediaWithMetadataOptional = Omit< |
| 133 | CollectionMediaWithMetadata, |