Skip to content

Commit

Permalink
fix: hide some debug options in prod build
Browse files Browse the repository at this point in the history
  • Loading branch information
limpbrains committed Jun 13, 2024
1 parent 502cbc5 commit 73f2fef
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 84 deletions.
50 changes: 25 additions & 25 deletions e2e/settings.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -613,31 +613,31 @@ d('Settings', () => {
});
});

// d('Dev Settings', () => {
// it('Shows the crash error screen when triggering render error', async () => {
// if (checkComplete('settings-dev')) {
// return;
// }

// await element(by.id('Settings')).tap();
// if (!__DEV__) {
// await element(by.id('DevOptions')).multiTap(5); // enable dev mode
// }
// await element(by.id('DevSettings')).tap();

// // Error screen will not be rendered in development mode
// if (__DEV__) {
// markComplete('settings-dev');
// return;
// }

// await element(by.id('TriggerRenderError')).tap();
// await expect(element(by.id('ErrorClose'))).toBeVisible();
// await expect(element(by.id('ErrorReport'))).toBeVisible();

// markComplete('settings-dev');
// });
// });
d('Dev Settings', () => {
it('Shows the crash error screen when triggering render error', async () => {
if (checkComplete('settings-dev')) {
return;
}

await element(by.id('Settings')).tap();
if (!__DEV__) {
await element(by.id('DevOptions')).multiTap(5); // enable dev mode
}
await element(by.id('DevSettings')).tap();

// Error screen will not be rendered in development mode
if (__DEV__) {
markComplete('settings-dev');
return;
}

await element(by.id('TriggerRenderError')).tap();
await expect(element(by.id('ErrorClose'))).toBeVisible();
await expect(element(by.id('ErrorReport'))).toBeVisible();

markComplete('settings-dev');
});
});

d('Support', () => {
it('Can see app status', async () => {
Expand Down
126 changes: 67 additions & 59 deletions src/screens/Settings/DevSettings/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,15 @@ import { getFakeTransaction } from '../../../utils/wallet/testing';
import Dialog from '../../../components/Dialog';
import { resetBackupState } from '../../../store/slices/backup';
import { updateUi } from '../../../store/slices/ui';
import { __E2E__ } from '../../../constants/env';

const DevSettings = ({
navigation,
}: SettingsScreenProps<'DevSettings'>): ReactElement => {
const dispatch = useAppDispatch();
const { t } = useTranslation('lightning');
const [showDialog, setShowDialog] = useState(false);
// const [throwError, setThrowError] = useState(false);
const [throwError, setThrowError] = useState(false);
const selectedWallet = useAppSelector(selectedWalletSelector);
const selectedNetwork = useAppSelector(selectedNetworkSelector);
const addressType = useAppSelector(addressTypeSelector);
Expand Down Expand Up @@ -162,61 +163,6 @@ const DevSettings = ({
refreshWallet({ selectedWallet, selectedNetwork }).then();
},
},
// {
// title: 'Trigger exception in React render',
// type: EItemType.button,
// testID: 'TriggerRenderError',
// onPress: (): void => {
// setThrowError(true);
// },
// },
{
title: 'Trigger exception in action handler',
type: EItemType.button,
testID: 'TriggerActionError',
onPress: (): void => {
throw new Error('test action error');
},
},
{
title: 'Trigger unhandled async exception',
type: EItemType.button,
testID: 'TriggerAsyncError',
onPress: (): void => {
throw new Error('test async error');
},
},
{
title: 'Trigger Storage Warning',
type: EItemType.button,
hide: selectedNetwork !== 'bitcoinRegtest',
testID: 'TriggerStorageWarning',
onPress: (): void => {
const wallet = getWalletStore();
const addresses =
wallet.wallets[selectedWallet].addresses[selectedNetwork][
addressType
];
Object.keys(addresses).map((key) => {
if (addresses[key].index === 0) {
addresses[key].address =
'bcrt1qjp22nm804mtl6vtzf65z2jgmeaedrlvzlxffjv';
}
});
const changeAddresses =
wallet.wallets[selectedWallet].changeAddresses[selectedNetwork][
addressType
];
Object.keys(changeAddresses).map((key) => {
if (changeAddresses[key].index === 0) {
changeAddresses[key].address =
'bcrt1qwxfllzxchc9eq95zrcc9cjxhzqpkgtznc4wpzc';
}
});
updateWallet(wallet);
runChecks({ selectedWallet, selectedNetwork }).then();
},
},
],
},
{
Expand Down Expand Up @@ -331,9 +277,71 @@ const DevSettings = ({
},
];

// if (throwError) {
// throw new Error('test render error');
// }
// add only in dev or e2e mode
if (__DEV__ || __E2E__) {
settingsListData[1].data = [
...settingsListData[1].data,
{
title: 'Trigger exception in React render',
type: EItemType.button,
testID: 'TriggerRenderError',
onPress: (): void => {
setThrowError(true);
},
},
{
title: 'Trigger exception in action handler',
type: EItemType.button,
testID: 'TriggerActionError',
onPress: (): void => {
throw new Error('test action error');
},
},
{
title: 'Trigger unhandled async exception',
type: EItemType.button,
testID: 'TriggerAsyncError',
onPress: (): void => {
throw new Error('test async error');
},
},
{
title: 'Trigger Storage Warning',
type: EItemType.button,
hide: selectedNetwork !== 'bitcoinRegtest',
testID: 'TriggerStorageWarning',
onPress: (): void => {
const wallet = getWalletStore();
const addresses =
wallet.wallets[selectedWallet].addresses[selectedNetwork][
addressType
];
Object.keys(addresses).map((key) => {
if (addresses[key].index === 0) {
addresses[key].address =
'bcrt1qjp22nm804mtl6vtzf65z2jgmeaedrlvzlxffjv';
}
});
const changeAddresses =
wallet.wallets[selectedWallet].changeAddresses[selectedNetwork][
addressType
];
Object.keys(changeAddresses).map((key) => {
if (changeAddresses[key].index === 0) {
changeAddresses[key].address =
'bcrt1qwxfllzxchc9eq95zrcc9cjxhzqpkgtznc4wpzc';
}
});
updateWallet(wallet);
runChecks({ selectedWallet, selectedNetwork }).then();
},
},
];
}

if (throwError) {
throw new Error('test render error');
}

return (
<>
Expand Down

0 comments on commit 73f2fef

Please sign in to comment.