378 lines
13 KiB
JavaScript
378 lines
13 KiB
JavaScript
import { TEST_STUDENT1_USER_ID } from "../../consts";
|
|
import { login } from "../helpers";
|
|
|
|
function completePraxisAssignment() {
|
|
cy.visit("/course/test-lehrgang/learn/reisen/mein-kundenstamm");
|
|
cy.learningContentMultiLayoutNextStep();
|
|
cy.testLearningContentTitle(
|
|
"Teilaufgabe 1: Filtere nach Kundeneigenschaften"
|
|
);
|
|
cy.get("[data-cy=\"it-textarea-user-text-input-1\"]")
|
|
.clear()
|
|
.type("Hallo Teilaufgabe 1.1");
|
|
cy.wait(550);
|
|
cy.get("[data-cy=\"it-textarea-user-text-input-2\"]")
|
|
.clear()
|
|
.type("Hallo Teilaufgabe 1.2");
|
|
cy.wait(550);
|
|
cy.get("[data-cy=\"it-textarea-user-text-input-3\"]")
|
|
.clear()
|
|
.type("Hallo Teilaufgabe 1.3");
|
|
cy.wait(550);
|
|
cy.get("[data-cy=\"it-textarea-user-text-input-4\"]")
|
|
.clear()
|
|
.type("Hallo Teilaufgabe 1.4");
|
|
cy.wait(550);
|
|
cy.get("[data-cy=\"it-textarea-user-text-input-5\"]")
|
|
.clear()
|
|
.type("Hallo Teilaufgabe 1.5");
|
|
// wait because of input debounce
|
|
cy.wait(550);
|
|
cy.learningContentMultiLayoutNextStep();
|
|
|
|
// step 2
|
|
cy.testLearningContentTitle("Teilaufgabe 2: Filtere nach Versicherungen");
|
|
cy.get("[data-cy=\"it-textarea-user-text-input-1\"]")
|
|
.clear()
|
|
.type("Hallo Teilaufgabe 2.1");
|
|
cy.wait(550);
|
|
cy.get("[data-cy=\"it-textarea-user-text-input-2\"]")
|
|
.clear()
|
|
.type("Hallo Teilaufgabe 2.2");
|
|
cy.wait(550);
|
|
cy.get("[data-cy=\"it-textarea-user-text-input-3\"]")
|
|
.clear()
|
|
.type("Hallo Teilaufgabe 2.3");
|
|
cy.wait(550);
|
|
cy.get("[data-cy=\"it-textarea-user-text-input-4\"]")
|
|
.clear()
|
|
.type("Hallo Teilaufgabe 2.4");
|
|
// wait because of input debounce
|
|
cy.wait(550);
|
|
cy.learningContentMultiLayoutNextStep();
|
|
|
|
// check that results are stored on server
|
|
// load AssignmentCompletion from DB and check
|
|
cy.loadAssignmentCompletion("assignment_user_id", TEST_STUDENT1_USER_ID).then(
|
|
(ac) => {
|
|
expect(ac.completion_status).to.equal("IN_PROGRESS");
|
|
expect(JSON.stringify(ac.completion_data)).to.include(
|
|
"Hallo Teilaufgabe 2.1"
|
|
);
|
|
}
|
|
);
|
|
|
|
// step 3
|
|
cy.testLearningContentTitle(
|
|
"Teilaufgabe 3: Filtere nach besonderen Ereignissen"
|
|
);
|
|
cy.get("[data-cy=\"it-textarea-user-text-input-1\"]")
|
|
.clear()
|
|
.type("Hallo Teilaufgabe 3.1");
|
|
cy.wait(550);
|
|
cy.get("[data-cy=\"it-textarea-user-text-input-2\"]")
|
|
.clear()
|
|
.type("Hallo Teilaufgabe 3.2");
|
|
// wait because of input debounce
|
|
cy.wait(550);
|
|
cy.learningContentMultiLayoutNextStep();
|
|
|
|
// step 4
|
|
cy.testLearningContentTitle("Teilaufgabe 4: Kundentelefonate");
|
|
cy.get("[data-cy=\"it-textarea-user-text-input-0\"]")
|
|
.clear()
|
|
.type("Hallo Teilaufgabe 4.1");
|
|
// wait because of input debounce
|
|
cy.wait(550);
|
|
cy.learningContentMultiLayoutNextStep();
|
|
|
|
// step 5
|
|
cy.testLearningContentTitle("Teilaufgabe 5: Kundentelefonate2");
|
|
cy.get("[data-cy=\"it-textarea-user-text-input-0\"]")
|
|
.clear()
|
|
.type("Hallo Teilaufgabe 5.1");
|
|
// wait because of input debounce
|
|
cy.wait(550);
|
|
cy.learningContentMultiLayoutNextStep();
|
|
|
|
cy.get("[data-cy=\"confirm-submit-results\"]").should("not.exist");
|
|
cy.get("[data-cy=\"confirm-submit-person\"]").should(
|
|
"contain",
|
|
"Folgende Person soll mir Feedback zu meinen Ergebnissen geben."
|
|
);
|
|
|
|
cy.get("[data-cy=\"confirm-submit-person\"]").click();
|
|
cy.get("[data-cy='select-learning-mentor']").should("be.visible").select(0);
|
|
|
|
cy.get("[data-cy=\"submit-assignment\"]").click();
|
|
cy.get("[data-cy=\"success-text\"]").should("exist");
|
|
|
|
// app goes back to circle view -> check if assignment is marked as completed
|
|
cy.url().should((url) => {
|
|
expect(url).to.match(/\/reisen#lu-reisen?$/);
|
|
});
|
|
cy.reload();
|
|
cy.get(
|
|
"[data-cy=\"test-lehrgang-lp-circle-reisen-lc-mein-kundenstamm-checkbox\"]"
|
|
).should("have.class", "cy-checked");
|
|
}
|
|
|
|
describe("assignmentStudent.cy.js", () => {
|
|
beforeEach(() => {
|
|
cy.manageCommand("cypress_reset --create-learning-mentor");
|
|
login("test-student1@example.com", "test");
|
|
cy.visit(
|
|
"/course/test-lehrgang/learn/fahrzeug/überprüfen-einer-motorfahrzeug-versicherungspolice"
|
|
);
|
|
});
|
|
|
|
describe("Assignment", () => {
|
|
it("can open assignment", () => {
|
|
cy.testLearningContentTitle("Einleitung");
|
|
cy.testLearningContentSubtitle(
|
|
"Überprüfen einer Motorfahrzeugs-Versicherungspolice"
|
|
);
|
|
});
|
|
|
|
it("can navigate through assignment", () => {
|
|
// 1 Step forward
|
|
cy.learningContentMultiLayoutNextStep();
|
|
cy.testLearningContentTitle(
|
|
"Teilaufgabe 1: Beispiel einer Versicherungspolice finden"
|
|
);
|
|
|
|
cy.learningContentMultiLayoutNextStep();
|
|
cy.testLearningContentTitle(
|
|
"Teilaufgabe 2: Kundensituation und Ausgangslage"
|
|
);
|
|
|
|
cy.learningContentMultiLayoutNextStep();
|
|
cy.testLearningContentTitle("Teilaufgabe 3: Aktuelle Versicherung");
|
|
|
|
cy.learningContentMultiLayoutPreviousStep();
|
|
|
|
cy.testLearningContentTitle(
|
|
"Teilaufgabe 2: Kundensituation und Ausgangslage"
|
|
);
|
|
});
|
|
|
|
it("can save confirmation", () => {
|
|
// 1 Step forward
|
|
cy.learningContentMultiLayoutNextStep();
|
|
cy.testLearningContentTitle(
|
|
"Teilaufgabe 1: Beispiel einer Versicherungspolice finden"
|
|
);
|
|
// Click confirmation
|
|
cy.get("[data-cy=\"it-checkbox-confirmation-1\"]").click();
|
|
|
|
cy.reload();
|
|
cy.get("[data-cy=\"it-checkbox-confirmation-1\"]").should(
|
|
"have.class",
|
|
"cy-checked"
|
|
);
|
|
});
|
|
|
|
it("can save text", () => {
|
|
// 2 Steps forward
|
|
cy.learningContentMultiLayoutNextStep();
|
|
cy.learningContentMultiLayoutNextStep();
|
|
cy.testLearningContentTitle(
|
|
"Teilaufgabe 2: Kundensituation und Ausgangslage"
|
|
);
|
|
// Enter text
|
|
cy.get("[data-cy=\"it-textarea-user-text-input-1\"]")
|
|
.clear()
|
|
.type("Hallovelo");
|
|
// wait because of input debounce
|
|
cy.wait(550);
|
|
cy.reload();
|
|
|
|
cy.get("[data-cy=\"it-textarea-user-text-input-1\"]").should(
|
|
"have.value",
|
|
"Hallovelo"
|
|
);
|
|
});
|
|
|
|
it("can visit sub step directly via url", () => {
|
|
cy.visit(
|
|
"/course/test-lehrgang/learn/fahrzeug/überprüfen-einer-motorfahrzeug-versicherungspolice?step=3"
|
|
);
|
|
cy.testLearningContentTitle("Teilaufgabe 3: Aktuelle Versicherung");
|
|
});
|
|
|
|
it("can visit sub step by clicking navigation bar", () => {
|
|
cy.get("[data-cy=\"nav-progress-step-4\"]").click();
|
|
cy.testLearningContentTitle("Teilaufgabe 4: Deine Empfehlungen");
|
|
});
|
|
|
|
it("can submit assignment", () => {
|
|
cy.visit(
|
|
"/course/test-lehrgang/learn/fahrzeug/überprüfen-einer-motorfahrzeug-versicherungspolice?step=7"
|
|
);
|
|
cy.get("[data-cy=\"confirm-submit-results\"] label").click();
|
|
cy.get("[data-cy=\"confirm-submit-person\"]").click();
|
|
cy.get("[data-cy=\"submit-assignment\"]").click();
|
|
cy.get("[data-cy=\"success-text\"]").should("exist");
|
|
|
|
// Check if trainer received notification
|
|
cy.clearLocalStorage();
|
|
cy.clearCookies();
|
|
cy.reload(true);
|
|
login("test-trainer1@example.com", "test");
|
|
cy.visit("/notifications");
|
|
cy.get(`[data-cy=notification-idx-0]`).within(() => {
|
|
cy.get("[data-cy=\"unread\"]").should("exist");
|
|
cy.get("[data-cy=\"notification-target-idx-0-verb\"]").contains(
|
|
"Test Student1 hat die geleitete Fallarbeit «Überprüfen einer Motorfahrzeugs-Versicherungspolice» abgegeben."
|
|
);
|
|
});
|
|
});
|
|
|
|
it("can make complete assignment", () => {
|
|
cy.learningContentMultiLayoutNextStep();
|
|
cy.testLearningContentTitle(
|
|
"Teilaufgabe 1: Beispiel einer Versicherungspolice finden"
|
|
);
|
|
// Click confirmation
|
|
cy.get("[data-cy=\"it-checkbox-confirmation-1\"]").click();
|
|
cy.learningContentMultiLayoutNextStep();
|
|
|
|
// step 2
|
|
cy.testLearningContentTitle(
|
|
"Teilaufgabe 2: Kundensituation und Ausgangslage"
|
|
);
|
|
cy.get("[data-cy=\"it-textarea-user-text-input-1\"]")
|
|
.clear()
|
|
.type("Hallo Teilaufgabe 2");
|
|
// wait because of input debounce
|
|
cy.wait(550);
|
|
cy.learningContentMultiLayoutNextStep();
|
|
|
|
// check that results are stored on server
|
|
// load AssignmentCompletion from DB and check
|
|
cy.loadAssignmentCompletion(
|
|
"assignment_user_id",
|
|
TEST_STUDENT1_USER_ID
|
|
).then((ac) => {
|
|
expect(ac.completion_status).to.equal("IN_PROGRESS");
|
|
expect(JSON.stringify(ac.completion_data)).to.include(
|
|
"Hallo Teilaufgabe 2"
|
|
);
|
|
});
|
|
|
|
// step 3
|
|
cy.testLearningContentTitle("Teilaufgabe 3: Aktuelle Versicherung");
|
|
cy.get("[data-cy=\"it-textarea-user-text-input-1\"]")
|
|
.clear()
|
|
.type("Hallo Teilaufgabe 3");
|
|
// wait because of input debounce
|
|
cy.wait(550);
|
|
cy.learningContentMultiLayoutNextStep();
|
|
|
|
// step 4
|
|
cy.testLearningContentTitle("Teilaufgabe 4: Deine Empfehlungen");
|
|
cy.get("[data-cy=\"it-textarea-user-text-input-1\"]")
|
|
.clear()
|
|
.type("Hallo Teilaufgabe 4.1");
|
|
cy.wait(550);
|
|
cy.get("[data-cy=\"it-textarea-user-text-input-2\"]")
|
|
.clear()
|
|
.type("Hallo Teilaufgabe 4.2");
|
|
cy.wait(550);
|
|
cy.get("[data-cy=\"it-textarea-user-text-input-3\"]")
|
|
.clear()
|
|
.type("Hallo Teilaufgabe 4.3");
|
|
// wait because of input debounce
|
|
cy.wait(550);
|
|
cy.learningContentMultiLayoutNextStep();
|
|
|
|
// step 5
|
|
cy.testLearningContentTitle("Teilaufgabe 5: Reflexion");
|
|
cy.get("[data-cy=\"it-textarea-user-text-input-1\"]")
|
|
.clear()
|
|
.type("Hallo Teilaufgabe 5.1");
|
|
cy.wait(550);
|
|
cy.get("[data-cy=\"it-textarea-user-text-input-2\"]")
|
|
.clear()
|
|
.type("Hallo Teilaufgabe 5.2");
|
|
cy.wait(550);
|
|
cy.get("[data-cy=\"it-textarea-user-text-input-3\"]")
|
|
.clear()
|
|
.type("Hallo Teilaufgabe 5.3");
|
|
// wait because of input debounce
|
|
cy.wait(550);
|
|
cy.learningContentMultiLayoutNextStep();
|
|
|
|
// step 6
|
|
cy.testLearningContentTitle("Teilaufgabe 6: Learnings");
|
|
cy.get("[data-cy=\"it-textarea-user-text-input-1\"]")
|
|
.clear()
|
|
.type("Hallo Teilaufgabe 6.1");
|
|
cy.wait(550);
|
|
cy.get("[data-cy=\"it-textarea-user-text-input-2\"]")
|
|
.clear()
|
|
.type("Hallo Teilaufgabe 6.2");
|
|
// wait because of input debounce
|
|
cy.wait(550);
|
|
cy.learningContentMultiLayoutNextStep();
|
|
|
|
cy.get("[data-cy=\"confirm-submit-person\"]").should(
|
|
"contain",
|
|
"Ja, die folgende Person soll meine Ergebnisse bewerten."
|
|
);
|
|
cy.get("[data-cy=\"confirm-submit-results\"] label").click();
|
|
cy.get("[data-cy=\"confirm-submit-person\"]").click();
|
|
cy.get("[data-cy=\"submit-assignment\"]").click();
|
|
cy.get("[data-cy=\"success-text\"]").should("exist");
|
|
|
|
cy.get("[data-cy=\"confirm-container\"]")
|
|
.find("[data-cy=\"show-sample-solution\"]")
|
|
.then(($elements) => {
|
|
if ($elements.length > 0) {
|
|
// Ist die Musterlösung da?
|
|
cy.get("[data-cy=\"show-sample-solution\"]").should("exist");
|
|
cy.get("[data-cy=\"show-sample-solution-button\"]").should("exist");
|
|
}
|
|
});
|
|
|
|
cy.visit("/course/test-lehrgang/learn/fahrzeug/");
|
|
|
|
cy.get(
|
|
"[data-cy=\"test-lehrgang-lp-circle-fahrzeug-lc-überprüfen-einer-motorfahrzeug-versicherungspolice-checkbox\"]"
|
|
).should("have.class", "cy-checked");
|
|
|
|
//reopening page should get directly to last step
|
|
cy.visit(
|
|
"/course/test-lehrgang/learn/fahrzeug/überprüfen-einer-motorfahrzeug-versicherungspolice"
|
|
);
|
|
cy.url().should("include", "step=7");
|
|
|
|
// load AssignmentCompletion from DB and check
|
|
cy.loadAssignmentCompletion(
|
|
"assignment_user_id",
|
|
TEST_STUDENT1_USER_ID
|
|
).then((ac) => {
|
|
expect(ac.completion_status).to.equal("SUBMITTED");
|
|
expect(ac.evaluation_max_points).to.equal(24);
|
|
const completionString = JSON.stringify(ac.completion_data);
|
|
console.log(completionString);
|
|
expect(completionString).to.include("Hallo Teilaufgabe 2");
|
|
expect(completionString).to.include("Hallo Teilaufgabe 3");
|
|
expect(completionString).to.include("Hallo Teilaufgabe 4.1");
|
|
expect(completionString).to.include("Hallo Teilaufgabe 4.2");
|
|
expect(completionString).to.include("Hallo Teilaufgabe 4.3");
|
|
expect(completionString).to.include("Hallo Teilaufgabe 5.1");
|
|
expect(completionString).to.include("Hallo Teilaufgabe 5.2");
|
|
expect(completionString).to.include("Hallo Teilaufgabe 5.3");
|
|
expect(completionString).to.include("Hallo Teilaufgabe 6.1");
|
|
expect(completionString).to.include("Hallo Teilaufgabe 6.2");
|
|
});
|
|
});
|
|
});
|
|
|
|
describe("Praxis Assignment", () => {
|
|
it("can make complete assignment with mentor", () =>
|
|
completePraxisAssignment());
|
|
});
|
|
});
|