Feature: Add web push notification permission in frontend (#766)
Add webpush notification permission in frontend Co-authored-by: Sojan <sojan@pepalo.com>
This commit is contained in:
@@ -70,7 +70,7 @@ RSpec.describe 'Contacts API', type: :request do
|
||||
expect do
|
||||
post "/api/v1/accounts/#{account.id}/contacts", headers: admin.create_new_auth_token,
|
||||
params: valid_params
|
||||
end .to change(Contact, :count).by(1)
|
||||
end.to change(Contact, :count).by(1)
|
||||
|
||||
expect(response).to have_http_status(:success)
|
||||
end
|
||||
|
||||
@@ -17,14 +17,66 @@ RSpec.describe 'Notifications Subscriptions API', type: :request do
|
||||
|
||||
it 'creates a notification subscriptions' do
|
||||
post '/api/v1/notification_subscriptions',
|
||||
params: { notification_subscription: { subscription_type: 'browser_push', 'subscription_attributes': { test: 'test' } } },
|
||||
params: {
|
||||
notification_subscription: {
|
||||
subscription_type: 'browser_push',
|
||||
'subscription_attributes': {
|
||||
endpoint: 'test',
|
||||
p256dh: 'test',
|
||||
auth: 'test'
|
||||
}
|
||||
}
|
||||
},
|
||||
headers: agent.create_new_auth_token,
|
||||
as: :json
|
||||
|
||||
expect(response).to have_http_status(:success)
|
||||
json_response = JSON.parse(response.body)
|
||||
expect(json_response['subscription_type']).to eq('browser_push')
|
||||
expect(json_response['subscription_attributes']).to eq({ 'test' => 'test' })
|
||||
expect(json_response['subscription_attributes']['auth']).to eq('test')
|
||||
end
|
||||
|
||||
it 'returns existing notification subscription if subscription exists' do
|
||||
subscription = create(:notification_subscription, user: agent)
|
||||
post '/api/v1/notification_subscriptions',
|
||||
params: {
|
||||
notification_subscription: {
|
||||
subscription_type: 'browser_push',
|
||||
'subscription_attributes': {
|
||||
endpoint: 'test',
|
||||
p256dh: 'test',
|
||||
auth: 'test'
|
||||
}
|
||||
}
|
||||
},
|
||||
headers: agent.create_new_auth_token,
|
||||
as: :json
|
||||
|
||||
expect(response).to have_http_status(:success)
|
||||
json_response = JSON.parse(response.body)
|
||||
expect(json_response['id']).to eq(subscription.id)
|
||||
end
|
||||
|
||||
it 'move notification subscription to user if its of another user' do
|
||||
subscription = create(:notification_subscription, user: create(:user))
|
||||
post '/api/v1/notification_subscriptions',
|
||||
params: {
|
||||
notification_subscription: {
|
||||
subscription_type: 'browser_push',
|
||||
'subscription_attributes': {
|
||||
endpoint: 'test',
|
||||
p256dh: 'test',
|
||||
auth: 'test'
|
||||
}
|
||||
}
|
||||
},
|
||||
headers: agent.create_new_auth_token,
|
||||
as: :json
|
||||
|
||||
expect(response).to have_http_status(:success)
|
||||
json_response = JSON.parse(response.body)
|
||||
expect(json_response['id']).to eq(subscription.id)
|
||||
expect(json_response['user_id']).to eq(agent.id)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user