Skip to content

Conversation

@yashas-hm
Copy link
Contributor

Description (Proposed Changes)

  • Removed dependencies on the golden_toolkit package.
  • Replaced golden_toolkit functions with flutter_test's testWidgets() and screenMatchesGolden().
  • Added the necessary setup for localization and app size before rendering the widget.

Link to the issue :

Closes: #732

Checklist

  • Set a 100 character limit in your editor/IDE to avoid white space diffs in the PR
  • Tests for the changes have been added (for bug fixes / features)
  • Added yourself to AUTHORS.md
  • Updated/added relevant documentation (doc comments with ///).
  • Added relevant reviewers.
await tester.tap(find.byType(TextButton));
await tester.pumpAndSettle();

await screenMatchesGolden(tester, 'nutritional_plan_1_default_view', skip: !Platform.isLinux);
Copy link
Member

@rolandgeider rolandgeider Mar 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since the new goldens use some kind of abstract font I'm hoping it's not an issue anymore, but do you know if the rendered output is now the same in all platforms? We initially added the skip because there would be a couple of different pixels and the tests would fail dependening on where the goldens were generated

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added the function to load the fonts during the test. The test was failing due to some renderflex issue on my local device when i tested. It should be same for all platforms theoretically.

This was the test error on my device:

The following assertion was thrown during layout:
A RenderFlex overflowed by 0.100 pixels on the right.

The relevant error-causing widget was:
Row
Row:file://wager-project/lib/widgets/nutrition/meal.dart:318:19

The overflowing RenderFlex has an orientation of Axis.horizontal.
The edge of the RenderFlex that is overflowing has been marked in the rendering with a yellow and
black striped pattern. This is usually caused by the contents being too big for the RenderFlex.
Consider applying a flex factor (e.g. using an Expanded widget) to force the children of the
RenderFlex to fit within the available space instead of being sized to their natural size.
This is considered an error condition because it indicates that there is content that cannot be
seen. If the content is legitimately bigger than the available space, consider clipping it with a
ClipRect widget before putting it in the flex, or using a scrollable container rather than a Flex,
like a ListView.
The specific RenderFlex in question is: RenderFlex#513a5 relayoutBoundary=up23 OVERFLOWING:
creator: Row ← Column ← Expanded ← Row ← DefaultTextStyle ← AnimatedDefaultTextStyle ← _ListTile ←
IconButtonTheme ← IconTheme ← Builder ← MediaQuery ← Padding ← ⋯
parentData: offset=Offset(0.0, 28.0); flex=null; fit=null (can use size)
constraints: BoxConstraints(0.0<=w<=308.0, 0.0<=h<=Infinity)
size: Size(308.0, 20.0)
direction: horizontal
mainAxisAlignment: start
mainAxisSize: max
crossAxisAlignment: center
textDirection: ltr
verticalDirection: down
spacing: 0.0

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also updated the golden images for the test so that they don't fail with the new version

yashas-hm and others added 7 commits March 24, 2025 12:21
# Conflicts: #	AUTHORS.md #	pubspec.yaml #	test/workout/goldens/routine_logs_screen_detail.png #	test/workout/routine_logs_screen_test.dart
This should also fix the problem when generating the goldens. The loadAppFonts and the check for Linux was removed as well, if the pseudo-font helps with a constant rendering among all platforms we don't need those.
Also add a constant device size for all goldens
@rolandgeider
Copy link
Member

@yashas-hm I finally took a look at this and fixed the overflow error in one of the meal widgets, now the goldens build correctly and the tests pass. It also seems that even with that general font the rendering is sufficiently different that it can't be compared across OSs, which is a pity but we can live with it.

@rolandgeider rolandgeider merged commit 9858089 into wger-project:master Apr 12, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants