forked from eatvio/eatvio_app
feat(personalized_feed): added fixtures for new feed, added new feed parsing and layout, added webview player for post videos
This commit is contained in:
15
test/fixtures/feed/post_feed_empty_response.json
vendored
Normal file
15
test/fixtures/feed/post_feed_empty_response.json
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"data": [],
|
||||
"links": {
|
||||
"first": null,
|
||||
"last": null,
|
||||
"prev": null,
|
||||
"next": null
|
||||
},
|
||||
"meta": {
|
||||
"path": "/api/feed",
|
||||
"per_page": 20,
|
||||
"next_cursor": null,
|
||||
"prev_cursor": null
|
||||
}
|
||||
}
|
||||
45
test/fixtures/feed/post_feed_next_page_response.json
vendored
Normal file
45
test/fixtures/feed/post_feed_next_page_response.json
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
{
|
||||
"data": [
|
||||
{
|
||||
"id": 104,
|
||||
"post_id": 4,
|
||||
"post_author_id": 13,
|
||||
"post_author_name": "Олег Кузнецов",
|
||||
"post_author_image_url": "/storage/avatars/oleg.png",
|
||||
"post_author_profile_url": "/ru/profiles/oleg-kuznetsov",
|
||||
"post_created_at": "2024-06-04T11:00:00.000000Z",
|
||||
"post_title": "Ужин за 20 минут",
|
||||
"post_short_description": "Быстрый ужин после работы",
|
||||
"post_text_md": "Курица с овощами на сковороде.",
|
||||
"post_image_url": "/storage/posts/dinner.jpg",
|
||||
"images": [],
|
||||
"video_embed_url": null,
|
||||
"post_views_count": 88,
|
||||
"post_likes_count": 7,
|
||||
"post_comments_count": 2,
|
||||
"post_is_liked_by_user": false,
|
||||
"is_entity_subscribed_by_me": false,
|
||||
"post_url": "/ru/blog_post/4",
|
||||
"video_url_thumb": null,
|
||||
"post_state": "active",
|
||||
"post_author_detailz_json": {
|
||||
"slug": "oleg-kuznetsov",
|
||||
"is_consultant": false
|
||||
},
|
||||
"created_at": "2024-06-04T11:05:00.000000Z",
|
||||
"updated_at": "2024-06-04T11:05:00.000000Z"
|
||||
}
|
||||
],
|
||||
"links": {
|
||||
"first": null,
|
||||
"last": null,
|
||||
"prev": "https://example.com/api/feed?cursor=eyJpZCI6MTAzfQ",
|
||||
"next": null
|
||||
},
|
||||
"meta": {
|
||||
"path": "/api/feed",
|
||||
"per_page": 20,
|
||||
"next_cursor": null,
|
||||
"prev_cursor": "eyJpZCI6MTAzfQ"
|
||||
}
|
||||
}
|
||||
115
test/fixtures/feed/post_feed_response.json
vendored
Normal file
115
test/fixtures/feed/post_feed_response.json
vendored
Normal file
@@ -0,0 +1,115 @@
|
||||
{
|
||||
"data": [
|
||||
{
|
||||
"id": 101,
|
||||
"post_id": 1,
|
||||
"post_author_id": 10,
|
||||
"post_author_name": "Анна Иванова",
|
||||
"post_author_image_url": "/storage/avatars/anna.png",
|
||||
"post_author_profile_url": "/ru/profiles/anna-ivanova",
|
||||
"post_created_at": "2024-06-01T10:00:00.000000Z",
|
||||
"post_title": "Завтрак с овсянкой",
|
||||
"post_short_description": "Простой и полезный завтрак",
|
||||
"post_text_md": "Сегодня приготовила **овсянку** с ягодами.",
|
||||
"post_image_url": "/storage/posts/oatmeal.jpg",
|
||||
"images": [
|
||||
{
|
||||
"url": "/storage/posts/oatmeal-1.jpg",
|
||||
"orientation": "horizontal"
|
||||
},
|
||||
{
|
||||
"url": "/storage/posts/oatmeal-2.jpg",
|
||||
"orientation": "vertical"
|
||||
}
|
||||
],
|
||||
"video_embed_url": "https://rutube.ru/play/embed/08c00eb3a54c056aeca34f58d8fd1db8/",
|
||||
"post_views_count": 120,
|
||||
"post_likes_count": 15,
|
||||
"post_comments_count": 4,
|
||||
"post_is_liked_by_user": false,
|
||||
"is_entity_subscribed_by_me": false,
|
||||
"post_url": "/ru/blog_post/1",
|
||||
"post_state": "active",
|
||||
"video_url_thumb": "https://mike-dev-ach5iekohk4n.eatv.io/storage/3409/20260720-96266cae-5852-40c9-9692-0a4047e8c934.png",
|
||||
"post_author_detailz_json": {
|
||||
"slug": "anna-ivanova",
|
||||
"is_consultant": true
|
||||
},
|
||||
"created_at": "2024-06-01T10:05:00.000000Z",
|
||||
"updated_at": "2024-06-01T10:05:00.000000Z"
|
||||
},
|
||||
{
|
||||
"id": 102,
|
||||
"post_id": 2,
|
||||
"post_author_id": 11,
|
||||
"post_author_name": "Игорь Петров",
|
||||
"post_author_image_url": "/storage/avatars/igor.png",
|
||||
"post_author_profile_url": "/ru/profiles/igor-petrov",
|
||||
"post_created_at": "2024-06-02T08:30:00.000000Z",
|
||||
"post_title": "Тренировка дома",
|
||||
"post_short_description": "Короткая тренировка без оборудования",
|
||||
"post_text_md": "15 минут кардио и растяжка.",
|
||||
"post_image_url": "/storage/posts/workout.jpg",
|
||||
"images": [],
|
||||
"video_embed_url": "https://www.youtube.com/embed/dQw4w9WgXcQ",
|
||||
"post_views_count": 340,
|
||||
"post_likes_count": 42,
|
||||
"post_comments_count": 9,
|
||||
"post_is_liked_by_user": true,
|
||||
"is_entity_subscribed_by_me": true,
|
||||
"post_url": "/ru/blog_post/2",
|
||||
"post_state": "active",
|
||||
"post_author_detailz_json": {
|
||||
"slug": "igor-petrov",
|
||||
"is_consultant": false
|
||||
},
|
||||
"created_at": "2024-06-02T08:35:00.000000Z",
|
||||
"updated_at": "2024-06-02T09:00:00.000000Z"
|
||||
},
|
||||
{
|
||||
"id": 103,
|
||||
"post_id": 3,
|
||||
"post_author_id": 12,
|
||||
"post_author_name": "Мария Смирнова",
|
||||
"post_author_image_url": null,
|
||||
"post_author_profile_url": "/ru/profiles/maria-smirnova",
|
||||
"post_created_at": "2024-06-03T14:15:00.000000Z",
|
||||
"post_title": "Рецепт смузи",
|
||||
"post_short_description": null,
|
||||
"post_text_md": null,
|
||||
"post_image_url": null,
|
||||
"images": [
|
||||
{
|
||||
"url": "/storage/posts/smoothie.jpg",
|
||||
"orientation": "horizontal"
|
||||
}
|
||||
],
|
||||
"video_embed_url": "https://rutube.ru/play/embed/6a62f217aa99daf00af8fa6cebebf218/",
|
||||
"post_views_count": 50,
|
||||
"post_likes_count": 3,
|
||||
"post_comments_count": 1,
|
||||
"post_is_liked_by_user": false,
|
||||
"is_entity_subscribed_by_me": null,
|
||||
"post_url": "/ru/blog_post/3",
|
||||
"post_state": "active",
|
||||
"post_author_detailz_json": {
|
||||
"slug": "maria-smirnova",
|
||||
"is_consultant": false
|
||||
},
|
||||
"created_at": "2024-06-03T14:20:00.000000Z",
|
||||
"updated_at": "2024-06-03T14:20:00.000000Z"
|
||||
}
|
||||
],
|
||||
"links": {
|
||||
"first": null,
|
||||
"last": null,
|
||||
"prev": null,
|
||||
"next": "https://example.com/api/feed?cursor=eyJpZCI6MTAzfQ"
|
||||
},
|
||||
"meta": {
|
||||
"path": "/api/feed",
|
||||
"per_page": 20,
|
||||
"next_cursor": "eyJpZCI6MTAzfQ",
|
||||
"prev_cursor": null
|
||||
}
|
||||
}
|
||||
51
test/fixtures/feed_fixtures.dart
vendored
Normal file
51
test/fixtures/feed_fixtures.dart
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
import 'package:eatvio_app/features/feed/models/feed_blog_post_model.dart';
|
||||
import 'package:eatvio_app/features/feed/models/post_feed_mapper.dart';
|
||||
import 'package:eatvio_app/features/feed/models/post_feed_pagination_model.dart';
|
||||
|
||||
import 'fixture_reader.dart';
|
||||
|
||||
class FeedFixtures {
|
||||
FeedFixtures._();
|
||||
|
||||
static Map<String, dynamic> postFeedResponseJson() {
|
||||
return FixtureReader.readAsMap('feed/post_feed_response.json');
|
||||
}
|
||||
|
||||
static Map<String, dynamic> postFeedNextPageResponseJson() {
|
||||
return FixtureReader.readAsMap('feed/post_feed_next_page_response.json');
|
||||
}
|
||||
|
||||
static Map<String, dynamic> postFeedEmptyResponseJson() {
|
||||
return FixtureReader.readAsMap('feed/post_feed_empty_response.json');
|
||||
}
|
||||
|
||||
static Map<String, dynamic> feedBlogPostResponseJson() {
|
||||
return FixtureReader.readAsMap('feed/feed_blog_post_response.json');
|
||||
}
|
||||
|
||||
static PostFeedPaginationModel postFeedPaginationModel() {
|
||||
return PostFeedPaginationModel.fromJson(postFeedResponseJson());
|
||||
}
|
||||
|
||||
static PostFeedPaginationModel postFeedNextPagePaginationModel() {
|
||||
return PostFeedPaginationModel.fromJson(postFeedNextPageResponseJson());
|
||||
}
|
||||
|
||||
static PostFeedPaginationModel postFeedEmptyPaginationModel() {
|
||||
return PostFeedPaginationModel.fromJson(postFeedEmptyResponseJson());
|
||||
}
|
||||
|
||||
static PostFeedItemModel postFeedItem({int index = 0}) {
|
||||
return postFeedPaginationModel().data[index];
|
||||
}
|
||||
|
||||
static List<FeedBlogPostModel> mappedFeedPosts({int? currentUserId}) {
|
||||
return postFeedPaginationModel().data
|
||||
.map((item) => PostFeedMapper.fromPostFeedItem(item, currentUserId: currentUserId))
|
||||
.toList();
|
||||
}
|
||||
|
||||
static FeedBlogPostModel feedBlogPostModel() {
|
||||
return FeedBlogPostModel.fromJson(feedBlogPostResponseJson());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user