diff --git a/jest.config.js b/jest.config.js index 973afe748c..4ab01f1387 100644 --- a/jest.config.js +++ b/jest.config.js @@ -44,7 +44,6 @@ module.exports = { "!/src/pages/NewsCreate.page.vue", "!/src/pages/NewsEdit.page.vue", "!/src/pages/ProxyError.page.vue", - "!/src/pages/TermsOfUse.vue", ], // maxWorkers: 2, // limited for not taking all workers within of a single github action diff --git a/src/components/administration/AdminMigrationSection.unit.ts b/src/components/administration/AdminMigrationSection.unit.ts index 26a7a6b373..85ef7a01c4 100644 --- a/src/components/administration/AdminMigrationSection.unit.ts +++ b/src/components/administration/AdminMigrationSection.unit.ts @@ -1,7 +1,11 @@ import AdminMigrationSection from "@/components/administration/AdminMigrationSection.vue"; import EnvConfigModule from "@/store/env-config"; import SchoolsModule from "@/store/schools"; -import { ENV_CONFIG_MODULE_KEY, I18N_KEY } from "@/utils/inject"; +import { + ENV_CONFIG_MODULE_KEY, + I18N_KEY, + SCHOOLS_MODULE_KEY, +} from "@/utils/inject"; import { createModuleMocks } from "@/utils/mock-store-module"; import createComponentMocks from "@@/tests/test-utils/componentMocks"; import { Wrapper, mount, shallowMount } from "@vue/test-utils"; @@ -39,7 +43,7 @@ describe("AdminMigrationSection", () => { }), provide: { [I18N_KEY.valueOf()]: i18nMock, - schoolsModule, + [SCHOOLS_MODULE_KEY.valueOf()]: schoolsModule, [ENV_CONFIG_MODULE_KEY.valueOf()]: envConfigModule, }, }); diff --git a/src/components/administration/AdminMigrationSection.vue b/src/components/administration/AdminMigrationSection.vue index 9478b5bc5b..5c1ff94502 100644 --- a/src/components/administration/AdminMigrationSection.vue +++ b/src/components/administration/AdminMigrationSection.vue @@ -169,23 +169,25 @@ - - diff --git a/src/components/organisms/administration/SchoolPolicy.unit.ts b/src/components/organisms/administration/SchoolPolicy.unit.ts index 8092b5f528..077dbf2309 100644 --- a/src/components/organisms/administration/SchoolPolicy.unit.ts +++ b/src/components/organisms/administration/SchoolPolicy.unit.ts @@ -7,8 +7,14 @@ import { shallowMount, Wrapper } from "@vue/test-utils"; import createComponentMocks from "@@/tests/test-utils/componentMocks"; import { mockSchool } from "@@/tests/test-utils/mockObjects"; import { ConsentVersion } from "@/store/types/consent-version"; -import { I18N_KEY } from "@/utils/inject"; +import { + AUTH_MODULE_KEY, + I18N_KEY, + PRIVACY_POLICY_MODULE_KEY, + SCHOOLS_MODULE_KEY, +} from "@/utils/inject"; import Vue from "vue"; +import { i18nMock } from "@@/tests/test-utils"; describe("SchoolPolicy", () => { let authModule: jest.Mocked; @@ -67,10 +73,10 @@ describe("SchoolPolicy", () => { i18n: true, }), provide: { - [I18N_KEY as symbol]: { t: (key: string) => key }, - authModule, - schoolsModule, - privacyPolicyModule, + [I18N_KEY.valueOf()]: i18nMock, + [PRIVACY_POLICY_MODULE_KEY.valueOf()]: privacyPolicyModule, + [AUTH_MODULE_KEY.valueOf()]: authModule, + [SCHOOLS_MODULE_KEY.valueOf()]: schoolsModule, }, }); diff --git a/src/components/organisms/administration/SchoolPolicy.vue b/src/components/organisms/administration/SchoolPolicy.vue index 42094d07a0..d54e0c35e7 100644 --- a/src/components/organisms/administration/SchoolPolicy.vue +++ b/src/components/organisms/administration/SchoolPolicy.vue @@ -23,7 +23,7 @@ /> - {{ pdfIcon }} + $file_pdf_outline @@ -34,7 +34,7 @@ {{ t("pages.administration.school.index.schoolPolicy.uploadedOn", { date: dayjs(privacyPolicy.publishedAt).format( - "DD.MM.YYYY HH:mm" + t("format.dateTime") ), }) }} @@ -60,9 +60,7 @@ t('pages.administration.school.index.schoolPolicy.edit') " > - - {{ mdiPencilOutline }} - + $mdiPencilOutline - - {{ mdiTrayArrowDown }} - + $mdiTrayArrowDown @@ -96,24 +92,17 @@ diff --git a/src/components/organisms/administration/SchoolTermsFormDialog.unit.ts b/src/components/organisms/administration/SchoolTermsFormDialog.unit.ts new file mode 100644 index 0000000000..28abfd76df --- /dev/null +++ b/src/components/organisms/administration/SchoolTermsFormDialog.unit.ts @@ -0,0 +1,95 @@ +import TermsOfUseModule from "@/store/terms-of-use"; +import { createModuleMocks } from "@/utils/mock-store-module"; +import SchoolsModule from "@/store/schools"; +import { mockSchool } from "@@/tests/test-utils/mockObjects"; +import { mount, MountOptions, Wrapper } from "@vue/test-utils"; +import createComponentMocks from "@@/tests/test-utils/componentMocks"; +import NotifierModule from "@/store/notifier"; +import SchoolTermsFormDialog from "./SchoolTermsFormDialog.vue"; +import Vue from "vue"; +import { + I18N_KEY, + NOTIFIER_MODULE_KEY, + SCHOOLS_MODULE_KEY, + TERMS_OF_USE_MODULE_KEY, +} from "@/utils/inject"; +import { i18nMock } from "@@/tests/test-utils"; + +describe("SchoolPolicyFormDialog", () => { + let notifierModule: jest.Mocked; + let schoolsModule: jest.Mocked; + let termsOfUseModule: jest.Mocked; + + const mockProps = { + isOpen: true, + }; + + const setup = ( + getters: Partial = { + getTermsOfUse: null, + getBusinessError: { + statusCode: "", + message: "", + }, + getStatus: "completed", + } + ) => { + const el = document.createElement("div"); + el.setAttribute("data-app", "true"); + document.body.appendChild(el); + + schoolsModule = createModuleMocks(SchoolsModule, { + getSchool: mockSchool, + }); + + termsOfUseModule = createModuleMocks(TermsOfUseModule, { + ...getters, + }); + + notifierModule = createModuleMocks(NotifierModule); + + const wrapper: Wrapper = mount( + SchoolTermsFormDialog as MountOptions, + { + ...createComponentMocks({ + i18n: true, + }), + provide: { + [I18N_KEY.valueOf()]: i18nMock, + [NOTIFIER_MODULE_KEY.valueOf()]: notifierModule, + [TERMS_OF_USE_MODULE_KEY.valueOf()]: termsOfUseModule, + [SCHOOLS_MODULE_KEY.valueOf()]: schoolsModule, + }, + propsData: mockProps, + } + ); + + return wrapper; + }; + + describe("when form is not valid", () => { + it("should disable submit button", () => { + const wrapper = setup(); + + expect( + wrapper.find('[data-testid="submit-button"]').attributes().disabled + ).toBeDefined(); + }); + + it("should render warning icon", async () => { + const wrapper = setup(); + (wrapper.vm as any).isTouched = true; + await Vue.nextTick(); + expect(wrapper.find('[data-testid="warning-icon"]').exists()).toBe(true); + }); + }); + + describe("when cancel button is clicked", () => { + it("should emit 'close'", () => { + const wrapper = setup(); + + wrapper.find('[data-testid="cancel-button"]').trigger("click"); + expect(wrapper.emitted()).toHaveProperty("close"); + }); + }); +}); diff --git a/src/components/organisms/administration/SchoolTermsFormDialog.vue b/src/components/organisms/administration/SchoolTermsFormDialog.vue new file mode 100644 index 0000000000..eac46ceec6 --- /dev/null +++ b/src/components/organisms/administration/SchoolTermsFormDialog.vue @@ -0,0 +1,205 @@ + + + + + diff --git a/src/components/templates/CommonTermsOfUse.vue b/src/components/templates/CommonTermsOfUse.vue deleted file mode 100644 index 7e93ec20f1..0000000000 --- a/src/components/templates/CommonTermsOfUse.vue +++ /dev/null @@ -1,67 +0,0 @@ - diff --git a/src/locales/de.json b/src/locales/de.json index 35086604b7..f4c95e82b5 100644 --- a/src/locales/de.json +++ b/src/locales/de.json @@ -115,6 +115,7 @@ "common.words.lernstore": "Lern-Store", "common.words.planned": "geplant", "common.words.privacyPolicy": "Datenschutzerklärung", + "common.words.termsOfUse": "Nutzungsordnung", "common.words.published": "veröffentlicht", "common.words.ready": "bereit", "common.words.schoolYear": "Schuljahr", @@ -704,6 +705,20 @@ "pages.administration.school.index.schoolPolicy.longText.willReplaceAndSendConsent": "Die neue Datenschutzerklärung wird die alte unwiderruflich ersetzen und allen Nutzern dieser Schule zur Genehmigung vorgelegt werden.", "pages.administration.school.index.schoolPolicy.edit": "Datenschutzerklärung bearbeiten", "pages.administration.school.index.schoolPolicy.download": "Datenschutzerklärung herunterladen", + "pages.administration.school.index.termsOfUse.labels.uploadFile": "Datei auswählen", + "pages.administration.school.index.termsOfUse.hints.uploadFile": "Datei hochladen (nur PDF, max. 4MB)", + "pages.administration.school.index.termsOfUse.validation.fileTooBig": "Die Datei ist größer als 4MB. Bitte reduzieren sie die Dateigröße", + "pages.administration.school.index.termsOfUse.validation.notPdf": "Dieses Dateiformat wird nicht unterstützt. Verwenden Sie bitte PDF", + "pages.administration.school.index.termsOfUse.error": "Beim Laden der Nutzungsordnung ist ein Fehler aufgetreten", + "pages.administration.school.index.termsOfUse.success": "Neue Datei wurde erfolgreich hochgeladen.", + "pages.administration.school.index.termsOfUse.replace": "Ersetzen", + "pages.administration.school.index.termsOfUse.cancel": "Abbrechen", + "pages.administration.school.index.termsOfUse.uploadedOn": "Hochgeladen am {date}", + "pages.administration.school.index.termsOfUse.notUploadedYet": "Noch nicht hochgeladen", + "pages.administration.school.index.termsOfUse.fileName": "Nutzungsordnung der Schule", + "pages.administration.school.index.termsOfUse.longText.willReplaceAndSendConsent": "Die neue Nutzungsordnung wird die alte unwiderruflich ersetzen und allen Nutzern dieser Schule zur Genehmigung vorgelegt werden.", + "pages.administration.school.index.termsOfUse.edit": "Nutzungsordnung bearbeiten", + "pages.administration.school.index.termsOfUse.download": "Nutzungsordnung herunterladen", "pages.administration.school.index.authSystems.title": "Authentifizierung", "pages.administration.school.index.authSystems.alias": "Alias", "pages.administration.school.index.authSystems.type": "Typ", diff --git a/src/locales/en.json b/src/locales/en.json index cb45087594..6883d9c7c5 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -114,6 +114,7 @@ "common.words.lernstore": "Learning Store", "common.words.planned": "planned", "common.words.privacyPolicy": "Privacy Policy", + "common.words.termsOfUse": "Terms of Use", "common.words.published": "published", "common.words.ready": "ready", "common.words.schoolYear": "School year", @@ -698,10 +699,24 @@ "pages.administration.school.index.schoolPolicy.cancel": "Cancel", "pages.administration.school.index.schoolPolicy.uploadedOn": "Uploaded on {date}", "pages.administration.school.index.schoolPolicy.notUploadedYet": "Not uploaded yet", - "pages.administration.school.index.schoolPolicy.fileName": "Privacy policy of the school", - "pages.administration.school.index.schoolPolicy.longText.willReplaceAndSendConsent": "The new privacy policy will irretrievably replace the old one and will be presented to all users of this school for approval.", - "pages.administration.school.index.schoolPolicy.edit": "Edit privacy policy", - "pages.administration.school.index.schoolPolicy.download": "Download privacy policy", + "pages.administration.school.index.schoolPolicy.fileName": "Privacy Policy of the school", + "pages.administration.school.index.schoolPolicy.longText.willReplaceAndSendConsent": "The new Privacy Policy will irretrievably replace the old one and will be presented to all users of this school for approval.", + "pages.administration.school.index.schoolPolicy.edit": "Edit Privacy Policy", + "pages.administration.school.index.schoolPolicy.download": "Download Privacy Policy", + "pages.administration.school.index.termsOfUse.labels.uploadFile": "Select file", + "pages.administration.school.index.termsOfUse.hints.uploadFile": "Upload file (PDF only, 4MB max)", + "pages.administration.school.index.termsOfUse.validation.fileTooBig": "The file is larger than 4MB. Please reduce the file size", + "pages.administration.school.index.termsOfUse.validation.notPdf": "This file format is not supported. Please use PDF only", + "pages.administration.school.index.termsOfUse.error": "An error occurred while loading the terms of use", + "pages.administration.school.index.termsOfUse.success": "New file was successfully uploaded.", + "pages.administration.school.index.termsOfUse.replace": "Replace", + "pages.administration.school.index.termsOfUse.cancel": "Cancel", + "pages.administration.school.index.termsOfUse.uploadedOn": "Uploaded on {date}", + "pages.administration.school.index.termsOfUse.notUploadedYet": "Not uploaded yet", + "pages.administration.school.index.termsOfUse.fileName": "Terms of Use of the school", + "pages.administration.school.index.termsOfUse.longText.willReplaceAndSendConsent": "The new Terms of Use will irretrievably replace the old one and will be presented to all users of this school for approval.", + "pages.administration.school.index.termsOfUse.edit": "Edit Terms of Use", + "pages.administration.school.index.termsOfUse.download": "Download Terms of Use", "pages.administration.school.index.authSystems.title": "Authentification", "pages.administration.school.index.authSystems.alias": "Alias", "pages.administration.school.index.authSystems.type": "Type", diff --git a/src/locales/es.json b/src/locales/es.json index bb82bbb9c5..d361897e46 100644 --- a/src/locales/es.json +++ b/src/locales/es.json @@ -113,7 +113,8 @@ "common.words.learnContent": "Contenidos de aprendizaje", "common.words.lernstore": "Lern-Store", "common.words.planned": "previsto", - "common.words.privacyPolicy": "Política de privacidad", + "common.words.privacyPolicy": "Política de Privacidad", + "common.words.termsOfUse": "Condiciones de Uso", "common.words.published": "publicado", "common.words.ready": "listo", "common.words.schoolYear": "Año escolar", @@ -681,16 +682,30 @@ "pages.administration.school.index.schoolPolicy.hints.uploadFile": "Cargar archivo (sólo PDF, 4 MB como máximo)", "pages.administration.school.index.schoolPolicy.validation.fileTooBig": "El archivo pesa más de 4 MB. Por favor, reduzca el tamaño del archivo", "pages.administration.school.index.schoolPolicy.validation.notPdf": "Este formato de archivo no es compatible. Utilice sólo PDF", - "pages.administration.school.index.schoolPolicy.error": "Se ha producido un error al cargar la política de privacidad", + "pages.administration.school.index.schoolPolicy.error": "Se ha producido un error al cargar la Política de Privacidad", "pages.administration.school.index.schoolPolicy.success": "El nuevo archivo se ha cargado correctamente.", "pages.administration.school.index.schoolPolicy.replace": "Sustituir", "pages.administration.school.index.schoolPolicy.cancel": "Cancelar", "pages.administration.school.index.schoolPolicy.uploadedOn": "Subido el {date}", "pages.administration.school.index.schoolPolicy.notUploadedYet": "Aún no se ha cargado", - "pages.administration.school.index.schoolPolicy.fileName": "Política de privacidad de la escuela", - "pages.administration.school.index.schoolPolicy.longText.willReplaceAndSendConsent": "La nueva política de privacidad sustituirá irremediablemente a la anterior y se presentará a todos los usuarios de esta escuela para su aprobación.", - "pages.administration.school.index.schoolPolicy.edit": "Editar política de privacidad", - "pages.administration.school.index.schoolPolicy.download": "Descargar política de privacidad", + "pages.administration.school.index.schoolPolicy.fileName": "Política de Privacidad de la escuela", + "pages.administration.school.index.schoolPolicy.longText.willReplaceAndSendConsent": "La nueva Política de Privacidad sustituirá irremediablemente a la anterior y se presentará a todos los usuarios de esta escuela para su aprobación.", + "pages.administration.school.index.schoolPolicy.edit": "Editar Política de Privacidad", + "pages.administration.school.index.schoolPolicy.download": "Descargar Política de Privacidad", + "pages.administration.school.index.termsOfUse.labels.uploadFile": "Seleccionar archivo", + "pages.administration.school.index.termsOfUse.hints.uploadFile": "Cargar archivo (sólo PDF, 4 MB como máximo)", + "pages.administration.school.index.termsOfUse.validation.fileTooBig": "El archivo pesa más de 4 MB. Por favor, reduzca el tamaño del archivo", + "pages.administration.school.index.termsOfUse.validation.notPdf": "Este formato de archivo no es compatible. Utilice sólo PDF", + "pages.administration.school.index.termsOfUse.error": "Se ha producido un error al cargar la Condiciones de Uso", + "pages.administration.school.index.termsOfUse.success": "El nuevo archivo se ha cargado correctamente.", + "pages.administration.school.index.termsOfUse.replace": "Sustituir", + "pages.administration.school.index.termsOfUse.cancel": "Cancelar", + "pages.administration.school.index.termsOfUse.uploadedOn": "Subido el {date}", + "pages.administration.school.index.termsOfUse.notUploadedYet": "Aún no se ha cargado", + "pages.administration.school.index.termsOfUse.fileName": "Condiciones de Uso de la escuela", + "pages.administration.school.index.termsOfUse.longText.willReplaceAndSendConsent": "La nueva Condiciones de Uso sustituirá irremediablemente a la anterior y se presentará a todos los usuarios de esta escuela para su aprobación.", + "pages.administration.school.index.termsOfUse.edit": "Editar Condiciones de Uso", + "pages.administration.school.index.termsOfUse.download": "Descargar Condiciones de Uso", "pages.administration.school.index.authSystems.title": "Autenticación", "pages.administration.school.index.authSystems.alias": "Alias", "pages.administration.school.index.authSystems.type": "Tipo", diff --git a/src/locales/uk.json b/src/locales/uk.json index 526786084b..966e4a2dd8 100644 --- a/src/locales/uk.json +++ b/src/locales/uk.json @@ -115,6 +115,7 @@ "common.words.lernstore": "Навчальний магазин", "common.words.planned": "запланований", "common.words.privacyPolicy": "Політика конфіденційності", + "common.words.termsOfUse": "Умови використання", "common.words.published": "опубліковано", "common.words.ready": "Готовий", "common.words.schoolYear": "Навчальний рік", @@ -671,6 +672,20 @@ "pages.administration.school.index.schoolPolicy.longText.willReplaceAndSendConsent": "Нова політика конфіденційності безповоротно замінить стару і буде представлена всім користувачам цієї школи для затвердження.", "pages.administration.school.index.schoolPolicy.edit": "Редагувати політику конфіденційності", "pages.administration.school.index.schoolPolicy.download": "Завантажте політику конфіденційності", + "pages.administration.school.index.termsOfUse.labels.uploadFile": "Виберіть файл", + "pages.administration.school.index.termsOfUse.hints.uploadFile": "Завантажити файл (тільки PDF, максимум 4 МБ)", + "pages.administration.school.index.termsOfUse.validation.fileTooBig": "Розмір файлу перевищує 4 МБ. Будь ласка, зменшіть розмір файлу", + "pages.administration.school.index.termsOfUse.validation.notPdf": "Цей формат файлу не підтримується. Будь ласка, використовуйте тільки PDF", + "pages.administration.school.index.termsOfUse.error": "Виникла помилка під час завантаження Умови використання", + "pages.administration.school.index.termsOfUse.success": "Новий файл успішно завантажено.", + "pages.administration.school.index.termsOfUse.replace": "Замінити", + "pages.administration.school.index.termsOfUse.cancel": "Скасувати", + "pages.administration.school.index.termsOfUse.uploadedOn": "Завантажено {date}", + "pages.administration.school.index.termsOfUse.notUploadedYet": "Ще не завантажено", + "pages.administration.school.index.termsOfUse.fileName": "Умови використання школи", + "pages.administration.school.index.termsOfUse.longText.willReplaceAndSendConsent": "Нова Умови використання безповоротно замінить стару і буде представлена всім користувачам цієї школи для затвердження.", + "pages.administration.school.index.termsOfUse.edit": "Редагувати Умови використання", + "pages.administration.school.index.termsOfUse.download": "Завантажте Умови використання", "pages.administration.school.index.title": "Керувати школою", "pages.administration.school.index.usedFileStorage": "Використовуване файлове сховище у хмарі", "pages.administration.select": "вибрати", diff --git a/src/main.ts b/src/main.ts index 492150e968..107f6f673b 100644 --- a/src/main.ts +++ b/src/main.ts @@ -16,6 +16,7 @@ import { newsModule, notifierModule, privacyPolicyModule, + termsOfUseModule, roomModule, roomsModule, schoolExternalToolsModule, @@ -67,6 +68,9 @@ import { SYSTEMS_MODULE_KEY, USER_LOGIN_MIGRATION_MODULE_KEY, VIDEO_CONFERENCE_MODULE_KEY, + PRIVACY_POLICY_MODULE_KEY, + TERMS_OF_USE_MODULE_KEY, + SCHOOLS_MODULE_KEY, } from "./utils/inject"; Vue.config.productionTip = false; @@ -153,11 +157,12 @@ Vue.use(VueDOMPurifyHTML, { loadingStateModule, newsModule, [NOTIFIER_MODULE_KEY.valueOf()]: notifierModule, - privacyPolicyModule, + [PRIVACY_POLICY_MODULE_KEY.valueOf()]: privacyPolicyModule, + [TERMS_OF_USE_MODULE_KEY.valueOf()]: termsOfUseModule, [ROOM_MODULE_KEY.valueOf()]: roomModule, roomsModule, [SCHOOL_EXTERNAL_TOOLS_MODULE_KEY.valueOf()]: schoolExternalToolsModule, - schoolsModule, + [SCHOOLS_MODULE_KEY.valueOf()]: schoolsModule, shareModule, [STATUS_ALERTS_MODULE_KEY.valueOf()]: statusAlertsModule, [SYSTEMS_MODULE_KEY.valueOf()]: systemsModule, diff --git a/src/pages/TermsOfUse.vue b/src/pages/TermsOfUse.vue deleted file mode 100644 index 488a85aa07..0000000000 --- a/src/pages/TermsOfUse.vue +++ /dev/null @@ -1,40 +0,0 @@ - - - diff --git a/src/pages/administration/SchoolSettings.page.vue b/src/pages/administration/SchoolSettings.page.vue index d08da618ab..a648db4677 100644 --- a/src/pages/administration/SchoolSettings.page.vue +++ b/src/pages/administration/SchoolSettings.page.vue @@ -36,6 +36,7 @@ +