discourse/plugins/chat/spec
Alan Guo Xiang Tan 14517785b2
DEV: Fix flaky system test when expanding chat message actions on mobile (#22428)
Why this change?

Chat system tests that opens the message actions on mobile have been
flaky on our CI. Those system test usually fails when the message
actions do not show up as expected causing subsequent actions to fail.

In the case of the `Reply to message - channel - mobile when the message has an existing thread replies to the existing thread`
system test, failure screenshot shows that we ended up navigating to the
thread instead of opening the message actions button. To understand why
this happens, we first need to understand that by default Capybara clicks
on the centre of an element. Also, we need to note that the HTML structure of
a chat message is like so:

```
<div class="chat-message-container">
  <div class="chat-message">
    <div class="chat-message-avatar" />
    <div class="chat-message-content" />
    <div class="chat-message-thread-indicator" />
  </div>
</div>
```

Since `PageObjects::Pages::ChatChannel#expand_message_actions_mobile`
attempts to click on the `.chat-message-contaier`, there is a
possibility that the center of that element is the
`.chat-message-thread-indicator` element which would explain why we
navigated to the thread list instead of opening up the message actions.
This is possible because the content of the original chat message as
well as the message excerpt in the thread is randomly generated where the
length of the message and how the text wraps on mobile can affect the
height of the `.chat-message-content` element as thus its position in
the `.chat-message-container` element. In most cases, the middle of the
`.chat-message-container` happens to be the `.chat-message-content`
which is why this test "flakes" sometimes.

What is the solution?

Instead of clicking on the `.chat-message-container`, we be more
specific and click on the `.chat-message-content` element instead.
2023-07-05 10:39:04 +08:00
..
components/chat DEV: Refactor DM channel creation into new service pattern (#22144) 2023-07-03 10:18:37 +10:00
fabricators FEATURE: Thread indicator improvements and participants (#21909) 2023-06-15 10:49:27 +10:00
integration DEV: Update chat cooked quote spec (#22202) 2023-06-20 10:30:33 +08:00
jobs DEV: Move user count update for channels to ensure_consistency! (#22321) 2023-07-03 11:41:51 +10:00
lib DEV: Refactor DM channel creation into new service pattern (#22144) 2023-07-03 10:18:37 +10:00
mailers DEV: Refactor DM channel creation into new service pattern (#22144) 2023-07-03 10:18:37 +10:00
models DEV: Move user count update for channels to ensure_consistency! (#22321) 2023-07-03 11:41:51 +10:00
queries/chat DEV: Update the rubocop-discourse gem 2023-06-26 11:41:52 +02:00
requests DEV: Refactor DM channel creation into new service pattern (#22144) 2023-07-03 10:18:37 +10:00
serializer DEV: Update the rubocop-discourse gem 2023-06-26 11:41:52 +02:00
services DEV: Refactor DM channel creation into new service pattern (#22144) 2023-07-03 10:18:37 +10:00
support DEV: Refactor DM channel creation into new service pattern (#22144) 2023-07-03 10:18:37 +10:00
system DEV: Fix flaky system test when expanding chat message actions on mobile (#22428) 2023-07-05 10:39:04 +08:00
validators DEV: properly namespace chat (#20690) 2023-03-17 14:24:38 +01:00
plugin_helper.rb DEV: Refactor DM channel creation into new service pattern (#22144) 2023-07-03 10:18:37 +10:00
plugin_spec.rb DEV: Move user count update for channels to ensure_consistency! (#22321) 2023-07-03 11:41:51 +10:00