Skip to content

Commit

Permalink
Revert "Merge pull request #56926 from callstack-internal/feat/add-tr…
Browse files Browse the repository at this point in the history
…oubleshoot-menu-to-publicscreens"

This reverts commit fd654cb, reversing
changes made to aea1f85.
  • Loading branch information
carlosmiceli committed Feb 25, 2025
1 parent cba89eb commit d49a6d4
Show file tree
Hide file tree
Showing 17 changed files with 239 additions and 306 deletions.
8 changes: 1 addition & 7 deletions src/Expensify.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,9 @@ import GrowlNotification from './components/GrowlNotification';
import RequireTwoFactorAuthenticationModal from './components/RequireTwoFactorAuthenticationModal';
import AppleAuthWrapper from './components/SignInButtons/AppleAuthWrapper';
import SplashScreenHider from './components/SplashScreenHider';
import TestToolsModal from './components/TestToolsModal';
import UpdateAppModal from './components/UpdateAppModal';
import * as CONFIG from './CONFIG';
import CONST from './CONST';
import useDebugShortcut from './hooks/useDebugShortcut';
import useIsAuthenticated from './hooks/useIsAuthenticated';
import useLocalize from './hooks/useLocalize';
import {updateLastRoute} from './libs/actions/App';
import {disconnect} from './libs/actions/Delegate';
Expand Down Expand Up @@ -100,8 +97,6 @@ function Expensify() {
const [focusModeNotification] = useOnyx(ONYXKEYS.FOCUS_MODE_NOTIFICATION, {initWithStoredValues: false});
const [lastVisitedPath] = useOnyx(ONYXKEYS.LAST_VISITED_PATH);

useDebugShortcut();

useEffect(() => {
if (!account?.needsTwoFactorAuthSetup || account.requiresTwoFactorAuth) {
return;
Expand All @@ -118,7 +113,7 @@ function Expensify() {
setAttemptedToOpenPublicRoom(true);
}, [isCheckingPublicRoom]);

const isAuthenticated = useIsAuthenticated();
const isAuthenticated = useMemo(() => !!(session?.authToken ?? null), [session]);
const autoAuthState = useMemo(() => session?.autoAuthState ?? '', [session]);

const shouldInit = isNavigationReady && hasAttemptedToOpenPublicRoom;
Expand Down Expand Up @@ -311,7 +306,6 @@ function Expensify() {
/>
)}
{shouldHideSplash && <SplashScreenHider onHide={onSplashHide} />}
<TestToolsModal />
</DeeplinkWrapper>
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/ROUTES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ const ROUTES = {
SETTINGS_STATUS_CLEAR_AFTER_DATE: 'settings/profile/status/clear-after/date',
SETTINGS_STATUS_CLEAR_AFTER_TIME: 'settings/profile/status/clear-after/time',
SETTINGS_TROUBLESHOOT: 'settings/troubleshoot',
CONSOLE_DEBUG: {
SETTINGS_CONSOLE: {
route: 'settings/troubleshoot/console',
getRoute: (backTo?: string) => getUrlWithBackToParam(`settings/troubleshoot/console`, backTo),
},
Expand Down
2 changes: 1 addition & 1 deletion src/SCREENS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ const SCREENS = {
ADVANCED_FILTERS_IN_RHP: 'Search_Advanced_Filters_In_RHP',
TRANSACTION_HOLD_REASON_RHP: 'Search_Transaction_Hold_Reason_RHP',
},
CONSOLE_DEBUG: 'Console_Debug',
SETTINGS: {
ROOT: 'Settings_Root',
SHARE_CODE: 'Settings_Share_Code',
Expand All @@ -78,6 +77,7 @@ const SCREENS = {
CLOSE: 'Settings_Close',
REPORT_CARD_LOST_OR_DAMAGED: 'Settings_ReportCardLostOrDamaged',
TROUBLESHOOT: 'Settings_Troubleshoot',
CONSOLE: 'Settings_Console',
SHARE_LOG: 'Share_Log',

PROFILE: {
Expand Down
97 changes: 45 additions & 52 deletions src/components/TestToolMenu.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import React from 'react';
import {useOnyx} from 'react-native-onyx';
import useIsAuthenticated from '@hooks/useIsAuthenticated';
import useLocalize from '@hooks/useLocalize';
import useThemeStyles from '@hooks/useThemeStyles';
import {isUsingStagingApi} from '@libs/ApiUtils';
import {setShouldFailAllRequests, setShouldForceOffline, setShouldSimulatePoorConnection} from '@userActions/Network';
import {expireSessionWithDelay, invalidateAuthToken, invalidateCredentials} from '@userActions/Session';
import {setIsDebugModeEnabled, setShouldUseStagingServer} from '@userActions/User';
import * as ApiUtils from '@libs/ApiUtils';

Check failure on line 5 in src/components/TestToolMenu.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Namespace imports from @libs are not allowed. Use named imports instead. Example: import { method } from "@libs/module"
import * as Network from '@userActions/Network';

Check failure on line 6 in src/components/TestToolMenu.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Namespace imports from @userActions are not allowed. Use named imports instead. Example: import { action } from "@userActions/module"
import * as Session from '@userActions/Session';

Check failure on line 7 in src/components/TestToolMenu.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Namespace imports from @userActions are not allowed. Use named imports instead. Example: import { action } from "@userActions/module"
import * as User from '@userActions/User';

Check failure on line 8 in src/components/TestToolMenu.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

Namespace imports from @userActions are not allowed. Use named imports instead. Example: import { action } from "@userActions/module"
import CONFIG from '@src/CONFIG';
import ONYXKEYS from '@src/ONYXKEYS';
import type {User as UserOnyx} from '@src/types/onyx';
Expand All @@ -29,14 +28,11 @@ function TestToolMenu() {
const [network] = useOnyx(ONYXKEYS.NETWORK);
const [user = USER_DEFAULT] = useOnyx(ONYXKEYS.USER);
const [isUsingImportedState] = useOnyx(ONYXKEYS.IS_USING_IMPORTED_STATE);
const shouldUseStagingServer = user?.shouldUseStagingServer ?? isUsingStagingApi();
const shouldUseStagingServer = user?.shouldUseStagingServer ?? ApiUtils.isUsingStagingApi();
const isDebugModeEnabled = !!user?.isDebugModeEnabled;
const styles = useThemeStyles();
const {translate} = useLocalize();

// Check if the user is authenticated to show options that require authentication
const isAuthenticated = useIsAuthenticated();

return (
<>
<Text
Expand All @@ -45,45 +41,14 @@ function TestToolMenu() {
>
{translate('initialSettingsPage.troubleshoot.testingPreferences')}
</Text>
{isAuthenticated && (
<>
{/* When toggled the app will be put into debug mode. */}
<TestToolRow title={translate('initialSettingsPage.troubleshoot.debugMode')}>
<Switch
accessibilityLabel={translate('initialSettingsPage.troubleshoot.debugMode')}
isOn={isDebugModeEnabled}
onToggle={() => setIsDebugModeEnabled(!isDebugModeEnabled)}
/>
</TestToolRow>

{/* Instantly invalidates a user's local authToken. Useful for testing flows related to reauthentication. */}
<TestToolRow title={translate('initialSettingsPage.troubleshoot.authenticationStatus')}>
<Button
small
text={translate('initialSettingsPage.troubleshoot.invalidate')}
onPress={() => invalidateAuthToken()}
/>
</TestToolRow>

{/* Invalidate stored user auto-generated credentials. Useful for manually testing sign out logic. */}
<TestToolRow title={translate('initialSettingsPage.troubleshoot.deviceCredentials')}>
<Button
small
text={translate('initialSettingsPage.troubleshoot.destroy')}
onPress={() => invalidateCredentials()}
/>
</TestToolRow>

{/* Sends an expired session to the FE and invalidates the session by the same time in the BE. Action is delayed for 15s */}
<TestToolRow title={translate('initialSettingsPage.troubleshoot.authenticationStatus')}>
<Button
small
text={translate('initialSettingsPage.troubleshoot.invalidateWithDelay')}
onPress={() => expireSessionWithDelay()}
/>
</TestToolRow>
</>
)}
{/* When toggled the app will be put into debug mode. */}
<TestToolRow title={translate('initialSettingsPage.troubleshoot.debugMode')}>
<Switch
accessibilityLabel={translate('initialSettingsPage.troubleshoot.debugMode')}
isOn={isDebugModeEnabled}
onToggle={() => User.setIsDebugModeEnabled(!isDebugModeEnabled)}
/>
</TestToolRow>

{/* Option to switch between staging and default api endpoints.
This enables QA, internal testers and external devs to take advantage of sandbox environments for 3rd party services like Plaid and Onfido.
Expand All @@ -93,7 +58,7 @@ function TestToolMenu() {
<Switch
accessibilityLabel="Use Staging Server"
isOn={shouldUseStagingServer}
onToggle={() => setShouldUseStagingServer(!shouldUseStagingServer)}
onToggle={() => User.setShouldUseStagingServer(!shouldUseStagingServer)}
/>
</TestToolRow>
)}
Expand All @@ -103,7 +68,7 @@ function TestToolMenu() {
<Switch
accessibilityLabel="Force offline"
isOn={!!network?.shouldForceOffline}
onToggle={() => setShouldForceOffline(!network?.shouldForceOffline)}
onToggle={() => Network.setShouldForceOffline(!network?.shouldForceOffline)}
disabled={!!isUsingImportedState || !!network?.shouldSimulatePoorConnection || network?.shouldFailAllRequests}
/>
</TestToolRow>
Expand All @@ -113,7 +78,7 @@ function TestToolMenu() {
<Switch
accessibilityLabel="Simulate poor internet connection"
isOn={!!network?.shouldSimulatePoorConnection}
onToggle={() => setShouldSimulatePoorConnection(!network?.shouldSimulatePoorConnection, network?.poorConnectionTimeoutID)}
onToggle={() => Network.setShouldSimulatePoorConnection(!network?.shouldSimulatePoorConnection, network?.poorConnectionTimeoutID)}
disabled={!!isUsingImportedState || !!network?.shouldFailAllRequests || network?.shouldForceOffline}
/>
</TestToolRow>
Expand All @@ -123,10 +88,38 @@ function TestToolMenu() {
<Switch
accessibilityLabel="Simulate failing network requests"
isOn={!!network?.shouldFailAllRequests}
onToggle={() => setShouldFailAllRequests(!network?.shouldFailAllRequests)}
onToggle={() => Network.setShouldFailAllRequests(!network?.shouldFailAllRequests)}
disabled={!!network?.shouldForceOffline || network?.shouldSimulatePoorConnection}
/>
</TestToolRow>

{/* Instantly invalidates a user's local authToken. Useful for testing flows related to reauthentication. */}
<TestToolRow title={translate('initialSettingsPage.troubleshoot.authenticationStatus')}>
<Button
small
text={translate('initialSettingsPage.troubleshoot.invalidate')}
onPress={() => Session.invalidateAuthToken()}
/>
</TestToolRow>

{/* Invalidate stored user auto-generated credentials. Useful for manually testing sign out logic. */}
<TestToolRow title={translate('initialSettingsPage.troubleshoot.deviceCredentials')}>
<Button
small
text={translate('initialSettingsPage.troubleshoot.destroy')}
onPress={() => Session.invalidateCredentials()}
/>
</TestToolRow>

{/* Sends an expired session to the FE and invalidates the session by the same time in the BE. Action is delayed for 15s */}
<TestToolRow title={translate('initialSettingsPage.troubleshoot.authenticationStatus')}>
<Button
small
text={translate('initialSettingsPage.troubleshoot.invalidateWithDelay')}
onPress={() => Session.expireSessionWithDelay()}
/>
</TestToolRow>

<TestCrash />
</>
);
Expand Down
2 changes: 1 addition & 1 deletion src/components/TestToolsModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function TestToolsModal() {
text={translate('initialSettingsPage.debugConsole.viewConsole')}
onPress={() => {
toggleTestToolsModal();
Navigation.navigate(ROUTES.CONSOLE_DEBUG.getRoute(Navigation.getActiveRoute()));
Navigation.navigate(ROUTES.SETTINGS_CONSOLE.getRoute(Navigation.getActiveRoute()));
}}
/>
</TestToolRow>
Expand Down
26 changes: 0 additions & 26 deletions src/hooks/useDebugShortcut.ts

This file was deleted.

11 changes: 0 additions & 11 deletions src/hooks/useIsAuthenticated.ts

This file was deleted.

13 changes: 13 additions & 0 deletions src/libs/Navigation/AppNavigator/AuthScreens.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import OptionsListContextProvider from '@components/OptionListContextProvider';
import {SearchContextProvider} from '@components/Search/SearchContext';
import {useSearchRouterContext} from '@components/Search/SearchRouter/SearchRouterContext';
import SearchRouterModal from '@components/Search/SearchRouter/SearchRouterModal';
import TestToolsModal from '@components/TestToolsModal';
import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails';
import useOnboardingFlowRouter from '@hooks/useOnboardingFlow';
import {ReportIDsContextProvider} from '@hooks/useReportIDs';
Expand Down Expand Up @@ -44,6 +45,7 @@ import * as PersonalDetails from '@userActions/PersonalDetails';
import * as PriorityMode from '@userActions/PriorityMode';
import * as Report from '@userActions/Report';
import * as Session from '@userActions/Session';
import toggleTestToolsModal from '@userActions/TestTool';
import * as User from '@userActions/User';
import CONFIG from '@src/CONFIG';
import CONST from '@src/CONST';
Expand Down Expand Up @@ -246,6 +248,7 @@ function AuthScreens({session, lastOpenedPublicRoomID, initialLastUpdateIDApplie
const shortcutsOverviewShortcutConfig = CONST.KEYBOARD_SHORTCUTS.SHORTCUTS;
const searchShortcutConfig = CONST.KEYBOARD_SHORTCUTS.SEARCH;
const chatShortcutConfig = CONST.KEYBOARD_SHORTCUTS.NEW_CHAT;
const debugShortcutConfig = CONST.KEYBOARD_SHORTCUTS.DEBUG;
const currentUrl = getCurrentUrl();
const isLoggingInAsNewUser = !!session?.email && SessionUtils.isLoggingInAsNewUser(currentUrl, session.email);
// Sign out the current user if we're transitioning with a different user
Expand Down Expand Up @@ -361,12 +364,21 @@ function AuthScreens({session, lastOpenedPublicRoomID, initialLastUpdateIDApplie
true,
);

const unsubscribeDebugShortcut = KeyboardShortcut.subscribe(
debugShortcutConfig.shortcutKey,
() => toggleTestToolsModal(),
debugShortcutConfig.descriptionKey,
debugShortcutConfig.modifiers,
true,
);

return () => {
unsubscribeEscapeKey();
unsubscribeOnyxModal();
unsubscribeShortcutsOverviewShortcut();
unsubscribeSearchShortcut();
unsubscribeChatShortcut();
unsubscribeDebugShortcut();
Session.cleanupSession();
};

Expand Down Expand Up @@ -615,6 +627,7 @@ function AuthScreens({session, lastOpenedPublicRoomID, initialLastUpdateIDApplie
component={ConnectionCompletePage}
/>
</RootStack.Navigator>
<TestToolsModal />
<SearchRouterModal />
<ActiveGuidesEventListener />
</ComposeProviders>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import React from 'react';
import createPlatformStackNavigator from '@libs/Navigation/PlatformStackNavigation/createPlatformStackNavigator';
import type {
AddPersonalBankAccountNavigatorParamList,
ConsoleNavigatorParamList,
DebugParamList,
EditRequestNavigatorParamList,
EnablePaymentsNavigatorParamList,
Expand Down Expand Up @@ -227,10 +226,6 @@ const NewTeachersUniteNavigator = createModalStackNavigator<TeachersUniteNavigat
[SCREENS.I_AM_A_TEACHER]: () => require<ReactComponentModule>('../../../../pages/TeachersUnite/ImTeacherPage').default,
});

const ConsoleModalStackNavigator = createModalStackNavigator<ConsoleNavigatorParamList>({
[SCREENS.CONSOLE_DEBUG]: () => require<ReactComponentModule>('../../../../pages/settings/AboutPage/ConsolePage').default,
});

const SettingsModalStackNavigator = createModalStackNavigator<SettingsNavigatorParamList>({
[SCREENS.SETTINGS.SHARE_CODE]: () => require<ReactComponentModule>('../../../../pages/ShareCodePage').default,
[SCREENS.SETTINGS.PROFILE.PRONOUNS]: () => require<ReactComponentModule>('../../../../pages/settings/Profile/PronounsPage').default,
Expand All @@ -252,7 +247,7 @@ const SettingsModalStackNavigator = createModalStackNavigator<SettingsNavigatorP
[SCREENS.SETTINGS.PREFERENCES.THEME]: () => require<ReactComponentModule>('../../../../pages/settings/Preferences/ThemePage').default,
[SCREENS.SETTINGS.CLOSE]: () => require<ReactComponentModule>('../../../../pages/settings/Security/CloseAccountPage').default,
[SCREENS.SETTINGS.APP_DOWNLOAD_LINKS]: () => require<ReactComponentModule>('../../../../pages/settings/AppDownloadLinks').default,
[SCREENS.CONSOLE_DEBUG]: () => require<ReactComponentModule>('../../../../pages/settings/AboutPage/ConsolePage').default,
[SCREENS.SETTINGS.CONSOLE]: () => require<ReactComponentModule>('../../../../pages/settings/AboutPage/ConsolePage').default,
[SCREENS.SETTINGS.SHARE_LOG]: () => require<ReactComponentModule>('../../../../pages/settings/AboutPage/ShareLogPage').default,
[SCREENS.SETTINGS.WALLET.CARDS_DIGITAL_DETAILS_UPDATE_ADDRESS]: () => require<ReactComponentModule>('../../../../pages/settings/Profile/PersonalDetails/PersonalAddressPage').default,
[SCREENS.SETTINGS.WALLET.DOMAIN_CARD]: () => require<ReactComponentModule>('../../../../pages/settings/Wallet/ExpensifyCardPage').default,
Expand Down Expand Up @@ -766,5 +761,4 @@ export {
MissingPersonalDetailsModalStackNavigator,
DebugModalStackNavigator,
WorkspaceConfirmationModalStackNavigator,
ConsoleModalStackNavigator,
};
Loading

0 comments on commit d49a6d4

Please sign in to comment.