Fakultas Ilmu Komputer UI

Commit 802d0e69 authored by Adib Yusril Wafi's avatar Adib Yusril Wafi
Browse files

Merge branch 'master' of gitlab.cs.ui.ac.id:pmpl/class-project/kape into 1606837991-#224

parents 527697fd a6e57223
Pipeline #26852 passed with stages
in 7 minutes and 43 seconds
File added
......@@ -191,16 +191,17 @@ karyawan
key={this.state.refresh}
onSubmit={this.handleSubmit}
>
<Form.Field>
<Form.Field required>
<label htmlFor="name">Nama Perusahaan</label>
<input
placeholder="Nama Perusahaan"
name="name"
onChange={this.handleChange}
defaultValue={this.state.name === null ? null : this.state.name}
required
/>
</Form.Field>
<Form.Field>
<Form.Field required>
<label htmlFor="address">Alamat Perusahaan</label>
<input
placeholder="Alamat Perusahaan"
......@@ -209,9 +210,10 @@ karyawan
defaultValue={
this.state.address === null ? null : this.state.address
}
required
/>
</Form.Field>
<Form.Field>
<Form.Field required>
<label htmlFor="description">Deskripsi</label>
<TextArea
placeholder="Try adding multiple lines"
......@@ -223,9 +225,23 @@ karyawan
? null
: this.state.description
}
required
/>
</Form.Field>
<Form.Field>
<Form.Field required>
<label htmlFor="founded">Founded:</label>
<input
name="founded"
placeholder="YYYY-MM-DD"
pattern="\d{4}\-\d{2}\-\d{2}"
onChange={this.handleChange}
defaultValue={
this.state.founded === null ? null : this.state.founded
}
required
/>
</Form.Field>
<Form.Field required>
<label htmlFor="size">Jumlah karyawan</label>
<input
placeholder="Jumlah karyawan keseluruhan"
......@@ -235,9 +251,10 @@ karyawan
defaultValue={
this.state.size === null ? '0' : this.state.size
}
required
/>
</Form.Field>
<Form.Field>
<Form.Field required>
<label htmlFor="website">Website</label>
<input
placeholder="Alamat Website"
......@@ -246,6 +263,7 @@ karyawan
defaultValue={
this.state.website === null ? null : this.state.website
}
required
/>
</Form.Field>
<Form.Field>
......
......@@ -54,6 +54,7 @@ export default class EditProfile extends ProfileHandler {
awards: '',
projects: '',
certification: '',
sertifikat:'',
languages: '',
seminar: '',
interests: '',
......@@ -62,6 +63,7 @@ export default class EditProfile extends ProfileHandler {
refresh: 1,
loading: false,
linkedin_url: '',
self_description: '',
hackerrank_url: '',
student_gpa: 0.0,
student_toefl: 0,
......@@ -117,6 +119,7 @@ export default class EditProfile extends ProfileHandler {
awards: data.awards,
projects: data.projects,
certification: data.certification,
sertifikat:data.sertifikat,
languages: data.languages,
seminar: data.seminar,
interests: data.interests,
......@@ -341,15 +344,6 @@ export default class EditProfile extends ProfileHandler {
name="student_gpa"
/>
</Form.Field>
<Form.Field>
<label htmlFor="resume">Resume</label>
<input
onChange={this.handleFile}
placeholder="Resume"
name="resume"
type="File"
/>
</Form.Field>
<Form.Field>
<label htmlFor="expected_salary">Expected Salary</label>
<input onChange={this.handleChange} placeholder="2000000" name="expected_salary" />
......@@ -461,6 +455,93 @@ export default class EditProfile extends ProfileHandler {
<label htmlFor="latest_work_desc">
Latest Working Experience Description
</label>
<input
onChange={this.handleChange}
placeholder={
this.state.latest_work_desc === null
? 'Evaluate weekly assignment for 15 students'
: this.state.latest_work_desc
}
defaultValue={
this.state.latest_work_desc === null
? null
: this.state.latest_work_desc
}
name="latest_work_desc"
/>
</Form.Field>
<Form.Field>
<label htmlFor="awards">Awards and Achievements</label>
<input
onChange={this.handleChange}
placeholder={
this.state.awards === null
? 'Juara 2 UIUX Gemastik 2019'
: this.state.awards
}
defaultValue={
this.state.awards === null ? null : this.state.awards
}
name="awards"
/>
</Form.Field>
<Form.Field>
<label htmlFor="projects">Projects</label>
<input
onChange={this.handleChange}
placeholder={
this.state.projects === null
? 'Ow-Jek - Android Mobile Project'
: this.state.projects
}
defaultValue={
this.state.projects === null ? null : this.state.projects
}
name="projects"
/>
</Form.Field>
<Form.Field>
<label htmlFor="certification">Sertifikasi</label>
<input
onChange={this.handleChange}
placeholder={
this.state.certification === null
? 'TOEFL'
: this.state.certification
}
defaultValue={
this.state.certification === null
? null
: this.state.certification
}
name="certification"
/>
</Form.Field>
<Form.Field>
<label htmlFor="sertifikat">Sertifikat</label>
<input
onChange={this.handleFile}
placeholder="Sertifikat"
name="pdf_sertifikat"
type="File"
/>
</Form.Field>
<Form.Field>
<label htmlFor="languages">Bahasa yang dikuasai</label>
<input
onChange={this.handleChange}
placeholder={
this.state.languages === null
? 'Indonesia'
: this.state.languages
}
defaultValue={
this.state.languages === null ? null : this.state.languages
}
name="languages"
/>
</Form.Field>
<Form.Field>
<input
onChange={this.handleChange}
placeholder={
......
This diff is collapsed.
......@@ -2,6 +2,7 @@ import React from 'react';
import ReactTestUtils from 'react-dom/test-utils';
import fetchMock from 'fetch-mock';
import EditProfil from '../EditProfile';
import Storage from '../lib/Storage';
import { studentSession, response, response2 } from '../object/Response';
describe('EditProfil', () => {
......@@ -49,4 +50,45 @@ describe('EditProfil', () => {
ReactTestUtils.Simulate.change(emailNode, { target: { value: password } });
expect(emailNode.value).to.equal(password);
});
it('check if the user data is set correctly', () => {
fetchMock.get('*', response2);
const profile = ReactTestUtils.renderIntoDocument(
<EditProfil route={{ own: true, data: studentSession }} user={{ data: studentSession }} params={{ id: 3 }} />);
profile.getProfile().then(()=> expect(profile.props.route.own).to.equal(true));
const userData = Storage.get('user-data');
expect(userData.student).to.equal(null);
fetchMock.restore();
});
it('get student that doesnt exist', () => {
fetchMock.get('*', response2);
const profile = ReactTestUtils.renderIntoDocument(
<EditProfil route={{ own: false, data: studentSession }} user={{ data: studentSession }} params={{ id: -1 }} />);
profile.getProfile().then(()=> expect(profile.state.name).to.equal('Gagal mendapatkan informasi'));
fetchMock.restore();
});
it('check if the date parser is working properly', () => {
fetchMock.get('*', response2);
const profile = ReactTestUtils.renderIntoDocument(
<EditProfil route={{ own: true, data: studentSession }} user={{ data: studentSession }} params={{ id: 3 }} />);
const birthDate = '1996-06-30'
const parsedDate = profile.parseIndonesianDateFormat(birthDate)
expect(parsedDate).to.equal('30 Juni 1996')
fetchMock.restore();
});
it('check if the form is showing correctly', () => {
fetchMock.get('*', response2);
const profile = ReactTestUtils.renderIntoDocument(
<EditProfil route={{ own: true, data: studentSession }} user={{ data: studentSession }} params={{ id: 3 }} />);
profile.getProfile();
expect(profile.updateForm(false)).to.exist;
fetchMock.restore();
});
});
......@@ -29,7 +29,9 @@ const studentUserVerified = {
updated: '2017-03-28T13:33:46.148248Z',
npm: 1406543593,
resume: null,
self_description: null,
phone_number: null,
sertifikat:'ada',
bookmarked_vacancies: [
3,
],
......@@ -41,8 +43,9 @@ const studentUserVerified = {
},
};
describe('Sertifikat', () => {
it('render sertifikat', () => {
describe('Sertifikat doesnt exists', () => {
it('render sertifikat doesnt exists', () => {
studentUserVerified.data.sertifikat = null;
const sertifikat = ReactTestUtils.renderIntoDocument(
<p>Sertifikat belum ada</p>,
);
......@@ -50,6 +53,15 @@ describe('Sertifikat', () => {
});
});
describe('Sertifikat exists', () => {
it('render sertifikat exists', () => {
const sertifikat = ReactTestUtils.renderIntoDocument(
<p>Sertifikat sudah ada</p>,
);
expect(sertifikat).to.exist;
});
});
describe('ProfilePage', () => {
it('renders without problem', () => {
fetchMock.get('*', response);
......@@ -110,6 +122,7 @@ describe('ProfilePage', () => {
studentUserVerified.data.student.bookmarked_vacancies);
expect(profile.state.applied_vacancies).to.equal(
studentUserVerified.data.student.applied_vacancies);
expect(profile.state.self_description).to.equal(studentUserVerified.data.self_description);
});
})
......@@ -123,8 +136,11 @@ describe('ProfilePage', () => {
/>,
);
const phoneNumberNode = ReactTestUtils.scryRenderedDOMComponentsWithTag(profile, 'Input')[2];
profile.getProfile().then(()=> expect(
profile.state.phone_number).to.equal(phoneNumberNode.value));
const selfDescNode = ReactTestUtils.scryRenderedDOMComponentsWithTag(profile, 'Input')[4];
profile.getProfile().then(()=> {
expect(profile.state.phone_number).to.equal(phoneNumberNode.value);
expect(profile.state.self_description).to.equal(selfDescNode.value);
});
// profile.updateForm(true);
fetchMock.restore();
});
......
import React from 'react';
import ReactTestUtils from 'react-dom/test-utils';
import AdminVerificationModal from '../../components/AdminVerificationModal';
describe('AdminVerificationModal', () => {
it('renders without problem', () => {
const modalAdmin = ReactTestUtils.renderIntoDocument(
<AdminVerificationModal />,
);
expect(modalAdmin).to.exist;
});
it('close without problem', () => {
const modalAdmin = ReactTestUtils.renderIntoDocument(
<AdminVerificationModal />,
);
modalAdmin.handleClose();
expect(modalAdmin.state.modalOpen).to.equal(false);
});
it('open without problem', () => {
const modalAdmin = ReactTestUtils.renderIntoDocument(
<AdminVerificationModal />,
);
modalAdmin.handleOpen();
expect(modalAdmin.state.modalOpen).to.equal(true);
});
});
......@@ -47,6 +47,14 @@ describe('CompanyRegisterModal', () => {
expect(companyRegister.categoryOptions).to.exist;
});
it('renders recaptcha without problem', () => {
const companyRegister = ReactTestUtils.renderIntoDocument(
<CompanyRegisterModal />,
);
const recaptcha = ReactTestUtils.scryRenderedComponentsWithType(companyRegister, 'ReCAPTCHA');
expect(recaptcha).to.exist;
});
it('handle password validation', () => {
const password = '3s24Aasd';
expect(validatePassword(password)).to.equal(true);
......@@ -58,4 +66,11 @@ describe('CompanyRegisterModal', () => {
);
expect(companyRegister.state.benefits).to.exist;
});
it('Register modal state contain recaptchaValue', () => {
const companyRegister = ReactTestUtils.renderIntoDocument(
<CompanyRegisterModal />,
);
expect(companyRegister.state.recaptchaValue).to.equal(null);
});
});
......@@ -63,7 +63,9 @@ describe('LoginForm', () => {
<LoginForm url="" />,
);
const submitButton = ReactTestUtils.findRenderedDOMComponentWithTag(formLogin, 'Button');
const submitButton = ReactTestUtils.findRenderedDOMComponentWithClass(formLogin, 'submit');
console.log(submitButton);
ReactTestUtils.Simulate.click(submitButton);
const form = ReactTestUtils.findRenderedDOMComponentWithTag(formLogin, 'Form');
......@@ -77,7 +79,7 @@ describe('LoginForm', () => {
<LoginForm url="" />,
);
const submitButton = ReactTestUtils.findRenderedDOMComponentWithTag(formLogin, 'Button');
const submitButton = ReactTestUtils.findRenderedDOMComponentWithClass(formLogin, 'submit');
ReactTestUtils.Simulate.click(submitButton);
const form = ReactTestUtils.findRenderedDOMComponentWithTag(formLogin, 'Form');
......
......@@ -389,6 +389,17 @@ describe('VacancyList', () => {
expect(vacancyList.generateVacancies()).to.exist;
});
it('filters filled-out applications for stident user', () => {
const vacancyList = ReactTestUtils.renderIntoDocument(
<VacancyList items={newResponse} userId={3} user={studentUser} />,
);
vacancyList.state.vacancies = newResponse;
vacancyList.state.vacancyStateFilter = 3;
expect(vacancyList.generateVacancies()).to.exist;
vacancyList.state.vacancyStateFilter = 4;
expect(vacancyList.generateVacancies()).to.exist;
});
it('renders without problem for company', () => {
const vacancyList = ReactTestUtils.renderIntoDocument(
<VacancyList items={newResponse} userId={1} user={companyUser} />,
......
import React from 'react';
import ReactTestUtils from 'react-dom/test-utils';
import VerifyAdminModal from '../../components/VerifyAdminModal';
describe('VerifyAdminModal', () => {
it('renders without problem', () => {
const verifyModal = ReactTestUtils.renderIntoDocument(
<VerifyAdminModal />,
);
expect(verifyModal).to.exist;
});
it('open without problem', () => {
const verifyModal = ReactTestUtils.renderIntoDocument(
<VerifyAdminModal id={4} />,
);
const modal = ReactTestUtils.findRenderedDOMComponentWithTag(verifyModal, 'Button');
ReactTestUtils.Simulate.click(modal);
expect(verifyModal.state.modalOpen).to.equal(true);
});
it('close without problem', () => {
const verifyModal = ReactTestUtils.renderIntoDocument(
<VerifyAdminModal id={4} />,
);
verifyModal.handleClose();
expect(verifyModal.state.modalOpen).to.equal(false);
});
});
import React from 'react';
import {
Button, Header, Modal, Grid,
} from 'semantic-ui-react';
export default class AdminVerificationModal extends React.Component {
state = { modalOpen: false }
componentWillUpdate() {
this.fixBody();
}
componentDidUpdate() {
this.fixBody();
}
fixBody = () => {
const anotherModal = document.getElementsByClassName('ui page modals').length;
if (anotherModal > 0) document.body.classList.add('scrolling', 'dimmable', 'dimmed');
};
handleOpen = () => this.setState({
modalOpen: true,
});
handleClose = () => this.setState({
modalOpen: false,
});
render() {
return (
<Modal
trigger={
<Button color="blue" icon="right chevron" labelPosition="right" floated="right" content="ubah" onClick={this.handleOpen} />
}
closeIcon="close"
open={this.state.modalOpen}
onClose={this.handleClose}
>
<Modal.Header>Software Engineer</Modal.Header>
<Modal.Content>
<Modal.Description>
<Header>Deskripsi Lowongan</Header>
Lorem ipsum dolor sit amet, consectetur adipiscing elit,
sed do eiusmod tempor incididunt ut labore et dolore
magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco
laboris nisi ut aliquip ex ea commodo consequat.
</Modal.Description>
</Modal.Content>
<Modal.Actions>
<Grid columns={2}>
<Grid.Column>
<Button color="red" floated="left" onClick={this.handleClose}>Hapus</Button>
</Grid.Column>
<Grid.Column>
<Button color="blue" floated="right" onClick={this.handleClose}>Ubah</Button>
<Button color="green" floated="right" onClick={this.handleClose}>Verifikasi</Button>
</Grid.Column>
</Grid>
</Modal.Actions>
</Modal>
);
}
}
......@@ -7,6 +7,7 @@ import ModalAlert from './ModalAlert';
import Server from '../lib/Server';
import Storage from '../lib/Storage';
import Dumper from '../lib/Dumper';
import ReCAPTCHA from "react-google-recaptcha";
export default class CompanyRegisterModal extends React.Component {
constructor(props) {
......@@ -19,6 +20,7 @@ export default class CompanyRegisterModal extends React.Component {
{ text: 'Mempermudah mencari calon peserta magang' },
{ text: 'Dan banyak keuntungan lainnya' },
],
recaptchaValue: null,
};
this.handleChange = this.handleChange.bind(this);
this.handleFile = this.handleFile.bind(this);
......@@ -97,16 +99,25 @@ export default class CompanyRegisterModal extends React.Component {
}
};
handleRecaptchaValue = (value) => {
this.setState({ recaptchaValue: value });
};
handleSubmit = (e) => {
e.preventDefault();
this.setState({ loading: true });
Server.submit('/register/', this.state).then((response) => {
Storage.set('user-data', response);
browserHistory.push('/home');
}, (error) => error.then((r) => {
this.setState({ loading: false });
this.modalAlert.open('Gagal Membuat Akun', Dumper.dump(r));
}));
if(this.state.recaptchaValue != null){
this.setState({ loading: true });
Server.submit('/register/', this.state).then((response) => {
Storage.set('user-data', response);
browserHistory.push('/home');
}, (error) => error.then((r) => {
this.setState({ loading: false });
this.modalAlert.open('Gagal Membuat Akun', Dumper.dump(r));
}));
}
else {
this.modalAlert.open('Pastikan anda bukan robot', Dumper.dump());
}
};
render() {
......@@ -193,6 +204,10 @@ export default class CompanyRegisterModal extends React.Component {
<label htmlFor="description">Deskripsi</label>
<TextArea onChange={this.handleChange} placeholder="Tell us more" name="description" autoHeight required />
</Form.Field>
<Form.Field required>
<label htmlFor="founded">Founded</label>
<TextArea onChange={this.handleChange} placeholder="YYYY-MM-DD" name="founded" required />
</Form.Field>
<Form.Field required>
<label htmlFor="address">Alamat</label>
<Input onChange={this.handleChange} placeholder="Alamat" name="address" required />
......@@ -205,6 +220,10 @@ export default class CompanyRegisterModal extends React.Component {
<label htmlFor="address">Website</label>
<Input onChange={this.handleChange} placeholder="Website perusahaan anda" name="website" required />
</Form.Field>
<ReCAPTCHA
sitekey="6LfUYMYUAAAAAF_Yj073qov9JOMrYQaNIu3-UIF7"
onChange={(value) => { this.handleRecaptchaValue(value); }}
/>
<Modal.Actions style={{ textAlign: 'right' }}>