From 8810dc3a35a8ebba80b3b7e268d4df0e3fc9b61f Mon Sep 17 00:00:00 2001 From: Ankit Mahato Date: Sun, 31 Aug 2025 20:13:45 +0530 Subject: [PATCH] Fix SettingsModel equality for defaultAIModel map Replaces direct comparison of defaultAIModel with mapEquals to ensure deep equality. Updates related tests to include defaultAIModel in test cases for serialization, deserialization, copyWith, and toString. --- lib/models/settings_model.dart | 3 ++- test/models/settings_model_test.dart | 9 ++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/models/settings_model.dart b/lib/models/settings_model.dart index c876279d..b3222bf0 100644 --- a/lib/models/settings_model.dart +++ b/lib/models/settings_model.dart @@ -1,4 +1,5 @@ import 'package:apidash_core/apidash_core.dart'; +import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:apidash/consts.dart'; @@ -213,7 +214,7 @@ class SettingsModel { other.workspaceFolderPath == workspaceFolderPath && other.isSSLDisabled == isSSLDisabled && other.isDashBotEnabled == isDashBotEnabled && - other.defaultAIModel == defaultAIModel; + mapEquals(other.defaultAIModel, defaultAIModel); } @override diff --git a/test/models/settings_model_test.dart b/test/models/settings_model_test.dart index 3a7827d5..0ea7746a 100644 --- a/test/models/settings_model_test.dart +++ b/test/models/settings_model_test.dart @@ -19,6 +19,7 @@ void main() { workspaceFolderPath: null, isSSLDisabled: true, isDashBotEnabled: true, + defaultAIModel: {"model": "llama"}, ); test('Testing toJson()', () { @@ -38,6 +39,7 @@ void main() { "workspaceFolderPath": null, "isSSLDisabled": true, "isDashBotEnabled": true, + "defaultAIModel": {"model": "llama"} }; expect(sm.toJson(), expectedResult); }); @@ -59,6 +61,7 @@ void main() { "workspaceFolderPath": null, "isSSLDisabled": true, "isDashBotEnabled": true, + "defaultAIModel": {"model": "llama"} }; expect(SettingsModel.fromJson(input), sm); }); @@ -77,6 +80,7 @@ void main() { historyRetentionPeriod: HistoryRetentionPeriod.oneWeek, isSSLDisabled: false, isDashBotEnabled: false, + defaultAIModel: {"model": "llama"}, ); expect( sm.copyWith( @@ -104,7 +108,10 @@ void main() { "historyRetentionPeriod": "oneWeek", "workspaceFolderPath": null, "isSSLDisabled": true, - "isDashBotEnabled": true + "isDashBotEnabled": true, + "defaultAIModel": { + "model": "llama" + } }'''; expect(sm.toString(), expectedResult); });