From 56aef3c082bac517ba48b0b225c7d1372b9ad688 Mon Sep 17 00:00:00 2001 From: Martin Brennan Date: Tue, 4 Jul 2023 16:23:04 +1000 Subject: [PATCH] DEV: Fix or remove flaky chat specs (#22406) * DEV: Fix flaky thread nav spec When we transitioned from the chat thread panel under some conditions the request for the thread would come back and realise the component was destroyed, which was trying to do a transition to the channel itself. Now we check for the previous route here too and transition to the correct route. * DEV: Fix chat transcript spec relying on animation The on-animation-end modifier is not reliable in system specs because it fires instantly (we have disabled capybara animations) so the showCopySuccess boolean can be mutated back to false straight away. Better to have a separate boolean tracked with a data-attr that we can reliably inspect in the system spec. --- .../discourse/components/chat-thread.js | 11 ++++++++++- .../components/chat/selection-manager.hbs | 5 ++++- .../components/chat/selection-manager.js | 7 +++++++ .../discourse/components/chat/thread/header.js | 17 +++++++++-------- plugins/chat/spec/system/transcript_spec.rb | 4 ++-- 5 files changed, 32 insertions(+), 12 deletions(-) diff --git a/plugins/chat/assets/javascripts/discourse/components/chat-thread.js b/plugins/chat/assets/javascripts/discourse/components/chat-thread.js index a471d27c71c..7cbb7b731e1 100644 --- a/plugins/chat/assets/javascripts/discourse/components/chat-thread.js +++ b/plugins/chat/assets/javascripts/discourse/components/chat-thread.js @@ -25,6 +25,7 @@ export default class ChatThreadPanel extends Component { @service chatThreadPaneSubscriptionsManager; @service appEvents; @service capabilities; + @service chatHistory; @tracked loading; @tracked uploadDropZone; @@ -168,7 +169,15 @@ export default class ChatThreadPanel extends Component { this._selfDeleted || this.args.thread.channel.id !== result.meta.channel_id ) { - this.router.transitionTo("chat.channel", "-", result.meta.channel_id); + if (this.chatHistory.previousRoute?.name === "chat.channel.index") { + this.router.transitionTo( + "chat.channel", + "-", + result.meta.channel_id + ); + } else { + this.router.transitionTo("chat.channel.threads"); + } } const [messages, meta] = this.afterFetchCallback( diff --git a/plugins/chat/assets/javascripts/discourse/components/chat/selection-manager.hbs b/plugins/chat/assets/javascripts/discourse/components/chat/selection-manager.hbs index 986efe55de3..7468f8b4ada 100644 --- a/plugins/chat/assets/javascripts/discourse/components/chat/selection-manager.hbs +++ b/plugins/chat/assets/javascripts/discourse/components/chat/selection-manager.hbs @@ -1,4 +1,7 @@ -
+