chore(dependencies): add webview_flutter_platform_interface package to pubspec.yaml and clean up test files by removing unnecessary whitespace

This commit is contained in:
mso7nueh
2025-12-11 14:12:41 +03:00
parent 70e4a42e98
commit 960afbd6ed
91 changed files with 6152 additions and 1209 deletions

View File

@@ -1,103 +1,193 @@
import 'package:eatvio_app/core/models/pagination_model.dart';
import 'package:eatvio_app/features/feed/models/comment_model.dart';
import 'package:eatvio_app/core/models/pagination_model.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
group('CommentModel', () {
test('создает экземпляр с данными', () {
final comment = Comment(
id: 1,
authorName: 'Test Author',
authorSlug: 'test-author',
authorProfileIcon: 'icon.png',
body: 'Test comment',
childrenComments: [],
createdAt: DateTime.now(),
test('creates CommentModel with empty list', () {
const links = Links(
first: 'http://example.com?page=1',
last: 'http://example.com?page=1',
prev: null,
next: null,
);
const meta = Meta(
currentPage: 1,
from: null,
lastPage: 1,
links: [],
path: '/api/comments',
perPage: 10,
to: null,
total: 0,
);
const model = CommentModel(
data: [],
links: links,
meta: meta,
);
expect(model.data, isEmpty);
expect(model.meta.total, 0);
});
test('creates CommentModel with comments', () {
final comments = [
Comment(
id: 1,
authorName: 'John Doe',
authorSlug: 'john-doe',
authorProfileIcon: 'icon1.jpg',
body: 'First comment',
childrenComments: [],
createdAt: DateTime(2023, 1, 1),
),
Comment(
id: 2,
authorName: 'Jane Smith',
authorSlug: 'jane-smith',
authorProfileIcon: 'icon2.jpg',
body: 'Second comment',
childrenComments: [],
createdAt: DateTime(2023, 1, 2),
),
];
const links = Links(
first: 'http://example.com?page=1',
last: 'http://example.com?page=1',
prev: null,
next: null,
);
const meta = Meta(
currentPage: 1,
from: 1,
lastPage: 1,
links: [],
path: '/api/comments',
perPage: 10,
to: 2,
total: 2,
);
final model = CommentModel(
data: [comment],
links: const Links(first: '', last: '', prev: null, next: null),
meta: const Meta(currentPage: 1, from: null, lastPage: 1, links: [], perPage: 10, to: null, total: 0),
data: comments,
links: links,
meta: meta,
);
expect(model.data.length, 1);
expect(model.data.first.id, 1);
expect(model.data.first.body, 'Test comment');
expect(model.data.length, 2);
expect(model.data[0].id, 1);
expect(model.data[0].authorName, 'John Doe');
expect(model.data[1].id, 2);
expect(model.data[1].authorName, 'Jane Smith');
});
test('fromJson создает модель из JSON', () {
test('creates CommentModel from JSON', () {
final json = {
'data': [
{
'id': 1,
'author_name': 'Test Author',
'author_slug': 'test-author',
'author_profile_icon': 'icon.png',
'author_name': 'John Doe',
'author_slug': 'john-doe',
'author_profile_icon': 'icon1.jpg',
'body': 'Test comment',
'children_comments': [],
'created_at': '2024-01-01T00:00:00Z',
}
'created_at': '2023-01-01T00:00:00Z',
},
],
'links': {'first': '', 'last': '', 'prev': null, 'next': null},
'links': {
'first': 'http://example.com?page=1',
'last': 'http://example.com?page=1',
'prev': null,
'next': null,
},
'meta': {
'current_page': 1,
'from': null,
'from': 1,
'last_page': 1,
'links': [],
'path': '/api/comments',
'per_page': 10,
'to': null,
'total': 0,
'to': 1,
'total': 1,
},
};
final model = CommentModel.fromJson(json);
expect(model.data.length, 1);
expect(model.data.first.id, 1);
expect(model.data[0].id, 1);
expect(model.data[0].authorName, 'John Doe');
});
});
group('Comment', () {
test('создает экземпляр с данными', () {
test('creates Comment with all parameters', () {
final comment = Comment(
id: 1,
authorName: 'Test Author',
authorSlug: 'test-author',
authorProfileIcon: 'icon.png',
body: 'Test comment',
authorName: 'John Doe',
authorSlug: 'john-doe',
authorProfileIcon: 'icon.jpg',
body: 'Test comment body',
childrenComments: [],
createdAt: DateTime.now(),
createdAt: DateTime(2023, 1, 1),
);
expect(comment.id, 1);
expect(comment.authorName, 'Test Author');
expect(comment.body, 'Test comment');
expect(comment.authorName, 'John Doe');
expect(comment.authorSlug, 'john-doe');
expect(comment.authorProfileIcon, 'icon.jpg');
expect(comment.body, 'Test comment body');
expect(comment.childrenComments, isEmpty);
expect(comment.createdAt, DateTime(2023, 1, 1));
});
test('поддерживает вложенные комментарии', () {
test('creates Comment with nested children', () {
final childComment = Comment(
id: 2,
authorName: 'Child Author',
authorSlug: 'child-author',
authorProfileIcon: 'child.png',
body: 'Child comment',
authorName: 'Jane Smith',
authorSlug: 'jane-smith',
authorProfileIcon: 'icon2.jpg',
body: 'Reply comment',
childrenComments: [],
createdAt: DateTime.now(),
createdAt: DateTime(2023, 1, 2),
);
final parentComment = Comment(
id: 1,
authorName: 'Parent Author',
authorSlug: 'parent-author',
authorProfileIcon: 'parent.png',
authorName: 'John Doe',
authorSlug: 'john-doe',
authorProfileIcon: 'icon1.jpg',
body: 'Parent comment',
childrenComments: [childComment],
createdAt: DateTime.now(),
createdAt: DateTime(2023, 1, 1),
);
expect(parentComment.childrenComments.length, 1);
expect(parentComment.childrenComments.first.id, 2);
expect(parentComment.childrenComments[0].id, 2);
expect(parentComment.childrenComments[0].authorName, 'Jane Smith');
});
test('creates Comment from JSON', () {
final json = {
'id': 1,
'author_name': 'John Doe',
'author_slug': 'john-doe',
'author_profile_icon': 'icon.jpg',
'body': 'Test comment',
'children_comments': [],
'created_at': '2023-01-01T00:00:00Z',
};
final comment = Comment.fromJson(json);
expect(comment.id, 1);
expect(comment.authorName, 'John Doe');
expect(comment.body, 'Test comment');
});
});
}

View File

@@ -1,27 +1,29 @@
import 'package:eatvio_app/features/feed/models/diets_pagination_model.dart';
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';
void main() {
group('FeedBlogPostModel', () {
test('создает FeedBlogPostModel с правильными значениями', () {
test('creates FeedBlogPostModel with all parameters', () {
const author = Author(
authorSlug: 'author1',
authorName: 'Author Name',
authorProfileIcon: 'icon.jpg',
authorIsMe: false,
isEntitySubscribedByMe: false,
authorPlaceInRating: null,
);
final model = FeedBlogPostModel(
id: 1,
state: 'published',
image: 'https://example.com/image.jpg',
description: 'Test description',
author: const Author(
authorSlug: 'author',
authorName: 'Author Name',
authorProfileIcon: 'https://example.com/icon.jpg',
authorIsMe: false,
isEntitySubscribedByMe: null,
authorPlaceInRating: null,
),
image: 'post.jpg',
description: 'Blog post description',
author: author,
videoUrl: '',
createdAt: DateTime(2024, 1, 1),
updatedAt: DateTime(2024, 1, 2),
title: 'Test Post',
createdAt: DateTime(2023, 1, 1),
updatedAt: DateTime(2023, 1, 2),
title: 'Blog Post Title',
totalLikes: 10,
totalViews: 100,
totalComments: 5,
@@ -29,26 +31,63 @@ void main() {
);
expect(model.id, 1);
expect(model.title, 'Test Post');
expect(model.title, 'Blog Post Title');
expect(model.state, 'published');
expect(model.description, 'Blog post description');
expect(model.totalLikes, 10);
expect(model.wasLikedByMe, isFalse);
expect(model.totalViews, 100);
expect(model.totalComments, 5);
expect(model.wasLikedByMe, false);
expect(model.author.authorName, 'Author Name');
});
test('fromJson создает FeedBlogPostModel из JSON', () {
test('creates FeedBlogPostModel with video URL', () {
const author = Author(
authorSlug: 'author2',
authorName: 'Author 2',
authorProfileIcon: 'icon2.jpg',
authorIsMe: true,
isEntitySubscribedByMe: false,
authorPlaceInRating: 1,
);
final model = FeedBlogPostModel(
id: 2,
state: 'published',
image: 'post2.jpg',
description: 'Post with video',
author: author,
videoUrl: 'https://example.com/video.mp4',
createdAt: DateTime(2023, 2, 1),
updatedAt: DateTime(2023, 2, 2),
title: 'Video Post',
totalLikes: 20,
totalViews: 200,
totalComments: 10,
wasLikedByMe: true,
);
expect(model.videoUrl, 'https://example.com/video.mp4');
expect(model.wasLikedByMe, true);
expect(model.author.authorIsMe, true);
expect(model.author.authorPlaceInRating, 1);
});
test('creates FeedBlogPostModel from JSON', () {
final json = {
'id': 1,
'state': 'published',
'image': 'https://example.com/image.jpg',
'image': 'post.jpg',
'description': 'Test description',
'author': {
'author_slug': 'author',
'author_name': 'Author Name',
'author_profile_icon': 'https://example.com/icon.jpg',
'author_slug': 'author1',
'author_name': 'Author',
'author_profile_icon': 'icon.jpg',
'author_is_me': false,
},
'video_url': '',
'created_at': '2024-01-01T00:00:00Z',
'updated_at': '2024-01-02T00:00:00Z',
'created_at': '2023-01-01T00:00:00Z',
'updated_at': '2023-01-02T00:00:00Z',
'title': 'Test Post',
'total_likes': 10,
'total_views': 100,
@@ -62,6 +101,38 @@ void main() {
expect(model.title, 'Test Post');
expect(model.totalLikes, 10);
});
test('creates FeedBlogPostModel with different states', () {
const author = Author(
authorSlug: 'author',
authorName: 'Author',
authorProfileIcon: 'icon.jpg',
authorIsMe: false,
isEntitySubscribedByMe: false,
authorPlaceInRating: null,
);
final states = ['published', 'draft', 'archived'];
for (final state in states) {
final model = FeedBlogPostModel(
id: 1,
state: state,
image: 'post.jpg',
description: 'Description',
author: author,
videoUrl: '',
createdAt: DateTime.now(),
updatedAt: DateTime.now(),
title: 'Post',
totalLikes: 0,
totalViews: 0,
totalComments: 0,
wasLikedByMe: false,
);
expect(model.state, state);
}
});
});
}

View File

@@ -1,52 +1,121 @@
import 'package:eatvio_app/core/models/pagination_model.dart';
import 'package:eatvio_app/features/feed/models/diets_pagination_model.dart';
import 'package:eatvio_app/features/feed/models/feed_blog_post_model.dart';
import 'package:eatvio_app/features/feed/models/feed_blog_post_settings_model.dart';
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:eatvio_app/core/models/pagination_model.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
group('FeedBlogPostSettingsModel', () {
test('создает FeedBlogPostSettingsModel с правильными значениями', () {
final blogPost = FeedBlogPostModel(
id: 1,
state: 'active',
image: 'https://example.com/image.jpg',
description: 'Test description',
author: const Author(
authorSlug: 'author',
authorName: 'Author Name',
authorProfileIcon: 'https://example.com/icon.jpg',
authorIsMe: false,
isEntitySubscribedByMe: null,
authorPlaceInRating: null,
test('creates FeedBlogPostSettingsModel with empty list', () {
const meta = Meta(
currentPage: 1,
from: 1,
lastPage: 1,
links: [],
path: '/api/posts',
perPage: 10,
to: 0,
total: 0,
);
const model = FeedBlogPostSettingsModel(
feedBlogPostList: [],
meta: meta,
);
expect(model.feedBlogPostList, isEmpty);
expect(model.meta.total, 0);
});
test('creates FeedBlogPostSettingsModel with blog posts', () {
final blogPosts = [
FeedBlogPostModel(
id: 1,
title: 'Test Post',
image: 'image.jpg',
description: 'Test description',
state: 'published',
videoUrl: '',
createdAt: DateTime.now(),
updatedAt: DateTime.now(),
totalLikes: 10,
totalViews: 100,
totalComments: 5,
wasLikedByMe: false,
author: const Author(
authorSlug: 'author1',
authorName: 'Author',
authorProfileIcon: 'photo.jpg',
authorIsMe: false,
isEntitySubscribedByMe: false,
authorPlaceInRating: null,
),
),
videoUrl: 'https://example.com/video.mp4',
createdAt: DateTime(2024, 1, 1),
updatedAt: DateTime(2024, 1, 2),
title: 'Test Post',
totalLikes: 10,
totalViews: 100,
totalComments: 5,
wasLikedByMe: false,
];
const meta = Meta(
currentPage: 1,
from: 1,
lastPage: 1,
links: [],
path: '/api/posts',
perPage: 10,
to: 1,
total: 1,
);
final model = FeedBlogPostSettingsModel(
feedBlogPostList: [blogPost],
meta: const Meta(
currentPage: 1,
from: 1,
lastPage: 1,
links: [],
perPage: 10,
to: 1,
total: 1,
),
feedBlogPostList: blogPosts,
meta: meta,
);
expect(model.feedBlogPostList.length, 1);
expect(model.feedBlogPostList.first.id, 1);
expect(model.feedBlogPostList[0].id, 1);
expect(model.feedBlogPostList[0].title, 'Test Post');
expect(model.meta.total, 1);
});
test('creates FeedBlogPostSettingsModel from JSON', () {
final json = {
'data': [
{
'id': 1,
'title': 'Test Post',
'image': 'image.jpg',
'description': 'Test description',
'state': 'published',
'video_url': '',
'created_at': '2023-01-01T00:00:00Z',
'updated_at': '2023-01-01T00:00:00Z',
'total_comments': 5,
'was_liked_by_me': false,
'total_likes': 10,
'total_views': 100,
'author': {
'author_slug': 'author1',
'author_name': 'Author',
'author_profile_icon': 'photo.jpg',
'author_is_me': false,
},
},
],
'meta': {
'current_page': 1,
'from': 1,
'last_page': 1,
'links': [],
'path': '/api/posts',
'per_page': 10,
'to': 1,
'total': 1,
},
};
final model = FeedBlogPostSettingsModel.fromJson(json);
expect(model.feedBlogPostList.length, 1);
expect(model.feedBlogPostList[0].id, 1);
expect(model.meta.total, 1);
});
});
}

View File

@@ -0,0 +1,238 @@
import 'package:eatvio_app/features/feed/models/recipes_model.dart';
import 'package:eatvio_app/features/feed/models/diets_pagination_model.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
group('Recipe', () {
test('creates Recipe with all parameters', () {
const author = Author(
authorSlug: 'chef',
authorName: 'Chef Name',
authorProfileIcon: 'icon.jpg',
authorIsMe: false,
isEntitySubscribedByMe: false,
authorPlaceInRating: null,
);
const recipe = Recipe(
id: 1,
image: 'recipe.jpg',
state: 'published',
cookingTime: 30,
activeCookingTime: 15,
ingredients: null,
description: 'Test recipe description',
steps: null,
videoUrl: null,
createdAt: null,
updatedAt: null,
title: 'Test Recipe',
type: 'main',
slug: 'test-recipe',
commentsCount: 5,
wasLikedByMe: false,
isFavorite: false,
calories: 250.0,
servings: 4,
likesCount: 10,
viewsCount: 100,
tags: [],
author: author,
);
expect(recipe.id, 1);
expect(recipe.title, 'Test Recipe');
expect(recipe.slug, 'test-recipe');
expect(recipe.cookingTime, 30);
expect(recipe.calories, 250.0);
expect(recipe.author.authorName, 'Chef Name');
});
test('creates Recipe with ingredients and steps', () {
const author = Author(
authorSlug: 'chef',
authorName: 'Chef',
authorProfileIcon: 'icon.jpg',
authorIsMe: false,
isEntitySubscribedByMe: false,
authorPlaceInRating: null,
);
final ingredients = [
const Ingredient(name: 'Flour', unit: 'cup', portion: '1', productId: 1),
const Ingredient(name: 'Sugar', unit: 'tbsp', portion: '2', productId: 2),
];
final steps = [
const Step(image: 'step1.jpg', description: 'Step 1 description'),
const Step(image: 'step2.jpg', description: 'Step 2 description'),
];
final recipe = Recipe(
id: 1,
image: 'recipe.jpg',
state: 'published',
cookingTime: 30,
activeCookingTime: 15,
ingredients: ingredients,
description: 'Recipe with steps',
steps: steps,
videoUrl: 'video.mp4',
createdAt: DateTime(2023, 1, 1),
updatedAt: DateTime(2023, 1, 2),
title: 'Complete Recipe',
type: 'dessert',
slug: 'complete-recipe',
commentsCount: 10,
wasLikedByMe: true,
isFavorite: true,
calories: 300.0,
servings: 6,
likesCount: 20,
viewsCount: 200,
tags: [const Tag(name: 'sweet'), const Tag(name: 'dessert')],
author: author,
);
expect(recipe.ingredients, isNotNull);
expect(recipe.ingredients!.length, 2);
expect(recipe.steps, isNotNull);
expect(recipe.steps!.length, 2);
expect(recipe.videoUrl, 'video.mp4');
expect(recipe.tags.length, 2);
});
test('creates Recipe from JSON', () {
final json = {
'id': 1,
'image': 'recipe.jpg',
'state': 'published',
'cooking_time': 30,
'active_time': 15,
'ingredients': null,
'description_md': 'Test description',
'steps': null,
'video_url': null,
'created_at': null,
'updated_at': null,
'title': 'Test Recipe',
'type': 'main',
'slug': 'test-recipe',
'total_comments': 5,
'was_liked_by_me': false,
'is_favorite': false,
'energy_per_serving': 250.0,
'servings': 4,
'total_likes': 10,
'total_views': 100,
'tags': [],
'author': {
'author_slug': 'chef',
'author_name': 'Chef',
'author_profile_icon': 'icon.jpg',
'author_is_me': false,
},
};
final recipe = Recipe.fromJson(json);
expect(recipe.id, 1);
expect(recipe.title, 'Test Recipe');
expect(recipe.cookingTime, 30);
});
});
group('Tag', () {
test('creates Tag with name', () {
const tag = Tag(name: 'dessert');
expect(tag.name, 'dessert');
});
test('creates Tag from JSON', () {
final json = {'name': 'sweet'};
final tag = Tag.fromJson(json);
expect(tag.name, 'sweet');
});
});
group('Ingredient', () {
test('creates Ingredient with all parameters', () {
const ingredient = Ingredient(
name: 'Flour',
unit: 'cup',
portion: '1',
productId: 1,
);
expect(ingredient.name, 'Flour');
expect(ingredient.unit, 'cup');
expect(ingredient.portion, '1');
expect(ingredient.productId, 1);
});
test('creates Ingredient with null unit', () {
const ingredient = Ingredient(
name: 'Salt',
unit: null,
portion: 'pinch',
productId: 2,
);
expect(ingredient.unit, null);
});
test('creates Ingredient from JSON with string productId', () {
final json = {
'name': 'Flour',
'unit': 'cup',
'portion': '1',
'product_nutritional_id': '123',
};
final ingredient = Ingredient.fromJson(json);
expect(ingredient.productId, 123);
});
test('creates Ingredient from JSON with int productId', () {
final json = {
'name': 'Sugar',
'unit': 'tbsp',
'portion': '2',
'product_nutritional_id': 456,
};
final ingredient = Ingredient.fromJson(json);
expect(ingredient.productId, 456);
});
});
group('Step', () {
test('creates Step with image and description', () {
const step = Step(
image: 'step1.jpg',
description: 'Step 1 description',
);
expect(step.image, 'step1.jpg');
expect(step.description, 'Step 1 description');
});
test('creates Step from JSON', () {
final json = {
'image': 'step1.jpg',
'description_md': 'Step description',
};
final step = Step.fromJson(json);
expect(step.image, 'step1.jpg');
expect(step.description, 'Step description');
});
});
}

View File

@@ -1,50 +1,100 @@
import 'package:eatvio_app/features/feed/models/diets_pagination_model.dart';
import 'package:eatvio_app/features/feed/models/recipes_model.dart';
import 'package:eatvio_app/features/feed/models/recipes_pagination_model.dart';
import 'package:eatvio_app/features/feed/models/recipes_model.dart';
import 'package:eatvio_app/features/feed/models/diets_pagination_model.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
group('RecipesPagination', () {
test('создает RecipesPagination с правильными значениями', () {
const recipe = Recipe(
id: 1,
image: 'https://example.com/image.jpg',
state: 'active',
cookingTime: 30,
activeCookingTime: 15,
ingredients: [],
description: 'Test description',
steps: [],
videoUrl: null,
createdAt: null,
updatedAt: null,
title: 'Test Recipe',
type: 'main',
slug: 'test-recipe',
commentsCount: 5,
wasLikedByMe: false,
isFavorite: false,
calories: 300.0,
servings: 4,
likesCount: 10,
viewsCount: 100,
tags: [],
author: Author(
authorSlug: 'author',
authorName: 'Author Name',
authorProfileIcon: 'https://example.com/icon.jpg',
authorIsMe: false,
isEntitySubscribedByMe: null,
authorPlaceInRating: null,
),
);
test('creates RecipesPagination with empty list', () {
const pagination = RecipesPagination(recipesList: []);
const pagination = RecipesPagination(recipesList: [recipe]);
expect(pagination.recipesList, isEmpty);
});
test('creates RecipesPagination with recipes list', () {
final recipes = [
const Recipe(
id: 1,
image: 'image1.jpg',
state: 'published',
cookingTime: 30,
activeCookingTime: 15,
ingredients: null,
description: 'Test recipe 1',
steps: null,
videoUrl: null,
createdAt: null,
updatedAt: null,
title: 'Recipe 1',
type: 'main',
slug: 'recipe-1',
commentsCount: 5,
wasLikedByMe: false,
isFavorite: false,
calories: 250.0,
servings: 4,
likesCount: 10,
viewsCount: 100,
tags: [],
author: Author(
authorSlug: 'chef',
authorName: 'Chef',
authorProfileIcon: 'photo.jpg',
authorIsMe: false,
isEntitySubscribedByMe: false,
authorPlaceInRating: null,
),
),
];
final pagination = RecipesPagination(recipesList: recipes);
expect(pagination.recipesList.length, 1);
expect(pagination.recipesList.first.id, 1);
expect(pagination.recipesList.first.title, 'Test Recipe');
expect(pagination.recipesList[0].id, 1);
expect(pagination.recipesList[0].title, 'Recipe 1');
});
test('creates RecipesPagination from JSON', () {
final json = {
'data': [
{
'id': 1,
'image': 'image1.jpg',
'state': 'published',
'cooking_time': 30,
'active_time': 15,
'ingredients': null,
'description_md': 'Test recipe',
'steps': null,
'video_url': null,
'created_at': null,
'updated_at': null,
'title': 'Recipe 1',
'type': 'main',
'slug': 'recipe-1',
'total_comments': 5,
'was_liked_by_me': false,
'is_favorite': false,
'energy_per_serving': 250.0,
'servings': 4,
'total_likes': 10,
'total_views': 100,
'tags': [],
'author': {
'author_slug': 'chef',
'author_name': 'Chef',
'author_profile_icon': 'photo.jpg',
'author_is_me': false,
'is_entity_subscribed_by_me': false,
},
},
],
};
final pagination = RecipesPagination.fromJson(json);
expect(pagination.recipesList.length, 1);
expect(pagination.recipesList[0].id, 1);
});
});
}