Fix cypress tests

This commit is contained in:
Daniel Egger 2022-12-14 21:39:06 +01:00
parent 134d1f05d6
commit 15b5223dc5
10 changed files with 61 additions and 29 deletions

View File

@ -208,7 +208,7 @@ const profileDropdownData: DropdownListItem[] = [
Shop Shop
</a> </a>
<router-link <router-link
to="/media/versicherungsvermittlerin-media" to="/media/versicherungsvermittler-in-media"
class="nav-item" class="nav-item"
:class="{ 'nav-item--active': inMediaLibrary() }" :class="{ 'nav-item--active': inMediaLibrary() }"
data-cy="medialibrary-link" data-cy="medialibrary-link"

View File

@ -77,7 +77,7 @@ const clickLink = (to: string | undefined) => {
</a> </a>
</li> </li>
<li class="mt-6"> <li class="mt-6">
<button @click="clickLink(`/media/versicherungsvermittlerin-media`)"> <button @click="clickLink(`/media/versicherungsvermittler-in-media`)">
{{ $t("mediaLibrary.title") }} {{ $t("mediaLibrary.title") }}
</button> </button>
</li> </li>

View File

@ -5,7 +5,7 @@ describe("circle page", () => {
cy.manageCommand("cypress_reset"); cy.manageCommand("cypress_reset");
login("admin", "test"); login("admin", "test");
cy.visit("/learn/test-lehrgang-lp/analyse"); cy.visit("/course/test-lehrgang/learn/analyse");
}); });
it("can open circle page", () => { it("can open circle page", () => {
@ -92,7 +92,7 @@ describe("circle page", () => {
}); });
it("can open learning content by url", () => { it("can open learning content by url", () => {
cy.visit("/learn/test-lehrgang-lp/analyse/reiseversicherung"); cy.visit("/course/test-lehrgang/learn/analyse/reiseversicherung");
cy.get('[data-cy="ln-title"]').should("contain", "Reiseversicherung"); cy.get('[data-cy="ln-title"]').should("contain", "Reiseversicherung");
cy.get('[data-cy="close-learning-content"]').click(); cy.get('[data-cy="close-learning-content"]').click();

View File

@ -5,28 +5,50 @@ describe("Competence", () => {
cy.manageCommand("cypress_reset"); cy.manageCommand("cypress_reset");
login("admin", "test"); login("admin", "test");
cy.visit("/learn/test-lehrgang-lp/analyse"); cy.visit("/course/versicherungsvermittler-in/learn/analyse");
}); });
it("self evaluation should be neutral", () => { it("self evaluation should be neutral", () => {
cy.get('[data-cy="test-lehrgang-lp-circle-analyse-lu-fahrzeug"]').find('[data-cy="unknown"]').should('exist'); cy.get(
'[data-cy="versicherungsvermittler-in-lp-circle-analyse-lu-fahrzeug"]'
)
.find('[data-cy="unknown"]')
.should("exist");
}); });
it("should be able to make a happy self evaluation", () => { it("should be able to make a happy self evaluation", () => {
cy.get('[data-cy="test-lehrgang-lp-circle-analyse-lu-fahrzeug"]').click(); cy.get(
cy.makeSelfEvaluation([true, true]) '[data-cy="versicherungsvermittler-in-lp-circle-analyse-lu-fahrzeug"]'
cy.get('[data-cy="test-lehrgang-lp-circle-analyse-lu-fahrzeug"]').find('[data-cy="success"]').should('exist'); ).click();
cy.makeSelfEvaluation([true, true, true]);
cy.get(
'[data-cy="versicherungsvermittler-in-lp-circle-analyse-lu-fahrzeug"]'
)
.find('[data-cy="success"]')
.should("exist");
}); });
it("should be able to make a fail self evaluation", () => { it("should be able to make a fail self evaluation", () => {
cy.get('[data-cy="test-lehrgang-lp-circle-analyse-lu-fahrzeug"]').click(); cy.get(
cy.makeSelfEvaluation([false, false]) '[data-cy="versicherungsvermittler-in-lp-circle-analyse-lu-fahrzeug"]'
cy.get('[data-cy="test-lehrgang-lp-circle-analyse-lu-fahrzeug"]').find('[data-cy="fail"]').should('exist'); ).click();
cy.makeSelfEvaluation([false, false, false]);
cy.get(
'[data-cy="versicherungsvermittler-in-lp-circle-analyse-lu-fahrzeug"]'
)
.find('[data-cy="fail"]')
.should("exist");
}); });
it("should be able to make a mixed self evaluation", () => { it("should be able to make a mixed self evaluation", () => {
cy.get('[data-cy="test-lehrgang-lp-circle-analyse-lu-fahrzeug"]').click(); cy.get(
cy.makeSelfEvaluation([false, true]) '[data-cy="versicherungsvermittler-in-lp-circle-analyse-lu-fahrzeug"]'
cy.get('[data-cy="test-lehrgang-lp-circle-analyse-lu-fahrzeug"]').find('[data-cy="fail"]').should('exist'); ).click();
cy.makeSelfEvaluation([false, true, true]);
cy.get(
'[data-cy="versicherungsvermittler-in-lp-circle-analyse-lu-fahrzeug"]'
)
.find('[data-cy="fail"]')
.should("exist");
}); });
}); });

View File

@ -7,7 +7,7 @@ describe("learningPath page", () => {
it("can open learningPath page", () => { it("can open learningPath page", () => {
login("admin", "test"); login("admin", "test");
cy.visit("/learn/versicherungsvermittler-in-lp"); cy.visit("/course/versicherungsvermittler-in/learn");
cy.get('[data-cy="learning-path-title"]').should( cy.get('[data-cy="learning-path-title"]').should(
"contain", "contain",
@ -15,32 +15,38 @@ describe("learningPath page", () => {
); );
}); });
it("click on circle on learningPath page will open circle", () => { it("/course/versicherungsvermittler-in/learn", () => {
login("admin", "test"); login("admin", "test");
cy.visit("/learn/test-lehrgang-lp"); cy.visit("/course/versicherungsvermittler-in/learn");
cy.get('[data-cy="circle-analyse"]').click({ force: true }); cy.get('[data-cy="circle-analyse"]').click({ force: true });
cy.url().should("include", "/learn/test-lehrgang-lp/analyse"); cy.url().should(
"include",
"/course/versicherungsvermittler-in/learn/analyse"
);
cy.get('[data-cy="circle-title"]').should("contain", "Analyse"); cy.get('[data-cy="circle-title"]').should("contain", "Analyse");
}); });
it("open listView and click on circle will open circle", () => { it("open listView and click on circle will open circle", () => {
login("admin", "test"); login("admin", "test");
cy.visit("/learn/test-lehrgang-lp"); cy.visit("/course/versicherungsvermittler-in/learn");
cy.get('[data-cy="show-list-view"]').click(); cy.get('[data-cy="show-list-view"]').click();
cy.get('[data-cy="full-screen-modal"]').should("be.visible"); cy.get('[data-cy="full-screen-modal"]').should("be.visible");
cy.get('[data-cy="circle-analyse-vertical"]').click({ force: true }); cy.get('[data-cy="circle-analyse-vertical"]').click({ force: true });
cy.url().should("include", "/learn/test-lehrgang-lp/analyse"); cy.url().should(
"include",
"/course/versicherungsvermittler-in/learn/analyse"
);
cy.get('[data-cy="circle-title"]').should("contain", "Analyse"); cy.get('[data-cy="circle-title"]').should("contain", "Analyse");
}); });
it("weiter gehts button will open next circle", () => { it("weiter gehts button will open next circle", () => {
login("admin", "test"); login("admin", "test");
cy.visit("/learn/test-lehrgang-lp"); cy.visit("/course/versicherungsvermittler-in/learn");
// first click will open first circle // first click will open first circle
cy.get('[data-cy="lp-continue-button"]').should("contain", "Los geht's"); cy.get('[data-cy="lp-continue-button"]').should("contain", "Los geht's");
@ -51,7 +57,7 @@ describe("learningPath page", () => {
// mark a learning content in second circle // mark a learning content in second circle
cy.get('[data-cy="circle-analyse"]').click({ force: true }); cy.get('[data-cy="circle-analyse"]').click({ force: true });
cy.get( cy.get(
'[data-cy="test-lehrgang-lp-circle-analyse-lc-fachcheck-fahrzeug-checkbox"] > .cy-checkbox' '[data-cy="versicherungsvermittler-in-lp-circle-analyse-lc-fachcheck-fahrzeug-checkbox"] > .cy-checkbox'
).click(); ).click();
cy.get('[data-cy="back-to-learning-path-button"]').click(); cy.get('[data-cy="back-to-learning-path-button"]').click();

View File

@ -1,6 +1,11 @@
import { login } from "./helpers"; import { login } from "./helpers";
describe("login", () => { describe("login", () => {
Cypress.on("uncaught:exception", (err, runnable) => {
// do not fail on failed requests during tests
return false;
});
beforeEach(() => { beforeEach(() => {
cy.manageCommand("cypress_reset"); cy.manageCommand("cypress_reset");
}); });
@ -31,7 +36,7 @@ describe("login", () => {
}); });
it("login will redirect to requestet page", () => { it("login will redirect to requestet page", () => {
cy.visit("/learn/versicherungsvermittler-in-lp"); cy.visit("/course/versicherungsvermittler-in/learn");
cy.get("h1").should("contain", "Login"); cy.get("h1").should("contain", "Login");
cy.get("#username").type("admin"); cy.get("#username").type("admin");

View File

@ -5,13 +5,13 @@ describe("MediaLibrary", () => {
cy.manageCommand("cypress_reset"); cy.manageCommand("cypress_reset");
login("admin", "test"); login("admin", "test");
cy.visit("/learn/test-lehrgang-lp/analyse"); cy.visit("/");
}); });
it("should be accessible", () => { it("should be accessible", () => {
cy.get('[data-cy="medialibrary-link"]').click(); cy.get('[data-cy="medialibrary-link"]').click();
cy.get('[data-cy="Handlungsfelder-link"]').click(); cy.get('[data-cy="Handlungsfelder-link"]').click();
cy.get('[data-cy="Fahrzeug-link"]').click(); cy.get('[data-cy="Fahrzeug-link"]').click();
cy.get('[data-cy="hf-title"]').should('contain', 'Fahrzeug') cy.get('[data-cy="hf-title"]').should("contain", "Fahrzeug");
}); });
}); });

View File

@ -6,5 +6,4 @@ from vbv_lernwelt.course.models import CourseCompletion
@click.command() @click.command()
def command(): def command():
print("cypress reset data") print("cypress reset data")
CourseCompletion.objects.all().delete() CourseCompletion.objects.all().delete()

View File

@ -811,7 +811,7 @@ def create_standard_learning_unit(
( (
"media_library", "media_library",
MediaLibraryBlockFactory( MediaLibraryBlockFactory(
url=f"/media/versicherungsvermittlerin-media/category/{slugify(category_name)}" url=f"/media/versicherungsvermittler-in-media/category/{slugify(category_name)}"
), ),
) )
], ],

View File

@ -103,7 +103,7 @@ class RelativeLinkBlockFactory(wagtail_factories.StructBlockFactory):
description = "Platzhalter Querverweis" description = "Platzhalter Querverweis"
link_display_text = "Handlungsfeld anzeigen" link_display_text = "Handlungsfeld anzeigen"
icon_url = "/static/icons/demo/icon-hf-reisen.svg" icon_url = "/static/icons/demo/icon-hf-reisen.svg"
url = "/media/versicherungsvermittlerin-media/category/fahrzeug" url = "/media/versicherungsvermittler-in-media/category/fahrzeug"
# TODO: page = blocks.PageChooserBlock zu Handlungsfeld # TODO: page = blocks.PageChooserBlock zu Handlungsfeld