mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: Add a watched-words/mini_racer perf regression spec (#26341)
/t/121361
This commit is contained in:
parent
9c110ccbd8
commit
0aec53ee9b
@ -1954,6 +1954,39 @@ HTML
|
|||||||
describe "watched words - replace & link" do
|
describe "watched words - replace & link" do
|
||||||
after { Discourse.redis.flushdb }
|
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
|
it "replaces words with other words" do
|
||||||
Fabricate(
|
Fabricate(
|
||||||
:watched_word,
|
:watched_word,
|
||||||
|
Loading…
Reference in New Issue
Block a user