diff --git a/app/javascript/dashboard/constants/globals.js b/app/javascript/dashboard/constants/globals.js index 889ece96a..6d68824e4 100644 --- a/app/javascript/dashboard/constants/globals.js +++ b/app/javascript/dashboard/constants/globals.js @@ -40,6 +40,8 @@ export default { DOCS_URL: 'https://www.chatwoot.com/docs/product/', HELP_CENTER_DOCS_URL: 'https://www.chatwoot.com/docs/product/others/help-center', + APP_STORE_REVIEWS_INBOX_DOCS_URL: + 'https://www.chatwoot.com/hc/user-guide/articles/app-store-reviews-inbox', TESTIMONIAL_URL: 'https://testimonials.cdn.chatwoot.com/testimonial-content.json', WHATSAPP_EMBEDDED_SIGNUP_DOCS_URL: diff --git a/app/javascript/dashboard/i18n/locale/en/inboxMgmt.json b/app/javascript/dashboard/i18n/locale/en/inboxMgmt.json index f6ed9e288..ff57373b9 100644 --- a/app/javascript/dashboard/i18n/locale/en/inboxMgmt.json +++ b/app/javascript/dashboard/i18n/locale/en/inboxMgmt.json @@ -387,6 +387,7 @@ "APP_STORE": { "TITLE": "App Store Reviews", "DESC": "Manage and reply to your App Store reviews from Chatwoot.", + "LEARN_MORE": "Learn how to create App Store Connect credentials", "CHANNEL_NAME": { "LABEL": "Inbox Name", "PLACEHOLDER": "Please enter an inbox name", diff --git a/app/javascript/dashboard/routes/dashboard/settings/inbox/channels/AppStore.vue b/app/javascript/dashboard/routes/dashboard/settings/inbox/channels/AppStore.vue index 6eb5b6073..e6279b734 100644 --- a/app/javascript/dashboard/routes/dashboard/settings/inbox/channels/AppStore.vue +++ b/app/javascript/dashboard/routes/dashboard/settings/inbox/channels/AppStore.vue @@ -1,75 +1,71 @@ - @@ -79,6 +75,15 @@ export default { :header-title="$t('INBOX_MGMT.ADD.APP_STORE.TITLE')" :header-content="$t('INBOX_MGMT.ADD.APP_STORE.DESC')" /> + + {{ $t('INBOX_MGMT.ADD.APP_STORE.LEARN_MORE') }} + +
'Bearer first-token' }, + query: { include: 'response', limit: '200', sort: '-createdDate' } + ) + .to_return( + status: 200, + body: { + data: [], + links: { + next: 'https://api.appstoreconnect.apple.com/v1/apps/123456789/customerReviews?page=2' + } + }.to_json, + headers: { 'Content-Type' => 'application/json' } + ) + + stub_request(:get, 'https://api.appstoreconnect.apple.com/v1/apps/123456789/customerReviews?page=2') + .with(headers: { 'Authorization' => 'Bearer second-token' }) + .to_return( + status: 200, + body: { data: [] }.to_json, + headers: { 'Content-Type' => 'application/json' } + ) + + described_class.new(channel: channel).fetch_reviews + + expect(AppStoreConnect::TokenService).to have_received(:new).twice + end end describe '#create_review_response' do @@ -108,14 +143,21 @@ RSpec.describe AppStoreConnect::Client do describe '#update_review_response' do it 'updates an existing response' do - stub_request(:patch, 'https://api.appstoreconnect.apple.com/v1/customerReviewResponses/response-1') + stub_request(:post, 'https://api.appstoreconnect.apple.com/v1/customerReviewResponses') .with( body: { data: { type: 'customerReviewResponses', - id: 'response-1', attributes: { responseBody: 'Updated response' + }, + relationships: { + review: { + data: { + type: 'customerReviews', + id: 'review-1' + } + } } } }.to_json @@ -126,7 +168,7 @@ RSpec.describe AppStoreConnect::Client do headers: { 'Content-Type' => 'application/json' } ) - response = described_class.new(channel: channel).update_review_response('response-1', 'Updated response') + response = described_class.new(channel: channel).update_review_response('review-1', 'Updated response') expect(response['id']).to eq('response-1') end diff --git a/spec/services/app_store_connect/token_service_spec.rb b/spec/services/app_store_connect/token_service_spec.rb index d644080da..5c9b217b3 100644 --- a/spec/services/app_store_connect/token_service_spec.rb +++ b/spec/services/app_store_connect/token_service_spec.rb @@ -36,5 +36,21 @@ RSpec.describe AppStoreConnect::TokenService do expect(described_class.new(channel: channel).token).to eq('cached-token') end + + it 'generates a token before the channel is persisted' do + new_channel = instance_double( + Channel::AppStore, + id: nil, + updated_at: nil, + issuer_id: 'issuer-id', + key_id: 'key-id', + private_key: private_key + ) + + token = described_class.new(channel: new_channel).token + payload, = JWT.decode(token, nil, false) + + expect(payload['iss']).to eq('issuer-id') + end end end