fix: Conversation filter on dates (#5024)

This commit is contained in:
Tejaswini Chile
2022-07-13 10:08:24 +05:30
committed by GitHub
parent 8f8a1813bf
commit d7be0ea08e
2 changed files with 87 additions and 20 deletions

View File

@@ -58,13 +58,15 @@ describe ::Conversations::FilterService do
attribute_key: 'browser_language',
filter_operator: 'contains',
values: 'en',
query_operator: 'AND'
query_operator: 'AND',
custom_attribute_type: ''
}.with_indifferent_access,
{
attribute_key: 'status',
filter_operator: 'not_equal_to',
values: %w[resolved],
query_operator: nil
query_operator: nil,
custom_attribute_type: ''
}.with_indifferent_access
]
end
@@ -94,13 +96,15 @@ describe ::Conversations::FilterService do
user_1.id,
user_2.id
],
query_operator: 'AND'
query_operator: 'AND',
custom_attribute_type: ''
}.with_indifferent_access,
{
attribute_key: 'labels',
filter_operator: 'equal_to',
values: ['support'],
query_operator: nil
query_operator: nil,
custom_attribute_type: ''
}.with_indifferent_access
]
result = filter_service.new(params, user_1).perform
@@ -116,13 +120,15 @@ describe ::Conversations::FilterService do
user_1.id,
user_2.id
],
query_operator: 'AND'
query_operator: 'AND',
custom_attribute_type: ''
}.with_indifferent_access,
{
attribute_key: 'campaign_id',
filter_operator: 'is_present',
values: [],
query_operator: nil
query_operator: nil,
custom_attribute_type: ''
}.with_indifferent_access
]
result = filter_service.new(params, user_1).perform
@@ -150,7 +156,36 @@ describe ::Conversations::FilterService do
attribute_key: 'conversation_created',
filter_operator: 'is_less_than',
values: ['2022-01-20'],
query_operator: 'OR'
query_operator: 'OR',
custom_attribute_type: ''
}.with_indifferent_access,
{
attribute_key: 'labels',
filter_operator: 'equal_to',
values: ['support'],
query_operator: nil
}.with_indifferent_access
]
result = filter_service.new(params, user_1).perform
expect(result[:conversations].length).to be 1
expect(result[:conversations][0][:id]).to be user_2_assigned_conversation.id
end
it 'filter by custom_attributes and labels with custom_attribute_type nil' do
user_2_assigned_conversation.update_labels('support')
params[:payload] = [
{
attribute_key: 'conversation_type',
filter_operator: 'equal_to',
values: ['platinum'],
query_operator: 'AND'
}.with_indifferent_access,
{
attribute_key: 'conversation_created',
filter_operator: 'is_less_than',
values: ['2022-01-20'],
query_operator: 'OR',
custom_attribute_type: nil
}.with_indifferent_access,
{
attribute_key: 'labels',
@@ -170,13 +205,36 @@ describe ::Conversations::FilterService do
attribute_key: 'conversation_type',
filter_operator: 'equal_to',
values: ['platinum'],
query_operator: 'AND'
query_operator: 'AND',
custom_attribute_type: ''
}.with_indifferent_access,
{
attribute_key: 'conversation_created',
filter_operator: 'is_less_than',
values: ['2022-01-20'],
query_operator: nil
query_operator: nil,
custom_attribute_type: ''
}.with_indifferent_access
]
result = filter_service.new(params, user_1).perform
expect(result[:conversations].length).to be 1
end
it 'filter by custom_attributes with custom_attribute_type nil' do
params[:payload] = [
{
attribute_key: 'conversation_type',
filter_operator: 'equal_to',
values: ['platinum'],
query_operator: 'AND',
custom_attribute_type: nil
}.with_indifferent_access,
{
attribute_key: 'conversation_created',
filter_operator: 'is_less_than',
values: ['2022-01-20'],
query_operator: nil,
custom_attribute_type: nil
}.with_indifferent_access
]
result = filter_service.new(params, user_1).perform
@@ -189,13 +247,15 @@ describe ::Conversations::FilterService do
attribute_key: 'conversation_type',
filter_operator: 'equal_to',
values: ['platinum'],
query_operator: 'AND'
query_operator: 'AND',
custom_attribute_type: ''
}.with_indifferent_access,
{
attribute_key: 'browser_language',
filter_operator: 'is_equal_to',
values: 'en',
query_operator: nil
query_operator: nil,
custom_attribute_type: ''
}.with_indifferent_access
]
result = filter_service.new(params, user_1).perform
@@ -214,7 +274,8 @@ describe ::Conversations::FilterService do
attribute_key: 'created_at',
filter_operator: 'is_greater_than',
values: ['2022-01-20'],
query_operator: nil
query_operator: nil,
custom_attribute_type: ''
}.with_indifferent_access
]
result = filter_service.new(params, user_1).perform
@@ -228,13 +289,15 @@ describe ::Conversations::FilterService do
attribute_key: 'conversation_type',
filter_operator: 'equal_to',
values: ['platinum'],
query_operator: 'AND'
query_operator: 'AND',
custom_attribute_type: ''
}.with_indifferent_access,
{
attribute_key: 'created_at',
filter_operator: 'is_greater_than',
values: ['2022-01-20'],
query_operator: nil
query_operator: nil,
custom_attribute_type: ''
}.with_indifferent_access
]
result = filter_service.new(params, user_1).perform
@@ -257,13 +320,15 @@ describe ::Conversations::FilterService do
attribute_key: 'last_activity_at',
filter_operator: 'days_before',
values: [3],
query_operator: 'AND'
query_operator: 'AND',
custom_attribute_type: ''
}.with_indifferent_access,
{
attribute_key: 'conversation_type',
filter_operator: 'equal_to',
values: ['platinum'],
query_operator: nil
query_operator: nil,
custom_attribute_type: ''
}.with_indifferent_access
]
@@ -280,7 +345,8 @@ describe ::Conversations::FilterService do
attribute_key: 'last_activity_at',
filter_operator: 'days_before',
values: [3],
query_operator: nil
query_operator: nil,
custom_attribute_type: ''
}.with_indifferent_access
]