Skip to content
This repository was archived by the owner on Aug 9, 2024. It is now read-only.

feat(S-001): finalize Superformula test #17

Open
wants to merge 89 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
89 commits
Select commit Hold shift + click to select a range
5f524c8
feat: setup injection
jeilsonaraujo Feb 17, 2024
41264d6
feat: update flutter and add colours, graphics, and add locales
jeilsonaraujo Feb 17, 2024
4d1fb54
feat: add fixtures to dtos
jeilsonaraujo Feb 17, 2024
3b9e5f4
feat: add font and test styles
jeilsonaraujo Feb 17, 2024
a7ae70c
feat: refactor AppColors to RTColors
jeilsonaraujo Feb 17, 2024
da5fbf7
feat: create RTErrorWidget
jeilsonaraujo Feb 17, 2024
ec81f4a
feat: create RestaurantsListScreen and RestaurantsListViewModel
jeilsonaraujo Feb 17, 2024
6d75d4d
feat: create RestaurantItemWidget
jeilsonaraujo Feb 17, 2024
a981ef3
feat: add RestaurantsPage
jeilsonaraujo Feb 17, 2024
c6e82a1
feat: add FavoritesPage
jeilsonaraujo Feb 17, 2024
acf70df
feat: add provider dependency to project
jeilsonaraujo Feb 17, 2024
493c86b
feat: refactor delegate error handling responsibility to the view model
jeilsonaraujo Feb 17, 2024
93def46
feat: await for setupInjection, setup theme, and remove unused code
jeilsonaraujo Feb 17, 2024
27e6115
feat: remove unused import
jeilsonaraujo Feb 17, 2024
14c270b
feat: refactor add elevation to tabBar, and add padding to first item…
jeilsonaraujo Feb 17, 2024
0ae6b09
feat: show restaurant details in another screen
jeilsonaraujo Feb 17, 2024
69edbae
feat: refactor colors, add color default
jeilsonaraujo Feb 17, 2024
022d4c4
feat: create restaurant_review_widget
jeilsonaraujo Feb 17, 2024
db005eb
feat: create restaurant_details screen and restaurant_details_view_model
jeilsonaraujo Feb 17, 2024
1dfa472
feat: add shimmer load on restaurant list
jeilsonaraujo Feb 17, 2024
86be1a9
fix: remove default color on button, this was causing a issue on disa…
jeilsonaraujo Feb 17, 2024
6a61519
feat: add shared_preferences to save favorites locally, and fix error…
jeilsonaraujo Feb 18, 2024
b9fea07
feat: create favorite_service to manage data from shared_preferences,…
jeilsonaraujo Feb 18, 2024
13ea9cd
feat: add shared_preferences to save favorites locally, and fix error…
jeilsonaraujo Feb 18, 2024
f63f4c4
feat: add callback to restaurant_item, to refresh favorites page when…
jeilsonaraujo Feb 18, 2024
b3fa4cc
feat: enable the addition and removal of restaurants from the favorit…
jeilsonaraujo Feb 18, 2024
4b64460
feat: display an empty state to the user when there are no results av…
jeilsonaraujo Feb 18, 2024
466873a
feat: add pull to refresh on restaurants list
jeilsonaraujo Feb 18, 2024
87e8dd7
feat: refactor - rename yelp_repository to restaurant_repository
jeilsonaraujo Feb 18, 2024
d8177df
feat: create rt_image_network to be injected on tests to avois image_…
jeilsonaraujo Feb 18, 2024
5ef0f53
feat: register rt_image_network on get_it and replace image_network b…
jeilsonaraujo Feb 18, 2024
64482c8
feat: remove fake loading delay
jeilsonaraujo Feb 18, 2024
473c87d
feat: refactor rt_empty widget
jeilsonaraujo Feb 18, 2024
01cb946
feat: add mocktail to project and create some mocks to tests
jeilsonaraujo Feb 18, 2024
d472686
feat: add widget test to initial page
jeilsonaraujo Feb 18, 2024
7d2f39b
feat: add tests to favorites_page and restaurants_page
jeilsonaraujo Feb 18, 2024
4aa73ee
feat: add tests to restaurant_details_screen
jeilsonaraujo Feb 18, 2024
69ca6a1
feat: add golden tests
jeilsonaraujo Feb 18, 2024
76d96b0
feat: refactor extract restaurant_tour to a separated file and rename…
jeilsonaraujo Feb 18, 2024
80f7f9e
feat: add tests to restaurant_list_view_model
jeilsonaraujo Feb 18, 2024
9820627
feat: refactor folder name
jeilsonaraujo Feb 18, 2024
e428a85
feat: add tests to restaurant_details_view_model
jeilsonaraujo Feb 18, 2024
be0c6a8
feat: update .gitignore
jeilsonaraujo Feb 18, 2024
63e7836
feat: add test to restaurant_details_screen
jeilsonaraujo Feb 18, 2024
baee709
feat: refactor remove api key
jeilsonaraujo Feb 18, 2024
290d93b
fix: use .env files to store api secrets, move mocktail to dev_depend…
jeilsonaraujo Feb 18, 2024
a6be892
feat: stop call loadFavorites when change tab, refactor restaurant_de…
jeilsonaraujo Feb 19, 2024
48098cd
feat: create a widget_fot_tests to efficiently reuse components that …
jeilsonaraujo Feb 19, 2024
0b35ce8
feat: refactor names of widgets and folders structure
jeilsonaraujo Feb 19, 2024
7ff283b
chrore: refactor restaurant >> restaurants
jeilsonaraujo Feb 19, 2024
bc9ab1f
chore: add review
jeilsonaraujo Feb 19, 2024
f15be8c
feat: export components to reduce imports, add openDetailst on rt_ite…
jeilsonaraujo Feb 19, 2024
019558b
feat: refactor detail_screen, receive restaurantId instead object and…
jeilsonaraujo Feb 19, 2024
ec4a717
feat: save data using specific queries
jeilsonaraujo Feb 19, 2024
70327a9
feat: get the details from api, update tests
jeilsonaraujo Feb 19, 2024
0be0aa9
fix: favorites was not refreshing
jeilsonaraujo Feb 19, 2024
62bb55b
feat: add pagination to restaurants list and reviews
jeilsonaraujo Feb 19, 2024
34d910c
feat: refactor dto in separated files
jeilsonaraujo Feb 19, 2024
16f59ea
fix: fail to run on android
jeilsonaraujo Feb 20, 2024
4994fc8
feat: add try_again button to error_screen
jeilsonaraujo Feb 20, 2024
0cfb497
feat: use makefile to agregate scripts, sort locales
jeilsonaraujo Feb 20, 2024
b78615d
feat: add integration test
jeilsonaraujo Feb 20, 2024
f171049
feat: refactor code, add theme on goldentests and update images, and …
jeilsonaraujo Feb 20, 2024
8daede1
feat: load favorites in memory, clean up coverage report
jeilsonaraujo Feb 20, 2024
4a00530
feat: add tests for favorite_service
jeilsonaraujo Feb 20, 2024
1fbd9a6
feat: update fluter, update golden tests
jeilsonaraujo Feb 28, 2024
63a21ca
feat: fix test description
jeilsonaraujo Mar 2, 2024
740e446
feat: setup launch.json
jeilsonaraujo Mar 2, 2024
2a15057
fix: fail to run on android
jeilsonaraujo Mar 2, 2024
a7dd867
feat: refactor imports
jeilsonaraujo Mar 2, 2024
5e3f478
feat: use appBarTheme
jeilsonaraujo Mar 2, 2024
c3f2cbc
feat: refactor use theme colors
jeilsonaraujo Mar 2, 2024
71ac513
feat: refactor restaurants_view_model
jeilsonaraujo Mar 2, 2024
159977f
feat: paralelize api calls
jeilsonaraujo Mar 2, 2024
8d54374
feat: refactor theme colors
jeilsonaraujo Mar 2, 2024
ccf7cf4
feat: center title to android and ios
jeilsonaraujo Mar 3, 2024
bef6da2
feat: add logger and refactor imports
jeilsonaraujo Mar 3, 2024
5d75c88
feat: add interceptor logger
jeilsonaraujo Mar 3, 2024
3867f69
feat: refactor colors and makefile
jeilsonaraujo Mar 3, 2024
0f202ac
feat: refactor to use individual view_model for restaurants and favor…
jeilsonaraujo Mar 3, 2024
6cfdb4e
feat: setup pipe
jeilsonaraujo Mar 3, 2024
f80b0aa
feat: refactor use rt_size
jeilsonaraujo Mar 4, 2024
da7af39
feat: update goldens
jeilsonaraujo Mar 4, 2024
d7684b4
feat: refactor event_bus to dispose stream and rename view_models
jeilsonaraujo Mar 4, 2024
8f217f4
feat: use flutter_gen to track asset names, change makefile to add in…
jeilsonaraujo Mar 8, 2024
7fde339
feat: setup environments prod, stage, and local
jeilsonaraujo Mar 8, 2024
667642d
feat: update readme
jeilsonaraujo Mar 8, 2024
9570e08
feat: setup env_stage key
jeilsonaraujo Mar 8, 2024
9c2d2cf
feat: update tests
jeilsonaraujo Mar 8, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env_stage
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
API_KEY="KC7Is6ZMmm9pJtce2CCzin4Np4GuCDraZ3M3Pdl6ibKfE96Byt4-RZ2p0c7qj_Dhg8g5BaMPfZ8uYfQ7OEXJoJzC85OULRmwXuaitDLQ5kqthjeFGhTxePA3gu3QZXYx"
2 changes: 1 addition & 1 deletion .fvm/fvm_config.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"flutterSdkVersion": "3.13.9",
"flutterSdkVersion": "3.16.8",
"flavors": {}
}
20 changes: 20 additions & 0 deletions .github/workflows/dart.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: PR Changes

on:
pull_request:

jobs:
run_tests:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
with:
flutter-version: '3.13.9'
- run: dart pub global activate arb_utils
- run: flutter pub get
- run: flutter clean
- run: make gen
- run: make l10n
- run: make tests-ci-cd

5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@
.buildlog/
.history
.svn/

# automated_tests related
**/failures/
**/coverage/
# IntelliJ related
*.iml
*.ipr
*.iws
.idea/
*.env

# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
Expand Down
24 changes: 22 additions & 2 deletions .metadata
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,27 @@
# This file should be version controlled and should not be manually edited.

version:
revision: ffb2ecea5223acdd139a5039be2f9c796962833d
channel: stable
revision: "d211f42860350d914a5ad8102f9ec32764dc6d06"
channel: "stable"

project_type: app

# Tracks metadata for the flutter migrate command
migration:
platforms:
- platform: root
create_revision: d211f42860350d914a5ad8102f9ec32764dc6d06
base_revision: d211f42860350d914a5ad8102f9ec32764dc6d06
- platform: android
create_revision: d211f42860350d914a5ad8102f9ec32764dc6d06
base_revision: d211f42860350d914a5ad8102f9ec32764dc6d06

# User provided section

# List of Local paths (relative to this file) that should be
# ignored by the migrate tool.
#
# Files that are not part of the templates will be ignored by default.
unmanaged_files:
- 'lib/main.dart'
- 'ios/Runner.xcodeproj/project.pbxproj'
29 changes: 24 additions & 5 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,32 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "app",
"name": "Smoke Test (prod)",
"request": "launch",
"type": "dart"
"type": "dart",
"program": "integration_test/app_test.dart",
"args": [
"--dart-define=app.flavor=prod"
]
},
{
"name": "RestauranTour (stage)",
"request": "launch",
"type": "dart",
"program": "lib/main.dart",
"args": [
"--dart-define=app.flavor=stage"
]
},
{
"name": "RestauranTour (prod)",
"request": "launch",
"type": "dart",
"program": "lib/main.dart",
"args": [
"--dart-define=app.flavor=prod"
]
}
]
}
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"dart.flutterSdkPath": ".fvm/flutter_sdk",
"dart.flutterSdkPath": "~/fvm/versions/3.13.9",
"search.exclude": {
"**/.fvm": true
},
Expand Down
73 changes: 73 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# SETUP:
get :
flutter pub get

setup-fvm-version :
fvm install 3.16.8 && \
fvm global 3.16.8

pre-setup :
flutter clean &&\
dart run build_runner clean && \
dart pub global activate arb_utils && \
dart pub global activate flutter_gen


setup-env-file :
test -f .env || echo "API_KEY=''" >> .env

setup : pre-setup get l10n gen asset-gen setup-env-file unit-tests


fix-gen :
mkdir -p .dart_tool/flutter_gen/ && echo "name: stub" > .dart_tool/flutter_gen/pubspec.yaml

try-fix-gen : fix-gen
dart run build_runner build --delete-conflicting-outputs

# TESTS:

tests :
flutter test --coverage

all-tests : tests integration-tests

unit-tests :
flutter test -x golden --coverage

golden-tests :
flutter test -t golden --coverage

tests-ci-cd :
rm -rf coverage && flutter test --coverage --dart-define=runningOnCICD=true

integration-tests :
flutter test integration_test/app_test.dart

update-goldens : remove-goldens-failures
flutter test --update-goldens

remove-goldens-failures :
rm test/golden_test/failures/*

# TEST COVERAGE

show-coverage : tests lcov

lcov-ignore :
lcov --remove coverage/lcov.info 'lib/core/*' 'lib/theme/*' 'lib/models/*.g.dart' -o coverage/lcov.info

lcov : tests lcov-ignore
genhtml -q -o coverage coverage/lcov.info && open coverage/index.html


# CODE GENERATION

l10n :
flutter gen-l10n && arb_utils sort lib/l10n/app_en.arb

asset-gen :
fluttergen

gen :
dart run build_runner build --delete-conflicting-outputs || make try-fix-gen
165 changes: 144 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,38 +1,113 @@
# RestauranTour

Be sure to read **all** of this document carefully, and follow the guidelines within.

## Vendorized Flutter
## Welcom to RestauranTour!

3. We use [fvm](https://fvm.app/) for managing the flutter version within the project. Using terminal, while being on the test repository, install the tools dependencies by running the following commands:
The idea of this project is to help you to choose the best restaurants!

```sh
dart pub global activate fvm
```
### Some features:
- Navigate through the available restaurants and see basic information like `opened status`, `price` and `classification` from other users directly from the list.
- See details of the restaurant, when you open a restaurant the details page will show you more information like `review` from users.
- Save the best! On the details screen you can add to favorites those restaurant make you heartbeat!
- Favorite list shows all the restaurant that you love.

The output of the command will ask to add the folder `./pub-cache/bin` to your PATH variables, if you didn't already. If that is the case, add it to your environment variables, and restart the terminal.
## Setup:

```sh
export PATH="$PATH":"$HOME/.pub-cache/bin" # Add this to your environment variables
```

4. Install the project's flutter version using `fvm`.
To make things easier, we are using Makefile to manage the commands and setup you project.

```sh
fvm use
```
Before start with Make commands, make sure that you have installed the fvm in your system, see [Vendorized Flutter](#vendorized-flutter) before.

5. From now on, you will run all the flutter commands with the `fvm` prefix. Get all the projects dependencies.
#### 1 - make setup-fvm-version

```sh
fvm flutter pub get
```
Now that you have installed the fvm, by running the command `fvm --version` this should return the fvm version installed in your system like this:
```
$ fvm --version
2.4.1
```
Now we can proceed, well as mentioned before, we will use make for make things for us. To setup the fvm version run the following command:

More information on the approach can be found here:
``` bash
make setup-fvm-version
```
The curremt version of Flutter is `3.16.8` but don't worry about setup this, `make setup-fvm-version` will do it automatically.

> hhttps://fvm.app/docs/getting_started/installation
> Make setup-fvm-version will run the following commands: `fvm install 3.16.8` and `fvm global 3.16.8`

This will download the version that we are using on the project, and setup as global.

### 2 - make setup

This will setup all things that we need work on the project.
To make sure that everything is working well, `make setup` will run some commands:

Pre-setup:

- `flutter clean` # clean the flutter project
- `dart run build_runner clean` # clean the build runner
- `dart pub global activate arb_utils` # activate the arb_utils package to generate locales
- `dart pub global activate flutter_gen` # activate the flutter_gen package for management assets

Setup:
- `get` # flutter pub get
- `l10n` # generate the locales and sort
- `gen` # generate the models
- `asset-gen` # generate the assets
- `setup-env-file` # generate the `.env` file
- `unit-tests` # run unit tests to ensure everything is working

<details>
<summary>All make commands available</summary>

From the root directory:
<ul>
<details>
<summary>Setup</summary>

<ul><b>get</b> <i># run flutter pub get</i></ul>
<ul><b>setup-fvm-version</b> <i># download and setup the fvm flutter version for the project</i></ul>
<ul><b>pre-setup</b> <i># clean the project and install some dependencies</i></ul>
<ul><b>setup-env-file</b> <i># generate the .env file</i></ul>
<ul><b>setup</b> <i># run pre-setup, setup-env-file, run code generation and run unit tests</i></ul>
<ul><b>try-fix-gen</b> <i># try run code generation if fail try fix and run code generation again</i></ul>
<ul><b>fix-gen</b> <i># perform some steps to fix code generation</i></ul>

</details>
</ul>

<ul>
<details>
<summary>Tests</summary>
<ul><b>tests</b> <i># run unit and golden tests</i></ul>
<ul><b>all-tests</b> <i># run all type of tests on project, unit, golden and integration</i></ul>
<ul><b>unit-tests</b> <i># run only unit tests</i></ul>
<ul><b>tests-ci-cd</b> <i>#run tests with a flag that enable threshold for golden tests on pipeline</i></ul>
<ul><b>integration-tests</b> <i># run integration test</i></ul>
<ul><b>update-goldens</b> <i># update the golden images</i></ul>
<ul><b>remove-goldens-failures</b> <i># this remove the failure folder of golden tests</i></ul>
</details>
</ul>

<ul>
<details>
<summary>Coverage</summary>
See <a href="#coverage-reports---lcov">Coverage reports</a>

<ul><b>lcov</b> <i># run the tests and show the coverage report filtered</i></ul>
<ul><b>show-coverage</b> <i># run tests and show the coverage report</i></ul>
<ul><b>lcov-ignore</b> <i># remove some files from coverage report</i></ul>
</details>
</ul>

<ul>
<details>
<summary>Code gen</summary>
<ul><b>l10n</b> <i># generate the localization files</i></ul>
<ul><b>asset-gen</b> <i># generate the assets file</i></ul>
<ul><b>gen</b> <i># generate models using build_runner</i></ul>
</details>
</ul>

</details>


### IDE Setup
Expand Down Expand Up @@ -181,3 +256,51 @@ Just create a new issue in this repo and we will respond and get back to you qui
## Review

The coding challenge is a take-home test upon which we'll be conducting a thorough code review once complete. The review will consist of meeting some more of our mobile engineers and giving a review of the solution you have designed. Please be prepared to share your screen and run/demo the application to the group. During this process, the engineers will be asking questions.


## Vendorized Flutter

We use [fvm](https://fvm.app/) for managing the flutter version within the project. Using terminal, while being on the test repository, install the tools dependencies by running the following commands:

```sh
dart pub global activate fvm
```

The output of the command will ask to add the folder `./pub-cache/bin` to your PATH variables, if you didn't already. If that is the case, add it to your environment variables, and restart the terminal.

```sh
export PATH="$PATH":"$HOME/.pub-cache/bin" # Add this to your environment variables
```



More information on the approach can be found here:

> hhttps://fvm.app/docs/getting_started/installation

[Back to setup](#setup)

## Coverage reports - lcov
LCOV is an extension of GCOV, a GNU tool which provides information about
what parts of a program are actually executed (i.e. "covered") while running
a particular test case. The extension consists of a set of Perl scripts
which build on the textual GCOV output to implement the following enhanced
functionality:

- HTML based output: coverage rates are additionally indicated using bar
graphs and specific colors.

- Support for large projects: overview pages allow quick browsing of
coverage data by providing three levels of detail: directory view,
file view and source code view.

LCOV was initially designed to support Linux kernel coverage measurements,
but works as well for coverage measurements on standard user space
applications.

<a href="https://formulae.brew.sh/formula/lcov">Install on Linux/MacOs using brew</a>

<a href="https://community.chocolatey.org/packages/lcov?source=post_page-----7c58dda07080--------------------------------">Install on Windows</a>


[Back to make](#2---make-setup)
1 change: 0 additions & 1 deletion analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,4 @@ linter:
rules:
## The following rules are excluded only to keep compatibility with our previous lint set (pedantic).
## There's room to discuss them individually and raise PRs adjusting our codebase.
avoid_print: false
require_trailing_commas: true
Loading