Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support checklist key #16

Merged
merged 4 commits into from
Aug 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 7 additions & 56 deletions src/config/submission-requirement.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,12 @@
const submissionRequirements = {
PROJECT_HAVE_CORRECT_PORT: {
project_have_correct_port: {
status: false,
possibleChecklistId: [
47395, //aws 261
42180, //cloudeka 510
45840, //google cloud 342,
1, //test
],
checklistId: null,
},
PROJECT_HAVE_CORRECT_RUNNER_SCRIPT: {
project_have_correct_runner_script: {
status: false,
possibleChecklistId: [
47400, //aws 261
42185, //cloudeka 510
45845, //google cloud 342,
2, //test
],
checklistId: null,
},
API_CAN_INSERT_BOOK: {
api_can_insert_book: {
status: false,
possibleChecklistId: [
47370, //aws 261
42155, //cloudeka 510
45815, //google cloud 342
3, //test
],
checklistId: null,
postmanTestName: 'API dapat menyimpan buku',
reason: [],
postmanTestRequirements: [
Expand All @@ -36,48 +15,27 @@ const submissionRequirements = {
'[Mandatory] Add Book with Page Read More Than Page Count'
]
},
API_CAN_GET_ALL_BOOK: {
api_can_get_all_book: {
status: false,
reason: [],
possibleChecklistId: [
47375, //aws 261
42160, //cloudeka 510
45820, //google cloud 342
4, //test
],
checklistId: null,
postmanTestName: 'API dapat menampilkan seluruh buku',
postmanTestRequirements: [
'[Mandatory] Get All Books',
]
},
API_CAN_GET_DETAIL_BOOK: {
api_can_get_detail_book: {
status: false,
reason: [],
possibleChecklistId: [
47380, //aws 261
42165, //cloudeka 510
45825, //google cloud 342
5, //test
],
checklistId: null,
postmanTestName: 'API dapat menampilkan detail buku',
postmanTestRequirements:
[
'[Mandatory] Get Detail Books With Correct Id',
'[Mandatory] Get Detail Books With Invalid Id'
]
},
API_CAN_UPDATE_BOOK: {
api_can_update_book: {
status: false,
reason: [],
possibleChecklistId: [
47385, //aws 261
42170, //cloudeka 510
45830, //google cloud 342
6, //test
],
checklistId: null,
postmanTestName: 'API dapat mengubah data buku',
postmanTestRequirements: [
'[Mandatory] Update Book With Complete Data',
Expand All @@ -86,16 +44,9 @@ const submissionRequirements = {
'[Mandatory] Update Book with Invalid Id'
]
},
API_CAN_DELETE_BOOK: {
api_can_delete_book: {
status: false,
reason: [],
possibleChecklistId: [
47390, //aws 261
42175, //cloudeka 510
45835, //google cloud 342
7 //test
],
checklistId: null,
postmanTestName: 'API dapat menghapus buku',
postmanTestRequirements:
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ describe('course submission acception test', () => {
}

const submissionRequirement = getSubmissionRequirement()
submissionRequirement.API_CAN_INSERT_BOOK.status = true
submissionRequirement.API_CAN_UPDATE_BOOK.status = true
submissionRequirement.API_CAN_DELETE_BOOK.status = true
submissionRequirement.API_CAN_GET_ALL_BOOK.status = true
submissionRequirement.API_CAN_GET_DETAIL_BOOK.status = true
submissionRequirement.PROJECT_HAVE_CORRECT_PORT.status = true
submissionRequirement.PROJECT_HAVE_CORRECT_RUNNER_SCRIPT.status = true
submissionRequirement.api_can_insert_book.status = true
submissionRequirement.api_can_update_book.status = true
submissionRequirement.api_can_delete_book.status = true
submissionRequirement.api_can_get_all_book.status = true
submissionRequirement.api_can_get_detail_book.status = true
submissionRequirement.project_have_correct_port.status = true
submissionRequirement.project_have_correct_runner_script.status = true

const courseSubmissionAcception = new CourseSubmissionAcception(<SubmissionCriteriaCheck>{
reviewChecklistResult: submissionRequirement
Expand Down Expand Up @@ -108,11 +108,11 @@ describe('course submission acception test', () => {
}
}
}

const courseSubmissionAcception = new CourseSubmissionAcception(<SubmissionCriteriaCheck>{}, submissionRatingFactory);
courseSubmissionAcception.accept()

expect(courseSubmissionAcception.rating).toStrictEqual(4)
expect(courseSubmissionAcception.messages).toContain('...')
});
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import getSubmissionRequirements from "../../config/submission-requirement";

describe('mandatory criteria test', () => {
const submissionRequirements = getSubmissionRequirements()
submissionRequirements.PROJECT_HAVE_CORRECT_RUNNER_SCRIPT.status = true
submissionRequirements.PROJECT_HAVE_CORRECT_PORT.status = true
submissionRequirements.project_have_correct_runner_script.status = true
submissionRequirements.project_have_correct_port.status = true
const submissionCriteriaCheckFactory = new SubmissionCriteriaCheckFactory()

it('should grouping failed test by criteria and return approval false', function () {
Expand All @@ -30,12 +30,12 @@ describe('mandatory criteria test', () => {
]

const expectedReviewChecklistResult = getSubmissionRequirements()
expectedReviewChecklistResult.PROJECT_HAVE_CORRECT_PORT.status = true
expectedReviewChecklistResult.PROJECT_HAVE_CORRECT_RUNNER_SCRIPT.status = true
expectedReviewChecklistResult.API_CAN_DELETE_BOOK.status = true
expectedReviewChecklistResult.API_CAN_GET_DETAIL_BOOK.status = true
expectedReviewChecklistResult.API_CAN_UPDATE_BOOK.status = true
expectedReviewChecklistResult.API_CAN_INSERT_BOOK.reason = [
expectedReviewChecklistResult.project_have_correct_port.status = true
expectedReviewChecklistResult.project_have_correct_runner_script.status = true
expectedReviewChecklistResult.api_can_delete_book.status = true
expectedReviewChecklistResult.api_can_get_detail_book.status = true
expectedReviewChecklistResult.api_can_update_book.status = true
expectedReviewChecklistResult.api_can_insert_book.reason = [
{
"name": "[Mandatory] Add Book With Complete Data",
"tests": [
Expand All @@ -49,7 +49,7 @@ describe('mandatory criteria test', () => {
},
]
}]
expectedReviewChecklistResult.API_CAN_GET_ALL_BOOK.reason = [{
expectedReviewChecklistResult.api_can_get_all_book.reason = [{
"name": "[Mandatory] Get All Books",
"tests": [{
"message": "Failed to add book, 404",
Expand All @@ -70,13 +70,13 @@ describe('mandatory criteria test', () => {
expect(submissionCriteriaCheck.approvalStatus).toBeTruthy()

const expectedReviewChecklistResult = getSubmissionRequirements()
expectedReviewChecklistResult.API_CAN_INSERT_BOOK.status = true
expectedReviewChecklistResult.API_CAN_GET_ALL_BOOK.status = true
expectedReviewChecklistResult.API_CAN_GET_DETAIL_BOOK.status = true
expectedReviewChecklistResult.API_CAN_UPDATE_BOOK.status = true
expectedReviewChecklistResult.API_CAN_DELETE_BOOK.status = true
expectedReviewChecklistResult.PROJECT_HAVE_CORRECT_PORT.status = true
expectedReviewChecklistResult.PROJECT_HAVE_CORRECT_RUNNER_SCRIPT.status = true
expectedReviewChecklistResult.api_can_insert_book.status = true
expectedReviewChecklistResult.api_can_get_all_book.status = true
expectedReviewChecklistResult.api_can_get_detail_book.status = true
expectedReviewChecklistResult.api_can_update_book.status = true
expectedReviewChecklistResult.api_can_delete_book.status = true
expectedReviewChecklistResult.project_have_correct_port.status = true
expectedReviewChecklistResult.project_have_correct_runner_script.status = true

expect(submissionCriteriaCheck.reviewChecklistResult).toStrictEqual(expectedReviewChecklistResult)
})
Expand All @@ -85,10 +85,10 @@ describe('mandatory criteria test', () => {
const submissionCriteriaCheck = submissionCriteriaCheckFactory.check(submissionRequirements)
expect(submissionCriteriaCheck.approvalStatus).toBeFalsy()
const expectedReviewChecklistResult = getSubmissionRequirements()
expectedReviewChecklistResult.PROJECT_HAVE_CORRECT_RUNNER_SCRIPT.status = true
expectedReviewChecklistResult.PROJECT_HAVE_CORRECT_PORT.status = true
expectedReviewChecklistResult.project_have_correct_runner_script.status = true
expectedReviewChecklistResult.project_have_correct_port.status = true

expect(submissionCriteriaCheck.reviewChecklistResult).toStrictEqual(expectedReviewChecklistResult)
expect(submissionCriteriaCheck.failurePostmanTest).toBeNull()
});
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ class SubmissionCriteriaCheckFactory {
public check(submissionRequirements: SubmissionRequirement, failurePostmanTest: Array<ResultTestFailure> = null): SubmissionCriteriaCheck{

const postmanRequirements = [
submissionRequirements.API_CAN_INSERT_BOOK,
submissionRequirements.API_CAN_GET_ALL_BOOK,
submissionRequirements.API_CAN_GET_DETAIL_BOOK,
submissionRequirements.API_CAN_UPDATE_BOOK,
submissionRequirements.API_CAN_DELETE_BOOK
submissionRequirements.api_can_insert_book,
submissionRequirements.api_can_get_all_book,
submissionRequirements.api_can_get_detail_book,
submissionRequirements.api_can_update_book,
submissionRequirements.api_can_delete_book
]

postmanRequirements.forEach(postmanRequirement => {
Expand All @@ -29,4 +29,4 @@ class SubmissionCriteriaCheckFactory {
}
}

export default SubmissionCriteriaCheckFactory
export default SubmissionCriteriaCheckFactory
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default class SubmissionProjectFactory {

this.checkRunnerCommandUseNodeCommand(runnerCommand)

submissionRequirement.PROJECT_HAVE_CORRECT_RUNNER_SCRIPT.status = true
submissionRequirement.project_have_correct_runner_script.status = true
domainEvent('project has meet requirement')
return {
packageJsonContent: this.packageJsonContent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ describe('create submission project test', () => {
it('should throw error when project path not contain package.json', function () {
expect(() => submissionProjectFactory.create(submissionRequirement, null))
.toThrow(new ProjectErrorException('PATH_NOT_CONTAIN_PACKAGE_JSON'))
expect(submissionRequirement.PROJECT_HAVE_CORRECT_RUNNER_SCRIPT.status).toBeFalsy()
expect(submissionRequirement.project_have_correct_runner_script.status).toBeFalsy()
});

it('should throw error when package.json cannot be parsed', function () {
mockFS.readFileSync.mockReturnValue('{ missing curly braces')

expect(() => submissionProjectFactory.create(submissionRequirement, './xxxx'))
.toThrow(new ProjectErrorException('CANNOT_PARSE_PACKAGE_JSON'))
expect(submissionRequirement.PROJECT_HAVE_CORRECT_RUNNER_SCRIPT.status).toBeFalsy()
expect(submissionRequirement.project_have_correct_runner_script.status).toBeFalsy()

});

Expand All @@ -33,7 +33,7 @@ describe('create submission project test', () => {

expect(() => submissionProjectFactory.create(submissionRequirement, './xxxx'))
.toThrow(new ProjectErrorException('PACKAGE_JSON_NOT_CONTAIN_SCRIPT_PROPERTY'))
expect(submissionRequirement.PROJECT_HAVE_CORRECT_RUNNER_SCRIPT.status).toBeFalsy()
expect(submissionRequirement.project_have_correct_runner_script.status).toBeFalsy()

});

Expand All @@ -43,7 +43,7 @@ describe('create submission project test', () => {

expect(() => submissionProjectFactory.create(submissionRequirement,'.'))
.toThrow(new ProjectErrorException('RUNNER_SCRIPT_NOT_FOUND'))
expect(submissionRequirement.PROJECT_HAVE_CORRECT_RUNNER_SCRIPT.status).toBeFalsy()
expect(submissionRequirement.project_have_correct_runner_script.status).toBeFalsy()

});

Expand Down Expand Up @@ -85,7 +85,7 @@ describe('create submission project test', () => {
.create(submissionRequirement, '/home/app/1234')
expect(submissionProject.packageJsonContent).toStrictEqual({ "scripts": { "start": "node src/index.js" }})
expect(submissionProject.packageJsonPath).toStrictEqual('/home/app/1234')
expect(submissionRequirement.PROJECT_HAVE_CORRECT_RUNNER_SCRIPT.status).toBeTruthy()
expect(submissionRequirement.project_have_correct_runner_script.status).toBeTruthy()
});


Expand Down
31 changes: 16 additions & 15 deletions src/service/report-generator/report-generator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ describe('checklist id resolver test', () => {

it('should generate report properly', function () {
const submissionRequirement = getSubmissionRequirement()
submissionRequirement.API_CAN_DELETE_BOOK.status = true
submissionRequirement.API_CAN_UPDATE_BOOK.status = true
submissionRequirement.API_CAN_GET_DETAIL_BOOK.status = true
submissionRequirement.API_CAN_GET_ALL_BOOK.status = true
submissionRequirement.API_CAN_INSERT_BOOK.status = true
submissionRequirement.PROJECT_HAVE_CORRECT_RUNNER_SCRIPT.status = true
submissionRequirement.PROJECT_HAVE_CORRECT_PORT.status = true
submissionRequirement.api_can_delete_book.status = true
submissionRequirement.api_can_update_book.status = true
submissionRequirement.api_can_get_detail_book.status = true
submissionRequirement.api_can_get_all_book.status = true
submissionRequirement.api_can_insert_book.status = true
submissionRequirement.project_have_correct_runner_script.status = true
submissionRequirement.project_have_correct_port.status = true


const reviewResult: ReviewResult = {
Expand All @@ -29,14 +29,15 @@ describe('checklist id resolver test', () => {

const result = JSON.parse(fs.readFileSync('./test/student/review-result/report.json').toString())[0]

expect(result.checklist.PROJECT_HAVE_CORRECT_RUNNER_SCRIPT.checklistId).toStrictEqual(2)
expect(result.checklist.PROJECT_HAVE_CORRECT_PORT.checklistId).toStrictEqual(1)
expect(result.checklist.API_CAN_INSERT_BOOK.checklistId).toStrictEqual(3)
expect(result.checklist.API_CAN_GET_ALL_BOOK.checklistId).toStrictEqual(4)
expect(result.checklist.API_CAN_GET_DETAIL_BOOK.checklistId).toStrictEqual(5)
expect(result.checklist.API_CAN_UPDATE_BOOK.checklistId).toStrictEqual(6)
expect(result.checklist.API_CAN_DELETE_BOOK.checklistId).toStrictEqual(7)
expect(result.checklist_completed).toEqual([1, 2, 3, 4, 5, 6, 7])
expect(result.checklist_keys).toEqual([
"project_have_correct_port",
"project_have_correct_runner_script",
"api_can_insert_book",
"api_can_get_all_book",
"api_can_get_detail_book",
"api_can_update_book",
"api_can_delete_book"
])
expect(result.message).toStrictEqual('<p>Hallo <strong>snder12</strong>, terima kasih telah sabar menunggu. Kami membutuhkan waktu untuk bisa memberikan <em>feedback</em> sekomprehensif mungkin kepada setiap peserta kelas. Dalam kesempatan ini ada &nbsp;4 (empat) hal yang ingin kami sampaikan.&nbsp;</p><p><strong>Pertama</strong>, kami ingin mengucapkan selamat! Karena kamu telah menyelesaikan tugas submission dari kelas Belajar Membuat Aplikasi Back-End untuk Pemula. Jangan lihat bintang yang kamu raih, tapi lihat kemajuan yang sudah kamu capai. Ingat semua <em>expert&nbsp;</em>dahulu pemula.&nbsp;</p><p><strong>K</strong><strong>edua</strong>, kamu boleh bangga karena telah menyelesaikan submission sesuai dengan kriteria yang telah kami tentukan. Mumpung masih hangat semangatnya langsung lanjut kelas selanjutnya yaitu <a href="https://www.dicoding.com/academies/266">Architecting on AWS (Membangun Arsitektur AWS di Cloud)</a> atau <a href="https://www.dicoding.com/academies/271">Belajar Fundamental Aplikasi Back-End</a>.&nbsp;</p><p><strong>Ketiga</strong>, beberapa lulusan tidak tahu mereka memiliki akses kelas selamanya. Sebagai informasi kelas Dicoding selalu <em>update&nbsp;</em>sehingga memiliki perbedaan minimal 30% dari sejak kelas dirilis. Silakan mampir kembali untuk melihat materi saat kamu membutuhkan <em>update</em>.&nbsp;</p><p><strong>K</strong><strong>eempat</strong>, karena sudah praktik langsung maka kamu sudah menguasai ilmu kelas dasar ini antara 75-90%. Salah satu cara agar meningkatkan penguasaan ilmu agar bisa lebih maksimal (&gt;90%) adalah dengan memperbanyak latihan atau mengajarkan ilmu kepada orang lain.</p><p>Salah satu misi Dicoding adalah menyebarkan ilmu yang bermanfaat. Kami berusaha membangun kurikulum standar global dengan harapan agar developer Indonesia bisa menjadi jawara di negeri sendiri. Namun misi ini tidak akan tercapai tanpa kolaborasi dari kita semua.</p><hr><p>Supaya aplikasimu menjadi lebih baik lagi, berikut <em>beberapa</em> <em>catatan</em> terkait submission kamu:</p><ul>Selamat</ul><hr><p>Silakan berkunjung ke <a href="https://www.dicoding.com/academies/261/discussions">academy discussion</a> untuk mengasah penguasaan ilmu kamu dan membuat ilmu yang kamu dapatkan bisa semakin berkah dan bermanfaat dengan membantu kawan-kawan kita yang saat ini masih berjuang.</p><p>Terima kasih telah membantu misi kami. Kesuksesan developer Indonesia adalah energi bagi kami. Jika memiliki pertanyaan atau saran terkait kelas, silakan email ke <a href="mailto:%20academy@dicoding.com" rel="noreferrer noopener" target="_blank">academy@dicoding.com</a>.</p><hr><p style="text-align:right;"><em>Salam</em></p><p style="text-align:right;"><span style="color:rgb(226,80,65);">Dicoding Reviewer</span></p>')
});
})
Expand Down
Loading
Loading