From cf77f1b13f8b5e86d251d0dea1092e0d2c18b476 Mon Sep 17 00:00:00 2001 From: Mathis Hofer Date: Thu, 12 Dec 2024 16:04:06 +0100 Subject: [PATCH] Make footer content accessible without auth under /unrestricted #190 --- README.md | 1 + cypress/e2e/footer.cy.ts | 190 ++++++++++++------ doc/unrestricted-content.md | 17 ++ src/components/Content.ts | 3 + src/components/Header.ts | 7 +- src/components/Header/NavItemLink.ts | 32 --- src/components/Portal.ts | 5 +- .../{Header => header}/Hamburger.ts | 0 .../{Header => header}/LanguageSwitcher.ts | 0 .../{Header => header}/MobileNav.ts | 10 +- src/components/{Header => header}/Nav.ts | 1 + .../{Header => header}/NavGroupDropdown.ts | 0 .../{Header => header}/NavGroupToggle.ts | 1 + .../NotificationsDropdown.ts | 8 +- .../{Header => header}/NotificationsToggle.ts | 13 +- .../{Header => header}/ServiceNav.ts | 7 +- .../SubstitutionsDropdown.ts | 0 .../{Header => header}/SubstitutionsToggle.ts | 9 +- .../{Header => header}/UserSettings.ts | 0 src/components/index.ts | 20 -- .../unrestricted/ContentUnrestricted.ts | 104 ++++++++++ .../unrestricted/HeaderUnrestricted.ts | 100 +++++++++ .../unrestricted/PortalUnrestricted.ts | 68 +++++++ .../content}/Contact.ts | 2 +- .../content}/Imprint.ts | 6 +- .../{Footer => unrestricted/content}/Legal.ts | 4 +- src/index.ts | 2 +- src/unrestricted.ts | 1 + src/utils/routing.ts | 2 +- unrestricted/index.html | 30 +++ vite.config.ts | 9 + 31 files changed, 508 insertions(+), 144 deletions(-) create mode 100644 doc/unrestricted-content.md delete mode 100644 src/components/Header/NavItemLink.ts rename src/components/{Header => header}/Hamburger.ts (100%) rename src/components/{Header => header}/LanguageSwitcher.ts (100%) rename src/components/{Header => header}/MobileNav.ts (97%) rename src/components/{Header => header}/Nav.ts (98%) rename src/components/{Header => header}/NavGroupDropdown.ts (100%) rename src/components/{Header => header}/NavGroupToggle.ts (98%) rename src/components/{Header => header}/NotificationsDropdown.ts (96%) rename src/components/{Header => header}/NotificationsToggle.ts (92%) rename src/components/{Header => header}/ServiceNav.ts (90%) rename src/components/{Header => header}/SubstitutionsDropdown.ts (100%) rename src/components/{Header => header}/SubstitutionsToggle.ts (96%) rename src/components/{Header => header}/UserSettings.ts (100%) delete mode 100644 src/components/index.ts create mode 100644 src/components/unrestricted/ContentUnrestricted.ts create mode 100644 src/components/unrestricted/HeaderUnrestricted.ts create mode 100644 src/components/unrestricted/PortalUnrestricted.ts rename src/components/{Footer => unrestricted/content}/Contact.ts (92%) rename src/components/{Footer => unrestricted/content}/Imprint.ts (88%) rename src/components/{Footer => unrestricted/content}/Legal.ts (98%) create mode 100644 src/unrestricted.ts create mode 100644 unrestricted/index.html diff --git a/README.md b/README.md index 5e89d4f5..5edd6b54 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,7 @@ Download the [latest build](https://bkd-mba-fbi.github.io/evento-portal/evento-p - [Browser Testing](./doc/browser-testing.md) – Support & BrowserStack.com - [Progressive Web App (PWA)](./doc/pwa.md) – Installability & offline support - [iframe Limitations & Workarounds](./doc/iframe.md) – Implementation details (iframe.js) +- [Unrestricted Content Pages](./doc/unrestricted-content.md) – Footer content ### Operations diff --git a/cypress/e2e/footer.cy.ts b/cypress/e2e/footer.cy.ts index ad7c215e..f32fcf98 100644 --- a/cypress/e2e/footer.cy.ts +++ b/cypress/e2e/footer.cy.ts @@ -3,88 +3,158 @@ describe("Footer", () => { cy.resizeToDesktop(); }); - describe("de", () => { - beforeEach(() => { - cy.login({ locale: "de-CH", roles: ["TeacherRole"], permissions: [] }); - }); + describe("authenticated", () => { + describe("de", () => { + beforeEach(() => { + cy.login({ locale: "de-CH", roles: ["TeacherRole"], permissions: [] }); + }); - it("renders the footer with links to contact, legal and imprint pages", () => { - cy.visitPortal("/index.html"); + it("renders the footer with links to contact, legal and imprint pages", () => { + cy.visitPortal("/"); - cy.get("bkd-footer").within(() => { - cy.get("a").contains("Kontakt"); - cy.get("a").contains("Rechtliche Hinweise"); - cy.get("a").contains("Impressum"); + cy.get("bkd-footer").within(() => { + cy.get("a").contains("Kontakt"); + cy.get("a").contains("Rechtliche Hinweise"); + cy.get("a").contains("Impressum"); + }); }); - }); - it("renders the static contact page", () => { - cy.visitPortal("/index.html"); - cy.get("bkd-footer").find("a").contains("Kontakt").click(); + it("renders the static contact page", () => { + cy.visitPortal("/"); + cy.get("bkd-footer").find("a").contains("Kontakt").click(); - cy.get("h1").contains("Kontakt", {}); - cy.contains("an die zuständige Stelle in ihrer Schule"); - cy.get("iframe").should("not.exist"); - }); + cy.get("h1").contains("Kontakt", {}); + cy.contains("an die zuständige Stelle in ihrer Schule"); + cy.get("iframe").should("not.exist"); + }); - it("renders the static legal page", () => { - cy.visitPortal("/index.html"); - cy.get("bkd-footer").find("a").contains("Rechtliche Hinweise").click(); + it("renders the static legal page", () => { + cy.visitPortal("/"); + cy.get("bkd-footer").find("a").contains("Rechtliche Hinweise").click(); - cy.get("h1").contains("Rechtliche Hinweise", {}); - cy.contains("Haftungsausschluss"); - cy.get("iframe").should("not.exist"); + cy.get("h1").contains("Rechtliche Hinweise", {}); + cy.contains("Haftungsausschluss"); + cy.get("iframe").should("not.exist"); + }); + + it("renders the static imprint page", () => { + cy.visitPortal("/"); + cy.get("bkd-footer").find("a").contains("Impressum").click(); + + cy.get("h1").contains("Impressum", {}); + cy.contains("Inhaltsverantwortung"); + cy.get("iframe").should("not.exist"); + }); }); - it("renders the static imprint page", () => { - cy.visitPortal("/index.html"); - cy.get("bkd-footer").find("a").contains("Impressum").click(); + describe("fr", () => { + beforeEach(() => { + cy.login({ locale: "fr-CH", roles: ["TeacherRole"], permissions: [] }); + }); + + it("renders the footer with links to contact, legal and imprint pages", () => { + cy.visitPortal("/?locale=fr-CH"); + cy.get("bkd-footer").within(() => { + cy.get("a").contains("Contact"); + cy.get("a").contains("Mentions légales"); + cy.get("a").contains("Impressum"); + }); + }); + + it("renders the static contact page", () => { + cy.visitPortal("/?locale=fr-CH"); + cy.get("bkd-footer").find("a").contains("Contact").click(); + + cy.get("h1").contains("Contact", {}); + cy.contains("contacter le service compétent de leur établissement"); + cy.get("iframe").should("not.exist"); + }); + + it("renders the static legal page", () => { + cy.visitPortal("/?locale=fr-CH"); + cy.get("bkd-footer").find("a").contains("Mentions légales").click(); + + cy.get("h1").contains("Mentions légales", {}); + cy.contains("Exclusion de la responsabilité"); + cy.get("iframe").should("not.exist"); + }); + + it("renders the static imprint page", () => { + cy.visitPortal("/?locale=fr-CH"); + cy.get("bkd-footer").find("a").contains("Impressum").click(); - cy.get("h1").contains("Impressum", {}); - cy.contains("Inhaltsverantwortung"); - cy.get("iframe").should("not.exist"); + cy.get("h1").contains("Impressum", {}); + cy.contains("Responsabilité du contenu"); + cy.get("iframe").should("not.exist"); + }); }); }); - describe("fr", () => { - beforeEach(() => { - cy.login({ locale: "fr-CH", roles: ["TeacherRole"], permissions: [] }); - }); + describe("unauthenticated via /unrestricted/", () => { + describe("de", () => { + it("renders the static contact page", () => { + cy.visit("/unrestricted/?locale=de-CH&module=contact"); - it("renders the footer with links to contact, legal and imprint pages", () => { - cy.visitPortal("/index.html?locale=fr-CH"); - cy.get("bkd-footer").within(() => { - cy.get("a").contains("Contact"); - cy.get("a").contains("Mentions légales"); - cy.get("a").contains("Impressum"); + cy.get("h1").contains("Kontakt", {}); + cy.contains("an die zuständige Stelle in ihrer Schule"); }); - }); - it("renders the static contact page", () => { - cy.visitPortal("/index.html?locale=fr-CH"); - cy.get("bkd-footer").find("a").contains("Contact").click(); + it("renders the static legal page", () => { + cy.visit("/unrestricted/?locale=de-CH&module=legal"); - cy.get("h1").contains("Contact", {}); - cy.contains("contacter le service compétent de leur établissement"); - cy.get("iframe").should("not.exist"); - }); + cy.get("h1").contains("Rechtliche Hinweise", {}); + cy.contains("Haftungsausschluss"); + }); - it("renders the static legal page", () => { - cy.visitPortal("/index.html?locale=fr-CH"); - cy.get("bkd-footer").find("a").contains("Mentions légales").click(); + it("renders the static imprint page", () => { + cy.visit("/unrestricted/?locale=de-CH&module=imprint"); + + cy.get("h1").contains("Impressum", {}); + cy.contains("Inhaltsverantwortung"); + }); + + it("navigates to legal page via footer", () => { + cy.visit("/unrestricted/?locale=de-CH&module=contact"); + cy.get("h1").contains("Kontakt", {}); + + cy.get("bkd-footer").find("a").contains("Rechtliche Hinweise").click(); + cy.get("h1").contains("Rechtliche Hinweise", {}); + }); - cy.get("h1").contains("Mentions légales", {}); - cy.contains("Exclusion de la responsabilité"); - cy.get("iframe").should("not.exist"); + it("switches language", () => { + cy.visit("/unrestricted/?locale=de-CH&module=contact"); + cy.get("h1").contains("Kontakt", {}); + + cy.get("bkd-language-switcher").find("a").contains("fr").click(); + cy.get("h1").contains("Contact", {}); + cy.url().should( + "include", + "/unrestricted/?locale=fr-CH&module=contact", + ); + }); }); - it("renders the static imprint page", () => { - cy.visitPortal("/index.html?locale=fr-CH"); - cy.get("bkd-footer").find("a").contains("Impressum").click(); + describe("fr", () => { + it("renders the static contact page", () => { + cy.visit("/unrestricted/?locale=fr-CH&module=contact"); + + cy.get("h1").contains("Contact", {}); + cy.contains("contacter le service compétent de leur établissement"); + }); + + it("renders the static legal page", () => { + cy.visit("/unrestricted/?locale=fr-CH&module=legal"); - cy.get("h1").contains("Impressum", {}); - cy.contains("Responsabilité du contenu"); - cy.get("iframe").should("not.exist"); + cy.get("h1").contains("Mentions légales", {}); + cy.contains("Exclusion de la responsabilité"); + }); + + it("renders the static imprint page", () => { + cy.visit("/unrestricted/?locale=fr-CH&module=imprint"); + + cy.get("h1").contains("Impressum", {}); + cy.contains("Responsabilité du contenu"); + }); }); }); }); diff --git a/doc/unrestricted-content.md b/doc/unrestricted-content.md new file mode 100644 index 00000000..27f74673 --- /dev/null +++ b/doc/unrestricted-content.md @@ -0,0 +1,17 @@ +[back](../README.md) + +# Unrestricted Content Pages + +The pages linked in the footer (contact, legal & imprint) are rendered by the _Evento Portal_, not within the `