forked from eatvio/eatvio_app
feat(UGPC): issue-777
This commit is contained in:
@@ -4,6 +4,9 @@ import 'package:eatvio_app/core/enums/complained_content.dart';
|
||||
import 'package:eatvio_app/core/locator_service.dart';
|
||||
import 'package:eatvio_app/core/theme/theme_helper.dart';
|
||||
import 'package:eatvio_app/core/widgets/custom_popup.dart';
|
||||
import 'package:eatvio_app/features/feed/models/diets_pagination_model.dart';
|
||||
import 'package:eatvio_app/features/feed/models/plan_pagination_model.dart';
|
||||
import 'package:eatvio_app/features/feed/models/recipes_model.dart';
|
||||
import 'package:eatvio_app/generated/l10n.dart';
|
||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -185,6 +188,68 @@ void main() {
|
||||
expect(find.text('Удалить'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('CustomPopup for author recipe shows edit when recipe is provided', (tester) async {
|
||||
await tester.pumpWidget(
|
||||
wrap(
|
||||
CustomPopup(
|
||||
isAuthor: true,
|
||||
complainedContentType: ComplainedContent.recipe,
|
||||
path: 'recipes/slug',
|
||||
slug: 'slug',
|
||||
recipe: _recipe(),
|
||||
userSlug: 'author',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
await tester.tap(find.byIcon(Icons.more_horiz_rounded));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.text('Редактировать'), findsOneWidget);
|
||||
expect(find.text('Удалить'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('CustomPopup for author diet shows edit when diet is provided', (tester) async {
|
||||
await tester.pumpWidget(
|
||||
wrap(
|
||||
CustomPopup(
|
||||
isAuthor: true,
|
||||
complainedContentType: ComplainedContent.diet,
|
||||
path: 'diets/slug',
|
||||
id: 1,
|
||||
diet: _diet(),
|
||||
userSlug: 'author',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
await tester.tap(find.byIcon(Icons.more_horiz_rounded));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.text('Редактировать'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('CustomPopup for author plan shows edit when plan is provided', (tester) async {
|
||||
await tester.pumpWidget(
|
||||
wrap(
|
||||
CustomPopup(
|
||||
isAuthor: true,
|
||||
complainedContentType: ComplainedContent.plan,
|
||||
path: 'plans/slug',
|
||||
slug: 'slug',
|
||||
plan: _plan(),
|
||||
userSlug: 'author',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
await tester.tap(find.byIcon(Icons.more_horiz_rounded));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.text('Редактировать'), findsOneWidget);
|
||||
expect(find.text('Удалить'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('CustomPopup for non-author without complained type still renders static actions', (tester) async {
|
||||
await tester.pumpWidget(
|
||||
wrap(
|
||||
@@ -206,5 +271,72 @@ void main() {
|
||||
expect(find.text('Пожаловаться'), findsOneWidget);
|
||||
expect(find.text('Заблокировать автора'), findsOneWidget);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
Recipe _recipe() {
|
||||
return const Recipe(
|
||||
id: 1,
|
||||
image: 'image.jpg',
|
||||
state: 'active',
|
||||
cookingTime: 30,
|
||||
activeCookingTime: 15,
|
||||
ingredients: null,
|
||||
description: 'Описание',
|
||||
steps: null,
|
||||
videoUrl: null,
|
||||
title: 'Рецепт',
|
||||
type: 'main',
|
||||
slug: 'recipe-slug',
|
||||
commentsCount: 0,
|
||||
wasLikedByMe: false,
|
||||
isFavorite: false,
|
||||
calories: 100,
|
||||
likesCount: 0,
|
||||
viewsCount: 0,
|
||||
tags: [],
|
||||
author: Author(authorSlug: 'author', authorName: 'Author', authorProfileIcon: 'icon.jpg', authorIsMe: true),
|
||||
);
|
||||
}
|
||||
|
||||
Diet _diet() {
|
||||
return const Diet(
|
||||
id: 1,
|
||||
slug: 'diet-slug',
|
||||
name: 'Диета',
|
||||
image: 'image.jpg',
|
||||
duration: 7,
|
||||
state: DietState.active,
|
||||
type: DietType(),
|
||||
details: 'Описание',
|
||||
dailySchedule: {},
|
||||
author: Author(authorSlug: 'author', authorName: 'Author', authorProfileIcon: 'icon.jpg', authorIsMe: true),
|
||||
totalLikes: 0,
|
||||
totalViews: 0,
|
||||
totalComments: 0,
|
||||
wasLikedByMe: false,
|
||||
isFavorite: false,
|
||||
dailyNutrition: [],
|
||||
);
|
||||
}
|
||||
|
||||
PlanModel _plan() {
|
||||
return const PlanModel(
|
||||
id: 1,
|
||||
slug: 'plan-slug',
|
||||
name: 'План',
|
||||
image: 'image.jpg',
|
||||
duration: 7,
|
||||
state: 'active',
|
||||
type: PlanType(fit: true, slim: false, behavior: false, wellness: false),
|
||||
details: 'Описание',
|
||||
packetsCount: 1,
|
||||
author: Author(authorSlug: 'author', authorName: 'Author', authorProfileIcon: 'icon.jpg', authorIsMe: true),
|
||||
totalLikes: 0,
|
||||
totalViews: 0,
|
||||
totalComments: 0,
|
||||
isFavorite: false,
|
||||
minPriceOfOptions: 1200,
|
||||
maxPriceOfOptions: 1200,
|
||||
wasLikedByMe: false,
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user