REFACTOR: Remove `.erb` file from javascript tests

REFACTOR: Remove .erb file from javascript tests

We can’t use erb in Ember CLI (since it does not have Ruby) so this has been ported to use our javascript:update_constants rake test instead.

Note we don’t have to run this every time a notification type as it’s only used by fixtures to fill in some specific types we test against.

diff --git a/app/assets/javascripts/discourse/tests/fixtures/concerns/notification-types.js b/app/assets/javascripts/discourse/tests/fixtures/concerns/notification-types.js
new file mode 100644
index 0000000..222a849
--- /dev/null
+++ b/app/assets/javascripts/discourse/tests/fixtures/concerns/notification-types.js
@@ -0,0 +1,34 @@
+// DO NOT EDIT THIS FILE!!!
+// Update it by running `rake javascript:update_constants`
+
+
+export const NOTIFICATION_TYPES = {
+  mentioned: 1,
+  replied: 2,
+  quoted: 3,
+  edited: 4,
+  liked: 5,
+  private_message: 6,
+  invited_to_private_message: 7,
+  invitee_accepted: 8,
+  posted: 9,
+  moved_post: 10,
+  linked: 11,
+  granted_badge: 12,
+  invited_to_topic: 13,
+  custom: 14,
+  group_mentioned: 15,
+  group_message_summary: 16,
+  watching_first_post: 17,
+  topic_reminder: 18,
+  liked_consolidated: 19,
+  post_approved: 20,
+  code_review_commit_approved: 21,
+  membership_request_accepted: 22,
+  membership_request_consolidated: 23,
+  bookmark_reminder: 24,
+  reaction: 25,
+  votes_released: 26,
+  event_reminder: 27,
+  event_invitation: 28,
+};
diff --git a/app/assets/javascripts/discourse/tests/fixtures/concerns/notification-types.js.erb b/app/assets/javascripts/discourse/tests/fixtures/concerns/notification-types.js.erb
deleted file mode 100644
index d7a4023..0000000
--- a/app/assets/javascripts/discourse/tests/fixtures/concerns/notification-types.js.erb
+++ /dev/null
@@ -1 +0,0 @@
-export const NOTIFICATION_TYPES = <%= Notification.types.to_json %>;
diff --git a/lib/tasks/javascript.rake b/lib/tasks/javascript.rake
index a2a3a29..27ba82f 100644
--- a/lib/tasks/javascript.rake
+++ b/lib/tasks/javascript.rake
@@ -168,6 +168,16 @@ task 'javascript:update_constants' => :environment do
     export const SEARCH_PHRASE_REGEXP = '#{Search::PHRASE_MATCH_REGEXP_PATTERN}';
   JS
 
+  pretty_notifications = Notification.types.map do |n|
+    "  #{n[0]}: #{n[1]},"
+  end.join("\n")
+
+  write_template("discourse/tests/fixtures/concerns/notification-types.js", task_name, <<~JS)
+    export const NOTIFICATION_TYPES = {
+    #{pretty_notifications}
+    };
+  JS
+
   write_template("pretty-text/addon/emoji/data.js", task_name, <<~JS)
     export const emojis = #{Emoji.standard.map(&:name).flatten.inspect};
     export const tonableEmojis = #{Emoji.tonable_emojis.flatten.inspect};

GitHub sha: 4a8f5dbf

This commit appears in #10873 which was merged by eviltrout.