1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-02-20 14:54:15 +01:00

(bug) ES not synced during tests

This commit is contained in:
Sylvain 2022-11-17 16:59:33 +01:00
parent 4e531c280f
commit c684b892a7
3 changed files with 11 additions and 0 deletions

View File

@ -1,5 +1,7 @@
# Changelog Fab-manager
- Fix a bug: some automated tests were randomly failing because ElasticSearch was not synced
## v5.5.4 2022 November 17
- Fix a bug: unable to download an existing export of the statistics

View File

@ -12,6 +12,7 @@ class Exports::StatisticsExportTest < ActionDispatch::IntegrationTest
end
test 'export machine reservations statistics to Excel' do
Stats::Machine.refresh_index!
# Build the stats for the June 2015, a machine reservation should have happened at the time
::Statistics::BuilderService.generate_statistic({ start_date: '2015-06-01'.to_date.beginning_of_day,
end_date: '2015-06-30'.to_date.end_of_day })
@ -35,6 +36,7 @@ class Exports::StatisticsExportTest < ActionDispatch::IntegrationTest
assert_not_nil e, 'Export was not created in database'
# Run the worker
Stats::Machine.refresh_index!
worker = StatisticsExportWorker.new
worker.perform(e.id)
@ -69,6 +71,7 @@ class Exports::StatisticsExportTest < ActionDispatch::IntegrationTest
end
test 'export global statistics to Excel' do
Stats::Machine.refresh_index!
# Build the stats for the June 2015
::Statistics::BuilderService.generate_statistic({ start_date: '2015-06-01'.to_date.beginning_of_day,
end_date: '2015-06-30'.to_date.end_of_day })

View File

@ -91,6 +91,10 @@ class ReservationSubscriptionStatisticServiceTest < ActionDispatch::IntegrationT
]
}.to_json, headers: default_headers
Stats::Machine.refresh_index!
Stats::Training.refresh_index!
Stats::Subscription.refresh_index!
# Build the stats for the last 3 days, we expect the above invoices (reservations+subscription) to appear in the resulting stats
::Statistics::BuilderService.generate_statistic({ start_date: 2.days.ago.beginning_of_day,
end_date: DateTime.current.end_of_day })
@ -126,6 +130,8 @@ class ReservationSubscriptionStatisticServiceTest < ActionDispatch::IntegrationT
check_statistics_on_user(stat_hour)
# training
Stats::Training.refresh_index!
stat_training = Stats::Training.search(query: { bool: { must: [{ term: { date: 1.day.ago.to_date.iso8601 } },
{ term: { type: 'booking' } }] } }).first
assert_not_nil stat_training