DEV: attempt to fix some system spec flakes (#30182)

Since 3e7f0867ea, I started seeing some specs fail due to the following error

```plain
Error occurred while rendering: top-level application > discourse-root > topic > discourse-topic > topic-navigation > plugin-outlet > plugin-connector > topic-presence-display

/assets/plugins/discourse-presence.js - Uncaught TypeError: Cannot destructure property 'whisperer' of 'this.currentUser' as it is null.
```

For some reasons I can't fanthom, the presence components seem to be rendered even though they're using outlets that are only rendered when a user is signed in... 🤷‍♂️

Lost too much time trying to reproduce so I ended up adding this `if (!this.currentUser) { return; }` condition to both "presence display" component to (hopefully) fix these flakes.
This commit is contained in:
Régis Hanol 2024-12-09 18:01:22 +01:00 committed by GitHub
parent ca0ea3d201
commit 35656a1d5f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 0 deletions

View File

@ -33,6 +33,12 @@ export default class ComposerPresenceDisplay extends Component {
}); });
setupWhisperChannel = helperFn((_, on) => { setupWhisperChannel = helperFn((_, on) => {
// NOTE: this is here to prevent some flakes in tests
// For some random reasons, this component is being rendered even though `currentUser` is `null`
if (!this.currentUser) {
return;
}
const { topic } = this.args.model; const { topic } = this.args.model;
const { whisperer } = this.currentUser; const { whisperer } = this.currentUser;

View File

@ -30,6 +30,12 @@ export default class TopicPresenceDisplay extends Component {
}); });
setupWhisperChannel = helperFn((_, on) => { setupWhisperChannel = helperFn((_, on) => {
// NOTE: this is here to prevent some flakes in tests
// For some random reasons, this component is being rendered even though `currentUser` is `null`
if (!this.currentUser) {
return;
}
const { topic } = this.args; const { topic } = this.args;
const { whisperer } = this.currentUser; const { whisperer } = this.currentUser;