Skip to content

Fix dart tests#1248

Open
Fellmonkey wants to merge 7 commits intoappwrite:masterfrom
Fellmonkey:fix-dart-tests
Open

Fix dart tests#1248
Fellmonkey wants to merge 7 commits intoappwrite:masterfrom
Fellmonkey:fix-dart-tests

Conversation

@Fellmonkey
Copy link
Contributor

@Fellmonkey Fellmonkey commented Nov 4, 2025

What does this PR do?

  1. Enhanced test data generation for response models to use generic data structures when multiple models are present, while maintaining specific type expectations for single-model cases.
  2. Removed unnecessary server test intended for the client

This ensures that generated tests use valid enum values for properties with enums, preventing runtime errors during test execution.

Test Plan

regenerate sdk and run dart test

also push changes and ensure the GitHub Actions workflow for Dart SDK completes successfully with all tests passing. #1247

before:
image
image
after:
{7AD8E36C-F2DB-45FC-887E-CD8B0C5C9ECA}

Have you read the Contributing Guidelines on issues?

Yes

Summary by CodeRabbit

  • Tests
    • Enhanced test data generation for response models to use generic data structures when multiple models are present, while maintaining specific type expectations for single-model cases.

Updates Dart test template to use the first enum value for string properties with enums when generating test data, instead of always using the example value. This ensures generated test data is valid for properties with restricted enum values.
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 4, 2025

📝 Walkthrough

Walkthrough

A template file for generating Dart service tests has been updated to handle response model types conditionally. When multiple response models exist, the generated test expects a Map<String, dynamic> instead of a specific model type. When only one response model exists, the specific model type is still expected.

Changes

Cohort / File(s) Summary
Dart Test Template
templates/dart/test/services/service_test.dart.twig
Modified test data generation logic to expect Map<String, dynamic> for multiple response models, while preserving specific model type expectations for single response model scenarios.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Poem

🐰 Four lines of code, so neat and small,
A template tweak that handles them all,
When models multiply, a Map takes flight,
But one stays loyal, specific and tight! ✨

🚥 Pre-merge checks | ✅ 3 | ❌ 1
❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'Fix dart tests' is vague and generic, failing to specify which aspect of Dart tests is being fixed or what the actual change is. Use a more descriptive title that specifies the fix, such as 'Fix Dart tests by using valid enum values for string properties' or 'Ensure Dart tests use valid enum values in mock data'.
✅ Passed checks (3 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Merge Conflict Detection ✅ Passed ✅ No merge conflicts detected when merging into master
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Fellmonkey
Copy link
Contributor Author

{F22D911D-7C4F-4580-992B-260C53E694C2}

Updated the Dart service test template to check for Map<String, dynamic> when multiple response models are present, improving test accuracy for methods with multiple possible response types.
@Fellmonkey
Copy link
Contributor Author

commit -> failed test
image
image

Previously, the examples for the messaging service were invalid, but now everything is fine, I have restored the logic.
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