Commit Graph

42 Commits

Author SHA1 Message Date
Joffrey JAFFEUX
7c057878e2
DEV: skips two flakey specs (#24044) 2023-10-22 18:50:04 +02:00
Loïc Guitaut
e1ae32103d DEV: Refactor chat specs related to message creation
This is extracted from #22390.

This patch aims to ease the transition to the new message creation
service. (in progress in #22390) Indeed, the new service patch is
breaking some specs from `discourse-ai` and `discourse-templates`
because these plugins are using either `Chat::MessageCreator` or the
`chat_message` fabricator.

This patch addresses theses issues by normalizing how we create a chat
message in specs. To do so, the preferred way is to use
`Fabricate(:chat_message)` with a new `:use_service` option allowing to
call the service under the hood. While this patch will obviously call
`Chat::MessageCreator`, the new service patch will now be able to simply
change the call to `Chat::CreateMessage` without breaking any specs from
other plugins.

Another thing this patch does is to not create chat messages using the
service for specs that aren’t system ones, thus speeding the execution
time a bit in the process.
2023-08-31 11:21:23 +02:00
Joffrey JAFFEUX
a008f61f8f
FIX: correctly closes panel when exiting chat (#23201)
We don't use activate/deactivate as it would cause: close/open in short succession when going from threads to thread for example.
2023-08-23 13:05:15 +02:00
Joffrey JAFFEUX
b2b84cc957
FEATURE: implements user based sidebar mode (#23078) 2023-08-18 20:33:07 +02:00
Jan Cernik
a2eb2b0490
DEV: Remove experimental site setting for chat threads (#22720)
We are removing the experimental site setting. Admins can now decide on a per channel basis to enable/disable threading. It's disabled by default.
2023-07-26 12:46:23 +02:00
Alan Guo Xiang Tan
f933c9fcd9
DEV: Rename method PageObjects::Pages::Chat (#22583)
`has_right_header_href?` is a little verbose and `has_header_href?` has
the same meaning.
2023-07-13 13:00:49 +08:00
Alan Guo Xiang Tan
31073c715b
DEV: Attempt to fix flaky chat system test (#22580)
Why this change?

The following test is flaky on our CI:

```
  1) Navigation when sidebar is configured as the navigation menu when re-opening full page chat after navigating to a channel opens full page chat on correct channel
     Failure/Error: measurement = Benchmark.measure { example.run }
       expected "/" to equal "/chat/c/random-9/17"
```

The theory here is that system tests is running too fast that we're not
giving the href for the chat header icon a chance to update before
clicking on it. Therefore, we're adding an additional assertion to
assert that the link has the right href before clicking on it.
2023-07-13 09:30:24 +08:00
Alan Guo Xiang Tan
0106c9b4ca
DEV: Fix flaky chat navigation specs on CI (#22560)
Why this change?

The specs are flaky on CI and we've unable to figure out why so we've
decided to skip them only on CI for now. The tests are still ran in our
internal build so we still have some protection in place.
2023-07-12 09:16:35 +08:00
Alan Guo Xiang Tan
ab053ac669
UX: Remove section heading for community section (#22405)
Why is this change being made?

We've decided that the previous "community" section should look more
like a primary section that holds the most important navigation links
for the site and the word "community" doesn't quite fit that
description. Therefore, we've made the decision to drop the
section heading for the community section. 

As part of removing the section heading, the following changes are made
as well:

1. Button to customize the section has been moved to the "footer" of the
   "More..." section when `navigation_menu` site setting is set to `sidebar`. 
   When `navigation_menu` is set to `header dropdown`, a button to customize 
   the section is shown inline.

2. The section will no longer be collapsable.

3. The title of the section is no longer customisable as it is no longer
   displayed. As a technical note, we have not dropped any previous
   customisations of the section's title previously in case we have to
   bring back the header in the future.

4. The new topic button that was previously present in the header has
   been removed alongside the header. Admins can add a custom section
   link to the `/new-topic` route if there would like to make it easier for
   users to create a new topic in the sidebar.
2023-07-11 09:40:37 +08:00
Joffrey JAFFEUX
f0d82de5d9
DEV: fix flakeyness with drawer specs (#22476)
Chat drawer was using the `DiscourseURL` hook `afterRouteComplete`. This hook suffer from a very poor implementation which makes it very unreliable:

```javascript
if (typeof opts.afterRouteComplete === "function") {
  schedule("afterRender", opts.afterRouteComplete);
}
```

This commit attempts to return the promise from `handleURL` to directly use it and have a very reliable after transition hook.
2023-07-07 00:46:04 +02:00
Isaac Janzen
b8cf50798b
DEV: Skip flaky visit-channel system tests (#22469)
Consistently seeing failures on 
- visit-channel
- navigation

specs
2023-07-06 13:17:37 -05:00
Alan Guo Xiang Tan
9a65c78d87
DEV: Avoid waiting full capybara default wait time (#22449)
Why this change?

`not_to be_open` ends up calling `has_css?` on a selector that will
never appear so it ends up waiting the full default wait time.
2023-07-06 08:16:58 +08:00
Alan Guo Xiang Tan
772334a346
DEV: Add more helpful assertions for flaky system tests in CI (#22432)
Why this change?

In CI, we know we're clicking a link to a chat channel's threads list.
However, the threads list is not loaded and we want to add more
assertions here to try and figure out why. By asserting for the current
URL, we will at least know that the transition to the URL is successful.
2023-07-06 07:08:59 +08:00
Joffrey JAFFEUX
d75d64bf16
FEATURE: new jump to channel menu (#22383)
This commit replaces two existing screens:
- draft
- channel selection modal

Main features compared to existing solutions
- features are now combined, meaning you can for example create multi users DM
- it will show users with chat disabled
- it shows unread state
- hopefully a better look/feel
- lots of small details and fixes...

Other noticeable fixes
- starting a DM with a user, even from the user card and clicking <kbd>Chat</kbd> will not show a green dot for the target user (or even the channel) until a message is actually sent
- it should almost never do a full page reload anymore

---------

Co-authored-by: Martin Brennan <mjrbrennan@gmail.com>
Co-authored-by: Jordan Vidrine <30537603+jordanvidrine@users.noreply.github.com>
Co-authored-by: chapoi <101828855+chapoi@users.noreply.github.com>
Co-authored-by: Mark VanLandingham <markvanlan@gmail.com>
2023-07-05 18:18:27 +02:00
Martin Brennan
58a3cdc6ae
DEV: Try fix flaky chat navigation spec (#22356)
Followup to e57070af92,
try to check for href of link first before clicking.
2023-06-30 09:08:29 +08:00
Alan Guo Xiang Tan
e57070af92
DEV: Skip a flaky system test (#22354)
This has been flagged by our internal system as well and has been
failing on CI. Skip this for now to improve the stability of our system
test runs while we figure out why it is flaky.
2023-06-30 07:35:44 +08:00
Martin Brennan
ccdc0822a8
DEV: Fix flaky thread navigation spec (#22323)
Introduced in cec68b3e2c,
this is flaky because if you click the back button before
the route is fully transitioned to the loaded thread,
we end up going to the history _before_ the thread list,
which ends up being the channel.

We need to make sure that everything is loaded for the
thread first, meaning the skeleton is not there.

Also exclude some noise from the capybara logs (image load failures)
2023-06-28 17:20:05 +10:00
Martin Brennan
cec68b3e2c
FEATURE: Conditionally change back button route for thread (#22129)
When clicking back from a thread, we want to either go back to the
channel if the thread was opened from an indicator, or to the thread
list if we opened it from there. Since ember doesn't give a nice way
to get the previous route, we need to store this ourselves. We only
do this on mobile, on desktop we just follow existing behaviour.

Also implements a chat router history.

---------

Co-authored-by: Joffrey JAFFEUX <j.jaffeux@gmail.com>
2023-06-28 09:58:47 +10:00
Alan Guo Xiang Tan
41f8bff2c3
DEV: Remove superfluous js: true metadata (#21960)
Why this change?

It is very unlikely that we need to ever JS for system tests considering
that we rely on a JS framework on the frontend.
2023-06-07 09:26:58 +08:00
Alan Guo Xiang Tan
7ff8e5580f
DEV: Speed up chat plugin system tests (#21399)
See e323628d8a for more details.

This commit speeds up the tests by roughly 10 seconds locally where the
default wait time is 2 seconds. On CI, this speeds up the tests by 20
seconds where the default wait time is 4 seconds.
2023-05-05 08:16:23 +08:00
Joffrey JAFFEUX
18c81958e5
UX: various tweaks on thread (#21083)
- Back button in drawer will bring you back to channel
- Larger font for thread indicator
- Prevents screen flashing due to clearing messages when they were already loaded
- Fixes a bug where did-update params were inverted causing an error when expanding/collapsing drawer
2023-04-13 10:08:12 +02:00
Alan Guo Xiang Tan
2eb60c9713
DEV: Switch sidebar section link identifier to data attribute (#21051)
Data attribute is less restrictive than relying on the class attribute
2023-04-12 15:52:10 +08:00
Martin Brennan
7ae716fa69
FIX: Multiple channels marked active in sidebar (#21045)
Followup to c1dc6a2db4,
this commit just missed removing one of the @computed
decorators which was causing multiple active channels
to show in the sidebar. Fix the issue and introduce a
system spec to catch this.
2023-04-11 12:31:17 +10:00
Roman Rizzi
d07b472b79
DEV: /channel -> /c chat route rename (#19782)
* DEV: Rnemae channel path to just c

Also swap the channel id and channel slug params to be consistent with core.

* linting

* channel_path

* params in wrong order

* Drop slugify helper and channel route without slug

* Request slug and route models through the channel model if possible

* Add client side redirection for backwards-compatibility

Co-authored-by: Joffrey JAFFEUX <j.jaffeux@gmail.com>
2023-01-27 09:58:12 -03:00
Joffrey JAFFEUX
03d32f26bb
FIX: correctly handles navigating to a message (#19614)
Recent changes surfaced the various issues with this codepath:
- we were not correctly reseting `messageLookup` leading to us trying to scroll to a non existing message in the view
- we were calling markAsRead which would scroll to the bottom, even if we had a target message
- we were not debouncing fetchMessages, which could cause multiple reload of the messages when loading it with a targetMessageId: first fetch from last read and then immediately fetch from targetMessageId
- other naming inconsistencies
- not handling drawer

This commit also adds tests for classic scenarios related to this use case.
2022-12-23 19:48:14 +01:00
David Taylor
b1b53da71d
DEV: Improve performance of system test sign_in helper (#19579)
Previously, calling `sign_in` would cause the browser to be redirected to `/`, and would cause the Ember app to boot. We would then call `visit()`, causing the app to boot for a second time.

This commit adds a `redirect=false` option to the `/session/username/become` route. This avoids the unnecessary boot of the app, and leads to significantly faster system spec run times.

In local testing, this takes the full system-spec suite for chat from ~6min to ~4min.
2022-12-22 16:03:27 +00:00
Joffrey JAFFEUX
d2e24f9569
DEV: start glimmer-ification and optimisations of chat plugin (#19531)
Note this is a very large PR, and some of it could have been splited, but keeping it one chunk made it to merge conflicts and to revert if necessary. Actual new code logic is also not that much, as most of the changes are removing js tests, adding system specs or moving things around.

To make it possible this commit is doing the following changes:

- converting (and adding new) existing js acceptances tests into system tests. This change was necessary to ensure as little regressions as possible while changing paradigm
- moving away from store. Using glimmer and tracked properties requires to have class objects everywhere and as a result works well with models. However store/adapters are suffering from many bugs and limitations. As a workaround the `chat-api` and `chat-channels-manager` are an answer to this problem by encapsulating backend calls and frontend storage logic; while still using js models.
- dropping `appEvents` as much as possible. Using tracked properties and a better local storage of channel models, allows to be much more reactive and doesn’t require arbitrary manual updates everywhere in the app.
- while working on replacing store, the existing work of a chat api (backend) has been continued to support more cases.
- removing code from the `chat` service to separate concerns, `chat-subscriptions-manager` and `chat-channels-manager`, being the largest examples of where the code has been rewritten/moved.

Future wok:
- improve behavior when closing/deleting a channel, it's already slightly buggy on live, it's rare enough that it's not a big issue, but should be improved
- improve page objects used in chat
- move more endpoints to the API
- finish temporarily skipped tests
- extract more code from the `chat` service
- use glimmer for `chat-messages`
- separate concerns in `chat-live-pane`
- eventually add js tests for `chat-api`, `chat-channels-manager` and `chat-subscriptions-manager`, they are indirectly heavy tested through system tests but it would be nice to at least test the public API

<!-- NOTE: All pull requests should have tests (rspec in Ruby, qunit in JavaScript). If your code does not include test coverage, please include an explanation of why it was omitted. -->
2022-12-21 13:21:02 +01:00
Alan Guo Xiang Tan
fde9e6bc25
DEV: Migrate sidebar site settings (#19336)
This new site setting replaces the
`enable_experimental_sidebar_hamburger` and `enable_sidebar` site
settings as the sidebar feature exits the experimental phase.

Note that we're replacing this without depreciation since the previous
site setting was considered experimental.

Internal Ref: /t/86563
2022-12-08 09:44:29 +08:00
Joffrey JAFFEUX
1d42cc94a2
FIX: nullify active channel only when not on a chat channel (#19319)
This would nullify the active channel when going from channel settings page to the channel.
2022-12-05 22:42:35 +01:00
Joffrey JAFFEUX
9ade68233c
UX: alters chat icon behavior on drawer and mobile (#19192)
Refines the behavior of clicking the chat icon in mobile and when in drawer mode as follows: If chat is open, clicking the icon takes you to the index.
2022-11-25 15:12:32 +01:00
Joffrey JAFFEUX
84c1cc70d6
REFACTOR: naming and state refactor (#19187)
- better handling of drawer state using chat state manager
- removes various float and topic occurrences to use drawer
- ensures user can chat before doing a lot of chat setup
- fixes a bug which was creating presence errors in tests
- removes dead code
2022-11-25 14:15:38 +01:00
Kris
bc61629d0f
A11Y: improved titles for chat in the sidebar (#19134) 2022-11-22 09:24:39 +08:00
Martin Brennan
d3f02a1270
FEATURE: Generic hashtag autocomplete lookup and markdown cooking (#18937)
This commit fleshes out and adds functionality for the new `#hashtag` search and
lookup system, still hidden behind the `enable_experimental_hashtag_autocomplete`
feature flag.

**Serverside**

We have two plugin API registration methods that are used to define data sources
(`register_hashtag_data_source`) and hashtag result type priorities depending on
the context (`register_hashtag_type_in_context`). Reading the comments in plugin.rb
should make it clear what these are doing. Reading the `HashtagAutocompleteService`
in full will likely help a lot as well.

Each data source is responsible for providing its own **lookup** and **search**
method that returns hashtag results based on the arguments provided. For example,
the category hashtag data source has to take into account parent categories and
how they relate, and each data source has to define their own icon to use for the
hashtag, and so on.

The `Site` serializer has two new attributes that source data from `HashtagAutocompleteService`.
There is `hashtag_icons` that is just a simple array of all the different icons that
can be used for allowlisting in our markdown pipeline, and there is `hashtag_context_configurations`
that is used to store the type priority orders for each registered context.

When sending emails, we cannot render the SVG icons for hashtags, so
we need to change the HTML hashtags to the normal `#hashtag` text.

**Markdown**

The `hashtag-autocomplete.js` file is where I have added the new `hashtag-autocomplete`
markdown rule, and like all of our rules this is used to cook the raw text on both the clientside
and on the serverside using MiniRacer. Only on the server side do we actually reach out to
the database with the `hashtagLookup` function, on the clientside we just render a plainer
version of the hashtag HTML. Only in the composer preview do we do further lookups based
on this.

This rule is the first one (that I can find) that uses the `currentUser` based on a passed
in `user_id` for guardian checks in markdown rendering code. This is the `last_editor_id`
for both the post and chat message. In some cases we need to cook without a user present,
so the `Discourse.system_user` is used in this case.

**Chat Channels**

This also contains the changes required for chat so that chat channels can be used
as a data source for hashtag searches and lookups. This data source will only be
used when `enable_experimental_hashtag_autocomplete` is `true`, so we don't have
to worry about channel results suddenly turning up.

------

**Known Rough Edges**

- Onebox excerpts will not render the icon svg/use tags, I plan to address that in a follow up PR
- Selecting a hashtag + pressing the Quote button will result in weird behaviour, I plan to address that in a follow up PR
- Mixed hashtag contexts for hashtags without a type suffix will not work correctly, e.g. #ux which is both a category and a channel slug will resolve to a category when used inside a post or within a [chat] transcript in that post. Users can get around this manually by adding the correct suffix, for example ::channel. We may get to this at some point in future
- Icons will not show for the hashtags in emails since SVG support is so terrible in email (this is not likely to be resolved, but still noting for posterity)
- Additional refinements and review fixes wil
2022-11-21 08:37:06 +10:00
Joffrey JAFFEUX
895898b363
FIX: correctly opens drawer to message id when given (#18994) 2022-11-14 08:16:09 +01:00
Joffrey JAFFEUX
88ede43ec5
FIX: correctly highlights active channel (#18991)
Prior to this change, only hovering the row would highlight it.
2022-11-11 22:32:06 +01:00
Joffrey JAFFEUX
66130dc8c1
REFACTOR: handles every chat resource as an URL (#18961)
- Note this is also tweaking the UI a little bit as we are now using links/buttons in the header as needed
- It disables the find ideal channel in drawer mode, if loading `/chat` in drawer mode it will either reopen at the last position or just stay on index
2022-11-11 06:39:15 +01:00
Joffrey JAFFEUX
074aa5eb5e
FIX: handles starting draft dm from sidebar (#18946) 2022-11-08 23:58:11 +01:00
Joffrey JAFFEUX
21570410ab
FIX: makes sidebar links respect drawer mode (#18918)
Clicking a link of the sidebar will now open the drawer and load the correct channel.

This solution should correctly solve these cases:

closing drawer, clicking sidebar channel, should open the drawer on correct channel
visiting /chat then visiting / and clicking sidebar channel, should open full page chat on correct channel
2022-11-08 16:23:13 +01:00
Joffrey JAFFEUX
0a02a5d05a
FIX: follow up to #7fca078 (#18915)
- prevents triggering chat:open-channel two times
- builds a correct URL for home page
2022-11-07 19:31:08 +01:00
Joffrey JAFFEUX
7fca07821b
FIX: simplfies previous route handling (#18895)
This commits makes sure we correctly wait for the end of the transition to reopen the drawer on the correct channel/view. Also fixes a bug when previous URL was `/` and causing a double transition.
2022-11-07 14:48:18 +01:00
Joffrey JAFFEUX
a51e5e1987
DEV: separates preferred-chat-mode service (#18883)
Also adds end to end system tests to ensure navigation scenarios are working correctly. This separation will make it easier to implement state in/out from chat.
2022-11-07 09:04:43 +01:00
Joffrey JAFFEUX
11f3618b80
DEV: initial system tests for chat and plugins (#18881)
This is a very basic to ensure it's working and open future possible work
2022-11-04 15:06:24 +01:00