diff --git a/app/controllers/claims/support/mailers_controller.rb b/app/controllers/claims/support/mailers_controller.rb
new file mode 100644
index 0000000000..e8ba54d17d
--- /dev/null
+++ b/app/controllers/claims/support/mailers_controller.rb
@@ -0,0 +1,7 @@
+class Claims::Support::MailersController < Claims::Support::ApplicationController
+ before_action :skip_authorization
+
+ def index
+ @previews = ActionMailer::Preview.all.filter { |preview| preview.preview_name.start_with?("claims/") }
+ end
+end
diff --git a/app/views/claims/support/mailers/index.html.erb b/app/views/claims/support/mailers/index.html.erb
new file mode 100644
index 0000000000..5043c10a25
--- /dev/null
+++ b/app/views/claims/support/mailers/index.html.erb
@@ -0,0 +1,15 @@
+<% render "claims/support/primary_navigation", current: :settings %>
+
+
+
Email Previews
+
+ <% @previews.each do |mailer| %>
+ <%= mailer.preview_name.delete_prefix("claims/").titleize %>
+
+ <% email_links = mailer.emails.map do |email| %>
+ <% govuk_link_to(email, url_for(controller: "/rails/mailers", action: :preview, path: "#{mailer.preview_name}/#{email}"), no_visited_state: true, new_tab: true) %>
+ <% end %>
+
+ <%= govuk_list email_links, type: :bullet %>
+ <% end %>
+
diff --git a/app/views/claims/support/settings/index.html.erb b/app/views/claims/support/settings/index.html.erb
index 156c486b1f..ed6f9d9820 100644
--- a/app/views/claims/support/settings/index.html.erb
+++ b/app/views/claims/support/settings/index.html.erb
@@ -8,6 +8,7 @@
<%= govuk_list [
govuk_link_to("Background Jobs", "/good_job", no_visited_state: true, new_tab: true),
+ govuk_link_to("Emails", claims_support_mailers_path, no_visited_state: true),
], spaced: true %>
diff --git a/config/application.rb b/config/application.rb
index feb9bd958d..c565bc5f9b 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -36,6 +36,9 @@ class Application < Rails::Application
"node_modules/govuk-frontend/dist/govuk/assets",
)
+ config.action_mailer.show_previews = true
+ config.action_mailer.preview_paths << Rails.root.join("spec/mailers/previews").to_s
+
config.view_component.preview_paths << Rails.root.join("spec/components/previews").to_s
config.view_component.default_preview_layout = "component_preview"
diff --git a/config/routes/claims.rb b/config/routes/claims.rb
index 26026b01fa..682b7c9cea 100644
--- a/config/routes/claims.rb
+++ b/config/routes/claims.rb
@@ -108,5 +108,7 @@
end
get :settings, to: "settings#index"
+
+ resources :mailers, only: :index
end
end
diff --git a/spec/mailers/previews/claims/support_user_mailer_preview.rb b/spec/mailers/previews/claims/support_user_mailer_preview.rb
new file mode 100644
index 0000000000..d51e4e6074
--- /dev/null
+++ b/spec/mailers/previews/claims/support_user_mailer_preview.rb
@@ -0,0 +1,9 @@
+class Claims::SupportUserMailerPreview < ActionMailer::Preview
+ def support_user_invitation
+ SupportUserMailer.with(service: :claims).support_user_invitation(Claims::SupportUser.first)
+ end
+
+ def support_user_removal_notification
+ SupportUserMailer.with(service: :claims).support_user_removal_notification(Claims::SupportUser.first)
+ end
+end
diff --git a/spec/mailers/previews/claims/user_mailer_preview.rb b/spec/mailers/previews/claims/user_mailer_preview.rb
new file mode 100644
index 0000000000..553c11c053
--- /dev/null
+++ b/spec/mailers/previews/claims/user_mailer_preview.rb
@@ -0,0 +1,17 @@
+class Claims::UserMailerPreview < ActionMailer::Preview
+ def user_membership_created_notification
+ UserMailer.with(service: :claims).user_membership_created_notification(Claims::User.first, Claims::School.first)
+ end
+
+ def user_membership_destroyed_notification
+ UserMailer.with(service: :claims).user_membership_destroyed_notification(Claims::User.first, Claims::School.first)
+ end
+
+ def claim_submitted_notification
+ UserMailer.with(service: :claims).claim_submitted_notification(Claims::User.first, Claims::Claim.submitted.first)
+ end
+
+ def claim_created_support_notification
+ UserMailer.with(service: :claims).claim_created_support_notification(Claims::Claim.draft.first, Claims::User.first)
+ end
+end
diff --git a/spec/system/claims/support/view_emails_spec.rb b/spec/system/claims/support/view_emails_spec.rb
new file mode 100644
index 0000000000..ad56328bd3
--- /dev/null
+++ b/spec/system/claims/support/view_emails_spec.rb
@@ -0,0 +1,39 @@
+require "rails_helper"
+
+RSpec.describe "View Emails", service: :claims, type: :system do
+ let(:support_user) { create(:claims_support_user) }
+
+ before do
+ user_exists_in_dfe_sign_in(user: support_user)
+ given_i_sign_in
+ end
+
+ scenario "User visits the emails page" do
+ when_i_visit_the_emails_page
+ then_i_can_see_the_list_of_claims_email_templates
+ end
+
+ private
+
+ def given_i_sign_in
+ visit sign_in_path
+ click_on "Sign in using DfE Sign In"
+ end
+
+ def when_i_visit_the_emails_page
+ click_on "Settings"
+ click_on "Emails"
+ end
+
+ def then_i_can_see_the_list_of_claims_email_templates
+ expect(page).to have_content("Support User Mailer")
+ expect(page).to have_link("support_user_invitation (opens in new tab)", href: "/rails/mailers/claims/support_user_mailer/support_user_invitation")
+ expect(page).to have_link("support_user_removal_notification (opens in new tab)", href: "/rails/mailers/claims/support_user_mailer/support_user_removal_notification")
+
+ expect(page).to have_content("User Mailer")
+ expect(page).to have_link("claim_created_support_notification (opens in new tab)", href: "/rails/mailers/claims/user_mailer/claim_created_support_notification")
+ expect(page).to have_link("claim_submitted_notification (opens in new tab)", href: "/rails/mailers/claims/user_mailer/claim_submitted_notification")
+ expect(page).to have_link("user_membership_created_notification (opens in new tab)", href: "/rails/mailers/claims/user_mailer/user_membership_created_notification")
+ expect(page).to have_link("user_membership_destroyed_notification (opens in new tab)", href: "/rails/mailers/claims/user_mailer/user_membership_destroyed_notification")
+ end
+end