Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(cat-voices): adds web tests for flutter unit tests #1948

Merged
merged 24 commits into from
Mar 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
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
2 changes: 1 addition & 1 deletion .github/workflows/generate-allure-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
continue-on-error: true
with:
command: run
args: ./catalyst_voices+test-unit
args: ./catalyst_voices+test-unit-native

- name: Get python api test report
uses: input-output-hk/catalyst-forge/actions/run@ci/v1.7.1
Expand Down
6 changes: 3 additions & 3 deletions Earthfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
VERSION 0.8

IMPORT github.com/input-output-hk/catalyst-ci/earthly/mdlint:v3.3.0 AS mdlint-ci
IMPORT github.com/input-output-hk/catalyst-ci/earthly/cspell:v3.3.0 AS cspell-ci
IMPORT github.com/input-output-hk/catalyst-ci/earthly/postgresql:v3.3.0 AS postgresql-ci
IMPORT github.com/input-output-hk/catalyst-ci/earthly/mdlint:v3.3.1 AS mdlint-ci
IMPORT github.com/input-output-hk/catalyst-ci/earthly/cspell:v3.3.1 AS cspell-ci
IMPORT github.com/input-output-hk/catalyst-ci/earthly/postgresql:v3.3.1 AS postgresql-ci

FROM debian:stable-slim

Expand Down
2 changes: 1 addition & 1 deletion catalyst-gateway/Earthfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
VERSION 0.8

IMPORT github.com/input-output-hk/catalyst-ci/earthly/rust:v3.3.0 AS rust-ci
IMPORT github.com/input-output-hk/catalyst-ci/earthly/rust:v3.3.1 AS rust-ci
IMPORT ../ AS repo-ci

#cspell: words rustfmt toolsets USERARCH stdcfgs
Expand Down
2 changes: 1 addition & 1 deletion catalyst-gateway/event-db/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# the database and its associated software.
VERSION 0.8

IMPORT github.com/input-output-hk/catalyst-ci/earthly/postgresql:v3.3.0 AS postgresql-ci
IMPORT github.com/input-output-hk/catalyst-ci/earthly/postgresql:v3.3.1 AS postgresql-ci

# cspell: words

Expand Down
2 changes: 1 addition & 1 deletion catalyst-gateway/tests/Earthfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
VERSION 0.8
IMPORT github.com/input-output-hk/catalyst-ci/earthly/spectral:v3.3.0 AS spectral-ci
IMPORT github.com/input-output-hk/catalyst-ci/earthly/spectral:v3.3.1 AS spectral-ci
IMPORT .. AS gateway

docker-compose:
Expand Down
2 changes: 1 addition & 1 deletion catalyst-gateway/tests/api_tests/Earthfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
VERSION 0.8

IMPORT github.com/input-output-hk/catalyst-ci/earthly/python:v3.3.0 AS python-ci
IMPORT github.com/input-output-hk/catalyst-ci/earthly/python:v3.3.1 AS python-ci
IMPORT github.com/input-output-hk/catalyst-libs/rust:r20250227-00 AS cat-libs-rust

builder:
Expand Down
11 changes: 7 additions & 4 deletions catalyst_voices/Earthfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
VERSION 0.8

IMPORT ../catalyst-gateway AS catalyst-gateway
IMPORT github.com/input-output-hk/catalyst-ci/earthly/flutter:v3.2.40 AS flutter-ci

IMPORT github.com/input-output-hk/catalyst-ci/earthly/flutter:v3.3.1 AS flutter-ci

# repo-catalyst-voices - Creates artifacts of all configuration files,
# packages and folders related to catalyst_voices frontend.
Expand Down Expand Up @@ -98,9 +97,13 @@ check-license:
RUN melos run license-check

# Run unit tests
test-unit:
test-unit-native:
FROM +code-generator
DO flutter-ci+UNIT_TESTS --PLATFORM=native --REPORT=true

test-unit-web:
FROM +code-generator
DO flutter-ci+UNIT_TESTS
DO flutter-ci+UNIT_TESTS --PLATFORM=web --REPORT=false

# Runs static analysis on the code.
build-static-analysis:
Expand Down
2 changes: 1 addition & 1 deletion catalyst_voices/justfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ check-code:

# Runs unit tests
test-code:
earthly +test-unit
earthly +test-unit-native

# Pre Push Checks
pre-push: check-code
60 changes: 58 additions & 2 deletions catalyst_voices/melos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -232,12 +232,68 @@ scripts:
melos exec -c 1 --dir-exists="test" -- flutter test
description: Run `flutter test` for selected packages.

test:
test-native:
run: |
melos run test:select --no-select
description: Run `flutter test` for all packages.

test-report:
# TODO(kukkok3):
# catalyst_voices: this package should contain only widget tests
# catalyst_voices_repositories: enable when https://github.com/input-output-hk/catalyst-voices/issues/1980 is fixed
# catalyst_voices_assets: enable when https://github.com/input-output-hk/catalyst-voices/issues/1979 is fixed
test-web:
run: |
melos exec -c 1 --dir-exists="test" --ignore="catalyst_voices,catalyst_voices_repositories,catalyst_voices_assets" -- flutter test --platform chrome
description: Run `flutter test --platform chrome` for all packages.

test-report-web:
run: |
# cleanup from previous build and create empty folder where test reports will be stored
rm -fR $MELOS_ROOT_PATH/test_reports
mkdir $MELOS_ROOT_PATH/test_reports

# cleanup old coverage files and create empty folder where coverage files will be stored
find . -type d -name coverage -prune -exec rm -rf {} \;
mkdir $MELOS_ROOT_PATH/coverage
# run tests, generate junit reports in /test_reports/ & code coverage report
melos exec -c 1 --dir-exists="test" --ignore="catalyst_voices" -- \
' TESTS_OUTPUT_FILE="$MELOS_ROOT_PATH/test_reports/$MELOS_PACKAGE_NAME.tests-output.json"
JUNIT_REPORT_FILE="$MELOS_ROOT_PATH/test_reports/$MELOS_PACKAGE_NAME.junit-report.xml"
flutter test --platform chrome --reporter github --file-reporter=json:$TESTS_OUTPUT_FILE --coverage ; \
EXIT_CODE=$? ; \
cat $TESTS_OUTPUT_FILE | tojunit --output $JUNIT_REPORT_FILE ; \
exit $EXIT_CODE'

# store the exit code after running the tests,
# this is the exit code for the whole script
EXIT_CODE=$?

# removes code coverage for generated code
find . -name "*.lcov.info" -exec \
lcov --remove {} -o {} --ignore-errors unused,unused \
'*.g.dart' \
'*.freezed.dart' \
'*.chopper.dart' \
'*.swagger.dart' \
'*.openapi.dart' \
'*.gen.dart' \
'*.swagger.*.dart' \
'*.drift.dart' \
'lib/generated/**' \;

# merges all coverage reports into a single one and puts it in /coverage/lcov.info
dart pub global run combine_coverage --repo-path=.
mv ./coverage/lcov.info ./coverage/lcov.coverage.info

exit $EXIT_CODE

description: |
Run `flutter test --platform chrome` for all packages and generate junit and coverage reports.
The test reports are saved in /test_reports folder.
The coverages are saved in coverage/lcov.info file for each tested package.
The combined coverage is saved in the /coverage/lcov.coverage.info file.

test-report-native:
run: |
# cleanup from previous build and create empty folder where test reports will be stored
rm -fR $MELOS_ROOT_PATH/test_reports
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,7 @@ dependencies:
dev_dependencies:
build_runner: ^2.4.12
catalyst_analysis: ^3.0.0
flutter_test:
sdk: flutter
json_serializable: ^6.9.0
test: ^1.24.9
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,6 @@ dependencies:

dev_dependencies:
catalyst_analysis: ^3.0.0
flutter_test:
sdk: flutter
test: ^1.24.9
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
VERSION 0.8
IMPORT github.com/input-output-hk/catalyst-ci/earthly/flutter:v3.2.40 AS flutter-ci
IMPORT github.com/input-output-hk/catalyst-ci/earthly/playwright:v3.2.40 AS playwright-ci
IMPORT github.com/input-output-hk/catalyst-ci/earthly/flutter:v3.3.1 AS flutter-ci
IMPORT github.com/input-output-hk/catalyst-ci/earthly/playwright:v3.3.1 AS playwright-ci

deps:
DO playwright-ci+SETUP --workdir=/wallet-automation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ dependencies:
dev_dependencies:
build_runner: ^2.4.12
catalyst_analysis: ^3.0.0
flutter_test:
sdk: flutter
kiri_check: ^1.2.0
mockito: ^5.4.4
mocktail: ^1.0.1
Expand Down
2 changes: 2 additions & 0 deletions catalyst_voices/packages/libs/catalyst_cose/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,6 @@ dependencies:

dev_dependencies:
catalyst_analysis: ^3.0.0
flutter_test:
sdk: flutter
test: ^1.24.9
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
VERSION 0.8

IMPORT github.com/input-output-hk/catalyst-ci/earthly/flutter:v3.2.40 AS flutter-ci
IMPORT github.com/input-output-hk/catalyst-ci/earthly/flutter_rust_bridge:v3.2.40 AS flutter_rust_bridge
IMPORT github.com/input-output-hk/catalyst-ci/earthly/flutter:v3.3.1 AS flutter-ci
IMPORT github.com/input-output-hk/catalyst-ci/earthly/flutter_rust_bridge:v3.3.1 AS flutter_rust_bridge

builder:
FROM flutter_rust_bridge+builder
COPY . .

# Generated necessary files for running Flutter web locally and save it locally.
code-generator:
ARG local = false
ARG local = false
FROM +builder
DO flutter_rust_bridge+CODE_GENERATOR_WEB

IF [ $local = true ]
SAVE ARTIFACT ./assets/js AS LOCAL ./assets/js
SAVE ARTIFACT ./rust/src/frb_generated.rs AS LOCAL ./rust/src/frb_generated.rs
SAVE ARTIFACT ./lib/src AS LOCAL ./lib/src
ELSE
ELSE
SAVE ARTIFACT ./assets/js assets_js
SAVE ARTIFACT ./rust/src/frb_generated.rs frb_generated.rs
SAVE ARTIFACT ./lib/src src
Expand Down Expand Up @@ -60,7 +60,7 @@ integration-test-web:
WAIT
SAVE ARTIFACT $driver.log AS LOCAL $driver.log
END

IF [ -f fail ]
RUN --no-cache echo ""$browser" integration test failed" && \
echo "Printing "$driver" logs..." && \
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
VERSION 0.8

IMPORT github.com/input-output-hk/catalyst-ci/earthly/rust:v3.3.0 AS rust-ci
IMPORT github.com/input-output-hk/catalyst-ci/earthly/rust:v3.3.1 AS rust-ci
IMPORT ../ AS flutter-rust-bridge

# builder : Setup the builder
Expand Down
2 changes: 1 addition & 1 deletion catalyst_voices/utilities/uikit_example/Earthfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
VERSION 0.8

IMPORT ../../ AS catalyst-voices
IMPORT github.com/input-output-hk/catalyst-ci/earthly/flutter:v3.2.40 AS flutter-ci
IMPORT github.com/input-output-hk/catalyst-ci/earthly/flutter:v3.3.1 AS flutter-ci

# local-build-web - build web version of UIKit example.
# Prefixed by "local" to make sure it's not auto triggered, the target was
Expand Down
4 changes: 2 additions & 2 deletions docs/Earthfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
VERSION 0.8

IMPORT github.com/input-output-hk/catalyst-ci/earthly/docs:v3.3.0 AS docs-ci
IMPORT github.com/input-output-hk/catalyst-ci/earthly/docs:v3.3.1 AS docs-ci

IMPORT .. AS repo
IMPORT ../catalyst-gateway AS catalyst-gateway
Expand Down Expand Up @@ -42,7 +42,7 @@ local:

# This is a local only image, we do not publish it.
SAVE IMAGE cat-voices-docs:latest

# registry-local: Local preview target - Pushed to a local registry
registry-local:
FROM +local
Expand Down
2 changes: 1 addition & 1 deletion utilities/docs-preview/Earthfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
VERSION 0.8

IMPORT github.com/input-output-hk/catalyst-ci/earthly/docs:v3.3.0 AS docs-ci
IMPORT github.com/input-output-hk/catalyst-ci/earthly/docs:v3.3.1 AS docs-ci


# update-docs-dev-script: get the latest docs dev script from CI.
Expand Down