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,362 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
export const adminConsoleNavigation = [
{
type: ['team', 'e20'],
header: 'Edition and License',
sidebar: 'Edition and License',
url: 'admin_console/about/license',
},
{
type: ['cloud_enterprise'],
header: 'Subscription',
sidebar: 'Subscription',
url: 'admin_console/billing/subscription',
},
{
type: ['cloud_enterprise'],
header: 'Billing History',
sidebar: 'Billing History',
url: 'admin_console/billing/billing_history',
},
{
type: ['cloud_enterprise'],
header: 'Company Information',
sidebar: 'Company Information',
url: 'admin_console/billing/company_info',
},
{
type: ['team', 'e20', 'cloud_enterprise'],
header: 'System Statistics',
sidebar: 'System Statistics',
url: '/admin_console/reporting/system_analytics',
},
{
type: ['team', 'e20', 'cloud_enterprise'],
header: 'Team Statistics',
sidebar: 'Team Statistics',
url: '/admin_console/reporting/team_statistics',
headerContains: true,
},
{
type: ['team', 'e20'],
header: 'Server Logs',
sidebar: 'Server Logs',
url: '/admin_console/reporting/server_logs',
headerContains: true,
},
{
type: ['team', 'e20', 'cloud_enterprise'],
header: 'Mattermost Users',
headerSelector: '.admin-console__header #systemUsersTable-headerId',
sidebar: 'Users',
url: 'admin_console/user_management/users',
},
{
type: ['team', 'e20', 'cloud_enterprise'],
header: 'Groups',
sidebar: 'Groups',
url: 'admin_console/user_management/groups',
},
{
type: ['team', 'e20', 'cloud_enterprise'],
header: 'Mattermost Teams',
sidebar: 'Teams',
url: 'admin_console/user_management/teams',
},
{
type: ['team', 'e20', 'cloud_enterprise'],
header: 'Mattermost Channels',
team_header: 'Channels',
sidebar: 'Channels',
url: 'admin_console/user_management/channels',
},
{
type: ['team', 'e20', 'cloud_enterprise'],
header: 'Permission Schemes',
sidebar: 'Permissions',
url: 'admin_console/user_management/permissions',
},
{
type: ['team', 'e20', 'cloud_enterprise'],
header: 'Delegated Granular Administration',
sidebar: 'Delegated Granular Administration',
url: 'admin_console/user_management/system_roles',
},
{
type: ['team', 'e20'],
header: 'Web Server',
sidebar: 'Web Server',
url: 'admin_console/environment/web_server',
},
{
type: ['team', 'e20'],
header: 'Database',
sidebar: 'Database',
url: 'admin_console/environment/database',
},
{
type: ['e20'],
section: 'Environment',
header: 'Elasticsearch',
sidebar: 'Elasticsearch',
url: 'admin_console/environment/elasticsearch',
},
{
type: ['team', 'e20'],
section: 'Environment',
header: 'File Storage',
sidebar: 'File Storage',
url: 'admin_console/environment/file_storage',
},
{
type: ['team', 'e20'],
section: 'Environment',
header: 'Image Proxy',
sidebar: 'Image Proxy',
url: 'admin_console/environment/image_proxy',
},
{
type: ['team', 'e20'],
section: 'Environment',
header: 'SMTP',
sidebar: 'SMTP',
url: 'admin_console/environment/smtp',
},
{
type: ['team', 'e20'],
section: 'Environment',
header: 'Push Notification Server',
sidebar: 'Push Notification Server',
url: 'admin_console/environment/push_notification_server',
},
{
type: ['e20'],
section: 'Environment',
header: 'High Availability',
sidebar: 'High Availability',
url: 'admin_console/environment/high_availability',
},
{
type: ['team', 'e20'],
section: 'Environment',
header: 'Rate Limiting',
sidebar: 'Rate Limiting',
url: 'admin_console/environment/rate_limiting',
},
{
type: ['team', 'e20'],
section: 'Environment',
header: 'Logging',
sidebar: 'Logging',
url: 'admin_console/environment/logging',
},
{
type: ['team', 'e20'],
section: 'Environment',
header: 'Session Lengths',
sidebar: 'Session Lengths',
url: 'admin_console/environment/session_lengths',
},
{
type: ['team', 'e20'],
section: 'Environment',
header: 'Performance Monitoring',
sidebar: 'Performance Monitoring',
url: 'admin_console/environment/performance_monitoring',
},
{
type: ['team', 'e20'],
section: 'Environment',
header: 'Developer Settings',
sidebar: 'Developer',
url: 'admin_console/environment/developer',
},
{
type: ['team', 'e20', 'cloud_enterprise'],
header: 'Customization',
sidebar: 'Customization',
url: 'admin_console/site_config/customization',
},
{
type: ['team', 'e20', 'cloud_enterprise'],
header: 'Localization',
sidebar: 'Localization',
url: 'admin_console/site_config/localization',
},
{
type: ['team', 'e20', 'cloud_enterprise'],
header: 'Users and Teams',
sidebar: 'Users and Teams',
url: 'admin_console/site_config/users_and_teams',
},
{
type: ['team', 'e20', 'cloud_enterprise'],
header: 'Notifications',
sidebar: 'Notifications',
url: 'admin_console/environment/notifications',
},
{
type: ['team', 'e20', 'cloud_enterprise'],
header: 'Announcement Banner',
sidebar: 'Announcement Banner',
url: 'admin_console/site_config/announcement_banner',
},
{
type: ['team', 'e20', 'cloud_enterprise'],
header: 'Emoji',
sidebar: 'Emoji',
url: 'admin_console/site_config/emoji',
},
{
type: ['team', 'e20', 'cloud_enterprise'],
header: 'Posts',
sidebar: 'Posts',
url: 'admin_console/site_config/posts',
},
{
type: ['team', 'e20'],
header: 'File Sharing and Downloads',
sidebar: 'File Sharing and Downloads',
url: 'admin_console/site_config/file_sharing_downloads',
},
{
type: ['team', 'e20'],
header: 'Public Links',
sidebar: 'Public Links',
url: 'admin_console/site_config/public_links',
},
{
type: ['team', 'e20', 'cloud_enterprise'],
header: 'Notices',
sidebar: 'Notices',
url: 'admin_console/site_config/notices',
},
{
type: ['team', 'e20', 'cloud_enterprise'],
header: 'Signup',
sidebar: 'Signup',
url: 'admin_console/authentication/signup',
},
{
type: ['team', 'e20', 'cloud_enterprise'],
header: 'Email',
sidebar: 'Email',
url: 'admin_console/authentication/email',
},
{
type: ['team', 'e20', 'cloud_enterprise'],
header: 'Password',
sidebar: 'Password',
url: 'admin_console/authentication/password',
},
{
type: ['team', 'e20', 'cloud_enterprise'],
header: 'Multi-factor Authentication',
sidebar: 'MFA',
url: 'admin_console/authentication/mfa',
},
{
type: ['team', 'e20', 'cloud_enterprise'],
header: 'AD/LDAP Wizard',
sidebar: 'AD/LDAP',
url: 'admin_console/authentication/ldap',
},
{
type: ['team', 'e20', 'cloud_enterprise'],
header: 'SAML 2.0',
sidebar: 'SAML 2.0',
url: 'admin_console/authentication/saml',
},
{
type: ['team'],
header: 'GitLab',
sidebar: 'GitLab',
url: 'admin_console/authentication/gitlab',
},
{
type: ['team', 'e20', 'cloud_enterprise'],
header: 'OpenID Connect',
sidebar: 'OpenID Connect',
url: 'admin_console/authentication/openid',
},
{
type: ['team', 'e20', 'cloud_enterprise'],
header: 'Guest Access',
sidebar: 'Guest Access',
url: 'admin_console/authentication/guest_access',
},
{
type: ['team', 'e20', 'cloud_enterprise'],
header: 'Plugin Management',
sidebar: 'Plugin Management',
url: 'admin_console/plugins/plugin_management',
},
{
type: ['team', 'e20', 'cloud_enterprise'],
header: 'Integration Management',
sidebar: 'Integration Management',
url: 'admin_console/integrations/integration_management',
},
{
type: ['team', 'e20', 'cloud_enterprise'],
header: 'Bot Accounts',
sidebar: 'Bot Accounts',
url: 'admin_console/integrations/bot_accounts',
},
{
type: ['team', 'e20', 'cloud_enterprise'],
header: 'GIF',
sidebar: 'GIF',
url: 'admin_console/integrations/gif',
},
{
type: ['team', 'e20'],
header: 'CORS',
sidebar: 'CORS',
url: 'admin_console/integrations/cors',
},
{
type: ['e20', 'cloud_enterprise'],
header: 'Data Retention Policies',
sidebar: 'Data Retention Policies',
url: 'admin_console/compliance/data_retention_settings',
},
{
type: ['team'],
header: 'Data Retention Policy',
sidebar: 'Data Retention Policy',
url: 'admin_console/compliance/data_retention',
},
{
type: ['team', 'e20', 'cloud_enterprise'],
header: 'Compliance Export',
sidebar: 'Compliance Export',
url: 'admin_console/compliance/export',
},
{
type: ['e20', 'cloud_enterprise'],
header: 'Compliance Monitoring',
sidebar: 'Compliance Monitoring',
url: 'admin_console/compliance/monitoring',
},
{
type: ['team', 'e20', 'cloud_enterprise'],
header: 'Custom Terms of Service',
sidebar: 'Custom Terms of Service',
url: 'admin_console/compliance/custom_terms_of_service',
},
{
type: ['team', 'e20', 'cloud_enterprise'],
header: 'Experimental Features',
sidebar: 'Features',
url: 'admin_console/experimental/features',
},
{
type: ['team', 'e20', 'cloud_enterprise'],
header: 'Feature Flags',
sidebar: 'Feature Flags',
url: 'admin_console/experimental/feature_flags',
},
];

View File

@@ -0,0 +1,29 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
export function reportBenchmarkResults(cy, win) {
const testName = getTestName();
const selectors = win.getSortedTrackedSelectors();
win.dumpTrackedSelectorsStatistics();
cy.log(selectors.length);
cy.writeFile(`tests/integration/benchmark/__benchmarks__/${testName}.json`, JSON.stringify(selectors));
}
// From https://github.com/cypress-io/cypress/issues/2972#issuecomment-577072392
function getTestName() {
const cypressContext = Cypress.mocha.getRunner().suite.ctx.test;
const testTitles = [];
function extractTitles(obj) {
if (Object.hasOwn(obj, 'parent')) {
testTitles.push(obj.title);
const nextObj = obj.parent;
extractTitles(nextObj);
}
}
extractTitles(cypressContext);
const orderedTitles = testTitles.reverse();
const fileName = orderedTitles.join(' -- ');
return fileName;
}

View File

@@ -0,0 +1,34 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
export function getKeycloakServerSettings() {
const baseUrl = Cypress.config('baseUrl');
const {keycloakBaseUrl, keycloakAppName} = Cypress.expose();
const idpDescriptorUrl = `${keycloakBaseUrl}/auth/realms/${keycloakAppName}`;
const idpUrl = `${idpDescriptorUrl}/protocol/saml`;
return {
SamlSettings: {
Enable: true,
Encrypt: false,
IdpURL: idpUrl,
IdpDescriptorURL: idpDescriptorUrl,
ServiceProviderIdentifier: `${baseUrl}/login/sso/saml`,
AssertionConsumerServiceURL: `${baseUrl}/login/sso/saml`,
SignatureAlgorithm: 'RSAwithSHA256',
PublicCertificateFile: '',
PrivateKeyFile: '',
FirstNameAttribute: 'firstName',
LastNameAttribute: 'lastName',
EmailAttribute: 'email',
UsernameAttribute: 'username',
EnableSyncWithLdap: true,
EnableSyncWithLdapIncludeAuth: true,
IdAttribute: 'username',
},
LdapSettings: {
EnableSync: true,
BaseDN: 'ou=e2etest,dc=mm,dc=test,dc=com',
},
};
}

View File

@@ -0,0 +1,58 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
export const FEEDBACK_EMAIL = 'test@example.com';
export const ABOUT_LINK = 'https://mattermost.com/pl/about-mattermost';
export const ASK_COMMUNITY_LINK = 'https://mattermost.com/pl/default-ask-mattermost-community/';
export const HELP_LINK = 'https://mattermost.com/pl/help/';
export const PRIVACY_POLICY_LINK = 'https://mattermost.com/pl/privacy-policy/';
export const TERMS_OF_SERVICE_LINK = 'https://mattermost.com/pl/terms-of-use/';
export const MATTERMOST_USER_GUIDE = 'https://docs.mattermost.com/guides/use-mattermost.html';
export const CLOUD = 'Cloud';
export const E20 = 'E20';
export const TEAM = 'Team';
export const FixedPublicLinks = {
TermsOfService: 'https://mattermost.com/pl/terms-of-use/',
PrivacyPolicy: 'https://mattermost.com/pl/privacy-policy/',
};
export const SupportSettings = {
ABOUT_LINK,
ASK_COMMUNITY_LINK,
HELP_LINK,
PRIVACY_POLICY_LINK,
TERMS_OF_SERVICE_LINK,
MATTERMOST_USER_GUIDE,
};
export const FixedCloudConfig = {
EmailSettings: {
FEEDBACK_EMAIL,
},
SupportSettings,
};
export const ServerEdition = {
CLOUD,
E20,
TEAM,
};
export const Constants = {
FixedCloudConfig,
ServerEdition,
};
export const CustomStatusDuration = {
DONT_CLEAR: '',
THIRTY_MINUTES: 'thirty_minutes',
ONE_HOUR: 'one_hour',
FOUR_HOURS: 'four_hours',
TODAY: 'today',
THIS_WEEK: 'this_week',
DATE_AND_TIME: 'date_and_time',
};
export default Constants;

View File

@@ -0,0 +1,148 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
export function getEmailUrl() {
const smtpUrl = Cypress.expose('smtpUrl') || 'http://localhost:9001';
return `${smtpUrl}/api/v1/mailbox`;
}
export function splitEmailBodyText(text) {
return text.split('\n').map((d) => d.trim());
}
export function getEmailResetEmailTemplate(userEmail) {
return [
'----------------------',
'You updated your email',
'----------------------',
'',
`Your email address for Mattermost has been changed to ${userEmail}.`,
'If you did not make this change, please contact the system administrator.',
'',
'To change your notification preferences, log in to your team site and go to Settings > Notifications.',
];
}
export function getJoinEmailTemplate(sender, userEmail, team, isGuest = false) {
const baseUrl = Cypress.config('baseUrl');
return [
`${sender} invited you to join the ${team.display_name} team.`,
`${isGuest ? 'You were invited as a guest to collaborate with the team' : 'Start collaborating with your team on Mattermost'}`,
'',
`<join-link-check> Join now ( ${baseUrl}/signup_user_complete/?d=${encodeURIComponent(JSON.stringify({display_name: team.display_name.replace(' ', '+'), email: userEmail, name: team.name}))}&t=<actual-token> )`,
'',
'What is Mattermost?',
'Mattermost is a flexible, open source messaging platform that enables secure team collaboration.',
'Learn more ( mattermost.com )',
'',
`© 2015 - ${new Date().getFullYear()} Mattermost, Inc. 2100 Geng Road, Suite 210, Palo Alto, CA, 94303`,
];
}
export function getMentionEmailTemplate(sender, message, postId, siteName, teamName, channelDisplayName) {
const baseUrl = Cypress.config('baseUrl');
return [
`@${sender} mentioned you in a message`,
`While you were away, @${sender} mentioned you in the ${channelDisplayName} channel.`,
'',
`Reply in Mattermost ( ${baseUrl}/landing#/${teamName}/pl/${postId} )`,
'',
`@${sender}`,
'<skip-local-time-check>',
channelDisplayName,
'',
message,
'',
'Want to change your notifications settings?',
`Login to ${siteName} ( ${baseUrl} ) and go to Settings > Notifications`,
'',
`© 2015 - ${new Date().getFullYear()} Mattermost, Inc. 2100 Geng Road, Suite 210, Palo Alto, CA, 94303`,
];
}
export function getPasswordResetEmailTemplate() {
const baseUrl = Cypress.config('baseUrl');
return [
'Reset Your Password',
'Click the button below to reset your password. If you didn’t request this, you can safely ignore this email.',
'',
`<reset-password-link-check> Reset Password ( http://${baseUrl}/reset_password_complete?token=<actual-token> )`,
'',
'The password reset link expires in 24 hours.',
'',
`© 2015 - ${new Date().getFullYear()} Mattermost, Inc. 2100 Geng Road, Suite 210, Palo Alto, CA, 94303`,
];
}
export function getEmailVerifyEmailTemplate(userEmail) {
const baseUrl = Cypress.config('baseUrl');
return [
'Verify your email address',
`Thanks for joining ${baseUrl.split('/')[2]}. ( ${baseUrl} )`,
'Click below to verify your email address.',
'',
`<email-verify-link-check> Verify Email ( ${baseUrl}/do_verify_email?token=<actual-token>&email=${encodeURIComponent(userEmail)} )`,
'',
'This email address was used to create an account with Mattermost.',
'If it was not you, you can safely ignore this email.',
'',
`© 2015 - ${new Date().getFullYear()} Mattermost, Inc. 2100 Geng Road, Suite 210, Palo Alto, CA, 94303`,
];
}
export function getWelcomeEmailTemplate(userEmail, siteName, teamName) {
const baseUrl = Cypress.config('baseUrl');
return [
'Welcome to the team',
`Thanks for joining ${baseUrl.split('/')[2]}. ( ${baseUrl} )`,
'Click below to verify your email address.',
'',
`<email-verify-link-check> Verify Email ( ${baseUrl}/do_verify_email?token=<actual-token>&email=${encodeURIComponent(userEmail)}&redirect_to=/${teamName} )`,
'',
`This email address was used to create an account with ${siteName}.`,
'If it was not you, you can safely ignore this email.',
'',
'Download the desktop and mobile apps',
'For the best experience, download the apps for PC, Mac, iOS and Android.',
'',
'Download ( https://mattermost.com/pl/download-apps )',
'',
`© 2015 - ${new Date().getFullYear()} Mattermost, Inc. 2100 Geng Road, Suite 210, Palo Alto, CA, 94303`,
];
}
export function verifyEmailBody(expectedBody, actualBody) {
expect(expectedBody.length).to.equal(actualBody.length);
for (let i = 0; i < expectedBody.length; i++) {
if (expectedBody[i].includes('skip-local-time-check')) {
continue;
}
if (expectedBody[i].includes('email-verify-link-check')) {
expect(actualBody[i]).to.include('Verify Email');
expect(actualBody[i]).to.include('do_verify_email?token=');
continue;
}
if (expectedBody[i].includes('join-link-check')) {
expect(actualBody[i]).to.include('Join now');
expect(actualBody[i]).to.include('signup_user_complete/?d=');
continue;
}
if (expectedBody[i].includes('reset-password-link-check')) {
expect(actualBody[i]).to.include('Reset Password');
expect(actualBody[i]).to.include('reset_password_complete?token=');
continue;
}
expect(expectedBody[i], `Line ${i} expects "${expectedBody[i]}" but got ${actualBody[i]}`).to.equal(actualBody[i]);
}
}

View File

@@ -0,0 +1,27 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
// Converts a file size in bytes into a human-readable string of the form '123MB'.
export function fileSizeToString(bytes) {
// it's unlikely that we'll have files bigger than this
if (bytes > 1024 ** 4) {
// check if file is smaller than 10 to display fractions
if (bytes < (1024 ** 4) * 10) {
return (Math.round((bytes / (1024 ** 4)) * 10) / 10) + 'TB';
}
return Math.round(bytes / (1024 ** 4)) + 'TB';
} else if (bytes > 1024 ** 3) {
if (bytes < (1024 ** 3) * 10) {
return (Math.round((bytes / (1024 ** 3)) * 10) / 10) + 'GB';
}
return Math.round(bytes / (1024 ** 3)) + 'GB';
} else if (bytes > 1024 ** 2) {
if (bytes < (1024 ** 2) * 10) {
return (Math.round((bytes / (1024 ** 2)) * 10) / 10) + 'MB';
}
return Math.round(bytes / (1024 ** 2)) + 'MB';
} else if (bytes > 1024) {
return Math.round(bytes / 1024) + 'KB';
}
return bytes + 'B';
}

View File

@@ -0,0 +1,102 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {v4 as uuidv4} from 'uuid';
import messageMenusData from '../fixtures/hooks/message_menus.json';
import messageMenusWithDatasourceData from '../fixtures/hooks/message_menus_with_datasource.json';
export * from './constants';
export * from './email';
export * from './file';
export * from './plugins';
/**
* @param {Number} length - length on random string to return, e.g. 7 (default)
* @return {String} random string
*/
export function getRandomId(length = 7) {
const MAX_SUBSTRING_INDEX = 27;
return uuidv4().replace(/-/g, '').substring(MAX_SUBSTRING_INDEX - length, MAX_SUBSTRING_INDEX);
}
export function getRandomLetter(length) {
return Array.from({length}, () => String.fromCharCode(97 + Math.floor(Math.random() * 26))).join('');
}
export function getMessageMenusPayload({dataSource, options, prefix = Date.now()} = {}) {
let data;
if (dataSource) {
data = messageMenusWithDatasourceData;
data.attachments[0].actions[0].data_source = dataSource;
data.attachments[0].pretext = `${prefix}: This is attachment pretext with ${dataSource} options`;
data.attachments[0].text = `${prefix}: This is attachment text with ${dataSource} options`;
} else {
data = messageMenusData;
data.attachments[0].pretext = `${prefix}: This is attachment pretext with basic options`;
data.attachments[0].text = `${prefix}: This is attachment text with basic options`;
if (options) {
data.attachments[0].actions[0].options = options;
}
}
const callbackUrl = Cypress.expose().webhookBaseUrl + '/message_menus';
data.attachments[0].actions[0].integration.url = callbackUrl;
return data;
}
export function hexToRgbArray(hex) {
const rgbArr = hex.replace('#', '').match(/.{1,2}/g);
return [
parseInt(rgbArr[0], 16),
parseInt(rgbArr[1], 16),
parseInt(rgbArr[2], 16),
];
}
export function rgbArrayToString(rgbArr) {
return `rgb(${rgbArr[0]}, ${rgbArr[1]}, ${rgbArr[2]})`;
}
// Returns a FIPS-compliant test password (>= 14 chars with complexity).
// Static for now but could generate unique passwords if requirements change.
export function newTestPassword() {
return 'Passwd4Testing!';
}
export const reUrl = /(https?:\/\/[^ ]*)/;
const userAgent = () => window.navigator.userAgent;
export function isWindows() {
return userAgent().indexOf('Windows') !== -1;
}
export function isMac() {
return userAgent().indexOf('Macintosh') !== -1;
}
// Stubs out the clipboard so that we can intercept copy events. Note that this only stubs out calls to
// navigator.clipboard.writeText and not document.execCommand.
export function stubClipboard() {
const clipboard = {contents: '', wasCalled: false};
cy.window().then((win) => {
if (!win.navigator.clipboard) {
win.navigator.clipboard = {
writeText: () => {},
};
}
cy.stub(win.navigator.clipboard, 'writeText').callsFake((link) => {
clipboard.wasCalled = true;
clipboard.contents = link;
return Promise.resolve(true);
});
});
return cy.wrap(clipboard);
}

View File

@@ -0,0 +1,80 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
/**
* @id - plugin ID
* @version - plugin version
* @url - A URL where the plugin can be downloaded
* @filename - Name of a plugin file which should be available at "e2e/cypress/tests/fixtures/[filename]"
* upon manual download from the given URL. File is not to be included in the commit.
*
* Note:
* 1. Only those with "@filename" field is required to have corresponding file at fixtures folder.
* Download the plugin file from the given "@url" and save to "e2e/cypress/tests/fixtures/[@filename]".
* 2. Plugin should typically install in test via URL, unless it is specifically required to upload
* by file.
*/
export const agendaPlugin = {
id: 'com.mattermost.agenda',
version: '0.2.2',
url: 'https://github.com/mattermost/mattermost-plugin-agenda/releases/download/v0.2.2/com.mattermost.agenda-0.2.2.tar.gz',
};
export const demoPlugin = {
id: 'com.mattermost.demo-plugin',
version: '0.11.0',
url: 'https://github.com/mattermost/mattermost-plugin-demo/releases/download/v0.11.0/mattermost-plugin-demo-v0.11.0.tar.gz',
filename: 'mattermost-plugin-demo-v0.11.0.tar.gz',
};
export const demoPluginOld = {
id: 'com.mattermost.demo-plugin',
version: '0.8.0',
url: 'https://github.com/mattermost/mattermost-plugin-demo/releases/download/v0.8.0/com.mattermost.demo-plugin-0.8.0.tar.gz',
filename: 'com.mattermost.demo-plugin-0.8.0.tar.gz',
};
export const drawPlugin = {
id: 'com.mattermost.draw-plugin',
version: '0.0.4',
url: 'https://github.com/jespino/mattermost-plugin-draw/releases/download/v0.0.4/com.mattermost.draw-plugin-0.0.4.tar.gz',
};
export const githubPlugin = {
id: 'github',
version: '2.0.1',
url: 'https://github.com/mattermost/mattermost-plugin-github/releases/download/v2.0.1/github-2.0.1.tar.gz',
};
export const githubPluginOld = {
id: 'github',
version: '1.0.0',
url: 'https://github.com/mattermost/mattermost-plugin-github/releases/download/v1.0.0/github-1.0.0.tar.gz',
};
export const gitlabPlugin = {
id: 'com.github.manland.mattermost-plugin-gitlab',
version: '1.3.0',
url: 'https://github.com/mattermost/mattermost-plugin-gitlab/releases/download/v1.3.0/com.github.manland.mattermost-plugin-gitlab-1.3.0.tar.gz',
filename: 'com.github.manland.mattermost-plugin-gitlab-1.3.0.tar.gz',
};
export const jiraPlugin = {
id: 'jira',
version: '3.0.1',
url: 'https://github.com/mattermost/mattermost-plugin-jira/releases/download/v3.0.1/jira-3.0.1.tar.gz',
};
export const matterpollPlugin = {
id: 'com.github.matterpoll.matterpoll',
version: '1.8.0',
url: 'https://github.com/matterpoll/matterpoll/releases/download/v1.8.0/com.github.matterpoll.matterpoll-1.8.0.tar.gz',
filename: 'com.github.matterpoll.matterpoll-1.8.0.tar.gz',
};
export const testPlugin = {
id: 'com.mattermost.test-plugin',
version: '0.1.0',
url: 'https://github.com/mattermost/mattermost-plugin-test/releases/download/v0.1.0/com.mattermost.test-plugin-0.1.0.tar.gz',
};

View File

@@ -0,0 +1,15 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import timezones from 'timezones.json';
export function getTimezoneLabel(timezone = '') {
for (let i = 0; i < timezones.length; i++) {
const zone = timezones[i];
if (zone.utc.includes(timezone)) {
return zone.text;
}
}
return timezone;
}