117 lines
3.6 KiB
JavaScript
117 lines
3.6 KiB
JavaScript
import { login } from "./helpers";
|
|
|
|
describe("notifications.cy.js", () => {
|
|
beforeEach(() => {
|
|
cy.manageCommand("cypress_reset");
|
|
cy.manageCommand("create_default_notifications");
|
|
});
|
|
|
|
it("can paginate notifications", () => {
|
|
login("admin", "test");
|
|
cy.visit("/notifications");
|
|
|
|
cy.get('[data-cy="no-notifications"]').should("not.exist");
|
|
cy.get("[data-cy^=notification-idx-]").should("have.length", 7);
|
|
// All notifications shall be marker as unread
|
|
cy.get("[data-cy^=notification-idx-]")
|
|
.first()
|
|
.within(() => {
|
|
cy.get('[data-cy="unread"]').should("exist");
|
|
});
|
|
|
|
// 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");
|
|
|
|
for (let i = 0; i < 7; i++) {
|
|
cy.get(`[data-cy=notification-idx-${i}]`).within(() => {
|
|
cy.get('[data-cy="unread"]').should("not.exist");
|
|
});
|
|
}
|
|
for (let i = 7; i < 13; i++) {
|
|
cy.get(`[data-cy=notification-idx-${i}]`)
|
|
.first()
|
|
.within(() => {
|
|
cy.get('[data-cy="unread"]').should("exist");
|
|
});
|
|
}
|
|
});
|
|
|
|
it("can click notifications", () => {
|
|
login("admin", "test");
|
|
cy.visit("/notifications");
|
|
|
|
cy.get('[data-cy="no-notifications"]').should("not.exist");
|
|
cy.get("[data-cy=notification-target-idx-0]").click();
|
|
cy.location().should((loc) => {
|
|
expect(loc.pathname).to.eq("/");
|
|
});
|
|
});
|
|
});
|
|
|
|
describe("notification popover", () => {
|
|
beforeEach(() => {
|
|
cy.manageCommand("cypress_reset");
|
|
cy.manageCommand("create_default_notifications");
|
|
});
|
|
|
|
function toggleNotificationPopover() {
|
|
cy.get('[data-cy="notification-bell-button"]')
|
|
.filter(":visible")
|
|
.click({ force: true });
|
|
}
|
|
|
|
it("displays four notifications", () => {
|
|
login("admin", "test");
|
|
cy.visit("/");
|
|
cy.wait(1000);
|
|
|
|
toggleNotificationPopover();
|
|
cy.get("[data-cy^=notification-idx-]").should("have.length", 4);
|
|
});
|
|
|
|
it("can show all notifications", () => {
|
|
login("admin", "test");
|
|
cy.visit("/");
|
|
cy.wait(1000);
|
|
|
|
toggleNotificationPopover();
|
|
cy.get('[data-cy="show-all-notifications"]').click({ force: true });
|
|
cy.location().should((loc) => {
|
|
expect(loc.pathname).to.eq("/notifications");
|
|
});
|
|
});
|
|
});
|
|
|
|
describe("email notification settings", () => {
|
|
beforeEach(() => {
|
|
cy.manageCommand("cypress_reset");
|
|
cy.manageCommand("create_default_notifications");
|
|
});
|
|
|
|
it("can update 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 });
|
|
|
|
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"]').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");
|
|
});
|
|
});
|