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: from.length == 1
|
||||||
? from.first
|
? from.first
|
||||||
: null,
|
: null,
|
||||||
notKeyword: notKeyword.length == 1
|
|
||||||
? notKeyword.first
|
|
||||||
: null,
|
|
||||||
hasKeyword: hasKeyword.length == 1
|
hasKeyword: hasKeyword.length == 1
|
||||||
? hasKeyword.first
|
? hasKeyword.first
|
||||||
: null,
|
: null,
|
||||||
@@ -127,7 +124,7 @@ class SearchEmailFilter with EquatableMixin, OptionParamMixin {
|
|||||||
Operator.OR,
|
Operator.OR,
|
||||||
from.map((e) => EmailFilterCondition(from: e)).toSet(),
|
from.map((e) => EmailFilterCondition(from: e)).toSet(),
|
||||||
),
|
),
|
||||||
if (notKeyword.length > 1)
|
if (notKeyword.isNotEmpty)
|
||||||
LogicFilterOperator(
|
LogicFilterOperator(
|
||||||
Operator.NOT,
|
Operator.NOT,
|
||||||
notKeyword.map((e) => EmailFilterCondition(text: e)).toSet(),
|
notKeyword.map((e) => EmailFilterCondition(text: e)).toSet(),
|
||||||
|
|||||||
@@ -164,6 +164,26 @@ void main() {
|
|||||||
expect(logicOperator.operator, Operator.AND);
|
expect(logicOperator.operator, Operator.AND);
|
||||||
expect(logicOperator.conditions.length, greaterThan(1));
|
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