Files
assistant-storefront/spec/enterprise/models/sla_event_spec.rb
Liang XJ 092fb2e083
Some checks failed
Lock Threads / action (push) Has been cancelled
Mark stale issues and pull requests / stale (push) Has been cancelled
Publish Chatwoot EE docker images / build (linux/amd64, ubuntu-latest) (push) Has been cancelled
Publish Chatwoot EE docker images / build (linux/arm64, ubuntu-22.04-arm) (push) Has been cancelled
Publish Chatwoot EE docker images / merge (push) Has been cancelled
Publish Chatwoot CE docker images / build (linux/amd64, ubuntu-latest) (push) Has been cancelled
Publish Chatwoot CE docker images / build (linux/arm64, ubuntu-22.04-arm) (push) Has been cancelled
Publish Chatwoot CE docker images / merge (push) Has been cancelled
Run Chatwoot CE spec / lint-backend (push) Has been cancelled
Run Chatwoot CE spec / lint-frontend (push) Has been cancelled
Run Chatwoot CE spec / frontend-tests (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (0, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (1, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (10, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (11, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (12, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (13, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (14, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (15, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (2, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (3, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (4, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (5, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (6, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (7, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (8, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (9, 16) (push) Has been cancelled
Run Linux nightly installer / nightly (push) Has been cancelled
Initial commit: Add logistics and order_detail message types
- Add Logistics component with progress tracking
- Add OrderDetail component for order information
- Support data-driven steps and actions
- Add blue color scale to widget SCSS
- Fix node overflow and progress bar rendering issues
- Add English translations for dashboard components

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-01-26 11:16:56 +08:00

77 lines
2.9 KiB
Ruby

require 'rails_helper'
RSpec.describe SlaEvent, type: :model do
describe 'associations' do
it { is_expected.to belong_to(:applied_sla) }
it { is_expected.to belong_to(:conversation) }
it { is_expected.to belong_to(:account) }
it { is_expected.to belong_to(:sla_policy) }
it { is_expected.to belong_to(:inbox) }
end
describe 'push_event_data' do
it 'returns the correct hash' do
sla_event = create(:sla_event)
expect(sla_event.push_event_data).to eq(
{
id: sla_event.id,
event_type: 'frt',
meta: sla_event.meta,
created_at: sla_event.created_at.to_i,
updated_at: sla_event.updated_at.to_i
}
)
end
end
describe 'validates_factory' do
it 'creates valid sla event object' do
sla_event = create(:sla_event)
expect(sla_event.event_type).to eq 'frt'
end
end
describe 'backfilling ids' do
it 'automatically backfills account_id, inbox_id, and sla_id upon creation' do
sla_event = create(:sla_event)
expect(sla_event.account_id).to eq sla_event.conversation.account_id
expect(sla_event.inbox_id).to eq sla_event.conversation.inbox_id
expect(sla_event.sla_policy_id).to eq sla_event.applied_sla.sla_policy_id
end
end
describe 'create notifications' do
# create account, user and inbox
let!(:account) { create(:account) }
let!(:assignee) { create(:user, account: account) }
let!(:participant) { create(:user, account: account) }
let!(:admin) { create(:user, account: account, role: :administrator) }
let!(:inbox) { create(:inbox, account: account) }
let(:conversation) { create(:conversation, inbox: inbox, assignee: assignee, account: account) }
let(:sla_policy) { create(:sla_policy, account: conversation.account) }
let(:sla_event) { create(:sla_event, event_type: 'frt', conversation: conversation, sla_policy: sla_policy) }
before do
# to ensure notifications are not sent to other users
create(:user, account: account)
create(:inbox_member, inbox: inbox, user: participant)
create(:conversation_participant, conversation: conversation, user: participant)
end
it 'creates notifications for conversation participants, admins, and assignee' do
sla_event
expect(Notification.count).to eq(3)
# check if notification type is sla_missed_first_response
expect(Notification.where(notification_type: 'sla_missed_first_response').count).to eq(3)
# Check if notification is created for the assignee
expect(Notification.where(user_id: assignee.id).count).to eq(1)
# Check if notification is created for the account admin
expect(Notification.where(user_id: admin.id).count).to eq(1)
# Check if notification is created for participant
expect(Notification.where(user_id: participant.id).count).to eq(1)
end
end
end