TF-3621 Fix search return wrong result if searching with option "Doesn't have"
Signed-off-by: dab246 <tdvu@linagora.com>
This commit is contained in:
@@ -109,9 +109,6 @@ class SearchEmailFilter with EquatableMixin, OptionParamMixin {
|
||||
from: from.length == 1
|
||||
? from.first
|
||||
: null,
|
||||
notKeyword: notKeyword.length == 1
|
||||
? notKeyword.first
|
||||
: null,
|
||||
hasKeyword: hasKeyword.length == 1
|
||||
? hasKeyword.first
|
||||
: null,
|
||||
@@ -127,7 +124,7 @@ class SearchEmailFilter with EquatableMixin, OptionParamMixin {
|
||||
Operator.OR,
|
||||
from.map((e) => EmailFilterCondition(from: e)).toSet(),
|
||||
),
|
||||
if (notKeyword.length > 1)
|
||||
if (notKeyword.isNotEmpty)
|
||||
LogicFilterOperator(
|
||||
Operator.NOT,
|
||||
notKeyword.map((e) => EmailFilterCondition(text: e)).toSet(),
|
||||
|
||||
@@ -164,6 +164,26 @@ void main() {
|
||||
expect(logicOperator.operator, Operator.AND);
|
||||
expect(logicOperator.conditions.length, greaterThan(1));
|
||||
});
|
||||
|
||||
test('SHOULD wrap a simple EmailFilterCondition inside a NOT LogicFilterOperator when notKeyword is given', () {
|
||||
// Arrange
|
||||
final filter = SearchEmailFilter(
|
||||
notKeyword: {'hello'},
|
||||
);
|
||||
|
||||
// Act
|
||||
final result = filter.mappingToEmailFilterCondition();
|
||||
|
||||
// Assert
|
||||
expect(result, isA<LogicFilterOperator>());
|
||||
final logicFilter = result as LogicFilterOperator;
|
||||
expect(result.conditions.isNotEmpty, isTrue);
|
||||
expect(logicFilter.operator, equals(Operator.NOT));
|
||||
|
||||
final emailCondition = result.conditions.first as EmailFilterCondition;
|
||||
expect(emailCondition.text, 'hello');
|
||||
expect(emailCondition.notKeyword, isNull);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user