Fix direct message screen showing deactivated accounts (#8795)
* Fix direct message screen showing deactivated accounts Fixes MM-63374. The create direct message screen was showing deactivated accounts in the user list. Fixed by: 1. Setting allow_inactive: false in userSearchFunction when searching profiles 2. Setting active: true in userFetchFunction when fetching profiles 3. Added a test to verify that deactivated users don't appear in the search results 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * Fix test for deactivated users in DM creation screen Updated the test to properly handle quotation marks that differ between CI and local environments. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> --------- Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
parent
04dedb3898
commit
e3e4fe245c
2 changed files with 35 additions and 4 deletions
|
|
@ -233,9 +233,9 @@ export default function CreateDirectMessage({
|
|||
const userFetchFunction = useCallback(async (page: number) => {
|
||||
let results;
|
||||
if (restrictDirectMessage) {
|
||||
results = await fetchProfilesInTeam(serverUrl, currentTeamId, page, General.PROFILE_CHUNK_SIZE);
|
||||
results = await fetchProfilesInTeam(serverUrl, currentTeamId, page, General.PROFILE_CHUNK_SIZE, '', {active: true});
|
||||
} else {
|
||||
results = await fetchProfiles(serverUrl, page, General.PROFILE_CHUNK_SIZE);
|
||||
results = await fetchProfiles(serverUrl, page, General.PROFILE_CHUNK_SIZE, {active: true});
|
||||
}
|
||||
|
||||
if (results.users?.length) {
|
||||
|
|
@ -249,9 +249,9 @@ export default function CreateDirectMessage({
|
|||
const lowerCasedTerm = searchTerm.toLowerCase();
|
||||
let results;
|
||||
if (restrictDirectMessage) {
|
||||
results = await searchProfiles(serverUrl, lowerCasedTerm, {team_id: currentTeamId, allow_inactive: true});
|
||||
results = await searchProfiles(serverUrl, lowerCasedTerm, {team_id: currentTeamId, allow_inactive: false});
|
||||
} else {
|
||||
results = await searchProfiles(serverUrl, lowerCasedTerm, {allow_inactive: true});
|
||||
results = await searchProfiles(serverUrl, lowerCasedTerm, {allow_inactive: false});
|
||||
}
|
||||
|
||||
if (results.data) {
|
||||
|
|
|
|||
|
|
@ -171,4 +171,35 @@ describe('Channels - Create Direct Message', () => {
|
|||
// # Go back to channel list screen
|
||||
await CreateDirectMessageScreen.close();
|
||||
});
|
||||
|
||||
it('MM-T63374 - should not display deactivated users in the create direct message screen', async () => {
|
||||
// # As admin, create a new user to test with
|
||||
const {user: deactivatedUser} = await User.apiCreateUser(siteOneUrl);
|
||||
await Team.apiAddUserToTeam(siteOneUrl, deactivatedUser.id, testTeam.id);
|
||||
|
||||
// # Open create direct message screen and verify we can find the user
|
||||
await CreateDirectMessageScreen.open();
|
||||
await CreateDirectMessageScreen.searchInput.replaceText(deactivatedUser.username);
|
||||
await wait(timeouts.ONE_SEC);
|
||||
|
||||
// * Verify the new user appears in search results before deactivation
|
||||
await expect(CreateDirectMessageScreen.getUserItemDisplayName(deactivatedUser.id)).toBeVisible();
|
||||
|
||||
// # Close the create direct message screen
|
||||
await CreateDirectMessageScreen.close();
|
||||
|
||||
// # Deactivate the user
|
||||
await User.apiDeactivateUser(siteOneUrl, deactivatedUser.id);
|
||||
|
||||
// # Open create direct message screen again and search for the deactivated user
|
||||
await CreateDirectMessageScreen.open();
|
||||
await CreateDirectMessageScreen.searchInput.replaceText(deactivatedUser.username);
|
||||
await wait(timeouts.ONE_SEC);
|
||||
|
||||
// * Verify the deactivated user does not appear in search results
|
||||
await expect(element(by.text(`No matches found for “${deactivatedUser.username}”`))).toBeVisible();
|
||||
|
||||
// # Go back to channel list screen
|
||||
await CreateDirectMessageScreen.close();
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue