chore: fix flaky spec (#7686)
- fix flaky reporting specs - fix flaky export spec
This commit is contained in:
parent
5598b4b27e
commit
6ab964b161
@ -9,7 +9,8 @@ describe V2::ReportBuilder do
|
||||
# Update this spec to use travel_to
|
||||
# This spec breaks in certain timezone
|
||||
describe '#timeseries' do
|
||||
before_all do
|
||||
before do
|
||||
travel_to(Time.zone.today) do
|
||||
user = create(:user, account: account)
|
||||
inbox = create(:inbox, account: account)
|
||||
create(:inbox_member, user: user, inbox: inbox)
|
||||
@ -52,6 +53,7 @@ describe V2::ReportBuilder do
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'when report type is account' do
|
||||
it 'return conversations count' do
|
||||
@ -100,6 +102,7 @@ describe V2::ReportBuilder do
|
||||
end
|
||||
|
||||
it 'return resolutions count' do
|
||||
travel_to(Time.zone.today) do
|
||||
params = {
|
||||
metric: 'resolutions_count',
|
||||
type: :account,
|
||||
@ -123,6 +126,7 @@ describe V2::ReportBuilder do
|
||||
expect(metrics[Time.zone.today]).to be 4
|
||||
expect(metrics[Time.zone.today - 2.days]).to be 0
|
||||
end
|
||||
end
|
||||
|
||||
it 'returns average first response time' do
|
||||
params = {
|
||||
@ -218,6 +222,7 @@ describe V2::ReportBuilder do
|
||||
end
|
||||
|
||||
it 'return resolutions count' do
|
||||
travel_to(Time.zone.today) do
|
||||
params = {
|
||||
metric: 'resolutions_count',
|
||||
type: :label,
|
||||
@ -243,6 +248,7 @@ describe V2::ReportBuilder do
|
||||
expect(metrics[Time.zone.today]).to be 4
|
||||
expect(metrics[Time.zone.today - 2.days]).to be 0
|
||||
end
|
||||
end
|
||||
|
||||
it 'returns average first response time' do
|
||||
label_2.reporting_events.update(value: 1.5)
|
||||
|
||||
@ -15,7 +15,7 @@ RSpec.describe 'Reports API', type: :request do
|
||||
|
||||
before do
|
||||
create_list(:conversation, 10, account: account, inbox: inbox,
|
||||
assignee: user, created_at: Time.zone.today)
|
||||
assignee: user, created_at: Time.current.in_time_zone(default_timezone).to_date)
|
||||
end
|
||||
|
||||
describe 'GET /api/v2/accounts/:account_id/reports/account' do
|
||||
|
||||
@ -37,15 +37,13 @@ RSpec.describe Account::ContactsExportJob do
|
||||
described_class.perform_now(account.id, [])
|
||||
|
||||
csv_data = CSV.parse(account.contacts_export.download, headers: true)
|
||||
first_row = csv_data[0]
|
||||
last_row = csv_data[csv_data.length - 1]
|
||||
first_contact = account.contacts.find_by(email: 'test1@text.example')
|
||||
last_contact = account.contacts.find_by(email: 'test2@text.example')
|
||||
emails = csv_data.pluck('email')
|
||||
phone_numbers = csv_data.pluck('phone_number')
|
||||
|
||||
expect(csv_data.length).to eq(account.contacts.count)
|
||||
|
||||
expect([first_row['email'], last_row['email']]).to contain_exactly(first_contact.email, last_contact.email)
|
||||
expect([first_row['phone_number'], last_row['phone_number']]).to contain_exactly(first_contact.phone_number, last_contact.phone_number)
|
||||
expect(emails).to include('test1@text.example', 'test2@text.example')
|
||||
expect(phone_numbers).to include('+910808080818', '+910808080808')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
Reference in New Issue
Block a user