146 lines
5.1 KiB
JavaScript
146 lines
5.1 KiB
JavaScript
import { TEST_STUDENT1_USER_ID, TEST_TRAINER1_USER_ID } from "../../consts";
|
|
import { EXPERT_COCKPIT_URL, login } from "../helpers";
|
|
|
|
describe("assignmentTrainer.cy.js", () => {
|
|
beforeEach(() => {
|
|
cy.manageCommand(
|
|
"cypress_reset --create-assignment-completion --create-assignment-evaluation",
|
|
);
|
|
login("test-trainer1@example.com", "test");
|
|
});
|
|
|
|
describe("Can reevaluation assignment", () => {
|
|
it("can start evaluation and store evaluation results", () => {
|
|
cy.visit(EXPERT_COCKPIT_URL);
|
|
cy.get(
|
|
'[data-cy="show-details-btn-test-lehrgang-lp-circle-fahrzeug-lc-überprüfen-einer-motorfahrzeug-versicherungspolice"]',
|
|
).click();
|
|
|
|
cy.get('[data-cy="Student1"]').find('[data-cy="show-results"]').click();
|
|
|
|
// on EvaluationSummary page
|
|
cy.get(
|
|
'[data-cy="assignment-history"] [data-cy="assignment-history-entry"]',
|
|
).should("have.length", 2);
|
|
cy.get('[data-cy="assignment-history"]')
|
|
.should("contain", "Ergebnisse abgegeben")
|
|
.should("contain", "Bewertung freigegeben");
|
|
cy.get('[data-cy="user-points"]').should("contain", "24");
|
|
cy.get('[data-cy="total-points"]').should("contain", "100%");
|
|
|
|
// reevaluation
|
|
cy.get('[data-cy="btn-reopen"]').click();
|
|
|
|
cy.get('[data-cy="evaluation-task"]').should(
|
|
"contain",
|
|
"Beurteilungskriterium 1 / 5",
|
|
);
|
|
cy.get('[data-cy="subtask-4"]').click();
|
|
cy.wait(500);
|
|
cy.get('[data-cy="next-step"]').click();
|
|
|
|
cy.get('[data-cy="evaluation-task"]').should(
|
|
"contain",
|
|
"Beurteilungskriterium 2 / 5",
|
|
);
|
|
cy.get('[data-cy="next-step"]').click();
|
|
|
|
cy.get('[data-cy="evaluation-task"]').should(
|
|
"contain",
|
|
"Beurteilungskriterium 3 / 5",
|
|
);
|
|
cy.get('[data-cy="subtask-4"]').click();
|
|
cy.wait(500);
|
|
cy.get('[data-cy="next-step"]').click();
|
|
|
|
cy.get('[data-cy="evaluation-task"]').should(
|
|
"contain",
|
|
"Beurteilungskriterium 4 / 5",
|
|
);
|
|
cy.get('[data-cy="subtask-2"]').click();
|
|
cy.wait(500);
|
|
cy.get('[data-cy="next-step"]').click();
|
|
|
|
cy.get('[data-cy="evaluation-task"]').should(
|
|
"contain",
|
|
"Beurteilungskriterium 5 / 5",
|
|
);
|
|
cy.get('[data-cy="next-step"]').click();
|
|
|
|
cy.get('[data-cy="user-points"]').should("contain", "19");
|
|
cy.get('[data-cy="total-points"]').should("contain", "79%");
|
|
|
|
cy.get('[data-cy="reason-text"]').type("nochmal bewertet");
|
|
cy.get(
|
|
'[data-cy="assignment-history"] [data-cy="assignment-history-entry"]',
|
|
).should("have.length", 3);
|
|
cy.get('[data-cy="assignment-history"]')
|
|
.should("contain", "Ergebnisse abgegeben")
|
|
.should("contain", "Bewertung freigegeben")
|
|
.should("contain", "Bewertung erneut bearbeitet");
|
|
|
|
cy.get('[data-cy="submit-evaluation"]').click();
|
|
|
|
// check stored data
|
|
cy.get('[data-cy="result-section"]').should(
|
|
"contain",
|
|
"Deine Bewertung für Test Student1 wurde freigegeben",
|
|
);
|
|
cy.reload();
|
|
cy.get(
|
|
'[data-cy="assignment-history"] [data-cy="assignment-history-entry"]',
|
|
).should("have.length", 4);
|
|
|
|
cy.loadAssignmentCompletion(
|
|
"evaluation_user_id",
|
|
TEST_TRAINER1_USER_ID,
|
|
).then((ac) => {
|
|
expect(ac.completion_status).to.equal("EVALUATION_SUBMITTED");
|
|
expect(ac.evaluation_points).to.equal(19);
|
|
expect(ac.completion_data.expert_evaluation_comment.text).to.equal(
|
|
"nochmal bewertet",
|
|
);
|
|
expect(ac.additional_json_data.submission_history).to.have.length(4);
|
|
expect(ac.additional_json_data.submission_history[0].status).to.equal(
|
|
"SUBMITTED",
|
|
);
|
|
expect(ac.additional_json_data.submission_history[1].status).to.equal(
|
|
"EVALUATION_SUBMITTED",
|
|
);
|
|
expect(ac.additional_json_data.submission_history[2].status).to.equal(
|
|
"EVALUATION_IN_PROGRESS",
|
|
);
|
|
expect(ac.additional_json_data.submission_history[3].status).to.equal(
|
|
"EVALUATION_SUBMITTED",
|
|
);
|
|
|
|
// check AssignmentCompletionAuditLog
|
|
cy.task(
|
|
"runSql",
|
|
`select * from assignment_assignmentcompletionauditlog
|
|
where assignment_slug = 'test-lehrgang-assignment-überprüfen-einer-motorfahrzeugs-versicherungspolice'
|
|
and assignment_user_id = '${TEST_STUDENT1_USER_ID}'
|
|
order by created_at asc;`,
|
|
).then((res) => {
|
|
console.log(res);
|
|
expect(res.rows).to.have.length(3);
|
|
expect(res.rows[0].completion_status).to.equal("SUBMITTED");
|
|
|
|
expect(res.rows[1].completion_status).to.equal(
|
|
"EVALUATION_SUBMITTED",
|
|
);
|
|
expect(res.rows[1].evaluation_points).to.equal(24);
|
|
|
|
expect(res.rows[2].completion_status).to.equal(
|
|
"EVALUATION_SUBMITTED",
|
|
);
|
|
expect(res.rows[2].evaluation_points).to.equal(19);
|
|
expect(res.rows[2].completion_data.expert_evaluation_comment.text).to.equal(
|
|
"nochmal bewertet",
|
|
);
|
|
});
|
|
});
|
|
});
|
|
});
|
|
});
|