fix: share link extension (#428)

This commit is contained in:
Erick
2023-01-23 19:38:53 -03:00
committed by GitHub
parent 041f17f3a6
commit 4d2c764886
4 changed files with 21 additions and 15 deletions

View File

@ -38,7 +38,7 @@ describe('Share API', () => {
test('Invalid file extension returns 404 and html', async () => {
const req = Object.assign({}, baseReq, {
path: 'wrong.mp3',
path: 'wrong.gif',
});
const res = await getShareResponse(req);
expect(res.status).toEqual(404);

View File

@ -14,7 +14,7 @@ import portalAnimationControllerTmpl from './templates/portal-animation-controll
import gaTmpl from './templates/ga';
const VALID_VIDEO_EXT = [ '.mp4', '.gif' ];
const VALID_VIDEO_EXT = [ '.mp4' ];
const BaseHTMLContext: Record<string, string | Record<string, string>> = {
appUrl: '',

View File

@ -93,7 +93,7 @@ class ConvertRepository {
json,
_processedFrames.first,
);
final shareUrl = _getShareUrl(videoResponse.gifUrl);
final shareUrl = _getShareUrl(videoResponse.videoUrl);
final shareText = Uri.encodeComponent(
'A new reality awaits in the #FlutterHolobooth. '
'See you at #FlutterForward!',

View File

@ -93,19 +93,25 @@ void main() {
expect(repository.generateVideo(), throwsException);
});
test('return ConvertResponse with video, gif and first frame', () async {
when(() => streamedResponse.statusCode).thenReturn(200);
when(() => streamedResponse.stream).thenAnswer(
(_) => ByteStream.fromBytes(
'{"video_url": "video", "gif_url": "gif"}'.codeUnits,
),
);
final response = await convertRepository.generateVideo();
test(
'return ConvertResponse with video, gif and first frame, and share '
'urls',
() async {
when(() => streamedResponse.statusCode).thenReturn(200);
when(() => streamedResponse.stream).thenAnswer(
(_) => ByteStream.fromBytes(
'{"video_url": "video", "gif_url": "gif"}'.codeUnits,
),
);
final response = await convertRepository.generateVideo();
expect(response.videoUrl, equals('video'));
expect(response.gifUrl, equals('gif'));
expect(response.firstFrame, Uint8List(1));
});
expect(response.videoUrl, equals('video'));
expect(response.gifUrl, equals('gif'));
expect(response.firstFrame, Uint8List(1));
expect(response.twitterShareUrl, contains(response.videoUrl));
expect(response.facebookShareUrl, contains(response.videoUrl));
},
);
test('throws ConvertException on status code different than 200',
() async {