Fix: Added the backend validation for name (#3878)
- Added the backend validation for name - Add message size constraint
This commit is contained in:
@@ -387,6 +387,18 @@ RSpec.describe 'Contacts API', type: :request do
|
||||
expect(json_response['payload']['contact']['custom_attributes']).to eq({ 'test' => 'test', 'test1' => 'test1' })
|
||||
end
|
||||
|
||||
it 'does not create the contact' do
|
||||
valid_params[:contact][:name] = 'test' * 999
|
||||
|
||||
post "/api/v1/accounts/#{account.id}/contacts", headers: admin.create_new_auth_token,
|
||||
params: valid_params
|
||||
|
||||
expect(response).to have_http_status(:unprocessable_entity)
|
||||
|
||||
json_response = JSON.parse(response.body)
|
||||
expect(json_response['message']).to eq('Name is too long (maximum is 255 characters)')
|
||||
end
|
||||
|
||||
it 'creates the contact inbox when inbox id is passed' do
|
||||
expect do
|
||||
post "/api/v1/accounts/#{account.id}/contacts", headers: admin.create_new_auth_token,
|
||||
|
||||
@@ -35,6 +35,21 @@ RSpec.describe 'Conversation Messages API', type: :request do
|
||||
expect(conversation.messages.first.content).to eq(params[:content])
|
||||
end
|
||||
|
||||
it 'does not create the message' do
|
||||
params = { content: "#{'h' * 150 * 1000}a", private: true }
|
||||
|
||||
post api_v1_account_conversation_messages_url(account_id: account.id, conversation_id: conversation.display_id),
|
||||
params: params,
|
||||
headers: agent.create_new_auth_token,
|
||||
as: :json
|
||||
|
||||
expect(response).to have_http_status(:unprocessable_entity)
|
||||
|
||||
json_response = JSON.parse(response.body)
|
||||
|
||||
expect(json_response['error']).to eq('Validation failed: Content is too long (maximum is 150000 characters)')
|
||||
end
|
||||
|
||||
it 'creates an outgoing text message with a specific bot sender' do
|
||||
agent_bot = create(:agent_bot)
|
||||
time_stamp = Time.now.utc.to_s
|
||||
|
||||
Reference in New Issue
Block a user