Snapshot tests for the flutter code#60
Conversation
| textColorHex: '#800080', | ||
| backgroundHex: '#000000', | ||
| textSize: '24.0', | ||
| textAllCaps: true, |
There was a problem hiding this comment.
It is really weird, it looks like all caps is not working
| flutter: | ||
| fonts: | ||
| - family: Roboto | ||
| fonts: |
There was a problem hiding this comment.
By default, flutter needs a font to the test env
|
|
||
| jobs: | ||
| build: | ||
| runs-on: macos-latest # Use macOS because I generated the golden images in my macoOS |
There was a problem hiding this comment.
I need to run this on macos, considering I generated the golden images on my macos laptop
This commit introduces two new properties to the `CraftDButton` widget: - `fillMaxSize`: When set to `true`, the button will expand to fill the available width. - `textAllCaps`: When set to `true`, the button's text will be displayed in uppercase. Corresponding snapshot tests have been added to verify these new functionalities. The `CraftDText` widget was also updated to respect the `textAllCaps` property.
…Tests
This commit introduces snapshot tests for the `CraftDText` widget and refactors existing snapshot tests for the `CraftDButton` widget.
**CraftDText Snapshot Tests:**
- Added two new snapshot tests for `CraftDText`:
- `craftd_text_allcaps_false_snapshot.png`: Verifies the rendering of `CraftDText` with `textAllCaps` set to `false`.
- `craftd_text_allcaps_true_snapshot.png`: Verifies the rendering of `CraftDText` with `textAllCaps` set to `true`.
**CraftDButton Snapshot Tests Refactoring:**
- Renamed and updated existing `CraftDButton` snapshot tests to improve clarity and reflect the tested property:
- `craftd_button_allcaps_snapshot.png` was removed and its test case modified to test `fillMaxSize: false`, resulting in `craftd_button_fill_max_size_false_snapshot.png`.
- `craftd_button_fill_max_size_snapshot.png` was renamed to `craftd_button_fill_max_size_true_snapshot.png` to explicitly indicate that `fillMaxSize` is `true`.
- Adjusted the properties (text color, background color, `textAllCaps`, `fillMaxSize`) in the `CraftDButton` test cases to align with the new snapshot test names and the properties being tested.
The `CraftDText` widget was not applying the background color specified in `textProperties`. This commit fixes the issue by setting the `backgroundColor` in the `TextStyle`.
Additionally, this commit:
- Adds default values for text properties in snapshot tests to improve readability and maintainability.
- Introduces new snapshot tests for `CraftDText` to cover different scenarios:
- Text with orange text color
- Text with orange background color
- Text with a big font size
- Updates existing snapshot images to reflect the changes.
Adds a golden file test for the `CraftDEmpty` widget to ensure its visual representation remains consistent.
| @override | ||
| Widget build(BuildContext context) { | ||
| if (buttonProperties.fillMaxSize == true) { | ||
| return SizedBox( |
There was a problem hiding this comment.
Bug fix: fillMaxSize was not working properly
|
|
||
| @override | ||
| Widget build(BuildContext context) { | ||
| final String text = textProperties.textAllCaps == true |
There was a problem hiding this comment.
Bug fix: textAllCaps was not working properly
| ? double.tryParse(textProperties.textSize!) | ||
| : 16.0, | ||
| color: CraftDColor.hexToColor(textProperties.textColorHex), | ||
| backgroundColor: CraftDColor.hexToColor(textProperties.backgroundHex), |
There was a problem hiding this comment.
Bug fix: backgroundColor was not working properly
The `flutter test` command was removed from the Flutter snapshot tests workflow. This is because the tests are already being run by the integration tests.
| branches: | ||
| - main | ||
| paths: | ||
| - "flutter/**" |
There was a problem hiding this comment.
any changes in the flutter source set will trigger this workflow
| branches: | ||
| - main | ||
| paths: | ||
| - "flutter/craftd_widget/lib/presentation/ui/**" |
There was a problem hiding this comment.
any changes in the ui folder (inside of flutter package) will trigger this workflow

Description
This update enhances our snapshot testing infrastructure and test cases for CraftD Flutter components.
Bug fixes:
It closes:
Check list