fix: tests

This commit is contained in:
Livio Bieri 2024-03-11 10:20:36 +01:00
parent 742801bf22
commit 754fa52fd3
5 changed files with 77 additions and 112 deletions

View File

@ -1,5 +1,5 @@
import {TEST_TRAINER1_USER_ID} from "../../consts"; import {TEST_TRAINER1_USER_ID} from "../../consts";
import { login } from "../helpers"; import {EXPERT_COCKPIT_URL, login} from "../helpers";
describe("assignmentTrainer.cy.js", () => { describe("assignmentTrainer.cy.js", () => {
beforeEach(() => { beforeEach(() => {
@ -9,10 +9,8 @@ describe("assignmentTrainer.cy.js", () => {
describe("Casework", () => { describe("Casework", () => {
it("can open cockpit assignment page and open user assignment", () => { it("can open cockpit assignment page and open user assignment", () => {
cy.visit("/course/test-lehrgang/cockpit"); cy.visit(EXPERT_COCKPIT_URL);
cy.get( cy.get('[data-cy="show-details-btn-test-lehrgang-lp-circle-fahrzeug-lc-überprüfen-einer-motorfahrzeug-versicherungspolice"]').click();
'[data-cy="show-details-btn-test-lehrgang-lp-circle-fahrzeug-lc-überprüfen-einer-motorfahrzeug-versicherungspolice"]'
).click();
cy.get('[data-cy="Student1"]').should("contain", "Ergebnisse abgegeben"); cy.get('[data-cy="Student1"]').should("contain", "Ergebnisse abgegeben");
cy.get('[data-cy="Student1"]').find('[data-cy="show-results"]').click(); cy.get('[data-cy="Student1"]').find('[data-cy="show-results"]').click();
@ -22,24 +20,16 @@ describe("assignmentTrainer.cy.js", () => {
}); });
it("can start evaluation and store evaluation results", () => { it("can start evaluation and store evaluation results", () => {
cy.visit("/course/test-lehrgang/cockpit"); cy.visit(EXPERT_COCKPIT_URL)
cy.get( cy.get('[data-cy="show-details-btn-test-lehrgang-lp-circle-fahrzeug-lc-überprüfen-einer-motorfahrzeug-versicherungspolice"]').click();
'[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(); cy.get('[data-cy="Student1"]').find('[data-cy="show-results"]').click();
cy.get('[data-cy="title"]').should("contain", "Bewertung"); cy.get('[data-cy="title"]').should("contain", "Bewertung");
cy.get('[data-cy="evaluation-duedate"]').should("exist"); cy.get('[data-cy="evaluation-duedate"]').should("exist");
cy.get('[data-cy="instruction"]').should( cy.get('[data-cy="instruction"]').should("contain", "Die Gesamtpunktzahl und die daraus resultierende Note wird auf Grund des hinterlegeten Beurteilungsinstrument berechnet.");
"contain",
"Die Gesamtpunktzahl und die daraus resultierende Note wird auf Grund des hinterlegeten Beurteilungsinstrument berechnet."
);
cy.get('[data-cy="start-evaluation"]').click(); cy.get('[data-cy="start-evaluation"]').click();
cy.get('[data-cy="evaluation-task"]').should( cy.get('[data-cy="evaluation-task"]').should("contain", "Beurteilungskriterium 1 / 5");
"contain",
"Beurteilungskriterium 1 / 5"
);
// without text input the button should be disabled // without text input the button should be disabled
cy.get('[data-cy="next-step"]').should("be.disabled"); cy.get('[data-cy="next-step"]').should("be.disabled");
@ -51,10 +41,7 @@ describe("assignmentTrainer.cy.js", () => {
cy.wait(500); cy.wait(500);
cy.get('[data-cy="next-step"]').click(); cy.get('[data-cy="next-step"]').click();
cy.get('[data-cy="evaluation-task"]').should( cy.get('[data-cy="evaluation-task"]').should("contain", "Beurteilungskriterium 2 / 5");
"contain",
"Beurteilungskriterium 2 / 5"
);
cy.get('[data-cy="subtask-2"]').click(); cy.get('[data-cy="subtask-2"]').click();
cy.get('[data-cy="reason-text"]').type("Nicht so gut"); cy.get('[data-cy="reason-text"]').type("Nicht so gut");
cy.wait(500); cy.wait(500);
@ -84,10 +71,7 @@ describe("assignmentTrainer.cy.js", () => {
cy.wait(500); cy.wait(500);
// load AssignmentCompletion from DB and check // load AssignmentCompletion from DB and check
cy.loadAssignmentCompletion( cy.loadAssignmentCompletion("evaluation_user_id", TEST_TRAINER1_USER_ID).then((ac) => {
"evaluation_user_id",
TEST_TRAINER1_USER_ID
).then((ac) => {
expect(ac.completion_status).to.equal("EVALUATION_IN_PROGRESS"); expect(ac.completion_status).to.equal("EVALUATION_IN_PROGRESS");
expect(JSON.stringify(ac.completion_data)).to.include("Nicht so gut"); expect(JSON.stringify(ac.completion_data)).to.include("Nicht so gut");
expect(Cypress._.values(ac.completion_data)).to.deep.include({ expect(Cypress._.values(ac.completion_data)).to.deep.include({
@ -100,20 +84,15 @@ describe("assignmentTrainer.cy.js", () => {
}); });
it("can make complete evaluation", () => { it("can make complete evaluation", () => {
cy.visit("/course/test-lehrgang/cockpit"); cy.visit(EXPERT_COCKPIT_URL)
cy.get( cy.get('[data-cy="show-details-btn-test-lehrgang-lp-circle-fahrzeug-lc-überprüfen-einer-motorfahrzeug-versicherungspolice"]').click();
'[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(); cy.get('[data-cy="Student1"]').find('[data-cy="show-results"]').click();
cy.get('[data-cy="start-evaluation"]').click(); cy.get('[data-cy="start-evaluation"]').click();
// step 1 // step 1
cy.get('[data-cy="evaluation-task"]').should( cy.get('[data-cy="evaluation-task"]').should("contain", "Beurteilungskriterium 1 / 5");
"contain",
"Beurteilungskriterium 1 / 5"
);
cy.get('[data-cy="subtask-6"]').click(); cy.get('[data-cy="subtask-6"]').click();
cy.get('[data-cy="reason-text"]').type("Begründung Schritt 1"); cy.get('[data-cy="reason-text"]').type("Begründung Schritt 1");
// wait for debounce // wait for debounce
@ -121,40 +100,28 @@ describe("assignmentTrainer.cy.js", () => {
cy.get('[data-cy="next-step"]').click(); cy.get('[data-cy="next-step"]').click();
// step 2 // step 2
cy.get('[data-cy="evaluation-task"]').should( cy.get('[data-cy="evaluation-task"]').should("contain", "Beurteilungskriterium 2 / 5");
"contain",
"Beurteilungskriterium 2 / 5"
);
cy.get('[data-cy="subtask-4"]').click(); cy.get('[data-cy="subtask-4"]').click();
cy.get('[data-cy="reason-text"]').type("Begründung Schritt 2"); cy.get('[data-cy="reason-text"]').type("Begründung Schritt 2");
cy.wait(500); cy.wait(500);
cy.get('[data-cy="next-step"]').click(); cy.get('[data-cy="next-step"]').click();
// step 3 // step 3
cy.get('[data-cy="evaluation-task"]').should( cy.get('[data-cy="evaluation-task"]').should("contain", "Beurteilungskriterium 3 / 5");
"contain",
"Beurteilungskriterium 3 / 5"
);
cy.get('[data-cy="subtask-2"]').click(); cy.get('[data-cy="subtask-2"]').click();
cy.get('[data-cy="reason-text"]').type("Begründung Schritt 3"); cy.get('[data-cy="reason-text"]').type("Begründung Schritt 3");
cy.wait(500); cy.wait(500);
cy.get('[data-cy="next-step"]').click(); cy.get('[data-cy="next-step"]').click();
// step 4 // step 4
cy.get('[data-cy="evaluation-task"]').should( cy.get('[data-cy="evaluation-task"]').should("contain", "Beurteilungskriterium 4 / 5");
"contain",
"Beurteilungskriterium 4 / 5"
);
cy.get('[data-cy="subtask-3"]').click(); cy.get('[data-cy="subtask-3"]').click();
cy.get('[data-cy="reason-text"]').type("Begründung Schritt 4"); cy.get('[data-cy="reason-text"]').type("Begründung Schritt 4");
cy.wait(500); cy.wait(500);
cy.get('[data-cy="next-step"]').click(); cy.get('[data-cy="next-step"]').click();
// step 5 // step 5
cy.get('[data-cy="evaluation-task"]').should( cy.get('[data-cy="evaluation-task"]').should("contain", "Beurteilungskriterium 5 / 5");
"contain",
"Beurteilungskriterium 5 / 5"
);
cy.get('[data-cy="subtask-2"]').click(); cy.get('[data-cy="subtask-2"]').click();
cy.get('[data-cy="reason-text"]').type("Begründung Schritt 5"); cy.get('[data-cy="reason-text"]').type("Begründung Schritt 5");
cy.wait(500); cy.wait(500);
@ -166,17 +133,12 @@ describe("assignmentTrainer.cy.js", () => {
cy.get('[data-cy="total-points"]').should("contain", "24"); cy.get('[data-cy="total-points"]').should("contain", "24");
cy.get('[data-cy="submit-evaluation"]').click(); cy.get('[data-cy="submit-evaluation"]').click();
cy.get('[data-cy="result-section"]').should( cy.get('[data-cy="result-section"]').should("contain", "Deine Bewertung für Test Student1 wurde freigegeben");
"contain",
"Deine Bewertung für Test Student1 wurde freigegeben"
);
// going back to cockpit should show points for student // going back to cockpit should show points for student
cy.visit("/course/test-lehrgang/cockpit"); cy.visit(EXPERT_COCKPIT_URL);
cy.reload(); cy.reload();
cy.get( cy.get('[data-cy="show-details-btn-test-lehrgang-lp-circle-fahrzeug-lc-überprüfen-einer-motorfahrzeug-versicherungspolice"]').click();
'[data-cy="show-details-btn-test-lehrgang-lp-circle-fahrzeug-lc-überprüfen-einer-motorfahrzeug-versicherungspolice"]'
).click();
cy.get('[data-cy="Student1"]').should("contain", "Bewertung freigegeben"); cy.get('[data-cy="Student1"]').should("contain", "Bewertung freigegeben");
cy.get('[data-cy="Student1"]').should("contain", "17 von 24 Punkte"); cy.get('[data-cy="Student1"]').should("contain", "17 von 24 Punkte");
@ -186,10 +148,7 @@ describe("assignmentTrainer.cy.js", () => {
cy.url().should("include", "step=6"); cy.url().should("include", "step=6");
// load AssignmentCompletion from DB and check // load AssignmentCompletion from DB and check
cy.loadAssignmentCompletion( cy.loadAssignmentCompletion("evaluation_user_id", TEST_TRAINER1_USER_ID).then((ac) => {
"evaluation_user_id",
TEST_TRAINER1_USER_ID
).then((ac) => {
expect(ac.completion_status).to.equal("EVALUATION_SUBMITTED"); expect(ac.completion_status).to.equal("EVALUATION_SUBMITTED");
expect(ac.evaluation_points).to.equal(17); expect(ac.evaluation_points).to.equal(17);
expect(ac.evaluation_max_points).to.equal(24); expect(ac.evaluation_max_points).to.equal(24);
@ -207,21 +166,16 @@ describe("assignmentTrainer.cy.js", () => {
//Todo: Move tests to Lernbegleitung once it is implemented //Todo: Move tests to Lernbegleitung once it is implemented
describe("Praxis Assignment", () => { describe("Praxis Assignment", () => {
it("can start evaluation and store evaluation results", () => { it("can start evaluation and store evaluation results", () => {
cy.visit("/course/test-lehrgang/cockpit"); cy.visit(EXPERT_COCKPIT_URL);
cy.get('[data-cy="dropdown-select"]').click(); cy.get('[data-cy="dropdown-select"]').click();
cy.get('[data-cy="dropdown-select-option-Reisen"]').click(); cy.get('[data-cy="dropdown-select-option-Reisen"]').click();
cy.get( cy.get('[data-cy="show-details-btn-test-lehrgang-lp-circle-reisen-lc-mein-kundenstamm"]').click();
'[data-cy="show-details-btn-test-lehrgang-lp-circle-reisen-lc-mein-kundenstamm"]'
).click();
cy.get('[data-cy="Student1"]').find('[data-cy="show-results"]').click(); cy.get('[data-cy="Student1"]').find('[data-cy="show-results"]').click();
cy.get('[data-cy="title"]').should("contain", "Feedback"); cy.get('[data-cy="title"]').should("contain", "Feedback");
cy.get('[data-cy="evaluation-duedate]"').should("not.exist"); cy.get('[data-cy="evaluation-duedate]"').should("not.exist");
cy.get('[data-cy="instruction"]').should( cy.get('[data-cy="instruction"]').should("contain", "Bitte unterstütze Test Student1 und gib Feedback zum Auftrag.");
"contain",
"Bitte unterstütze Test Student1 und gib Feedback zum Auftrag."
);
cy.get('[data-cy="start-evaluation"]').click(); cy.get('[data-cy="start-evaluation"]').click();
cy.get('[data-cy="evaluation-task"]').should("contain", "Feedback 1 / 5"); cy.get('[data-cy="evaluation-task"]').should("contain", "Feedback 1 / 5");
@ -239,10 +193,7 @@ describe("assignmentTrainer.cy.js", () => {
cy.wait(1000); cy.wait(1000);
// load AssignmentCompletion from DB and check // load AssignmentCompletion from DB and check
cy.loadAssignmentCompletion( cy.loadAssignmentCompletion("evaluation_user_id", TEST_TRAINER1_USER_ID).then((ac) => {
"evaluation_user_id",
TEST_TRAINER1_USER_ID
).then((ac) => {
console.log(ac.completion_status); console.log(ac.completion_status);
expect(ac.completion_status).to.equal("EVALUATION_IN_PROGRESS"); expect(ac.completion_status).to.equal("EVALUATION_IN_PROGRESS");
expect(JSON.stringify(ac.completion_data)).to.include("Nicht so gut"); expect(JSON.stringify(ac.completion_data)).to.include("Nicht so gut");
@ -256,12 +207,10 @@ describe("assignmentTrainer.cy.js", () => {
}); });
it("can make complete evaluation", () => { it("can make complete evaluation", () => {
cy.visit("/course/test-lehrgang/cockpit"); cy.visit(EXPERT_COCKPIT_URL);
cy.get('[data-cy="dropdown-select"]').click(); cy.get('[data-cy="dropdown-select"]').click();
cy.get('[data-cy="dropdown-select-option-Reisen"]').click(); cy.get('[data-cy="dropdown-select-option-Reisen"]').click();
cy.get( cy.get('[data-cy="show-details-btn-test-lehrgang-lp-circle-reisen-lc-mein-kundenstamm"]').click();
'[data-cy="show-details-btn-test-lehrgang-lp-circle-reisen-lc-mein-kundenstamm"]'
).click();
cy.get('[data-cy="Student1"]').find('[data-cy="show-results"]').click(); cy.get('[data-cy="Student1"]').find('[data-cy="show-results"]').click();
@ -303,19 +252,14 @@ describe("assignmentTrainer.cy.js", () => {
cy.get('[data-cy="total-points"]').should("not.exist"); cy.get('[data-cy="total-points"]').should("not.exist");
cy.get('[data-cy="submit-evaluation"]').click(); cy.get('[data-cy="submit-evaluation"]').click();
cy.get('[data-cy="result-section"]').should( cy.get('[data-cy="result-section"]').should("contain", "Dein Feedback für Test Student1 wurde freigegeben");
"contain",
"Dein Feedback für Test Student1 wurde freigegeben"
);
// going back to cockpit should show points for student // going back to cockpit should show points for student
cy.visit("/course/test-lehrgang/cockpit"); cy.visit(EXPERT_COCKPIT_URL);
cy.reload(); cy.reload();
cy.get('[data-cy="dropdown-select"]').click(); cy.get('[data-cy="dropdown-select"]').click();
cy.get('[data-cy="dropdown-select-option-Reisen"]').click(); cy.get('[data-cy="dropdown-select-option-Reisen"]').click();
cy.get( cy.get('[data-cy="show-details-btn-test-lehrgang-lp-circle-reisen-lc-mein-kundenstamm"]').click();
'[data-cy="show-details-btn-test-lehrgang-lp-circle-reisen-lc-mein-kundenstamm"]'
).click();
cy.get('[data-cy="Student1"]').should("contain", "Feedback freigegeben"); cy.get('[data-cy="Student1"]').should("contain", "Feedback freigegeben");
cy.get('[data-cy="Student1"]').should("not.contain", "Punkte"); cy.get('[data-cy="Student1"]').should("not.contain", "Punkte");
@ -325,10 +269,7 @@ describe("assignmentTrainer.cy.js", () => {
cy.url().should("include", "step=6"); cy.url().should("include", "step=6");
// load AssignmentCompletion from DB and check // load AssignmentCompletion from DB and check
cy.loadAssignmentCompletion( cy.loadAssignmentCompletion("evaluation_user_id", TEST_TRAINER1_USER_ID).then((ac) => {
"evaluation_user_id",
TEST_TRAINER1_USER_ID
).then((ac) => {
expect(ac.completion_status).to.equal("EVALUATION_SUBMITTED"); expect(ac.completion_status).to.equal("EVALUATION_SUBMITTED");
expect(ac.evaluation_max_points).to.equal(0); expect(ac.evaluation_max_points).to.equal(0);
const completionString = JSON.stringify(ac.completion_data); const completionString = JSON.stringify(ac.completion_data);

View File

@ -1,4 +1,4 @@
import { login } from "../helpers"; import {EXPERT_COCKPIT_URL, login} from "../helpers";
describe("feedbackTrainer.cy.js", () => { describe("feedbackTrainer.cy.js", () => {
beforeEach(() => { beforeEach(() => {
@ -8,7 +8,7 @@ describe("feedbackTrainer.cy.js", () => {
it("can open feedback results page with empty results", () => { it("can open feedback results page with empty results", () => {
cy.manageCommand("cypress_reset"); cy.manageCommand("cypress_reset");
login("test-trainer1@example.com", "test"); login("test-trainer1@example.com", "test");
cy.visit("/course/test-lehrgang/cockpit"); cy.visit(EXPERT_COCKPIT_URL);
cy.get( cy.get(
'[data-cy="show-feedback-btn-test-lehrgang-lp-circle-fahrzeug-lc-feedback"]' '[data-cy="show-feedback-btn-test-lehrgang-lp-circle-fahrzeug-lc-feedback"]'
).click(); ).click();
@ -20,7 +20,7 @@ describe("feedbackTrainer.cy.js", () => {
it("can open feedback results page with results", () => { it("can open feedback results page with results", () => {
cy.manageCommand("cypress_reset --create-feedback-responses"); cy.manageCommand("cypress_reset --create-feedback-responses");
login("test-trainer1@example.com", "test"); login("test-trainer1@example.com", "test");
cy.visit("/course/test-lehrgang/cockpit"); cy.visit(EXPERT_COCKPIT_URL);
cy.get( cy.get(
'[data-cy="show-feedback-btn-test-lehrgang-lp-circle-fahrzeug-lc-feedback"]' '[data-cy="show-feedback-btn-test-lehrgang-lp-circle-fahrzeug-lc-feedback"]'
).click(); ).click();
@ -138,7 +138,7 @@ describe("feedbackTrainer.cy.js", () => {
it("can open feedback results page with results", () => { it("can open feedback results page with results", () => {
cy.manageCommand("cypress_reset --create-feedback-responses"); cy.manageCommand("cypress_reset --create-feedback-responses");
login("test-trainer1@example.com", "test"); login("test-trainer1@example.com", "test");
cy.visit("/course/test-lehrgang/cockpit"); cy.visit(EXPERT_COCKPIT_URL);
cy.get('[data-cy="dropdown-select"]').click(); cy.get('[data-cy="dropdown-select"]').click();
cy.get('[data-cy="dropdown-select-option-Reisen"]').click(); cy.get('[data-cy="dropdown-select-option-Reisen"]').click();
cy.get( cy.get(

View File

@ -1,3 +1,5 @@
export const EXPERT_COCKPIT_URL = "course/test-lehrgang/cockpit/expert"
export const login = (username, password) => { export const login = (username, password) => {
cy.request({ cy.request({
method: "POST", url: "/api/core/login/", body: {username, password}, method: "POST", url: "/api/core/login/", body: {username, password},

View File

@ -1,4 +1,4 @@
import { login } from "./helpers"; import {EXPERT_COCKPIT_URL, login} from "./helpers";
describe("settings.cy.js", () => { describe("settings.cy.js", () => {
beforeEach(() => { beforeEach(() => {
@ -14,7 +14,7 @@ describe("settings.cy.js", () => {
it("trainer can see circle documents", () => { it("trainer can see circle documents", () => {
login("test-trainer1@example.com", "test"); login("test-trainer1@example.com", "test");
cy.visit("/course/test-lehrgang/cockpit"); cy.visit(EXPERT_COCKPIT_URL);
cy.get('[data-cy="circle-documents"]').should("exist"); cy.get('[data-cy="circle-documents"]').should("exist");
}); });
}); });
@ -33,7 +33,7 @@ describe("settings.cy.js", () => {
it("trainer cannot see circle documents", () => { it("trainer cannot see circle documents", () => {
login("test-trainer1@example.com", "test"); login("test-trainer1@example.com", "test");
cy.visit("/course/test-lehrgang/cockpit"); cy.visit(EXPERT_COCKPIT_URL);
cy.get('[data-cy="circle-documents"]').should("not.exist"); cy.get('[data-cy="circle-documents"]').should("not.exist");
}); });
}); });

View File

@ -48,6 +48,28 @@ class ActionTestCase(TestCase):
trainer_actions = course_session_permissions(trainer, self.course_session.id) trainer_actions = course_session_permissions(trainer, self.course_session.id)
# THEN # THEN
self.assertEqual(len(mentor_actions), 0) self.assertEqual(
self.assertEqual(participant_actions, ["complete-learning-content"]) mentor_actions,
self.assertEqual(trainer_actions, ["complete-learning-content"]) ["learning-mentor", "preview", "appointments", "expert-cockpit"],
)
self.assertEqual(
participant_actions,
[
"deprecated-mentor",
"media-library",
"appointments",
"learning-path",
"competence-navi",
"complete-learning-content",
],
)
self.assertEqual(
trainer_actions,
[
"preview",
"media-library",
"appointments",
"expert-cockpit",
"complete-learning-content",
],
)