Add cypress tests for circle page

This commit is contained in:
Daniel Egger 2022-08-29 16:22:31 +02:00
parent 3189e1cb7f
commit 919edf1a24
8 changed files with 66 additions and 13 deletions

View File

@ -30,6 +30,7 @@ const block = computed(() => {
<button
type="button"
class="btn-text inline-flex items-center px-3 py-2 font-normal"
data-cy="close-learnng-content"
@click="circleStore.closeLearningContent()"
>
<it-icon-arrow-left class="-ml-1 mr-1 h-5 w-5"></it-icon-arrow-left>
@ -41,6 +42,7 @@ const block = computed(() => {
<button
type="button"
class="btn-blue"
data-cy="complete-and-continue"
@click="circleStore.continueFromLearningContent()"
>
Abschliessen und weiter

View File

@ -68,6 +68,7 @@ const allFinished = computed(() => {
<ItCheckbox
:modelValue="learningContent.completed"
@click="toggleCompleted(learningContent)"
:data-cy="`lc-${learningContent.slug}`"
>
<span @click.stop="circleStore.openLearningContent(learningContent)">{{ learningContent.contents[0].type }}: {{ learningContent.title }}</span>
</ItCheckbox>

View File

@ -1,10 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>$Title$</title>
</head>
<body>
$END$
</body>
</html>

View File

@ -30,6 +30,8 @@ defineEmits(['update:modelValue'])
bg-[url('/static/icons/icon-checkbox-checked.svg')]
hover:bg-[url('/static/icons/icon-checkbox-checked-hover.svg')]
disabled:opacity-50
cy-checkbox
cy-checkbox-checked
"
></div>
<div
@ -40,9 +42,13 @@ defineEmits(['update:modelValue'])
bg-contain
bg-[url('/static/icons/icon-checkbox-unchecked.svg')]
hover:bg-[url('/static/icons/icon-checkbox-unchecked-hover.svg')]
cy-checkbox
cy-checkbox-unchecked
"
></div>
<div class="flex-auto pl-4"><slot></slot></div>
<div class="flex-auto pl-4">
<slot></slot>
</div>
</div>
</template>

53
cypress/e2e/circle.cy.js Normal file
View File

@ -0,0 +1,53 @@
import { login } from "./helpers";
describe("circle page", () => {
beforeEach(() => {
cy.manageCommand("cypress_reset");
login("admin", "test");
cy.visit("/circle/analyse");
});
it("can open circle page", () => {
cy.get('[data-cy="circle-title"]').should("contain", "Analyse");
});
it("can toggle learning content", () => {
cy.get('[data-cy="circle-title"]').should("contain", "Analyse");
cy.get(
'[data-cy="lc-ermittlung-des-kundenbedarfs-4"] > .cy-checkbox'
).click();
cy.get(
'[data-cy="lc-ermittlung-des-kundenbedarfs-4"] > .cy-checkbox-checked'
).should("have.class", "cy-checkbox-checked");
// completion data should still be there after reload
cy.reload();
cy.get(
'[data-cy="lc-ermittlung-des-kundenbedarfs-4"] > .cy-checkbox-checked'
).should("have.class", "cy-checkbox-checked");
});
it("can open learning contents and complete them by continuing", () => {
cy.get('[data-cy="lc-ermittlung-des-kundenbedarfs-4"]').click();
cy.get('[data-cy="complete-and-continue"]').click();
cy.get('[data-cy="complete-and-continue"]').click();
cy.get('[data-cy="complete-and-continue"]').click();
cy.get('[data-cy="close-learnng-content"]').click();
cy.get(
'[data-cy="lc-ermittlung-des-kundenbedarfs-4"] > .cy-checkbox-checked'
).should("have.class", "cy-checkbox-checked");
cy.get('[data-cy="lc-kundenanalyse"] > .cy-checkbox-checked').should(
"have.class",
"cy-checkbox-checked"
);
cy.get(
'[data-cy="lc-kundenbedürfnisse-erkennen-2"] > .cy-checkbox-checked'
).should("have.class", "cy-checkbox-checked");
});
});

View File

@ -1,6 +1,6 @@
import { login } from "./helpers";
describe("learningPath", () => {
describe("learningPath page", () => {
beforeEach(() => {
cy.manageCommand("cypress_reset");
});

View File

@ -1,5 +1,6 @@
import djclick as click
from vbv_lernwelt.completion.models import CircleCompletion
from vbv_lernwelt.learnpath.create_default_learning_path import create_default_learning_path, \
delete_default_learning_path
@ -13,4 +14,4 @@ def command(reset_learning_path):
delete_default_learning_path()
create_default_learning_path(skip_locales=True)
CircleCompletion.objects.all().delete()