snapshot of https://github.com/mattermost/mattermost.git (master, 2026-09-16; blobs > 131072B omitted)
Some checks failed
Server CI / Postgres (shard 0) (push) Has been skipped
Server CI / Postgres (shard 3) (push) Has been skipped
BuildEnv Docker Image / build-image (push) Failing after 4s
BuildEnv Docker Image / build-image-fips (push) Failing after 4s
Migration Review & Release Notes / Generate migration review & release notes (push) Failing after 3s
Server CI / Build Environment (push) Failing after 3s
Server CI / Postgres (shard 1) (push) Has been skipped
Tools CI / check-style (mattermost-govet) (push) Failing after 4s
Server CI / Postgres (shard 2) (push) Has been skipped
Tools CI / check-style (mmgotool) (push) Failing after 3s
Server CI / Elasticsearch v8 Compatibility (push) Has been skipped
Server CI / OpenSearch v2 Compatibility (push) Has been skipped
Server CI / Postgres FIPS (shard 0) (push) Has been skipped
Tools CI / Test (mattermost-govet) (push) Failing after 3s
Server CI / Postgres FIPS (shard 1) (push) Has been skipped
Server CI / Postgres FIPS (shard 2) (push) Has been skipped
Tools CI / Test (mmgotool) (push) Failing after 3s
Server CI / Postgres FIPS (shard 3) (push) Has been skipped
Server CI / Run mmctl tests (push) Has been skipped
Server CI / Run mmctl tests (FIPS) (push) Has been skipped
Server CI / Merge Postgres Test Results (push) Has been skipped
Server CI / Merge Postgres FIPS Test Results (push) Has been skipped
Server CI / Check backport migrations (push) Has been skipped
Server CI / Check generated files (push) Has been skipped
Server CI / check-style (push) Has been skipped
Server CI / Vet API (push) Has been skipped
Server CI / Build mattermost server app (push) Has been skipped
Server CI / Server CI Complete (push) Failing after 2s
Server CI / Server CI Artifacts (push) Has been skipped
Server CI / Sentry Upload (push) Has been skipped
Server CI / Server CI Report (push) Failing after 5m1s
Server CI Nightly Race / Race Detector (push) Has been skipped
CodeQL / Analyze (go) (push) Has been cancelled
CodeQL / Analyze (javascript) (push) Has been cancelled
Webapp CI Cache Warm / Warm Webapp node_modules Cache (push) Has been cancelled
E2E CI Cache Warm / Warm E2E npm Registry Cache (push) Has been cancelled
API / build (push) Has been cancelled
Web App CI / check-types (push) Has been cancelled
Web App CI / check-lint (push) Has been cancelled
Web App CI / check-i18n (push) Has been cancelled
Web App CI / check-external-links (push) Has been cancelled
Web App CI / test (platform) (push) Has been cancelled
Web App CI / test (mattermost-redux) (push) Has been cancelled
Web App CI / test (channels shard 1/4) (push) Has been cancelled
Web App CI / test (channels shard 2/4) (push) Has been cancelled
Web App CI / test (channels shard 3/4) (push) Has been cancelled
Web App CI / test (channels shard 4/4) (push) Has been cancelled
Web App CI / upload-coverage (push) Has been cancelled
Web App CI / build (push) Has been cancelled
YAML Lint / yamllint (push) Has been cancelled
Push mirrored docker images / cd/Push mirrored docker images (push) Has been cancelled
docs-cd / Build and deploy docs (push) Has been cancelled
Docs CI / build (push) Has been cancelled
E2E Cache Warm: Cypress deps / Warm Cypress deps cache (push) Has been cancelled
Scorecards supply-chain security / Scorecard analysis (push) Has been cancelled
Server CI Weekly / Postgres FIPS (push) Has been skipped
Server CI Weekly / Run mmctl tests (FIPS) (push) Has been skipped
Server CI Weekly / Postgres with binary parameters (push) Has been skipped
Server CI Weekly / Build Environment (push) Failing after 1s
Server CI Cache Warm / Warm Go Module and Build Cache (push) Failing after 2s
Server CI Nightly Race / Build Environment (push) Failing after 1s

This commit is contained in:
upstream-mirror
2026-09-16 00:29:55 +05:00
commit 240db4e2a7
15309 changed files with 2173406 additions and 0 deletions

View File

@@ -0,0 +1,153 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import type {Client4} from '@mattermost/client';
import type {Team} from '@mattermost/types/teams';
import {ChannelsPage, expect, extractEmailLink, getRecentEmail, test} from '@mattermost/playwright-lib';
type LockSetting = 'none' | 'name_and_username' | 'all';
test.beforeEach(async ({pw}) => {
await pw.ensureLicense();
await pw.skipIfNoLicense();
});
/**
* @objective Verify pre-set invite profile data survives email signup and is locked for the new member.
* @precondition An Enterprise license, Inbucket, and email invitations are available.
*/
test(
'carries admin-provisioned profile data from invite email through signup and enforces the lock',
{tag: '@locked_profile_fields'},
async ({pw, page}) => {
test.setTimeout(90_000);
// # Invite and register a member with administrator-provided profile details.
const {adminUser, adminClient, team} = await pw.initSetup();
await setLockConfig(adminClient, 'name_and_username');
const uniqueId = pw.random.id(6);
const invitedEmail = `new.user@${uniqueId}.example.com`;
const invitedUsername = `jane.doe.${uniqueId}`;
const {channelsPage: adminChannelsPage} = await pw.testBrowser.login(adminUser);
const inviteModal = await openInviteModal(adminChannelsPage, team);
await inviteModal.addEmail(invitedEmail);
const profile = inviteModal.getProfileRow(invitedEmail);
await profile.firstNameInput.fill('Jane');
await profile.lastNameInput.fill('Doe');
await profile.usernameInput.fill(invitedUsername);
const invitationStarted = new Date(Date.now() - 5_000);
await inviteModal.submitInvites();
await (await adminChannelsPage.getMembersInvitedModal(team.display_name)).toBeVisible();
const invitationEmail = await getRecentEmail(invitedEmail, {receivedAfter: invitationStarted});
const signupLink = extractEmailLink(invitationEmail, '/signup_user_complete/');
await pw.hasSeenLandingPage();
await pw.signupPage.goto(signupLink);
await pw.signupPage.toBeVisible();
await expect(pw.signupPage.usernameInput).toHaveValue(invitedUsername);
await expect(pw.signupPage.usernameInput).toBeDisabled();
await expect(pw.signupPage.adminChosenUsernameMessage).toBeVisible();
await expect(pw.signupPage.presetName).toHaveText("You'll join as Jane Doe.");
await pw.signupPage.createInvitedUser(pw.newTestPassword());
const channelsPage = new ChannelsPage(page);
await channelsPage.toBeVisible();
const createdUser = await adminClient.getUserByEmail(invitedEmail);
expect(createdUser.username).toBe(invitedUsername);
expect(createdUser.first_name).toBe('Jane');
expect(createdUser.last_name).toBe('Doe');
// * The resulting member cannot edit the managed name or username fields.
await adminClient.savePreferences(createdUser.id, [
{user_id: createdUser.id, category: 'tutorial_step', name: createdUser.id, value: '999'},
{
user_id: createdUser.id,
category: 'onboarding_task_list',
name: 'onboarding_task_list_show',
value: 'false',
},
]);
await page.reload();
await channelsPage.toBeVisible();
const profileModal = await channelsPage.openProfileModal();
await profileModal.openSection('name');
await expect(profileModal.managedByAdminMessage).toBeVisible();
await expect(profileModal.firstNameInput).not.toBeVisible();
await expect(profileModal.lastNameInput).not.toBeVisible();
await expect(profileModal.saveButton).not.toBeVisible();
await profileModal.closeSection();
await profileModal.openSection('username');
await expect(profileModal.managedByAdminMessage).toBeVisible();
await expect(profileModal.usernameInput).not.toBeVisible();
await expect(profileModal.saveButton).not.toBeVisible();
},
);
/**
* @objective Verify a System Admin can edit an email user's locked first and last names.
* @precondition An Enterprise license is available.
*/
test(
'allows a System Admin to edit locked first and last names from the user detail page',
{tag: '@locked_profile_fields'},
async ({pw}) => {
// # Edit the locked member's name from the System Console.
const {user, adminUser, adminClient} = await pw.initSetup();
await setLockConfig(adminClient, 'name_and_username');
const newFirstName = `AdminFirst${pw.random.id(5)}`;
const newLastName = `AdminLast${pw.random.id(5)}`;
const {systemConsolePage} = await pw.testBrowser.login(adminUser);
await systemConsolePage.page.goto(`/admin_console/user_management/user/${user.id}`);
const {userDetail} = systemConsolePage.users;
await userDetail.toBeVisible();
await expect(userDetail.userCard.firstNameInput).toBeEnabled();
await expect(userDetail.userCard.lastNameInput).toBeEnabled();
await userDetail.userCard.firstNameInput.fill(newFirstName);
await userDetail.userCard.lastNameInput.fill(newLastName);
await userDetail.save();
await userDetail.saveChangesModal.confirm();
// * The administrator's changes persist in the UI and API.
await expect(userDetail.userCard.firstNameInput).toHaveValue(newFirstName);
await expect(userDetail.userCard.lastNameInput).toHaveValue(newLastName);
const updatedUser = await adminClient.getUser(user.id);
expect(updatedUser.first_name).toBe(newFirstName);
expect(updatedUser.last_name).toBe(newLastName);
},
);
async function setLockConfig(adminClient: Client4, lockSetting: LockSetting) {
await adminClient.patchConfig({
ServiceSettings: {EnableEmailInvitations: true},
TeamSettings: {LockProfileFieldsForEmailUsers: lockSetting},
});
await expect
.poll(async () => {
const config = await adminClient.getConfig();
return {
emailInvitations: config.ServiceSettings?.EnableEmailInvitations,
profileLock: config.TeamSettings?.LockProfileFieldsForEmailUsers,
};
})
.toEqual({emailInvitations: true, profileLock: lockSetting});
}
async function openInviteModal(channelsPage: ChannelsPage, team: Team) {
await channelsPage.goto(team.name, 'town-square');
await channelsPage.toBeVisible();
await channelsPage.sidebarLeft.teamMenuButton.click();
await channelsPage.teamMenu.toBeVisible();
await channelsPage.teamMenu.clickInvitePeople();
const inviteModal = await channelsPage.getInvitePeopleModal(team.display_name);
await inviteModal.toBeVisible();
return inviteModal;
}