mirror of
https://github.com/lingble/chatwoot.git
synced 2025-11-02 12:08:01 +00:00
chore: Update data format for platform API feature management (#5718)
Updated JSON data format for Platform API for account creation update API endpoints features flags to accept false values on each feature. fixes: #5717
This commit is contained in:
@@ -42,29 +42,28 @@ RSpec.describe 'Platform Accounts API', type: :request do
|
||||
json_response = JSON.parse(response.body)
|
||||
expect(json_response['name']).to eq('Test Account')
|
||||
expect(json_response['locale']).to eq('es')
|
||||
expect(json_response['enabled_features']).to eq(
|
||||
{
|
||||
'agent_management' => true
|
||||
}
|
||||
)
|
||||
expect(json_response['enabled_features']['agent_management']).to be(true)
|
||||
end
|
||||
|
||||
it 'creates an account with feature flags' do
|
||||
InstallationConfig.where(name: 'ACCOUNT_LEVEL_FEATURE_DEFAULTS').first_or_create!(value: [{ 'name' => 'inbox_management',
|
||||
'enabled' => true },
|
||||
{ 'name' => 'disable_branding',
|
||||
'enabled' => true }])
|
||||
|
||||
post '/platform/api/v1/accounts', params: { name: 'Test Account', enabled_features: %w[feature_ip_lookup feature_help_center] },
|
||||
headers: { api_access_token: platform_app.access_token.token }, as: :json
|
||||
post '/platform/api/v1/accounts', params: { name: 'Test Account', features: {
|
||||
ip_lookup: true,
|
||||
help_center: true,
|
||||
disable_branding: false
|
||||
|
||||
} }, headers: { api_access_token: platform_app.access_token.token }, as: :json
|
||||
|
||||
json_response = JSON.parse(response.body)
|
||||
expect(json_response['name']).to include('Test Account')
|
||||
expect(json_response['enabled_features']).to eq(
|
||||
{
|
||||
'inbox_management' => true,
|
||||
'ip_lookup' => true,
|
||||
'help_center' => true
|
||||
}
|
||||
)
|
||||
expect(json_response['enabled_features']['inbox_management']).to be(true)
|
||||
expect(json_response['enabled_features']['ip_lookup']).to be(true)
|
||||
expect(json_response['enabled_features']['help_center']).to be(true)
|
||||
expect(json_response['enabled_features']['disable_branding']).to be_nil
|
||||
end
|
||||
|
||||
it 'creates an account with limits settings' do
|
||||
@@ -141,19 +140,25 @@ RSpec.describe 'Platform Accounts API', type: :request do
|
||||
|
||||
it 'updates an account when its permissible object' do
|
||||
create(:platform_app_permissible, platform_app: platform_app, permissible: account)
|
||||
account.enable_features!('inbox_management', 'channel_facebook')
|
||||
|
||||
patch "/platform/api/v1/accounts/#{account.id}", params: {
|
||||
name: 'Test Account',
|
||||
enabled_features: %w[feature_ip_lookup feature_help_center],
|
||||
features: {
|
||||
ip_lookup: true,
|
||||
help_center: true,
|
||||
channel_facebook: false
|
||||
},
|
||||
limits: { agents: 5, inboxes: 10 }
|
||||
}, headers: { api_access_token: platform_app.access_token.token }, as: :json
|
||||
|
||||
expect(response).to have_http_status(:success)
|
||||
expect(account.reload.name).to eq('Test Account')
|
||||
expect(account.reload.enabled_features['ip_lookup']).to be(true)
|
||||
expect(account.reload.enabled_features['help_center']).to be(true)
|
||||
expect(account.reload.limits['agents']).to eq(5)
|
||||
expect(account.reload.limits['inboxes']).to eq(10)
|
||||
account.reload
|
||||
expect(account.name).to eq('Test Account')
|
||||
expect(account.enabled_features.keys).to match_array(%w[inbox_management ip_lookup help_center])
|
||||
expect(account.enabled_features['channel_facebook']).to be_nil
|
||||
expect(account.limits['agents']).to eq(5)
|
||||
expect(account.limits['inboxes']).to eq(10)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user