Skip to content

Commit

Permalink
[#1515] Remove all consoles & capturing errors in AuthByPassForm
Browse files Browse the repository at this point in the history
  • Loading branch information
ifirmawan committed May 28, 2024
1 parent 830cb9a commit 54b4795
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
11 changes: 7 additions & 4 deletions app/src/pages/AuthByPassForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import React from 'react';
import { Asset } from 'expo-asset';
import { View, StyleSheet, Platform, ToastAndroid } from 'react-native';
import { Input, Button, Text, Dialog } from '@rneui/themed';
import * as Sentry from '@sentry/react-native';

import { CenterLayout, Image } from '../components';
import { api, cascades, i18n } from '../lib';
import { AuthState, UserState, UIState } from '../store';
Expand Down Expand Up @@ -37,17 +39,15 @@ const AuthByPassForm = ({ navigation }) => {
const bearerToken = 'NO TOKEN';
const lastSession = await crudSessions.selectLastSession();
if (!lastSession && lastSession?.token !== bearerToken) {
console.info('Saving tokens...');
await crudSessions.addSession({ token: bearerToken, passcode: 'NO PASSCODE' });
}
await cascades.createSqliteDir();
// save forms
const savedForm = await crudForms.addForm({
await crudForms.addForm({
id: data.id,
version: data.version,
formJSON: data,
});
console.info('Saved Forms...', data.id, savedForm);
// download cascades files
if (data?.cascades?.length) {
data.cascades.forEach((cascadeFile) => {
Expand Down Expand Up @@ -76,7 +76,10 @@ const AuthByPassForm = ({ navigation }) => {
goTo('Home');
}
} catch (err) {
console.error(err);
Sentry.captureMessage(
`[AuthByPassForm] Unable to store session, activeUser & redirect to Homepage`,
);
Sentry.captureException(err);
}
})
.catch((err) => {
Expand Down
2 changes: 0 additions & 2 deletions app/src/pages/__tests__/AuthByPassForm.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import { UIState } from '../../store';
jest.mock('../../lib/api');
jest.mock('../../database/crud');
jest.mock('../../lib/cascades');
// mock console error
global.console.error = jest.fn();

describe('AuthByPassForm', () => {
test('it renders correctly', () => {
Expand Down

0 comments on commit 54b4795

Please sign in to comment.