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.
This commit is contained in:
Robin Ward
2020-10-08 15:40:06 -04:00
parent ef7d99b0a8
commit 4a8f5dbfbd
3 changed files with 44 additions and 1 deletions

View File

@ -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};