## Description Adds the account-level `unread_count_for_filters` feature flag as the dark-launch gate for filtered sidebar unread counts. This reuses the deprecated `quoted_email_reply` flag slot, resets the reused bit for existing accounts, and removes stale defaults so new accounts do not reference the old flag. This also adds the feature where we are now calculating the unread counts for built in filters like mentions, participating and unattended along with unread count for saved filters/folders. Closes [CW-7262](https://linear.app/chatwoot/issue/CW-7262/unread-counts-for-filters-folders) ## Type of change - [ ] Bug fix (non-breaking change which fixes an issue) - [x] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality not to work as expected) - [ ] This change requires a documentation update
64 lines
2.1 KiB
Ruby
64 lines
2.1 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
require 'rails_helper'
|
|
|
|
RSpec.describe InboxMember do
|
|
include ActiveJob::TestHelper
|
|
|
|
describe '#DestroyAssociationAsyncJob' do
|
|
let(:inbox_member) { create(:inbox_member) }
|
|
|
|
# ref: https://github.com/chatwoot/chatwoot/issues/4616
|
|
context 'when parent inbox is destroyed' do
|
|
it 'enques and processes DestroyAssociationAsyncJob' do
|
|
perform_enqueued_jobs do
|
|
inbox_member.inbox.destroy!
|
|
end
|
|
expect { inbox_member.reload }.to raise_error(ActiveRecord::RecordNotFound)
|
|
end
|
|
end
|
|
end
|
|
|
|
describe 'filtered unread count invalidation' do
|
|
let(:account) { create(:account) }
|
|
let(:inbox) { create(:inbox, account: account) }
|
|
let(:user) { create(:user) }
|
|
let(:store) { Conversations::UnreadCounts::FilteredCountStore }
|
|
|
|
before do
|
|
account.enable_features!(:unread_count_for_filters)
|
|
end
|
|
|
|
it 'invalidates the user built-in filter version when inbox access is added' do
|
|
expect do
|
|
create(:inbox_member, inbox: inbox, user: user)
|
|
end.to change { store.built_in_filter_version(account_id: account.id, user_id: user.id) }.by(1)
|
|
end
|
|
|
|
it 'invalidates the user built-in filter version when inbox access is removed' do
|
|
inbox_member = create(:inbox_member, inbox: inbox, user: user)
|
|
|
|
expect do
|
|
inbox_member.destroy!
|
|
end.to change { store.built_in_filter_version(account_id: account.id, user_id: user.id) }.by(1)
|
|
end
|
|
|
|
it 'invalidates the user built-in filter version when the parent inbox is removed' do
|
|
create(:inbox_member, inbox: inbox, user: user)
|
|
|
|
expect do
|
|
perform_enqueued_jobs { inbox.destroy! }
|
|
end.to change { store.built_in_filter_version(account_id: account.id, user_id: user.id) }.by(1)
|
|
end
|
|
|
|
it 'invalidates administrator built-in filter versions when the parent inbox is removed' do
|
|
admin = create(:user)
|
|
create(:account_user, account: account, user: admin, role: :administrator)
|
|
|
|
expect do
|
|
perform_enqueued_jobs { inbox.destroy! }
|
|
end.to change { store.built_in_filter_version(account_id: account.id, user_id: admin.id) }.by(1)
|
|
end
|
|
end
|
|
end
|