Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
generateImageAttachment as generateImageAttachmentBase,
generateVideoAttachment as generateVideoAttachmentBase,
} from '../../../mock-builders/attachments';
import { generateMessage } from '../../../mock-builders/generator/message';

import { FileState } from '../../../utils/utils';
import { Channel } from '../../Channel/Channel';
Expand Down Expand Up @@ -629,4 +630,27 @@ describe('AttachmentUploadPreviewList', () => {
});
});
});

describe('VideoAttachmentUploadPreview', () => {
it('renders a video restored from a sent message, which has no local file', async () => {
act(() => {
channel.messageComposer.initState({
composition: generateMessage({
attachments: [
generateVideoAttachmentBase({
asset_url: 'https://video-attachment.mp4',
thumb_url: 'https://video-attachment-thumb.png',
}),
],
}),
});
});

renderComponent({ channel, client, props: {} });

await waitFor(() => {
expect(screen.queryAllByTestId('image-attachment-upload-preview')).toHaveLength(1);
});
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const VideoAttachmentUploadPreview = ({
// `localMetadata.file` is `File | FileReference`; only the RN `FileReference` carries a
// `duration` (and a required `uri` to discriminate on), so read it through a guard.
const localFile = attachment.localMetadata.file;
const duration = 'uri' in localFile ? localFile.duration : undefined;
const duration = localFile && 'uri' in localFile ? localFile.duration : undefined;

return previewUri ? (
<>
Expand Down
Loading