From fbde06f0ef14f0ecc984bd84f46b91b1fa657113 Mon Sep 17 00:00:00 2001 From: Elia Bieri Date: Thu, 8 Jun 2023 13:38:09 +0200 Subject: [PATCH 1/5] Fix notification settings cypress test --- cypress/e2e/notifications.cy.js | 47 ++++++++++++++----- .../core/management/commands/cypress_reset.py | 1 + 2 files changed, 37 insertions(+), 11 deletions(-) diff --git a/cypress/e2e/notifications.cy.js b/cypress/e2e/notifications.cy.js index 5b286520..75ff5fd8 100644 --- a/cypress/e2e/notifications.cy.js +++ b/cypress/e2e/notifications.cy.js @@ -94,23 +94,48 @@ describe("email notification settings", () => { login("admin", "test"); cy.visit("/settings"); cy.wait(1000); - cy.get('[data-cy="it-checkbox-USER_INTERACTION"]').should("not.be.checked"); - cy.get('[data-cy="it-checkbox-INFORMATION"]').should("not.be.checked"); - cy.get('[data-cy="it-checkbox-PROGRESS"]').should("not.be.checked"); - cy.get('[data-cy="it-checkbox-USER_INTERACTION"]').click({ force: true }); + // Checking prerequisites + cy.get('[data-cy="it-checkbox-USER_INTERACTION"]') + .should("exist") + .should("not.be.checked"); + cy.get('[data-cy="it-checkbox-INFORMATION"]') + .should("exist") + .should("not.be.checked"); + cy.get('[data-cy="it-checkbox-PROGRESS"]') + .should("exist") + .should("not.be.checked"); + + cy.get('[data-cy="it-checkbox-USER_INTERACTION"]') + .should("exist") + .check({ force: true }); cy.reload(); cy.wait(1000); - cy.get('[data-cy="it-checkbox-USER_INTERACTION"]').should("be.checked"); - cy.get('[data-cy="it-checkbox-INFORMATION"]').should("not.be.checked"); - cy.get('[data-cy="it-checkbox-PROGRESS"]').should("not.be.checked"); + cy.get('[data-cy="it-checkbox-USER_INTERACTION"]') + .should("exist") + .should("be.checked"); + cy.get('[data-cy="it-checkbox-INFORMATION"]') + .should("exist") + .should("not.be.checked"); + cy.get('[data-cy="it-checkbox-PROGRESS"]') + .should("exist") + .should("not.be.checked"); + + cy.get('[data-cy="it-checkbox-USER_INTERACTION"]') + .should("exist") + .uncheck({ force: true }); - cy.get('[data-cy="it-checkbox-USER_INTERACTION"]').click({ force: true }); cy.reload(); cy.wait(1000); - cy.get('[data-cy="it-checkbox-USER_INTERACTION"]').should("not.be.checked"); - cy.get('[data-cy="it-checkbox-INFORMATION"]').should("not.be.checked"); - cy.get('[data-cy="it-checkbox-PROGRESS"]').should("not.be.checked"); + cy.get('[data-cy="it-checkbox-USER_INTERACTION"]') + .should("exist") + .should("not.be.checked"); + cy.get('[data-cy="it-checkbox-INFORMATION"]') + .should("exist") + .should("not.be.checked"); + cy.get('[data-cy="it-checkbox-PROGRESS"]') + .should("exist") + .should("not.be.checked"); }); }); diff --git a/server/vbv_lernwelt/core/management/commands/cypress_reset.py b/server/vbv_lernwelt/core/management/commands/cypress_reset.py index 59cf44c6..9d1ad15d 100644 --- a/server/vbv_lernwelt/core/management/commands/cypress_reset.py +++ b/server/vbv_lernwelt/core/management/commands/cypress_reset.py @@ -25,6 +25,7 @@ def command(create_completion): Notification.objects.all().delete() AssignmentCompletion.objects.all().delete() User.objects.all().update(language="de") + User.objects.all().update(additional_json_data={}) if create_completion: print("create completion data for test course") From 8a7453ce0ef426a11eab0cd5d8592e56b5b82572 Mon Sep 17 00:00:00 2001 From: Elia Bieri Date: Thu, 8 Jun 2023 14:18:21 +0200 Subject: [PATCH 2/5] Soft delete notifications --- server/vbv_lernwelt/core/management/commands/cypress_reset.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/vbv_lernwelt/core/management/commands/cypress_reset.py b/server/vbv_lernwelt/core/management/commands/cypress_reset.py index 9d1ad15d..1c6507ad 100644 --- a/server/vbv_lernwelt/core/management/commands/cypress_reset.py +++ b/server/vbv_lernwelt/core/management/commands/cypress_reset.py @@ -22,7 +22,7 @@ from vbv_lernwelt.notify.models import Notification def command(create_completion): print("cypress reset data") CourseCompletion.objects.all().delete() - Notification.objects.all().delete() + Notification.objects.all().mark_all_as_deleted() AssignmentCompletion.objects.all().delete() User.objects.all().update(language="de") User.objects.all().update(additional_json_data={}) From 3f7b27c2666933996b9873ed7742ffb8b7d7e4fa Mon Sep 17 00:00:00 2001 From: Elia Bieri Date: Tue, 20 Jun 2023 15:13:53 +0200 Subject: [PATCH 3/5] Additional fixes --- cypress/e2e/notifications.cy.js | 9 ++++++--- cypress/support/commands.js | 18 ++++++++++-------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/cypress/e2e/notifications.cy.js b/cypress/e2e/notifications.cy.js index 75ff5fd8..8fd20b52 100644 --- a/cypress/e2e/notifications.cy.js +++ b/cypress/e2e/notifications.cy.js @@ -1,6 +1,6 @@ import { login } from "./helpers"; -describe("notifications.cy.js", () => { +describe("notification list page", () => { beforeEach(() => { cy.manageCommand("cypress_reset"); cy.manageCommand("create_default_notifications"); @@ -9,6 +9,7 @@ describe("notifications.cy.js", () => { it("can paginate notifications", () => { login("admin", "test"); cy.visit("/notifications"); + cy.wait(2000); cy.get('[data-cy="no-notifications"]').should("not.exist"); cy.get("[data-cy^=notification-idx-]").should("have.length", 7); @@ -21,8 +22,7 @@ describe("notifications.cy.js", () => { // We load additional 7 notifications cy.get('[data-cy="load-more-notifications"]').click(); - cy.get("[data-cy^=notification-idx-]").should("have.length", 13); - cy.get('[data-cy="load-more-notifications"]').should("not.exist"); + cy.get("[data-cy^=notification-idx-]").should("have.length", 14); for (let i = 0; i < 7; i++) { cy.get(`[data-cy=notification-idx-${i}]`).within(() => { @@ -109,6 +109,9 @@ describe("email notification settings", () => { cy.get('[data-cy="it-checkbox-USER_INTERACTION"]') .should("exist") .check({ force: true }); + cy.get('[data-cy="it-checkbox-USER_INTERACTION"]') + .should("exist") + .should("be.checked"); cy.reload(); cy.wait(1000); diff --git a/cypress/support/commands.js b/cypress/support/commands.js index d884523d..8c7c5821 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -55,15 +55,17 @@ const _ = Cypress._; Cypress.Commands.add("manageCommand", (command, preCommand = "") => { const execCommand = `${preCommand} python server/manage.py ${command} --settings=config.settings.test_cypress`; console.log(execCommand); + // hack to add my asdf python instance to the path + // so I can run the test directly from within IntelliJ + let pythonPaths = [ + "/Users/daniel/workspace/vbv_lernwelt/.direnv/python-3.10.6/bin", + "/Users/eliabieri/iterativ/vbv_lernwelt/.direnv/python-3.10.6/bin", + ]; + let bashCommand = `PATH=${pythonPaths.join(":")}:$PATH && ${execCommand}`; return cy - .exec( - // hack to add my asdf python instance to the path - // so I can run the test directly from within IntelliJ - `PATH=/Users/daniel/workspace/vbv_lernwelt/.direnv/python-3.10.6/bin:$PATH && ${execCommand}`, - { - failOnNonZeroExit: false, - } - ) + .exec(`bash -c "${bashCommand}"`, { + failOnNonZeroExit: true, + }) .then((result) => { if (result.code) { throw new Error(`Execution of "${command}" failed From db939c5eea601813aecdaac73a03df0067a44d61 Mon Sep 17 00:00:00 2001 From: Elia Bieri Date: Tue, 20 Jun 2023 15:32:37 +0200 Subject: [PATCH 4/5] Extend delay --- cypress/e2e/notifications.cy.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cypress/e2e/notifications.cy.js b/cypress/e2e/notifications.cy.js index 8fd20b52..1512bf0a 100644 --- a/cypress/e2e/notifications.cy.js +++ b/cypress/e2e/notifications.cy.js @@ -114,7 +114,7 @@ describe("email notification settings", () => { .should("be.checked"); cy.reload(); - cy.wait(1000); + cy.wait(2000); cy.get('[data-cy="it-checkbox-USER_INTERACTION"]') .should("exist") .should("be.checked"); From 0336e414d56deed685a538183216c354be93fbfa Mon Sep 17 00:00:00 2001 From: Elia Bieri Date: Tue, 20 Jun 2023 15:56:44 +0200 Subject: [PATCH 5/5] Antoher trial --- cypress/e2e/notifications.cy.js | 57 ++++++++++----------------------- 1 file changed, 17 insertions(+), 40 deletions(-) diff --git a/cypress/e2e/notifications.cy.js b/cypress/e2e/notifications.cy.js index 1512bf0a..40b94d0e 100644 --- a/cypress/e2e/notifications.cy.js +++ b/cypress/e2e/notifications.cy.js @@ -96,49 +96,26 @@ describe("email notification settings", () => { cy.wait(1000); // Checking prerequisites - cy.get('[data-cy="it-checkbox-USER_INTERACTION"]') - .should("exist") - .should("not.be.checked"); - cy.get('[data-cy="it-checkbox-INFORMATION"]') - .should("exist") - .should("not.be.checked"); - cy.get('[data-cy="it-checkbox-PROGRESS"]') - .should("exist") - .should("not.be.checked"); + cy.get('[data-cy="it-checkbox-USER_INTERACTION"]').should("not.be.checked"); + cy.get('[data-cy="it-checkbox-INFORMATION"]').should("not.be.checked"); + cy.get('[data-cy="it-checkbox-PROGRESS"]').should("not.be.checked"); - cy.get('[data-cy="it-checkbox-USER_INTERACTION"]') - .should("exist") - .check({ force: true }); - cy.get('[data-cy="it-checkbox-USER_INTERACTION"]') - .should("exist") - .should("be.checked"); - - cy.reload(); - cy.wait(2000); - cy.get('[data-cy="it-checkbox-USER_INTERACTION"]') - .should("exist") - .should("be.checked"); - cy.get('[data-cy="it-checkbox-INFORMATION"]') - .should("exist") - .should("not.be.checked"); - cy.get('[data-cy="it-checkbox-PROGRESS"]') - .should("exist") - .should("not.be.checked"); - - cy.get('[data-cy="it-checkbox-USER_INTERACTION"]') - .should("exist") - .uncheck({ force: true }); + cy.get('[data-cy="it-checkbox-USER_INTERACTION"]').check({ force: true }); + cy.get('[data-cy="it-checkbox-INFORMATION"]').check({ force: true }); cy.reload(); cy.wait(1000); - cy.get('[data-cy="it-checkbox-USER_INTERACTION"]') - .should("exist") - .should("not.be.checked"); - cy.get('[data-cy="it-checkbox-INFORMATION"]') - .should("exist") - .should("not.be.checked"); - cy.get('[data-cy="it-checkbox-PROGRESS"]') - .should("exist") - .should("not.be.checked"); + cy.get('[data-cy="it-checkbox-USER_INTERACTION"]').should("be.checked"); + cy.get('[data-cy="it-checkbox-INFORMATION"]').should("be.checked"); + cy.get('[data-cy="it-checkbox-PROGRESS"]').should("not.be.checked"); + + cy.get('[data-cy="it-checkbox-USER_INTERACTION"]').uncheck({ force: true }); + cy.get('[data-cy="it-checkbox-INFORMATION"]').uncheck({ force: true }); + + cy.reload(); + cy.wait(1000); + cy.get('[data-cy="it-checkbox-USER_INTERACTION"]').should("not.be.checked"); + cy.get('[data-cy="it-checkbox-INFORMATION"]').should("not.be.checked"); + cy.get('[data-cy="it-checkbox-PROGRESS"]').should("not.be.checked"); }); });