From 56260e93d4b311ace7d7d8202c2f325c500c5553 Mon Sep 17 00:00:00 2001 From: Harshil Sharma <18575143+harshilsharma63@users.noreply.github.com> Date: Tue, 12 Nov 2024 11:26:14 +0530 Subject: [PATCH] Added debug settings for testing and e2e tests (#29175) --- server/channels/app/server.go | 12 ++++++++++-- .../scheduled_post_custom_time_modal.tsx | 4 ++++ .../src/selectors/entities/general.ts | 4 ++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/server/channels/app/server.go b/server/channels/app/server.go index ca3abe38d0..3ae0fe59d7 100644 --- a/server/channels/app/server.go +++ b/server/channels/app/server.go @@ -82,7 +82,8 @@ import ( ) const ( - scheduledPostJobInterval = 5 * time.Minute + scheduledPostJobInterval = 5 * time.Minute + debugScheduledPostJobInterval = 2 * time.Second ) var SentryDSN = "https://9d7c9cccf549479799f880bcf4f26323@o94110.ingest.sentry.io/5212327" @@ -1841,10 +1842,17 @@ func runScheduledPostJob(a *App) { } func doRunScheduledPostJob(a *App) { + var jobInterval time.Duration + if *a.Config().ServiceSettings.EnableTesting { + jobInterval = debugScheduledPostJobInterval + } else { + jobInterval = scheduledPostJobInterval + } + rctx := request.EmptyContext(a.Log()) withMut(&a.ch.scheduledPostMut, func() { fn := func() { a.ProcessScheduledPosts(rctx) } - a.ch.scheduledPostTask = model.CreateRecurringTaskFromNextIntervalTime("Process Scheduled Posts", fn, scheduledPostJobInterval) + a.ch.scheduledPostTask = model.CreateRecurringTaskFromNextIntervalTime("Process Scheduled Posts", fn, jobInterval) }) } diff --git a/webapp/channels/src/components/advanced_text_editor/send_button/scheduled_post_custom_time_modal/scheduled_post_custom_time_modal.tsx b/webapp/channels/src/components/advanced_text_editor/send_button/scheduled_post_custom_time_modal/scheduled_post_custom_time_modal.tsx index ef5d96f3f9..8f66d15ab9 100644 --- a/webapp/channels/src/components/advanced_text_editor/send_button/scheduled_post_custom_time_modal/scheduled_post_custom_time_modal.tsx +++ b/webapp/channels/src/components/advanced_text_editor/send_button/scheduled_post_custom_time_modal/scheduled_post_custom_time_modal.tsx @@ -8,6 +8,7 @@ import {FormattedMessage, useIntl} from 'react-intl'; import {useDispatch, useSelector} from 'react-redux'; import {savePreferences} from 'mattermost-redux/actions/preferences'; +import {testingEnabled} from 'mattermost-redux/selectors/entities/general'; import {generateCurrentTimezoneLabel, getCurrentTimezone} from 'mattermost-redux/selectors/entities/timezone'; import {getCurrentUserId} from 'mattermost-redux/selectors/entities/users'; @@ -76,6 +77,8 @@ export default function ScheduledPostCustomTimeModal({channelId, onExited, onCon const label = formatMessage({id: 'schedule_post.custom_time_modal.title', defaultMessage: 'Schedule message'}); + const timePickerInterval = useSelector(testingEnabled) ? 1 : undefined; + return ( ); } diff --git a/webapp/channels/src/packages/mattermost-redux/src/selectors/entities/general.ts b/webapp/channels/src/packages/mattermost-redux/src/selectors/entities/general.ts index 4927522935..722f3503fd 100644 --- a/webapp/channels/src/packages/mattermost-redux/src/selectors/entities/general.ts +++ b/webapp/channels/src/packages/mattermost-redux/src/selectors/entities/general.ts @@ -161,3 +161,7 @@ export const getUsersStatusAndProfileFetchingPollInterval: (state: GlobalState) export function developerModeEnabled(state: GlobalState): boolean { return state.entities.general.config.EnableDeveloper === 'true'; } + +export function testingEnabled(state: GlobalState): boolean { + return state.entities.general.config.EnableTesting === 'true'; +}