From 788bcb7736f64af57e2fbd6e786db976d6252917 Mon Sep 17 00:00:00 2001 From: Martin Brennan Date: Fri, 23 Dec 2022 09:23:29 +1000 Subject: [PATCH] DEV: Fix hashtag system spec flakys (#19574) Honestly seems like it's being in some weird loop for discourse/hashtag_autocomplete_spec.rb for this: ```ruby within topic_page.post_by_number(2) do cooked_hashtags = page.all(".hashtag-cooked", count: 2) expect(cooked_hashtags[0]["outerHTML"]).to eq(<<~HTML.chomp) Cool Category HTML expect(cooked_hashtags[1]["outerHTML"]).to eq(<<~HTML.chomp) cooltag HTML end ``` I see this many times in the full logs with `SELENIUM_VERBOSE_DRIVER_LOGS=1`: ``` COMMAND FindElements { "using": "css selector", "value": "#post_2" } Followed by: COMMAND FindChildElements { "id": "26dfe542-659b-46cc-ac8c-a6c2d9cbdf0a", "using": "css selector", "value": ".hashtag-cooked" } ``` Over and over and over, there are 58 such occurrences. I am beginning to think `within` is just poison that should be avoided. --- .../spec/system/hashtag_autocomplete_spec.rb | 22 +++++++++---------- spec/system/hashtag_autocomplete_spec.rb | 17 ++++++-------- spec/system/page_objects/pages/topic.rb | 2 +- 3 files changed, 18 insertions(+), 23 deletions(-) diff --git a/plugins/chat/spec/system/hashtag_autocomplete_spec.rb b/plugins/chat/spec/system/hashtag_autocomplete_spec.rb index a69c783b483..ad613449436 100644 --- a/plugins/chat/spec/system/hashtag_autocomplete_spec.rb +++ b/plugins/chat/spec/system/hashtag_autocomplete_spec.rb @@ -60,18 +60,16 @@ describe "Using #hashtag autocompletion to search for and lookup channels", end expect(chat_channel_page).to have_message(id: message.id) - within chat_channel_page.message_by_id(message.id) do - cooked_hashtags = page.all(".hashtag-cooked", count: 3) + cooked_hashtags = page.all(".hashtag-cooked", count: 3) - expect(cooked_hashtags[0]["outerHTML"]).to eq(<<~HTML.chomp) - Random - HTML - expect(cooked_hashtags[1]["outerHTML"]).to eq(<<~HTML.chomp) - Raspberry - HTML - expect(cooked_hashtags[2]["outerHTML"]).to eq(<<~HTML.chomp) - razed - HTML - end + expect(cooked_hashtags[0]["outerHTML"]).to eq(<<~HTML.chomp) + Random + HTML + expect(cooked_hashtags[1]["outerHTML"]).to eq(<<~HTML.chomp) + Raspberry + HTML + expect(cooked_hashtags[2]["outerHTML"]).to eq(<<~HTML.chomp) + razed + HTML end end diff --git a/spec/system/hashtag_autocomplete_spec.rb b/spec/system/hashtag_autocomplete_spec.rb index 4366a156487..131c19d32fc 100644 --- a/spec/system/hashtag_autocomplete_spec.rb +++ b/spec/system/hashtag_autocomplete_spec.rb @@ -81,16 +81,13 @@ describe "Using #hashtag autocompletion to search for and lookup categories and topic_page.type_in_composer("this is a #cool-cat category and a #cooltag tag") topic_page.send_reply expect(topic_page).to have_post_number(2) + cooked_hashtags = page.all(".hashtag-cooked", count: 2) - within topic_page.post_by_number(2) do - cooked_hashtags = page.all(".hashtag-cooked", count: 2) - - expect(cooked_hashtags[0]["outerHTML"]).to eq(<<~HTML.chomp) - Cool Category - HTML - expect(cooked_hashtags[1]["outerHTML"]).to eq(<<~HTML.chomp) - cooltag - HTML - end + expect(cooked_hashtags[0]["outerHTML"]).to eq(<<~HTML.chomp) + Cool Category + HTML + expect(cooked_hashtags[1]["outerHTML"]).to eq(<<~HTML.chomp) + cooltag + HTML end end diff --git a/spec/system/page_objects/pages/topic.rb b/spec/system/page_objects/pages/topic.rb index 5815fb760cb..20a9675aad0 100644 --- a/spec/system/page_objects/pages/topic.rb +++ b/spec/system/page_objects/pages/topic.rb @@ -89,7 +89,7 @@ module PageObjects end def send_reply - within("#reply-control") { find(".save-or-cancel .create").click } + find("#reply-control .save-or-cancel .create").click end private