Add Unit Tests for v3 Layer and All GetX Controllers

Aberta
#619 3 comentários 0 reações 0 responsáveis Ver no GitHub

@srykaran já está trabalhando nisso.

Desde 13/3/2026.

Avaliação

Dificuldade
5/5
Tempo estimado
Mais de uma semana
Facilidade para iniciantes
35/100
Tipo de issue
Funcionalidade
Clareza
Razoavelmente clara
Status de atividade
Estagnada
Stack de tecnologia
dart, flutter
Domínio
mobile-dev, testing

Direção de pesquisa

Comece com pubspec.yaml e os padrões existentes em test/api_service_test.dart e test/models/json/task_test.dart. Adicione os helpers e testes listados em test/v3/ e test/modules/controllers/; depois execute build_runner e os dois comandos flutter test com escopo definido antes da suíte completa. Está concluído quando todos os 12 testes de v3 e os 14 testes de controller passarem, com a cobertura especificada de estado, mutação e casos extremos.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

Summary

The project has 91+ existing tests covering utilities, JSON models, routes, and tour UI — but the v3 data layer (12 files) and all 14 GetX controllers have zero unit test coverage. These are the most critical parts of the codebase: v3 contains the task database, network sync, and core models, while controllers hold all business logic and state management.

Motivation
  • Controllers are the sole owners of business logic per the GetX architecture contract — regressions here break the entire UI silently
  • The v3 layer handles live task data sync; bugs here cause data loss
  • No test infrastructure exists yet for either layer, making refactors risky

Scope
Phase 1 — Test Infrastructure
  • Add test/v3/helpers.dart — shared setup for sqflite FFI, SharedPreferences mock, binding init
  • Add test/modules/controllers/helpers.dart — GetX test mode setup (Get.testMode = true, Get.reset())
  • Run build_runner to regenerate mocks
Phase 2 — V3 Unit Tests (12 files)

Models (test/v3/models/)

  • test/v3/models/task_test.dart — Task fromJson/toJson, null fields, edge cases
  • test/v3/models/annotation_test.dart — Annotation serialization
  • test/v3/models/task_for_replica_test.dart — TaskForReplica model

Database (test/v3/db/)

  • test/v3/db/task_database_test.dart — open, CRUD operations (sqflite FFI)
  • test/v3/db/update_test.dart — migration/update logic

Network (test/v3/net/)

  • test/v3/net/add_task_test.dart
  • test/v3/net/complete_test.dart
  • test/v3/net/delete_test.dart
  • test/v3/net/fetch_test.dart
  • test/v3/net/modify_test.dart
  • test/v3/net/origin_test.dart

Champion (test/v3/champion/)

  • test/v3/champion/replica_test.dart — sync logic with mocked DB and origin
Phase 3 — Controller Unit Tests (14 files in test/modules/controllers/)
  • home_controller_test.dart — filterTasks, updateTags, reactive state, search
  • splash_controller_test.dart — init flow, navigation state
  • taskc_details_controller_test.dart — task init from args, field mutation, save
  • settings_controller_test.dart — language change, directory pick, theme
  • widget_controller_test.dart
  • logs_controller_test.dart
  • about_controller_test.dart
  • detail_route_controller_test.dart
  • manage_task_server_controller_test.dart — server add/remove, connection test
  • reports_controller_test.dart
  • profile_controller_test.dart
  • permission_controller_test.dart
  • onboarding_controller_test.dart
  • manage_task_champion_creds_controller_test.dart

Acceptance Criteria
  • flutter test test/v3/ passes with all 12 v3 tests green
  • flutter test test/modules/controllers/ passes with all 14 controller tests green
  • flutter test full suite passes without regression
  • Each controller test covers: onInit state, at least 2 state-mutating methods, and error/edge cases
Implementation Notes
  • No new pub dependencies needed — mockito and sqflite_ffi are already in pubspec.yaml
  • Reference existing patterns in test/api_service_test.dart (mock setup) and test/models/json/task_test.dart (model tests)
  • All 14 controllers extend GetxController — use Get.testMode = true per test group
  • v3 net tests should mock http.Client via @GenerateMocks([http.Client])
Labels

testing good first issue help wanted v3 controllers

Linguagem predominante
Dart
Estrelas
246
Forks
184
Métricas de merge de PRs
Nenhum PR com merge em 30d

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de CCExtractor/taskwarrior-flutter

Todas as issues de CCExtractor/taskwarrior-flutter

Issues semelhantes

Mais issues de Dart

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.