DEV: Add a watched-words/mini_racer perf regression spec (#26341)

/t/121361
This commit is contained in:
Jarek Radosz 2024-03-25 13:35:02 +01:00 committed by GitHub
parent 9c110ccbd8
commit 0aec53ee9b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1954,6 +1954,39 @@ HTML
describe "watched words - replace & link" do
after { Discourse.redis.flushdb }
# Makes sure that mini_racer/libv8-node env doesn't regress
it "finishes in a timely matter" do
sql = 1500.times.map { |i| <<~SQL }.join
INSERT INTO watched_words
(created_at, updated_at, word, action, replacement)
VALUES
(
:now,
:now,
'word_#{i}',
:action,
'replacement_#{i}'
);
SQL
DB.exec(sql, now: Time.current, action: WatchedWord.actions[:replace])
Fabricate(
:watched_word,
action: WatchedWord.actions[:replace],
word: "nope",
replacement: "yep",
)
# Due to a bug in node 18.16 and lower this takes about 11s.
# On node 18.19 and newer it takes about 250ms
expect do
Timeout.timeout(3) do
expect(PrettyText.cook("abc nope def")).to match_html("<p>abc yep def</p>")
end
end.not_to raise_error
end
it "replaces words with other words" do
Fabricate(
:watched_word,