Add safety to the spotlight search dialog (#9177)

* Add safety to the spotlight search dialog

Fixes https://github.com/vector-im/element-web/issues/22851

This test was triggering the mentioned bug only occasionally because it was dependent on when the search settled: if it settled early then the length was wrong. In testing, the dialog was caught multiple times to have passed the length chat but update to show duplicated results before the test closed the client, indicating a race condition within the tests.

To fix this, we just make sure everything settles before moving on. We do this on unaffected tests too to ensure they don't regress later.

The affected test was "should find group DMs by usernames or user ids".

* Update cypress/e2e/spotlight/spotlight.spec.ts

Co-authored-by: Robin <robin@robin.town>

Co-authored-by: Robin <robin@robin.town>
This commit is contained in:
Travis Ralston 2022-08-11 16:26:25 -06:00 committed by GitHub
parent 4a5ed2f899
commit 8db7766a40
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 35 additions and 1 deletions

View file

@ -376,7 +376,9 @@ const SpotlightDialog: React.FC<IProps> = ({ initialText = "", initialFilter = n
})),
...roomResults,
...userResults,
...(profile ? [new DirectoryMember(profile)] : []).map(toMemberResult),
...(profile && !alreadyAddedUserIds.has(profile.user_id)
? [new DirectoryMember(profile)]
: []).map(toMemberResult),
...publicRooms.map(toPublicRoomResult),
].filter(result => filter === null || result.filter.includes(filter));
},