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.
This commit is contained in:
Ankit Mahato
2025-08-31 20:13:45 +05:30
parent 0050634e09
commit 8810dc3a35
2 changed files with 10 additions and 2 deletions

View File

@@ -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

View File

@@ -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);
});