Fakultas Ilmu Komputer UI

Commit f4ba6c55 authored by Muhammad Fakhrillah Abdul Azis's avatar Muhammad Fakhrillah Abdul Azis
Browse files

Merge branch 'master' into '1606917531-210'

# Conflicts:
#   core/tests/test_accounts.py
parents 15d885c6 a57e5d7f
Pipeline #26829 passed with stages
in 11 minutes and 39 seconds
......@@ -29,7 +29,7 @@ test-backend:
- pip install -r requirements.txt
- python3 manage.py makemigrations
- python3 manage.py migrate
- python3 manage.py test
- python3 manage.py test -v 2
artifacts:
paths:
- test/
......
......@@ -207,19 +207,23 @@ card .formRegis {
.footer {
background-color: #031634;
position: absolute;
position: relative;
right: 0;
bottom: 0;
left: 0;
width: 100%;
height: 30px;
padding: 6px;
/* height: 30px; */
padding: 20px;
}
.footer h5 {
color: white;
padding: 5px 5px;
}
.footer a {
color: rgb(248, 233, 21);
/* padding: 5px 5px; */
}
.ui.segment.segmentProfileCompany {
margin-left: 10%;
margin-right: 10%;
......@@ -306,3 +310,4 @@ card .formRegis {
border-radius: 5px;
margin-left: 10px;
}
......@@ -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>
......
This diff is collapsed.
......@@ -11,25 +11,78 @@ export default class NotificationPage extends React.Component {
constructor(props) {
super(props);
this.state = {
list : [
{
title: "Your Application Has Been Rejected",
text: "Tutuplapak has rejected your applications",
timestamp: "2019-10-10T13:00:00",
},
{
title: "Your Application Has Been Accepted",
text: "Tutuplapak has rejected your applications",
timestamp: "2019-12-10T13:00:00",
},
{
title: "Your Application Has Been Responded",
text: "Tutuplapak has rejected your applications",
timestamp: "2019-11-10T13:00:00",
},
]
console.log('Notifikasi');
Storage.set('menu-active-state', 'Notifikasi');
}
console.log('Notifikasi');
Storage.set('menu-active-state', 'Notifikasi');
}
// componentDidUpdate(prevprops,prevstate){
// this.updateList();
// }
// updateList = () => {
// }
onClickDismiss = (index) => {
var array = [...this.state.list];
array.splice(index, 1);
console.log("eh kepencet")
console.log(index)
this.setState({
list : array
})
}
render() {
var id=-1
return (
<div className="notificationPage">
<Segment className="notifikasi">
<Notification
title="Your Application Has Been Rejected"
text="Tutuplapak has rejected your applications"
timestamp="2019-10-10T13:00:00"
/>
<Notification
title="Lorem Ipsum"
text="Dolor Sit Amet"
timestamp="1970-01-01T06:00:00"
{
this.state.list.map(item=>{
id=id+1
console.log(id)
return (
<Notification
id={id}
title={item.title}
text={item.text}
timestamp={item.timestamp}
dismiss = {this.onClickDismiss}
/>
)}
)}
</Segment>
</div>
);
......
import React from 'react';
import Server from './lib/Server';
import Dumper from './lib/Dumper';
import { isFromGithubLinkValid } from './Utils';
export default class ProfileHandler extends React.Component {
handleSubmit = (e) => {
e.preventDefault();
if (!isFromGithubLinkValid(this.state.form.github_url)) {
this.modalAlert.open(
'Pembaharuan profil gagal',
'Pastikan link github yang anda tulis benar.(Berpola : https://github.com/<username>',
);
} else {
const submitForm = {};
Object.keys(this.state.form).forEach((key) => {
if (this.state.form[key] !== '') {
submitForm[key] = this.state.form[key];
}
});
this.setState({ loading: true });
Server.submit(
`/students/${this.state.id}/profile/`,
submitForm,
'PATCH',
).then(
() => {
this.setState({ loading: false });
this.modalAlert.open(
'Profil berhasil diperbaharui',
'Silakan periksa kembali profil anda',
this.getProfile,
);
},
(error) => error.then((r) => {
this.setState({ loading: false });
this.modalAlert.open('Pembaharuan profil gagal', Dumper.dump(r));
}),
);
}
};
handleFile = (e) => {
const { form } = this.state;
form[e.target.name] = e.target.files[0];
this.setState({ form });
};
handleChange = (e) => {
const { form } = this.state;
form[e.target.name] = e.target.value;
this.setState({ form });
};
handleCheckbox = (e, d) => {
const { form } = this.state;
form[d.name] = d.checked;
this.setState({ form, show_transcript: d.checked });
};
handleRadioGender = (e, { value }) => {
const { form } = this.state;
form.gender = value;
this.setState({ form });
};
handleRadio = (e, { value }) => {
const { form } = this.state;
form.job_seeking_status = value;
this.setState({ form });
};
}
\ No newline at end of file
This diff is collapsed.
......@@ -3,8 +3,11 @@ import ReactTestUtils from 'react-dom/test-utils';
import fetchMock from 'fetch-mock';
import ApplicantPage from '../ApplicantPage';
import Tabs from '../components/Tabs';
import { shallow, configure } from 'enzyme';
describe('ApplicantPage', () => {
let wrapper;
const companyUser = {
role: 'company',
data: {
......@@ -212,4 +215,11 @@ describe('ApplicantPage', () => {
expect(applicantPage).to.exist;
fetchMock.restore();
});
it('State of selected contains Company User ID', () => {
const wrapper = shallow(<ApplicantPage user={companyUser} />);
expect(wrapper.state().selected).to.equal('/companies/3/applications/');
expect(wrapper.state().refresh).to.equal(0);
});
});
......@@ -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', () => {
......@@ -30,8 +31,8 @@ describe('EditProfil', () => {
const submitButton = ReactTestUtils.scryRenderedDOMComponentsWithTag(profile, 'Input')[1];
ReactTestUtils.Simulate.click(submitButton);
const form = ReactTestUtils.findRenderedDOMComponentWithTag(profile, 'Form');
ReactTestUtils.Simulate.submit(form);
const form = ReactTestUtils.findRenderedDOMComponentWithTag(profile, 'Button');
ReactTestUtils.Simulate.click(form);
fetchMock.restore();
});
......@@ -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();
});
});
import React from 'react';
import ReactTestUtils from 'react-dom/test-utils';
import fetchMock from 'fetch-mock';
import FeedbackPage from '../FeedbackPage';
describe('FeedbackPage', () => {
......@@ -18,4 +19,50 @@ describe('FeedbackPage', () => {
expect(titleh1.textContent).to.equal('Berikan Umpan Balik');
expect(titleh2.textContent).to.equal('Silahkan berikan umpan balik atas layanan yang disediakan oleh KaPe');
});
it('handle title feedback input without problem', () => {
const feedbackPage = ReactTestUtils.renderIntoDocument(
<FeedbackPage />,
);
const titleNode = ReactTestUtils.scryRenderedDOMComponentsWithTag(feedbackPage, 'input')[0];
const title = "Halo";
titleNode.value = title;
ReactTestUtils.Simulate.change(titleNode, { target: { name: "title", value: title } });
expect(titleNode.value).to.equal(title);
expect(feedbackPage.state.title).to.equal(title);
});
it('handle content feedback input without problem', () => {
const feedbackPage = ReactTestUtils.renderIntoDocument(
<FeedbackPage />,
);
const contentNode = ReactTestUtils.scryRenderedDOMComponentsWithTag(feedbackPage, 'TextArea')[0];
const content = "Good";
contentNode.value = content;
ReactTestUtils.Simulate.change(contentNode, { target: { name: "content", value: content } });
expect(contentNode.value).to.equal(content);
expect(feedbackPage.state.content).to.equal(content);
});
it('submit without problem', () => {
fetchMock.post('*', {});
const feedbackPage = ReactTestUtils.renderIntoDocument(
<FeedbackPage />,
);
feedbackPage.state = {title:'halo', content:'good'};
const form = ReactTestUtils.findRenderedDOMComponentWithTag(feedbackPage, 'Form');
ReactTestUtils.Simulate.submit(form);
fetchMock.restore();
});
it('render without problem when submit error', () => {
fetchMock.post('*', 404);
const feedbackPage = ReactTestUtils.renderIntoDocument(
<FeedbackPage />,
);
feedbackPage.state = {title:'halo', content:'good'};
const form = ReactTestUtils.findRenderedDOMComponentWithTag(feedbackPage, 'Form');
ReactTestUtils.Simulate.submit(form);
fetchMock.restore();
})
});
......@@ -62,4 +62,15 @@ describe('NotificationPage', () => {
);
expect(topmenu.state.activeItem).to.equal('Notifikasi');
});
it('test click dismiss notif',()=>{
const notifpage = ReactTestUtils.renderIntoDocument(
<NotificationPage
user={{ data: studentSession }}
/>,
);
notifpage.onClickDismiss(0);
expect(notifpage.state.list.length).to.equal(2);
});
});
......@@ -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);
......@@ -61,7 +73,7 @@ describe('ProfilePage', () => {
);
profile.getProfile().then(() => expect(profile.state.name).to.equal(response.name));
profile.getProfile().then(() => expect(profile.state.birth_date).to.equal('24 Februari 1995'));
profile.updateForm(true);
// profile.updateForm(true);
fetchMock.restore();
});
......@@ -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,9 +136,12 @@ describe('ProfilePage', () => {
/>,
);
const phoneNumberNode = ReactTestUtils.scryRenderedDOMComponentsWithTag(profile, 'Input')[2];
profile.getProfile().then(()=> expect(
profile.state.phone_number).to.equal(phoneNumberNode.value));
profile.updateForm(true);
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 { isFromGithubLinkValid } from "../Utils";
var assert = require('assert');
describe('isFromGithubLinkValid', function () {
it('should return nothing when param is null', function () {
assert(isFromGithubLinkValid(null) == null);
});
it('should return false when link doesnt include https://github.com', function () {
assert(isFromGithubLinkValid("https://haha.com") == false);
});
it('should return true when link include https://github.com', function () {
assert(isFromGithubLinkValid("https://github.com/ranisianipar") == true);
});
})
\ No newline at end of file
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);
});
});
/* eslint-disable no-unused-expressions */
import React from 'react';
import ReactTestUtils from 'react-dom/test-utils';
import CompanyInfo from '../../components/CompanyInfo';
describe('CompanyInfo', () => {
it('renders without problem', () => {
const modalInfo = ReactTestUtils.renderIntoDocument(<CompanyInfo buttonTitle="submit" />);
expect(modalInfo).to.exist;
});
it('open without problem', () => {
const modalCompany = ReactTestUtils.renderIntoDocument(<CompanyInfo buttonTitle="submit" />);
const modal = ReactTestUtils.findRenderedDOMComponentWithTag(modalCompany, 'Button');
modalCompany.handleApply();
ReactTestUtils.Simulate.click(modal);
expect(modalCompany).to.exist;
});
it('open with problem', () => {
const modalCompany = ReactTestUtils.renderIntoDocument(<CompanyInfo buttonTitle="submit" />);
const modal = ReactTestUtils.findRenderedDOMComponentWithTag(modalCompany, 'Button');
ReactTestUtils.Simulate.click(modal);
expect(modalCompany).to.exist;
});
});
......@@ -47,6 +47,14 @@ describe('CompanyRegisterModal', () => {
expect(companyRegister.categoryOptions).to.exist;