feat(personalized_feed): added video and multiple images handling to detailed blog post screen

This commit is contained in:
misha
2026-07-22 14:41:26 +03:00
parent dcf7b25989
commit 2cccc9e253
17 changed files with 595 additions and 246 deletions

View File

@@ -2,6 +2,8 @@ import 'package:eatvio_app/features/feed/models/feed_blog_post_model.dart';
import 'package:eatvio_app/features/feed/models/diets_pagination_model.dart';
import 'package:flutter_test/flutter_test.dart';
import '../../../fixtures/feed_fixtures.dart';
void main() {
group('FeedBlogPostModel', () {
test('creates FeedBlogPostModel with all parameters', () {
@@ -102,6 +104,52 @@ void main() {
expect(model.totalLikes, 10);
});
test('parses v2 show JSON with gallery images and video_url_embed', () {
final model = FeedBlogPostModel.fromJson({
'id': 1,
'state': 'active',
'image': 'media/1/cover.jpg',
'images': [
{'id': 10, 'url': 'media/1/a.jpg', 'position': 1, 'orientation': 'horizontal'},
{'id': 11, 'url': 'media/1/b.jpg', 'position': 2},
],
'description': 'Описание',
'author': {
'author_slug': 'author-slug',
'author_name': 'Автор',
'author_profile_icon': 'icon.jpg',
'author_is_me': false,
},
'video_url': 'https://rutube.ru/video/abc/',
'video_url_embed': 'https://rutube.ru/play/embed/abc/',
'video_url_thumb': 'media/1/thumb.jpg',
'created_at': '2024-01-15T12:00:00Z',
'updated_at': '2024-01-15T12:00:00Z',
'title': 'Заголовок',
'total_likes': 10,
'total_views': 100,
'total_comments': 5,
'was_liked_by_me': false,
});
expect(model.images, hasLength(2));
expect(model.images.first.id, 10);
expect(model.images.first.url, 'media/1/a.jpg');
expect(model.images.first.orientation, 'horizontal');
expect(model.images[1].orientation, 'horizontal');
expect(model.images[1].position, 2);
expect(model.videoEmbedUrl, 'https://rutube.ru/play/embed/abc/');
expect(model.videoUrlThumb, 'media/1/thumb.jpg');
});
test('parses fixture feedBlogPostModel with gallery and embed', () {
final model = FeedFixtures.feedBlogPostModel();
expect(model.images, hasLength(2));
expect(model.videoEmbedUrl, contains('rutube.ru/play/embed'));
expect(model.videoUrlThumb, 'media/1/thumb.jpg');
});
test('creates FeedBlogPostModel with different states', () {
const author = Author(
authorSlug: 'author',