Fakultas Ilmu Komputer UI

Commit 76e912fd authored by Nabilah Adani's avatar Nabilah Adani
Browse files

Merge branch 'zafir/ajukan-akun-kader' into 'pbi-5-form-akun-kader'

Zafir/ajukan akun kader

See merge request !1
parents e398fd65 2b7b7df2
Pipeline #76101 passed with stage
in 15 minutes and 59 seconds
......@@ -3,7 +3,7 @@
buildscript {
ext {
buildToolsVersion = "28.0.3"
minSdkVersion = 16
minSdkVersion = 21
compileSdkVersion = 28
targetSdkVersion = 28
}
......
File mode changed from 100755 to 100644
This diff is collapsed.
......@@ -18,10 +18,11 @@
"@types/crypto-js": "^3.1.44",
"@types/react-navigation": "^3.4.0",
"@types/styled-components": "^5.0.0",
"axios": "^0.19.2",
"axios": "^0.21.1",
"crypto-js": "^3.1.9-1",
"fbjs": "^3.0.0",
"react": "16.9.0",
"react-native": "^0.62.1",
"react-native": "^0.64.1",
"react-native-dotenv": "^0.2.0",
"react-native-gesture-handler": "^1.6.0",
"react-native-reanimated": "^1.7.0",
......@@ -41,13 +42,13 @@
"@types/react-test-renderer": "16.9.1",
"@typescript-eslint/eslint-plugin": "^2.12.0",
"@typescript-eslint/parser": "^2.12.0",
"babel-jest": "^25.2.6",
"babel-jest": "^25.5.1",
"babel-plugin-module-resolver": "^4.0.0",
"eslint": "^6.5.1",
"identity-obj-proxy": "^3.0.0",
"jest": "^25.1.0",
"jest": "^25.5.4",
"metro-react-native-babel-preset": "^0.56.0",
"react-test-renderer": "16.9.0",
"react-test-renderer": "^17.0.2",
"typescript": "^3.7.3"
},
"jest": {
......@@ -66,6 +67,9 @@
},
"setupFiles": [
"./node_modules/react-native-gesture-handler/jestSetup.js"
],
"transformIgnorePatterns": [
"node_modules/(?!react-native|react-navigation)/"
]
},
"rnpm": {
......
......@@ -8,6 +8,7 @@ import App from '.';
// Note: test renderer must be required after react-native.
import renderer from 'react-test-renderer';
jest.useFakeTimers();
it('renders correctly', () => {
renderer.create(<App />);
......
......@@ -163,7 +163,7 @@ exports[`DatePicker tests renders correctly 1`] = `
]
}
>
6/4/2020
10/5/2021
</Text>
</View>
<View
......
declare module '*.jpg';
declare module '*.jpeg';
declare module '*.png';
\ No newline at end of file
......@@ -30,6 +30,7 @@ const testProps = {
setCache: jest.fn()
};
jest.mock('axios');
jest.useFakeTimers();
const mockedAxios = axios as jest.Mocked<typeof axios>;
describe('Contact investigation form step 1', () => {
......
......@@ -42,6 +42,7 @@ const testProps = {
}
jest.mock('axios');
jest.useFakeTimers();
const mockedAxios = axios as jest.Mocked<typeof axios>;
mockedAxios.request.mockImplementation(
() => new Promise(resolve => {
......
......@@ -11,6 +11,7 @@ import Log from '.';
import ReactTestRenderer, {act} from 'react-test-renderer';
jest.mock('axios');
jest.useFakeTimers();
const Stack = createStackNavigator();
const testProps = {
services: {
......
......@@ -20,6 +20,7 @@ const testProps = {
},
cache: {},
};
jest.useFakeTimers();
it('renders correctly', () => {
const instance = ReactTestRenderer.create(
......
......@@ -909,7 +909,7 @@ exports[`can press previous button 1`] = `
]
}
>
6/4/2020
10/5/2021
</Text>
</View>
<View
......@@ -2365,7 +2365,7 @@ exports[`renders correctly 1`] = `
]
}
>
6/4/2020
10/5/2021
</Text>
</View>
<View
......@@ -3821,7 +3821,7 @@ exports[`renders form with correct fields 1`] = `
]
}
>
6/4/2020
10/5/2021
</Text>
</View>
<View
......@@ -5277,7 +5277,7 @@ exports[`submit data succesfully 1`] = `
]
}
>
6/4/2020
10/5/2021
</Text>
</View>
<View
......
......@@ -663,7 +663,7 @@ exports[`can press previous button 1`] = `
]
}
>
6/4/2020
10/5/2021
</Text>
</View>
<View
......@@ -881,7 +881,7 @@ exports[`can press previous button 1`] = `
]
}
>
6/4/2020
10/5/2021
</Text>
</View>
<View
......@@ -2070,7 +2070,7 @@ exports[`renders correctly 1`] = `
]
}
>
6/4/2020
10/5/2021
</Text>
</View>
<View
......@@ -2288,7 +2288,7 @@ exports[`renders correctly 1`] = `
]
}
>
6/4/2020
10/5/2021
</Text>
</View>
<View
......@@ -3477,7 +3477,7 @@ exports[`renders form with correct fields 1`] = `
]
}
>
6/4/2020
10/5/2021
</Text>
</View>
<View
......@@ -3695,7 +3695,7 @@ exports[`renders form with correct fields 1`] = `
]
}
>
6/4/2020
10/5/2021
</Text>
</View>
<View
......@@ -4884,7 +4884,7 @@ exports[`submit data succesfully 1`] = `
]
}
>
6/4/2020
10/5/2021
</Text>
</View>
<View
......@@ -5102,7 +5102,7 @@ exports[`submit data succesfully 1`] = `
]
}
>
6/4/2020
10/5/2021
</Text>
</View>
<View
......
const KELURAHAN_VALUES: {label: string; value: string}[] = [
{label: 'Beji', value: 'Beji'},
{label: 'Beji Timur', value: 'Beji Timur'},
{label: 'Kemirimuka', value: 'Kemirimuka'},
{label: 'Kukusan', value: 'Kukusan'},
{label: 'Pondok Cina', value: 'Pondok Cina'},
{label: 'Tanah Baru', value: 'Tanah Baru'},
{label: 'Bojongsari Baru', value: 'Bojongsari Baru'},
{label: 'Bojongsari Lama', value: 'Bojongsari Lama'},
{label: 'Curug', value: 'Curug'},
{label: 'Duren Mekar', value: 'Duren Mekar'},
{label: 'Duren Seribu', value: 'Duren Seribu'},
{label: 'Pondok Petir', value: 'Pondok Petir'},
{label: 'Serua', value: 'Serua'},
{label: 'Cilodong', value: 'Cilodong'},
{label: 'Jatimulya', value: 'Jatimulya'},
{label: 'Kalibaru', value: 'Kalibaru'},
{label: 'Kalimulya', value: 'Kalimulya'},
{label: 'Sukamaju', value: 'Sukamaju'},
{label: 'Cisalak Pasar', value: 'Cisalak Pasar'},
{label: 'Curug', value: 'Curug'},
{label: 'Harjamukti', value: 'Harjamukti'},
{label: 'Mekarsari', value: 'Mekarsari'},
{label: 'Pasir Gunung Selatan', value: 'Pasir Gunung Selatan'},
{label: 'Tugu', value: 'Tugu'},
{label: 'Cinere', value: 'Cinere'},
{label: 'Gandul', value: 'Gandul'},
{label: 'Pangkalan Jati', value: 'Pangkalan Jati'},
{label: 'Pangkalan Jati Baru', value: 'Pangkalan Jati Baru'},
{label: 'Bojong Pondok Terong', value: 'Bojong Pondok Terong'},
{label: 'Cipayung', value: 'Cipayung'},
{label: 'Cipayung Jaya', value: 'Cipayung Jaya'},
{label: 'Pondok Jaya', value: 'Pondok Jaya'},
{label: 'Ratujaya', value: 'Ratujaya'},
{label: 'Grogol', value: 'Grogol'},
{label: 'Krukut', value: 'Krukut'},
{label: 'Limo', value: 'Limo'},
{label: 'Meruyung', value: 'Meruyung'},
{label: 'Depok', value: 'Depok'},
{label: 'Depok Jaya', value: 'Depok Jaya'},
{label: 'Mampang', value: 'Mampang'},
{label: 'Pancoran Mas', value: 'Pancoran Mas'},
{label: 'Rangkapan Jaya', value: 'Rangkapan Jaya'},
{label: 'Rangkapan Jaya Baru', value: 'Rangkapan Jaya Baru'},
{label: 'Bedahan', value: 'Bedahan'},
{label: 'Cinangka', value: 'Cinangka'},
{label: 'Kedaung', value: 'Kedaung'},
{label: 'Pasir Putih', value: 'Pasir Putih'},
{label: 'Pengasinan', value: 'Pengasinan'},
{label: 'Sawangan Baru', value: 'Sawangan Baru'},
{label: 'Sawangan Lama', value: 'Sawangan Lama'},
{label: 'Abadijaya', value: 'Abadijaya'},
{label: 'Bakti Jaya', value: 'Bakti Jaya'},
{label: 'Cisalak', value: 'Cisalak'},
{label: 'Mekar Jaya', value: 'Mekar Jaya'},
{label: 'Sukmajaya', value: 'Sukmajaya'},
{label: 'Tirtajaya', value: 'Tirtajaya'},
{label: 'Cilangkap', value: 'Cilangkap'},
{label: 'Cimpaeun', value: 'Cimpaeun'},
{label: 'Jatijajar', value: 'Jatijajar'},
{label: 'Leuwinanggung', value: 'Leuwinanggung'},
{label: 'Sukamaju Baru', value: 'Sukamaju Baru'},
{label: 'Sukatani', value: 'Sukatani'},
{label: 'Tapos', value: 'Tapos'},
];
const KECAMATAN_VALUES: {label: string; value: string}[] = [
{ label: 'Beji', value: 'Beji' },
{ label: 'Bojongsari', value: 'Bojongsari' },
{ label: 'Cilodong', value: 'Cilodong' },
{ label: 'Cimanggis', value: 'Cimanggis' },
{ label: 'Cinere', value: 'Cinere' },
{ label: 'Cipayung', value: 'Cipayung' },
{ label: 'Limo', value: 'Limo' },
{ label: 'Pancoran Mas', value: 'Pancoran Mas' },
{ label: 'Sawangan', value: 'Sawangan' },
{ label: 'Sukmajaya', value: 'Sukmajaya' },
{ label: 'Tapos', value: 'Tapos' },
];
const KELURAHAN_VALUES: { [key: string]: {label: string; value: string}[] } = {
'Beji': [
{ label: 'Beji', value: 'Beji' },
{ label: 'Beji Timur', value: 'Beji Timur' },
{ label: 'Kemirimuka', value: 'Kemirimuka' },
{ label: 'Kukusan', value: 'Kukusan' },
{ label: 'Pondok Cina', value: 'Pondok Cina' },
{ label: 'Tanah Baru', value: 'Tanah Baru' },
],
'Bojongsari': [
{ label: 'Bojongsari Baru', value: 'Bojongsari Baru' },
{ label: 'Bojongsari Lama', value: 'Bojongsari Lama' },
{ label: 'Curug', value: 'Curug' },
{ label: 'Duren Mekar', value: 'Duren Mekar' },
{ label: 'Duren Seribu', value: 'Duren Seribu' },
{ label: 'Pondok Petir', value: 'Pondok Petir' },
{ label: 'Serua', value: 'Serua' },
],
'Cilodong': [
{ label: 'Cilodong', value: 'Cilodong' },
{ label: 'Jatimulya', value: 'Jatimulya' },
{ label: 'Kalibaru', value: 'Kalibaru' },
{ label: 'Kalimulya', value: 'Kalimulya' },
{ label: 'Sukamaju', value: 'Sukamaju' },
],
'Cimanggis': [
{ label: 'Cisalak Pasar', value: 'Cisalak Pasar' },
{ label: 'Curug', value: 'Curug' },
{ label: 'Harjamukti', value: 'Harjamukti' },
{ label: 'Mekarsari', value: 'Mekarsari' },
{ label: 'Pasir Gunung Selatan', value: 'Pasir Gunung Selatan' },
{ label: 'Tugu', value: 'Tugu' },
],
'Cinere': [
{ label: 'Cinere', value: 'Cinere' },
{ label: 'Gandul', value: 'Gandul' },
{ label: 'Pangkalan Jati', value: 'Pangkalan Jati' },
{ label: 'Pangkalan Jati Baru', value: 'Pangkalan Jati Baru' },
],
'Cipayung': [
{ label: 'Bojong Pondok Terong', value: 'Bojong Pondok Terong' },
{ label: 'Cipayung', value: 'Cipayung' },
{ label: 'Cipayung Jaya', value: 'Cipayung Jaya' },
{ label: 'Pondok Jaya', value: 'Pondok Jaya' },
{ label: 'Ratujaya', value: 'Ratujaya' },
],
'Limo': [
{ label: 'Grogol', value: 'Grogol' },
{ label: 'Krukut', value: 'Krukut' },
{ label: 'Limo', value: 'Limo' },
{ label: 'Meruyung', value: 'Meruyung' },
],
'Pancoran Mas': [
{ label: 'Depok', value: 'Depok' },
{ label: 'Depok Jaya', value: 'Depok Jaya' },
{ label: 'Mampang', value: 'Mampang' },
{ label: 'Pancoran Mas', value: 'Pancoran Mas' },
{ label: 'Rangkapan Jaya', value: 'Rangkapan Jaya' },
{ label: 'Rangkapan Jaya Baru', value: 'Rangkapan Jaya Baru' },
],
'Sawangan': [
{ label: 'Bedahan', value: 'Bedahan' },
{ label: 'Cinangka', value: 'Cinangka' },
{ label: 'Kedaung', value: 'Kedaung' },
{ label: 'Pasir Putih', value: 'Pasir Putih' },
{ label: 'Pengasinan', value: 'Pengasinan' },
{ label: 'Sawangan Baru', value: 'Sawangan Baru' },
{ label: 'Sawangan Lama', value: 'Sawangan Lama' },
],
'Sukmajaya': [
{ label: 'Abadijaya', value: 'Abadijaya' },
{ label: 'Bakti Jaya', value: 'Bakti Jaya' },
{ label: 'Cisalak', value: 'Cisalak' },
{ label: 'Mekar Jaya', value: 'Mekar Jaya' },
{ label: 'Sukmajaya', value: 'Sukmajaya' },
{ label: 'Tirtajaya', value: 'Tirtajaya' },
],
'Tapos': [
{ label: 'Cilangkap', value: 'Cilangkap' },
{ label: 'Cimpaeun', value: 'Cimpaeun' },
{ label: 'Jatijajar', value: 'Jatijajar' },
{ label: 'Leuwinanggung', value: 'Leuwinanggung' },
{ label: 'Sukamaju Baru', value: 'Sukamaju Baru' },
{ label: 'Sukatani', value: 'Sukatani' },
{ label: 'Tapos', value: 'Tapos' },
],
};
export {KECAMATAN_VALUES};
export {KELURAHAN_VALUES};
......@@ -13,7 +13,7 @@ import OfficerSignupForm from '.';
import ReactTestRenderer, { act } from 'react-test-renderer';
import { AppContext } from 'contexts';
import { useMainService } from 'services';
import { KELURAHAN_VALUES } from 'scenes/ContactInvestigationFormStep2/constants';
import { KECAMATAN_VALUES, KELURAHAN_VALUES } from './constants';
const Stack = createStackNavigator();
const testProps = {
......@@ -23,6 +23,7 @@ const testProps = {
cache: {},
}
jest.mock('axios');
jest.useFakeTimers();
const mockedAxios = axios as jest.Mocked<typeof axios>;
describe("OfficerSignupForm", () => {
......@@ -42,7 +43,7 @@ describe("OfficerSignupForm", () => {
expect(formPage).toBeTruthy();
});
it('area field has default value on render', () => {
it('district and subdistrict field has default value on render', () => {
const formPage = ReactTestRenderer.create(
<NavigationContainer>
<Stack.Navigator
......@@ -57,9 +58,12 @@ describe("OfficerSignupForm", () => {
expect(formPage).toBeTruthy();
const areaField = formPage.root.find(elem => elem.props.id === "area");
expect(areaField).toBeTruthy();
expect(areaField.props.value).toBe(KELURAHAN_VALUES[0].value);
const districtField = formPage.root.find(elem => elem.props.id === "district");
const sub_districtField = formPage.root.find(elem => elem.props.id === "sub_district");
expect(districtField).toBeTruthy();
expect(sub_districtField).toBeTruthy();
expect(districtField.props.value).toBe(KECAMATAN_VALUES[0].value);
expect(sub_districtField.props.value).toBe(KELURAHAN_VALUES[KECAMATAN_VALUES[0].value][0].value);
});
......@@ -96,18 +100,22 @@ describe("OfficerSignupForm", () => {
const phoneField = formPage.root.find(elem => elem.props.id === "phone")
expect(phoneField).toBeTruthy()
const areaField = formPage.root.find(elem => elem.props.id === "area")
expect(areaField).toBeTruthy()
const districtField = formPage.root.find(elem => elem.props.id === "district")
expect(districtField).toBeTruthy()
const sub_districtField = formPage.root.find(elem => elem.props.id === "sub_district")
expect(sub_districtField).toBeTruthy()
// Set value
act(() => {
if (nameField && usernameField && passwordField && emailField && phoneField && areaField) {
if (nameField && usernameField && passwordField && emailField && phoneField && districtField && sub_districtField) {
nameField.props.updateValue("your name")
usernameField.props.updateValue("username")
passwordField.props.updateValue("asdQWE123")
emailField.props.updateValue("email@gmail.com")
phoneField.props.updateValue("081802769312")
areaField.props.updateValue("cabang-cabangan")
districtField.props.updateValue("districtku")
sub_districtField.props.updateValue("subdistrictku")
}
})
......@@ -166,18 +174,22 @@ describe("OfficerSignupForm", () => {
const phoneField = formPage.root.find(elem => elem.props.id === "phone")
expect(phoneField).toBeTruthy()
const areaField = formPage.root.find(elem => elem.props.id === "area")
expect(areaField).toBeTruthy()
const districtField = formPage.root.find(elem => elem.props.id === "district")
expect(districtField).toBeTruthy()
const sub_districtField = formPage.root.find(elem => elem.props.id === "sub_district")
expect(sub_districtField).toBeTruthy()
// Set value
act(() => {
if (nameField && usernameField && passwordField && emailField && phoneField && areaField) {
if (nameField && usernameField && passwordField && emailField && phoneField && districtField && sub_districtField) {
nameField.props.updateValue("your name")
usernameField.props.updateValue("username")
passwordField.props.updateValue("asdQWE123")
emailField.props.updateValue("email@gmail.com")
phoneField.props.updateValue("081802769312")
areaField.props.updateValue("cabang-cabangan")
districtField.props.updateValue("districtku")
sub_districtField.props.updateValue("subdistrictku")
}
})
......@@ -241,18 +253,22 @@ describe("OfficerSignupForm", () => {
const phoneField = formPage.root.find(elem => elem.props.id === "phone")
expect(phoneField).toBeTruthy()
const areaField = formPage.root.find(elem => elem.props.id === "area")
expect(areaField).toBeTruthy()
const districtField = formPage.root.find(elem => elem.props.id === "district")
expect(districtField).toBeTruthy()
const sub_districtField = formPage.root.find(elem => elem.props.id === "sub_district")
expect(sub_districtField).toBeTruthy()
// Set value
act(() => {
if (nameField && usernameField && passwordField && emailField && phoneField && areaField) {
if (nameField && usernameField && passwordField && emailField && phoneField && districtField && sub_districtField) {
nameField.props.updateValue("your name")
usernameField.props.updateValue("username")
passwordField.props.updateValue("asdQWE123")
emailField.props.updateValue("email@gmail.com")
phoneField.props.updateValue("081802769312")
areaField.props.updateValue("cabang-cabangan")
districtField.props.updateValue("districtku")
sub_districtField.props.updateValue("subdistrictku")
}
})
......@@ -316,18 +332,22 @@ describe("OfficerSignupForm", () => {
const phoneField = formPage.root.find(elem => elem.props.id === "phone")
expect(phoneField).toBeTruthy()
const areaField = formPage.root.find(elem => elem.props.id === "area")
expect(areaField).toBeTruthy()
const districtField = formPage.root.find(elem => elem.props.id === "district")
expect(districtField).toBeTruthy()
const sub_districtField = formPage.root.find(elem => elem.props.id === "sub_district")
expect(sub_districtField).toBeTruthy()
// Set value
act(() => {
if (nameField && usernameField && passwordField && emailField && phoneField && areaField) {
if (nameField && usernameField && passwordField && emailField && phoneField && districtField && sub_districtField) {
nameField.props.updateValue("")
usernameField.props.updateValue("")
passwordField.props.updateValue("asaaaaa")
passwordField.props.updateValue("asaaaaaa")
emailField.props.updateValue("not email")
phoneField.props.updateValue("081")
areaField.props.updateValue("")
districtField.props.updateValue("")
sub_districtField.props.updateValue("")
}
})
......
......@@ -6,7 +6,7 @@ import {ActivityIndicator, ScrollView, View, Modal, Image} from 'react-native';
import {Header, Field, Button, Text} from '../../components';
import error_img from './img/folder.png';
import {useFormState} from 'helpers';
import {KELURAHAN_VALUES} from './constants';
import {KECAMATAN_VALUES, KELURAHAN_VALUES} from './constants';
import {useNavigation} from '@react-navigation/native';
import {AppContext} from 'contexts';
import translateError from './utilities'
......@@ -23,7 +23,8 @@ const OfficerSignupForm = () => {
password: {type: 'password'},
email: {type: 'email'},
phone_number: {type: 'phone'},
area: {type: 'any'},
district: {type: 'any'},
sub_district: {type: 'any'},
});
const [serverHasError, setServerHasError] = useState(false);
......@@ -33,7 +34,8 @@ const OfficerSignupForm = () => {
password: '',
email: '',
phoneNumber: '',
area: '',
district: '',
sub_district: '',
})
const [modalVisible, setModalVisible] =