Skip to content
This repository has been archived by the owner on Jan 15, 2021. It is now read-only.

Commit

Permalink
Merge pull request #39 from mslipenchuk267/staging
Browse files Browse the repository at this point in the history
Login/Sign Up Validation, AutoLogin, and Background BLE in progress
  • Loading branch information
mslipenchuk267 authored Nov 9, 2020
2 parents d01a8e8 + f32d855 commit b0f996c
Show file tree
Hide file tree
Showing 42 changed files with 4,252 additions and 112 deletions.
1 change: 1 addition & 0 deletions App.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import PushNotificationManager from './components/PushNotificationManager';

LogBox.ignoreLogs([
'Require cycle:', // issued by the fetch() function -> doesn't affect anything
'VirtualizedLists should never be nested' // issued by the scanned device flat list in lcdview on homescreen
])


Expand Down
8 changes: 8 additions & 0 deletions __tests__/StateSelectorScreen.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ describe('StateSelectorScreen', () => {
fireEvent.changeText(getByTestId("stateSearchBar"), "weefwfwefwe");
expect(getByTestId('ListEmptyComponent')).not.toBeNull();
})

it('should not render ListEmptyComponent children for a valid search', () => {
const { getByTestId, queryByText } = render(<StateSelectorScreen />);

fireEvent.changeText(getByTestId("stateSearchBar"), "new");
expect(queryByText('no results found 🕵️')).toBeNull();
expect(queryByText('please try another query')).toBeNull();
})

it('renders the ListEmptyComponent text when user gives a search query with no results', () => {
const {getByTestId, queryByText} = render(<StateSelectorScreen />)
Expand Down
156 changes: 156 additions & 0 deletions __tests__/inputValidationHelper.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
import {
userNameInputValidator,
passwordInputValidator
} from "../helpers/inputValidationHelper";

describe('userNameInputValidator', () => {
//Username check
//True

//Username length equal 4
it('should return true if username is 4 chars', () => {
const result = userNameInputValidator("abcd");
const expectedResult = true

expect(result).toEqual(expectedResult)
})

//Username length equal 5
it('should return true if username is 15 chars', () => {
const result = userNameInputValidator("asdfghjklqwerty");
const expectedResult = true

expect(result).toEqual(expectedResult)
})

//Username length greater equal to 4 and less equal to 15
it('should return true if username is between 4 and 15 chars', () => {
const result = userNameInputValidator("asdfghjkl");
const expectedResult = true

expect(result).toEqual(expectedResult)
})

//Username contains no white space
it('should return true if username contains no space', () => {
const result = userNameInputValidator("T8D5k2neQWbq");
const expectedResult = true
expect(result).toEqual(expectedResult)
})

//Username contains no trailing
it('should return true if username contains no trailing', () => {
const result = userNameInputValidator("T8D5k2neQWbq");
const expectedResult = true
expect(result).toEqual(expectedResult)
})

//Username doesn't contain special characters
it('should return true if username contains no special characters', () => {
const result = userNameInputValidator("45m8qWCsdG");
const expectedResult = true
expect(result).toEqual(expectedResult)
})



//False
//Username doesn't contain special characters
it('should return true if username contains no special characters', () => {
const result = userNameInputValidator("%45m8q=WCsdG");
const expectedResult = false
expect(result).toEqual(expectedResult)
})

//Username has trailing
it('should return false if username contains no trailing', () => {
const result = userNameInputValidator("_45m8qWCsdG");
const expectedResult = false
expect(result).toEqual(expectedResult)
})

//Username Contains space
it('should return false if username contains space', () => {
const result = userNameInputValidator("T8D5k2ne QWbq");
const expectedResult = false;
expect(result).toEqual(expectedResult)
})

//Username length less than 4
it('should return false if username is less than 4 chars', () => {
const result = userNameInputValidator("abc");
const expectedResult = false

expect(result).toEqual(expectedResult)
})

//Username length greater than 15
it('should return false if username is greater than 15 chars', () => {
const result = userNameInputValidator("asdfghjklqwertyu");
const expectedResult = false

expect(result).toEqual(expectedResult)
})
})

describe('passwordInputValidator', () => {
//Passwords check
//True:

//Passwords == 10
it('should return true if passwords length equals to 10', () => {
const result = passwordInputValidator("nhKmK4f4QY").numberValid;
const expectedResult = true
expect(result).toEqual(expectedResult)
})

//Passwords >=10 && < 24
it('should return true if passwords length greater equals to 10 and less than 24', () => {
const result = passwordInputValidator("4dztUk7pVG2GNwznptW").lengthValid;
const expectedResult = true
expect(result).toEqual(expectedResult)
})

//Passwords contains uppercase,lowercase, and numebers
it('should return true if Passwords contains uppercase,lowercase, and numebers', () => {
const result = passwordInputValidator("fGuED93mw2eh5tbtngX").isValid;
const expectedResult = true
expect(result).toEqual(expectedResult)
})

//False:
//Passwords < 10
it('should return false if Passwords length less than 10', () => {
const result = passwordInputValidator("DuWp65h").lengthValid;
const expectedResult = false
expect(result).toEqual(expectedResult)
})

//Passwords > 24
it('should return false if Passwords length greater than 24', () => {
const result = passwordInputValidator("3WxqC559sgaeckWKqVxQZuS5y").lengthValid;
const expectedResult = false
expect(result).toEqual(expectedResult)
})

//Passwords do not contains uppercase
it('should return false if Passwords do not contains uppercase', () => {
const result = passwordInputValidator("t74q7s8srwdq").caseValid;
const expectedResult = false
expect(result).toEqual(expectedResult)
})

//Passwords do not contains lowercase
it('should return false if Passwords do not contains lowercase', () => {
const result = passwordInputValidator("WGPH9U6SPEYP").caseValid;
const expectedResult = false
expect(result).toEqual(expectedResult)
})

//Passwords do not contains numbers
it('should return false if Passwords do not contains number', () => {
const result = passwordInputValidator("ppNfpqUprYUC").numberValid;
const expectedResult = false
expect(result).toEqual(expectedResult)
})
})
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ android {
applicationId "com.parliament_temple"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 5
versionName "0.2"
versionCode 7
versionName "0.3"
missingDimensionStrategy 'react-native-camera', 'general' // for camera permissions
}
splits {
Expand Down
Binary file modified android/app/release/app-release.aab
Binary file not shown.
5 changes: 5 additions & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.CAMERA" />

<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />

<!-- Start of react-native-ble-plx permissions -->
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
Expand All @@ -31,6 +34,8 @@
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>

<service android:name="com.asterinet.react.bgactions.RNBackgroundActionsTask" />
</application>

</manifest>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions Components/CustomButton.js → components/CustomButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ const styles = StyleSheet.create({
button: {
backgroundColor: "white",
elevation: 10,
borderRadius: 20,
borderRadius: 40,
paddingVertical: 20,
paddingHorizontal: 40,
paddingHorizontal: 25,
alignItems: 'center',
overflow: 'hidden',
// shadow
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
32 changes: 32 additions & 0 deletions components/LCDTextView.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import React from 'react';
import { TextInput, StyleSheet } from 'react-native';
import { lightGrey, mediumGrey } from '../constants/colors';

const LCDTextView = (props) => {
return (
<TextInput
placeholder={props.placeholder}
value={props.value}
secureTextEntry={props.secureTextEntry}
style={styles.textInput}
autoCapitalize='none'
placeholderTextColor='grey'
autoCompleteType='off'
onChangeText={props.onChangeText}
testID={props.testID || null}
/>
);
}


const styles = StyleSheet.create({
textInput: {
backgroundColor: "transparent",
borderColor: "grey",
//minWidth: '80%',
fontSize: 16,
},
});


export default LCDTextView;
4 changes: 2 additions & 2 deletions Components/LCDView.js → components/LCDView.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const LCDView = (props) => {
style={{
paddingVertical: 1,
paddingHorizontal: 1,
borderRadius: 15,
borderRadius: 11,
}}
useAngle={true}
angle={145}
Expand All @@ -19,7 +19,7 @@ const LCDView = (props) => {
style={{
paddingVertical: 15,
paddingHorizontal: 15,
borderRadius: 14,
borderRadius: 11,
borderWidth: 1,
borderColor: '#8E9896',
}}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import { useDispatch, useSelector } from 'react-redux';
import * as userActions from '../store/actions/user';
import { handleNotification } from '../helpers/notificationHelper';



const PushNotificationManager = (props) => {
const dispatch = useDispatch();
const contactedIDs = useSelector(state => state.user.contactedIDs);
Expand All @@ -17,7 +15,7 @@ const PushNotificationManager = (props) => {
Notifications.events().registerRemoteNotificationsRegistered(event => {
// Set the device token state
dispatch(userActions.setDeviceToken(event.deviceToken));
console.log('Device Token Received', event.deviceToken)
console.log('PushNotificationManager.js/registerDevice() - Device Token Received', event.deviceToken)

})
Notifications.events().registerRemoteNotificationsRegistrationFailed(event => {
Expand All @@ -28,7 +26,7 @@ const PushNotificationManager = (props) => {

registerNotificationEvents = () => {
Notifications.events().registerNotificationReceivedForeground((notification, completion) => {
console.log('Notification Received - Foreground', notification)
console.log('PushNotificationManager.js/registerNotificationEvents() - Notification Received - Foreground', notification)
const matchedContacts = handleNotification(notification, contactedIDs);
dispatch(userActions.updateNotificationHistory(matchedContacts));
// Calling completion on iOS with `alert: true` will present the native iOS inApp notification.
Expand Down
2 changes: 1 addition & 1 deletion helpers/authHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const uploadDeviceToken = async (deviceToken, accessToken) => {
var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
var raw = JSON.stringify({ "accessToken": accessToken, "deviceKey": deviceToken });

console.log(raw);
var requestOptions = {
method: 'POST',
headers: myHeaders,
Expand Down
Loading

0 comments on commit b0f996c

Please sign in to comment.