Skip to content

Unit and template tests#39

Merged
Arjun544 merged 14 commits into
mainfrom
unit-and-template-tests
May 22, 2026
Merged

Unit and template tests#39
Arjun544 merged 14 commits into
mainfrom
unit-and-template-tests

Conversation

@Arjun544
Copy link
Copy Markdown
Owner

@Arjun544 Arjun544 commented May 22, 2026

Summary by CodeRabbit

  • New Features

    • Added custom font upload support in the project wizard with drag-and-drop functionality
    • Added dotenv configuration support for environment variables
    • Added comprehensive testing guide documentation
  • Bug Fixes & Improvements

    • Improved error handling and validation in generated Flutter projects
    • Enhanced responsive design support for generated widgets
    • Fixed package imports and export handling across state management options
  • Documentation

    • Added detailed testing guide covering test layers and validation strategies

@vercel
Copy link
Copy Markdown

vercel Bot commented May 22, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
flutter-init Ready Ready Preview, Comment May 22, 2026 4:31am

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 22, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 10a0ba5d-9ea0-4384-b395-9334a85eefc1

📥 Commits

Reviewing files that changed from the base of the PR and between 6cde10e and a8c5535.

⛔ Files ignored due to path filters (2)
  • bun.lock is excluded by !**/*.lock
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (79)
  • .github/workflows/test-tier1.yml
  • .github/workflows/test-tier2.yml
  • .github/workflows/test-tier3.yml
  • .gitignore
  • CONTRIBUTING.md
  • README.md
  • app/api/generate/route.ts
  • app/components/landing/StatsSection.tsx
  • app/components/wizard/WizardShell.tsx
  • app/components/wizard/steps/BackendStep.tsx
  • app/components/wizard/steps/ThemeStep.tsx
  • app/lib/config/schema.ts
  • app/lib/generator/handlebars.ts
  • app/lib/generator/index.ts
  • app/lib/state/useWizardStore.tsx
  • components/ui/select.tsx
  • docs/testing.md
  • package.json
  • scripts/validate-dart.ts
  • templates/flutter/base/lib/main.dart.hbs
  • templates/flutter/base/lib/src/config/app_config.dart.hbs
  • templates/flutter/base/lib/src/imports/core_imports.dart.hbs
  • templates/flutter/base/lib/src/imports/packages_imports.dart.hbs
  • templates/flutter/base/lib/src/routing/app_router.dart.hbs
  • templates/flutter/base/lib/src/services/services.dart.hbs
  • templates/flutter/base/lib/src/shared/widgets/app_button.dart.hbs
  • templates/flutter/base/lib/src/shared/widgets/app_card.dart.hbs
  • templates/flutter/base/lib/src/shared/widgets/app_empty_state.dart.hbs
  • templates/flutter/base/lib/src/shared/widgets/app_icon.dart.hbs
  • templates/flutter/base/lib/src/shared/widgets/app_loading.dart.hbs
  • templates/flutter/base/lib/src/shared/widgets/app_top_bar.dart.hbs
  • templates/flutter/base/lib/src/shared/widgets/common_image.dart.hbs
  • templates/flutter/base/lib/src/shared/wrappers/(isRiverpod,isProvider,isBloc,isGetX,isMobX)@state_wrapper.dart.hbs``
  • templates/flutter/base/lib/src/shared/wrappers/(supportsLocalization)@localization_wrapper.dart.hbs``
  • templates/flutter/base/lib/src/shared/wrappers/(usesScreenutil)@screen_util_wrapper.dart.hbs``
  • templates/flutter/base/lib/src/shared/wrappers/(usesSkeletonizer)@skeleton_wrapper.dart.hbs``
  • templates/flutter/base/lib/src/shared/wrappers/session_listener_wrapper.dart.hbs
  • templates/flutter/base/lib/src/theme/text_theme.dart.hbs
  • templates/flutter/base/lib/src/theme/theme.dart.hbs
  • templates/flutter/base/pubspec.yaml.hbs
  • templates/flutter/base/test/widget_test.dart.hbs
  • templates/flutter/overlays/architecture/layer-first/lib/src/presentation/providers/(isNoneState)@auth_view_model.dart.hbs``
  • templates/flutter/overlays/backend/appwrite/lib/src/services/(usesAppwriteAuth)@auth_service.dart.hbs``
  • templates/flutter/overlays/backend/custom/lib/src/services/auth_service.dart.hbs
  • templates/flutter/overlays/extras/dotenv/.env.hbs
  • templates/flutter/partials/features/auth/auth_logic.hbs
  • templates/flutter/partials/features/auth/forgot_password_screen.hbs
  • templates/flutter/partials/features/auth/login_screen.hbs
  • templates/flutter/partials/features/auth/session_provider.hbs
  • templates/flutter/partials/features/auth/signup_screen.hbs
  • templates/flutter/partials/features/home/home_page.hbs
  • templates/flutter/partials/features/onboarding/onboarding_page.hbs
  • tests/e2e/dart-validation.spec.ts
  • tests/e2e/run-matrix.ts
  • tests/e2e/validate-combo.ts
  • tests/generator.spec.ts
  • tests/integration/full-pipeline.spec.ts
  • tests/integration/overlay-composition.spec.ts
  • tests/reporters/failed-tests-reporter.ts
  • tests/unit/backend.spec.ts
  • tests/unit/handlebars-helpers.spec.ts
  • tests/unit/matrix-shard-1.spec.ts
  • tests/unit/matrix-shard-2.spec.ts
  • tests/unit/matrix-shard-3.spec.ts
  • tests/unit/matrix-shard-4.spec.ts
  • tests/unit/misc-flags.spec.ts
  • tests/unit/navigation.spec.ts
  • tests/unit/state-management.spec.ts
  • tests/unit/theme.spec.ts
  • tests/utils/assertions.ts
  • tests/utils/combinations.ts
  • tests/utils/config-builder.ts
  • tests/utils/critical-combos.ts
  • tests/utils/generate.ts
  • tests/utils/matrix-tests.ts
  • tests/utils/matrix.config.ts
  • tests/utils/misc-profiles.ts
  • vitest.config.ts
  • vitest.e2e.config.ts

📝 Walkthrough

Walkthrough

This PR introduces custom font upload and management capabilities end-to-end (from drag-drop UI through generated Flutter theme output) alongside comprehensive multi-layer testing infrastructure (CI workflows, test utilities, test suites, and e2e validators covering 375 configuration combinations).

Changes

Custom Font Support & Testing Infrastructure

Layer / File(s) Summary
Font Configuration Schema & Types
app/lib/config/schema.ts
New font constants (SUPPORTED_FONT_EXTENSIONS, FONT_MAX_SIZE_BYTES), enums (fontStyleSchema, fontWeightSchema), helper (deriveFontFamily), and customFontEntrySchema model. Theme schema extended with customFonts array. usesDotenv changed from z.literal(true) to z.boolean().default(true) for optional dotenv.
Frontend Font Upload & Wizard State
app/components/wizard/steps/ThemeStep.tsx, app/lib/state/useWizardStore.tsx
ThemeStep UI adds drag-drop file upload with validation (extension/size checks), error banner, and FontCard subcomponent displaying family/weight/style metadata with remove action. WizardStore manages in-memory fontFiles map alongside persisted config.theme.customFonts metadata (excluded from localStorage).
API & Generator Font Integration
app/api/generate/route.ts, app/lib/generator/index.ts, app/components/wizard/WizardShell.tsx
POST handler accepts multipart/form-data instead of JSON; reads config string and collects font file entries. generateFlutterScaffold receives optional fontEntries and writes them into assets/fonts/. buildTemplateContext groups fonts by family and exposes hasCustomFonts, primaryFontFamily, and fontFamilies array. WizardShell sends multipart FormData with config + font blobs.
Theme Templates with Custom Fonts
templates/flutter/base/lib/src/theme/text_theme.dart.hbs, templates/flutter/base/lib/src/theme/theme.dart.hbs, templates/flutter/base/pubspec.yaml.hbs
buildTextTheme() conditionally applies custom fontFamily when hasCustomFonts. ThemeData and CupertinoTextThemeData conditionally include primary font family. Pubspec conditionally adds fonts: section with family/asset/weight/style iteration when custom fonts enabled.
Responsive Sizing & Widget Templates
templates/flutter/base/lib/src/shared/widgets/*, templates/flutter/base/pubspec.yaml.hbs
Handlebars res helper simplified for number formatting. Widget templates (app_button, app_card, app_empty_state, app_loading, app_top_bar, common_image, onboarding_page) add conditional screenutil-scaled sizing (.w, .h). Pubspec: auto_route bumped to ^11.1.0, Riverpod upgraded to 3.2.1, flutter_hooks conditional, test_api override for Riverpod. Services export HTTP/Dio conditionally (mutually exclusive).
Router & Wrapper Refactoring
templates/flutter/base/lib/src/routing/app_router.dart.hbs, templates/flutter/base/lib/src/shared/wrappers/*
AppRouter refactored to @AutoRouterConfig with routes as AutoRoute[] (removes manual route-info classes). StateWrapper uses typed generics. LocalizationWrapper always wraps with EasyLocalization. ScreenUtilWrapper always generated. SessionListenerWrapper conditionally excludes packages_imports for NoneState.
Auth Flow Lifecycle Safety
templates/flutter/partials/features/auth/auth_logic.hbs, templates/flutter/partials/features/auth/{login,signup,forgot_password}_screen.hbs, templates/flutter/partials/features/auth/session_provider.hbs, templates/flutter/partials/features/home/home_page.hbs
All auth error/success toasts guarded with context.mounted (or event.context.mounted for Bloc) across Riverpod/Bloc/Provider/GetX/MobX branches. MobX _AuthStoreSessionStoreBase rename. Login/signup/forgot-password setState calls mount-guarded. SessionProvider imports from imports.dart instead of packages_imports.dart. HomePage refactors session/user derivation to defer reactive access for GetX/MobX.
Package Imports & Exports
templates/flutter/base/lib/src/imports/{packages_imports,core_imports}.dart.hbs, templates/flutter/base/lib/src/config/app_config.dart.hbs, templates/flutter/base/lib/main.dart.hbs, templates/flutter/base/test/widget_test.dart.hbs, app/components/wizard/steps/BackendStep.tsx
Riverpod exports now include /legacy.dart (removes prior hide). MobX adds symbol hides (version, StringExtension, Action, Listener, Listenable). AutoRoute hides Cupertino transition symbols. HTTP export hides MultipartFile/Response when Dio enabled. FlutterNativeSplash export conditional. AppIcon type narrowed from dynamic to IconData. Font styling BackendStep/ThemeStep: font-semibold → font-medium. Select component adds font-normal.
CI Workflows (Tier 1, 2, 3)
.github/workflows/test-tier1.yml, .github/workflows/test-tier2.yml, .github/workflows/test-tier3.yml
Tier 1: pushes (non-main) + manual, runs Layer 1 unit tests, uploads failure logs. Tier 2: PRs to main + pushes (non-main) + manual, runs Layer 1 then Layer 2 sequentially (Flutter setup), uploads failure logs. Tier 3: pushes to main + manual, runs Layer 1, prepares chunked matrix, runs e2e in parallel by chunk, gate job verifies both layers.
Test Utilities
tests/utils/{assertions,combinations,config-builder,critical-combos,generate,matrix-tests,matrix.config,misc-profiles}.ts
Shared assertion helpers (token/empty/required/deps/pubspec/architecture/content validation). Cartesian product generator for dimensions. Config builder from combo + misc profile. 25 hardcoded critical combos. Generate to in-memory map or disk. Matrix test runner for parameterized combo suites. Dimension arrays (ARCHITECTURES, STATE_OPTIONS, BACKEND_OPTIONS, NAVIGATION_OPTIONS) + PRIMARY_COMBINATIONS (375 total). Misc profiles (bare-minimum, default, all-on, high-risk) + safeProfile for custom backend validation.
Test Suites
tests/unit/{backend,handlebars-helpers,matrix-shard-[1-4],misc-flags,navigation,state-management,theme}.spec.ts, tests/integration/{full-pipeline,overlay-composition}.spec.ts
Backend: dependency presence/absence per provider. Handlebars helpers: case conversion, boolean logic, res sizing, when conditional, json, indent. Matrix shards 1–4: split PRIMARY_COMBINATIONS (0–93, 93–186, 186–279, 279+). Misc flags: feature toggles (screenutil, hooks, hive, dio, shared_prefs, storage, splash, localization, dotenv). Navigation: go_router, auto_route, imperative. State management: riverpod, provider, bloc, mobx, none wrapper validation. Theme: presets and custom font rendering. Full pipeline: token/file/pubspec/structure validation across critical combos. Overlay composition: state/backend/localization/networking/storage/architecture overlay verification.
E2E Validators & Reporter
tests/e2e/{dart-validation,validate-combo,run-matrix}.ts, tests/reporters/failed-tests-reporter.ts, .github/workflows/test-tier{1,2,3}.yml
Dart-validation: runs critical combos through Dart pub/analyze. Validate-combo: single combo generator + dart pub/build_runner/analyze with exit codes. Run-matrix: orchestrates combos via validate-combo, logs progress/timing, exits 1 on failure. Failed-tests-reporter: collects Vitest failures, writes failed-tests.log, clears on pass.
Test Configuration & Documentation
vitest.config.ts, vitest.e2e.config.ts, docs/testing.md, CONTRIBUTING.md, README.md, .gitignore, package.json
Vitest default config excludes e2e, sets timeouts, uses failed-tests-reporter, controls parallelism. E2E config restricts to tests/e2e, longer timeouts, no parallelism, @ alias. Testing guide documents Layer 1/2 model, 375 combos, test structure, CI tiers, preflight, debugging, checklist. CONTRIBUTING adds test-gate PR checklist. README claims quality via matrix validation + testing guide link. .gitignore ignores /dev_out/, tests/results/, etc. package.json adds test:unit/integration/layer1/layer2/tier3/preflight/gate scripts.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes


Possibly related PRs

  • Arjun544/flutter_init#35: Introduces the same CI workflows (test-tier1, test-tier2, test-tier3) with overlapping job structure and artifact handling.
  • Arjun544/flutter_init#34: Modifies app/lib/generator/index.ts to extend TemplateContext.flags and buildTemplateContext for conditional template rendering.
  • Arjun544/flutter_init#27: Modifies app/components/landing/StatsSection.tsx fetch configuration, overlapping with this PR's cache option removal.

🐰 Custom fonts now flutter forth,
Testing towers stand so tall,
Layouts scale with grace, and all—
One grand init, rich and forthright! 🎨✨

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch unit-and-template-tests

@Arjun544 Arjun544 merged commit 41163a8 into main May 22, 2026
6 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant