forked from clairton/chatwoot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
revert: "fix:
message_type
inconsistency across message end points" (…
…chatwoot#10119) Reverts chatwoot#10108
- Loading branch information
Showing
13 changed files
with
22 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,21 +13,6 @@ | |
Widget::TokenService.new(payload: { source_id: second_session.source_id, inbox_id: web_widget.inbox.id }).generate_token | ||
end | ||
|
||
def conversation_params | ||
{ | ||
website_token: web_widget.website_token, | ||
contact: { | ||
name: 'contact-name', | ||
email: '[email protected]', | ||
phone_number: '+919745313456' | ||
}, | ||
message: { | ||
content: 'This is a test message' | ||
}, | ||
custom_attributes: { order_id: '12345' } | ||
} | ||
end | ||
|
||
describe 'GET /api/v1/widget/conversations' do | ||
context 'with a conversation' do | ||
it 'returns the correct conversation params' do | ||
|
@@ -62,10 +47,21 @@ def conversation_params | |
end | ||
|
||
describe 'POST /api/v1/widget/conversations' do | ||
it 'creates a conversation with correct details' do | ||
it 'creates a conversation' do | ||
post '/api/v1/widget/conversations', | ||
headers: { 'X-Auth-Token' => token }, | ||
params: conversation_params, | ||
params: { | ||
website_token: web_widget.website_token, | ||
contact: { | ||
name: 'contact-name', | ||
email: '[email protected]', | ||
phone_number: '+919745313456' | ||
}, | ||
message: { | ||
content: 'This is a test message' | ||
}, | ||
custom_attributes: { order_id: '12345' } | ||
}, | ||
as: :json | ||
|
||
expect(response).to have_http_status(:success) | ||
|
@@ -74,19 +70,8 @@ def conversation_params | |
expect(json_response['contact']['email']).to eq '[email protected]' | ||
expect(json_response['contact']['phone_number']).to eq '+919745313456' | ||
expect(json_response['contact']['name']).to eq 'contact-name' | ||
end | ||
|
||
it 'creates a conversation with correct message and custom attributes' do | ||
post '/api/v1/widget/conversations', | ||
headers: { 'X-Auth-Token' => token }, | ||
params: conversation_params, | ||
as: :json | ||
|
||
expect(response).to have_http_status(:success) | ||
json_response = response.parsed_body | ||
expect(json_response['custom_attributes']['order_id']).to eq '12345' | ||
expect(json_response['messages'][0]['content']).to eq 'This is a test message' | ||
expect(json_response['messages'][0]['message_type']).to eq 0 | ||
end | ||
|
||
it 'create a conversation with a name and without an email' do | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters