A platform for community discussion. Free, open, simple.
DEV: Fix and unskip CSV export specs (#39289)
Jarek Radosz8ba60d5bcad8
diff --git a/plugins/chat/spec/system/admin/csv_exports_spec.rb b/plugins/chat/spec/system/admin/csv_exports_spec.rbindex 8e180598217..73289fccc02 100644--- a/plugins/chat/spec/system/admin/csv_exports_spec.rb+++ b/plugins/chat/spec/system/admin/csv_exports_spec.rb@@ -12,9 +12,6 @@ RSpec.describe "Admin Chat CSV exports" doendit "exports chat messages" do- original_save_path = Capybara.save_path- Capybara.save_path = Downloads::FOLDER-Jobs.run_immediately!message_1 = Fabricate(:chat_message, created_at: 12.months.ago)message_2 = Fabricate(:chat_message, created_at: 6.months.ago)@@ -56,7 +53,6 @@ RSpec.describe "Admin Chat CSV exports" doassert_message(exported_data.fourth, message_3)assert_message(exported_data.fifth, message_4)ensure- Capybara.save_path = original_save_pathcsv_export_pm_page.clear_downloadsenddiff --git a/spec/system/csv_exports_spec.rb b/spec/system/csv_exports_spec.rbindex 531d46bbd04..37585037cb4 100644--- a/spec/system/csv_exports_spec.rb+++ b/spec/system/csv_exports_spec.rb@@ -17,42 +17,38 @@ RSpec.describe "CSV Exports" doFabricate(:user,title: "dr",- last_seen_at: Time.now,- last_posted_at: Time.now,- last_emailed_at: Time.now,+ last_seen_at: Time.current,+ last_posted_at: Time.current,+ last_emailed_at: Time.current,approved: true,- suspended_at: Time.now,- suspended_till: Time.now,- silenced_till: Time.now,+ suspended_at: Time.current,+ suspended_till: Time.current,+ silenced_till: Time.current,admin: true,moderator: true,staged: true,group_ids: [group1.id, group2.id],)end- let(:second_email) { "[email protected]" }- let(:third_email) { "[email protected]" }before do- user.user_emails.create!(email: second_email)- user.user_emails.create!(email: third_email)-- user.user_stat.topics_entered = 111- user.user_stat.posts_read_count = 112- user.user_stat.time_read = 113- user.user_stat.topic_count = 114- user.user_stat.post_count = 115- user.user_stat.likes_given = 116- user.user_stat.likes_received = 117- user.user_stat.save!-- user.user_profile.location = "Tbilisi"- user.user_profile.website = "https://www.discourse.org"- user.user_profile.views = 5- user.user_profile.save!+ user.user_emails.create!(email: "[email protected]")+ user.user_emails.create!(email: "[email protected]")++ user.user_stat.update!(+ topics_entered: 111,+ posts_read_count: 112,+ time_read: 113,+ topic_count: 114,+ post_count: 115,+ likes_given: 116,+ likes_received: 117,+ )++ user.user_profile.update!(location: "Tbilisi", website: "https://www.discourse.org", views: 5)end- xit "exports data" do+ it "exports data" dovisit "admin/users/list/active"click_button "Export"@@ -61,7 +57,6 @@ RSpec.describe "CSV Exports" doexpect(csv_export_pm_page).to have_download_linkexported_data = csv_export_pm_page.download_and_extract- expect(exported_data.length).to be(5)expect(exported_data.first).to eq(%w[id@@ -97,7 +92,7 @@ RSpec.describe "CSV Exports" dogroup_names],)- expect(exported_data.last).to eq(+ expect(exported_data.find { |row| row[0] == user.id.to_s }).to eq([user.id.to_s,user.name,@@ -118,7 +113,7 @@ RSpec.describe "CSV Exports" douser.moderator.to_s,user.ip_address.to_s,user.staged.to_s,- "#{second_email};#{third_email}",user.user_stat.topics_entered.to_s,user.user_stat.posts_read_count.to_s,user.user_stat.time_read.to_s,@@ -137,7 +132,7 @@ RSpec.describe "CSV Exports" doendend- context "with stuff actions log" do+ context "with staff actions log" dofab!(:user_history) doFabricate(:user_history,@@ -149,7 +144,7 @@ RSpec.describe "CSV Exports" do)end- xit "exports data" do+ it "exports data" dovisit "admin/logs/staff_action_logs"click_button "Export"@@ -181,7 +176,7 @@ RSpec.describe "CSV Exports" doFabricate(:bookmark)end- xit "exports the Bookmarks report" do+ it "exports the Bookmarks report" dovisit "admin/reports/bookmarks"click_button "Export"@@ -192,7 +187,7 @@ RSpec.describe "CSV Exports" doexpect(exported_data.length).to be(2)expect(exported_data.first).to eq(%w[Day Count])- expect(exported_data.second).to eq([Time.now.strftime("%Y-%m-%d"), "1"])+ expect(exported_data.second).to eq([Time.current.strftime("%Y-%m-%d"), "1"])ensurecsv_export_pm_page.clear_downloadsend@@ -202,7 +197,7 @@ RSpec.describe "CSV Exports" dofab!(:screened_email_1, :screened_email)fab!(:screened_email_2, :screened_email)- xit "exports data" do+ it "exports data" dovisit "admin/logs/screened_emails"click_button "Export"@@ -215,13 +210,13 @@ RSpec.describe "CSV Exports" doexpect(exported_data.first).to eq(%w[email action match_count last_match_at created_at ip_address],)- assert_export(exported_data.second, screened_email_2)- assert_export(exported_data.third, screened_email_1)+ assert_exported_row(exported_data.second, screened_email_2)+ assert_exported_row(exported_data.third, screened_email_1)ensurecsv_export_pm_page.clear_downloadsend- def assert_export(exported_email, email)+ def assert_exported_row(exported_email, email)expect(exported_email).to eq([email.email,@@ -239,7 +234,7 @@ RSpec.describe "CSV Exports" dofab!(:screened_ip_1, :screened_ip_address)fab!(:screened_ip_2, :screened_ip_address)- xit "exports data" do+ it "exports data" dovisit "admin/logs/screened_ip_addresses"click_button "Export"@@ -269,18 +264,9 @@ RSpec.describe "CSV Exports" doendcontext "with screened urls" do- fab!(:screened_url) do- Fabricate(- :screened_url,- action_type: ScreenedUrl.actions[:do_nothing],- match_count: 5,- domain: "https://discourse.org",- last_match_at: Time.now,- created_at: Time.now,- )- end+ fab!(:screened_url) { Fabricate(:screened_url, last_match_at: Time.current) }- xit "exports data" do+ it "exports data" dovisit "admin/logs/screened_urls"click_button "Export"diff --git a/spec/system/page_objects/pages/csv_export_pm.rb b/spec/system/page_objects/pages/csv_export_pm.rbindex 2c73dc380dd..aa0fe4ab8ba 100644--- a/spec/system/page_objects/pages/csv_export_pm.rb+++ b/spec/system/page_objects/pages/csv_export_pm.rb@@ -9,6 +9,9 @@ module PageObjectsenddef download_and_extract+ original_save_path = Capybara.save_path+ Capybara.save_path = Downloads::FOLDER+click_link ".zip"Downloads.wait_for_download@@ -19,6 +22,8 @@ module PageObjectscsv_path = unzip(zip_path).first@downloaded_files << csv_pathCSV.read(csv_path)+ ensure+ Capybara.save_path = original_save_pathenddef clear_downloads