2024-09-17 02:43:34 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
describe "Admin Notices", type: :system do
|
|
|
|
let(:admin_dashboard) { PageObjects::Pages::AdminDashboard.new }
|
|
|
|
|
|
|
|
before do
|
|
|
|
Fabricate(:admin_notice)
|
|
|
|
|
|
|
|
I18n.backend.store_translations(:en, dashboard: { problem: { test_notice: "Houston" } })
|
2024-10-07 01:14:01 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
context "when signed in as admin" do
|
|
|
|
fab!(:admin)
|
|
|
|
|
|
|
|
before { sign_in(admin) }
|
|
|
|
|
|
|
|
it "supports dismissing admin notices" do
|
|
|
|
admin_dashboard.visit
|
|
|
|
|
|
|
|
expect(admin_dashboard).to have_admin_notice(I18n.t("dashboard.problem.test_notice"))
|
|
|
|
|
|
|
|
admin_dashboard.dismiss_notice(I18n.t("dashboard.problem.test_notice"))
|
2024-09-17 02:43:34 -04:00
|
|
|
|
2024-10-07 01:14:01 -04:00
|
|
|
expect(admin_dashboard).to have_no_admin_notice(I18n.t("dashboard.problem.test_notice"))
|
|
|
|
end
|
2024-09-17 02:43:34 -04:00
|
|
|
end
|
|
|
|
|
2024-10-07 01:14:01 -04:00
|
|
|
context "when signed in as moderator" do
|
|
|
|
fab!(:moderator)
|
2024-09-17 02:43:34 -04:00
|
|
|
|
2024-10-07 01:14:01 -04:00
|
|
|
before { sign_in(moderator) }
|
2024-09-17 02:43:34 -04:00
|
|
|
|
2024-10-07 01:14:01 -04:00
|
|
|
it "doesn't render dismiss button on admin notices" do
|
|
|
|
admin_dashboard.visit
|
2024-09-17 02:43:34 -04:00
|
|
|
|
2024-10-07 01:14:01 -04:00
|
|
|
expect(admin_dashboard).to have_admin_notice(I18n.t("dashboard.problem.test_notice"))
|
|
|
|
expect(admin_dashboard).to have_no_css(
|
|
|
|
".dashboard-problem .btn",
|
|
|
|
text: I18n.t("admin_js.admin.dashboard.dismiss_notice"),
|
|
|
|
)
|
|
|
|
end
|
2024-09-17 02:43:34 -04:00
|
|
|
end
|
|
|
|
end
|