Skip to content

Commit

Permalink
Merge pull request #2 from dicoding-dev/feature/agrs-support-report
Browse files Browse the repository at this point in the history
Feature/agrs support report
  • Loading branch information
dimasmds authored Sep 14, 2023
2 parents 2561789 + ce51828 commit e08c664
Show file tree
Hide file tree
Showing 3 changed files with 3,018 additions and 2,999 deletions.
17 changes: 17 additions & 0 deletions src/service/report-generator/report-generator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,21 @@ import ReportGenerator from "./report-generator";
import ReviewResult, {ReviewResultStatus} from "../../entities/review-result/course-submission-review/review-result";
import * as fs from "fs";

function itShouldMeetAGRSReportSpec(report: any): void {
expect(report.submission_id).toBeDefined()
expect(typeof report.submission_id).toEqual('number')
expect(report.message).toBeDefined()
expect(typeof report.message).toEqual('string')
expect(report.rating).toBeDefined()
expect(typeof report.rating).toEqual('number')
expect(report.is_passed).toBeDefined()
expect(typeof report.is_passed).toEqual('boolean')
expect(report.is_draft).toBeDefined()
expect(typeof report.is_draft).toEqual('boolean')
expect(report.checklist_keys).toBeDefined()
expect(Array.isArray(report.checklist_keys)).toEqual(true)
}

describe('checklist id resolver test', () => {
const reportGenerator = new ReportGenerator('./test/student/review-result/')

Expand All @@ -29,6 +44,8 @@ describe('checklist id resolver test', () => {

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

itShouldMeetAGRSReportSpec(result)

expect(result.checklist_keys).toEqual([
"project_have_correct_port",
"project_have_correct_runner_script",
Expand Down
4 changes: 3 additions & 1 deletion src/service/report-generator/report-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ class ReportGenerator {
message: this.getReviewMessageWithTemplate(reviewResult, autoReviewConfig),
submission_path: submissionPath,
checklist: reviewResult.checklist,
checklist_keys: this.getCompletedChecklist(reviewResult)
checklist_keys: this.getCompletedChecklist(reviewResult),
is_passed: isApproved,
is_draft: true,
};

this.result.push(summary);
Expand Down
Loading

0 comments on commit e08c664

Please sign in to comment.