## 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
52 lines
1.7 KiB
Ruby
52 lines
1.7 KiB
Ruby
require 'rails_helper'
|
|
|
|
RSpec.describe TeamMember do
|
|
include ActiveJob::TestHelper
|
|
|
|
describe 'associations' do
|
|
it { is_expected.to belong_to(:team) }
|
|
it { is_expected.to belong_to(:user) }
|
|
end
|
|
|
|
describe 'filtered unread count invalidation' do
|
|
let(:account) { create(:account) }
|
|
let(:team) { create(:team, 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 team access is added' do
|
|
expect do
|
|
create(:team_member, team: team, 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 team access is removed' do
|
|
team_member = create(:team_member, team: team, user: user)
|
|
|
|
expect do
|
|
team_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 team is removed' do
|
|
create(:team_member, team: team, user: user)
|
|
|
|
expect do
|
|
perform_enqueued_jobs { team.destroy! }
|
|
end.to change { store.built_in_filter_version(account_id: account.id, user_id: user.id) }.by(1)
|
|
end
|
|
|
|
it 'invalidates saved filter snapshots when the parent team is removed' do
|
|
create(:conversation, account: account, team: team)
|
|
|
|
expect do
|
|
perform_enqueued_jobs { team.destroy! }
|
|
end.to change { store.conversation_version(account.id) }.by(1)
|
|
end
|
|
end
|
|
end
|