From bb8805a545f35a2e487d10f3965f591c37e887c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marvin=20=C3=96hlerking?= <103562092+MarvinOehlerkingCap@users.noreply.github.com> Date: Tue, 14 Nov 2023 08:59:31 +0100 Subject: [PATCH] N21-1311 Remove old User login migration (#2912) --- .../AdminMigrationSection.unit.ts | 260 +---------- .../administration/AdminMigrationSection.vue | 73 ++- src/serverApi/v3/api.ts | 432 ------------------ src/store/schools.ts | 95 +--- src/store/schools.unit.ts | 326 +------------ src/store/types/schools.ts | 8 - src/store/user-login-migration/index.ts | 1 - .../user-login-migration-flags.ts | 6 - src/store/user-login-migrations.ts | 16 +- src/store/user-login-migrations.unit.ts | 42 +- 10 files changed, 61 insertions(+), 1198 deletions(-) delete mode 100644 src/store/user-login-migration/user-login-migration-flags.ts diff --git a/src/components/administration/AdminMigrationSection.unit.ts b/src/components/administration/AdminMigrationSection.unit.ts index 74fbdfc46a..f126bba14b 100644 --- a/src/components/administration/AdminMigrationSection.unit.ts +++ b/src/components/administration/AdminMigrationSection.unit.ts @@ -1,6 +1,7 @@ import AdminMigrationSection from "@/components/administration/AdminMigrationSection.vue"; import EnvConfigModule from "@/store/env-config"; import SchoolsModule from "@/store/schools"; +import UserLoginMigrationModule from "@/store/user-login-migrations"; import { ENV_CONFIG_MODULE_KEY, I18N_KEY, @@ -8,10 +9,9 @@ import { USER_LOGIN_MIGRATION_MODULE_KEY, } from "@/utils/inject"; import { createModuleMocks } from "@/utils/mock-store-module"; -import createComponentMocks from "@@/tests/test-utils/componentMocks"; -import { Wrapper, mount } from "@vue/test-utils"; import { i18nMock, mockSchool } from "@@/tests/test-utils"; -import UserLoginMigrationModule from "@/store/user-login-migrations"; +import createComponentMocks from "@@/tests/test-utils/componentMocks"; +import { mount, Wrapper } from "@vue/test-utils"; describe("AdminMigrationSection", () => { let schoolsModule: jest.Mocked; @@ -38,13 +38,6 @@ describe("AdminMigrationSection", () => { }) as jest.Mocked; schoolsModule = createModuleMocks(SchoolsModule, { - getOauthMigration: { - enableMigrationStart: false, - oauthMigrationPossible: false, - oauthMigrationMandatory: false, - oauthMigrationFinished: "", - oauthMigrationFinalFinish: "", - }, getSchool: { ...mockSchool, officialSchoolNumber: undefined }, ...schoolGetters, }) as jest.Mocked; @@ -114,15 +107,7 @@ describe("AdminMigrationSection", () => { describe("Migration Control Section", () => { it("should render migration control section when grace period is not expired", () => { const { wrapper } = setup( - { - getOauthMigration: { - enableMigrationStart: false, - oauthMigrationPossible: false, - oauthMigrationMandatory: false, - oauthMigrationFinished: "", - oauthMigrationFinalFinish: "", - }, - }, + {}, { getUserLoginMigration: { sourceSystemId: "sourceSystemId", @@ -141,15 +126,7 @@ describe("AdminMigrationSection", () => { it("should not render migration description when grace period is expired", () => { const { wrapper } = setup( - { - getOauthMigration: { - enableMigrationStart: true, - oauthMigrationPossible: false, - oauthMigrationMandatory: false, - oauthMigrationFinished: new Date(2023, 1, 1).toString(), - oauthMigrationFinalFinish: new Date(2023, 1, 2).toString(), - }, - }, + {}, { getUserLoginMigration: { sourceSystemId: "sourceSystemId", @@ -173,15 +150,7 @@ describe("AdminMigrationSection", () => { describe("Info Text", () => { it("should display the info text for migration when it is not started", () => { const { wrapper } = setup( - { - getOauthMigration: { - enableMigrationStart: false, - oauthMigrationPossible: false, - oauthMigrationMandatory: false, - oauthMigrationFinished: "", - oauthMigrationFinalFinish: "", - }, - }, + {}, { getUserLoginMigration: undefined, } @@ -196,15 +165,7 @@ describe("AdminMigrationSection", () => { it("should display the info text activeMigration when the admin activated the migration", () => { const { wrapper } = setup( - { - getOauthMigration: { - enableMigrationStart: false, - oauthMigrationPossible: true, - oauthMigrationMandatory: false, - oauthMigrationFinished: "", - oauthMigrationFinalFinish: "", - }, - }, + {}, { getUserLoginMigration: { sourceSystemId: "sourceSystemId", @@ -228,15 +189,7 @@ describe("AdminMigrationSection", () => { describe("Mandatory Switch", () => { it("should be enabled when migration is available", () => { const { wrapper } = setup( - { - getOauthMigration: { - enableMigrationStart: false, - oauthMigrationPossible: true, - oauthMigrationMandatory: false, - oauthMigrationFinished: "", - oauthMigrationFinalFinish: "", - }, - }, + {}, { getUserLoginMigration: { sourceSystemId: "sourceSystemId", @@ -256,15 +209,7 @@ describe("AdminMigrationSection", () => { it("should be disabled when migration is not available", () => { const { wrapper } = setup( - { - getOauthMigration: { - enableMigrationStart: false, - oauthMigrationPossible: false, - oauthMigrationMandatory: false, - oauthMigrationFinished: "", - oauthMigrationFinalFinish: "", - }, - }, + {}, { getUserLoginMigration: undefined, } @@ -278,15 +223,7 @@ describe("AdminMigrationSection", () => { it("should set school oauth migration to mandatory, when click have been triggered", () => { const { wrapper } = setup( - { - getOauthMigration: { - enableMigrationStart: false, - oauthMigrationPossible: true, - oauthMigrationMandatory: false, - oauthMigrationFinished: "", - oauthMigrationFinalFinish: "", - }, - }, + {}, { getUserLoginMigration: { sourceSystemId: "sourceSystemId", @@ -309,15 +246,7 @@ describe("AdminMigrationSection", () => { it("should set school oauth migration to optional, when click has been triggered again", () => { const { wrapper } = setup( - { - getOauthMigration: { - enableMigrationStart: false, - oauthMigrationPossible: true, - oauthMigrationMandatory: true, - oauthMigrationFinished: "", - oauthMigrationFinalFinish: "", - }, - }, + {}, { getUserLoginMigration: { sourceSystemId: "sourceSystemId", @@ -362,15 +291,7 @@ describe("AdminMigrationSection", () => { it("should be disabled when migration is not enabled", () => { const { wrapper } = setup( - { - getOauthMigration: { - enableMigrationStart: false, - oauthMigrationPossible: false, - oauthMigrationMandatory: false, - oauthMigrationFinished: "", - oauthMigrationFinalFinish: "", - }, - }, + {}, { getUserLoginMigration: undefined, } @@ -388,15 +309,7 @@ describe("AdminMigrationSection", () => { it("should not render migration start button when grace period is expired", () => { const { wrapper } = setup( - { - getOauthMigration: { - enableMigrationStart: true, - oauthMigrationPossible: false, - oauthMigrationMandatory: false, - oauthMigrationFinished: new Date(2023, 1, 1).toString(), - oauthMigrationFinalFinish: new Date(2023, 1, 2).toString(), - }, - }, + {}, { getUserLoginMigration: { sourceSystemId: "sourceSystemId", @@ -421,13 +334,6 @@ describe("AdminMigrationSection", () => { it("should not render migration start button and migration mandatory switch, when click has been triggered", async () => { const { wrapper } = setup( { - getOauthMigration: { - enableMigrationStart: true, - oauthMigrationPossible: false, - oauthMigrationMandatory: false, - oauthMigrationFinished: "", - oauthMigrationFinalFinish: "", - }, getSchool: { ...mockSchool, officialSchoolNumber: "12345" }, }, { @@ -447,15 +353,7 @@ describe("AdminMigrationSection", () => { describe("Migration end button", () => { it("should exist and be enabled when migration has started", () => { const { wrapper } = setup( - { - getOauthMigration: { - enableMigrationStart: true, - oauthMigrationPossible: true, - oauthMigrationMandatory: false, - oauthMigrationFinished: "", - oauthMigrationFinalFinish: "", - }, - }, + {}, { getUserLoginMigration: { sourceSystemId: "sourceSystemId", @@ -481,13 +379,6 @@ describe("AdminMigrationSection", () => { it("should should not render migration end button and migration mandatory switch, when click has been triggered", async () => { const { wrapper } = setup( { - getOauthMigration: { - enableMigrationStart: true, - oauthMigrationPossible: true, - oauthMigrationMandatory: false, - oauthMigrationFinished: "", - oauthMigrationFinalFinish: "", - }, getSchool: { ...mockSchool, officialSchoolNumber: "12345" }, }, { @@ -516,13 +407,6 @@ describe("AdminMigrationSection", () => { it("should be rendered", async () => { const { wrapper } = setup( { - getOauthMigration: { - enableMigrationStart: true, - oauthMigrationPossible: false, - oauthMigrationMandatory: false, - oauthMigrationFinished: "", - oauthMigrationFinalFinish: "", - }, getSchool: { ...mockSchool, officialSchoolNumber: "12345" }, }, { @@ -542,13 +426,6 @@ describe("AdminMigrationSection", () => { it("should not render the card and start migration", async () => { const { wrapper } = setup( { - getOauthMigration: { - enableMigrationStart: true, - oauthMigrationPossible: false, - oauthMigrationMandatory: false, - oauthMigrationFinished: "", - oauthMigrationFinalFinish: "", - }, getSchool: { ...mockSchool, officialSchoolNumber: "12345" }, }, { @@ -577,13 +454,6 @@ describe("AdminMigrationSection", () => { it("should not render the card and not start migration", async () => { const { wrapper } = setup( { - getOauthMigration: { - enableMigrationStart: true, - oauthMigrationPossible: false, - oauthMigrationMandatory: false, - oauthMigrationFinished: "", - oauthMigrationFinalFinish: "", - }, getSchool: { ...mockSchool, officialSchoolNumber: "12345" }, }, { @@ -610,13 +480,6 @@ describe("AdminMigrationSection", () => { it("should be rendered", async () => { const { wrapper } = setup( { - getOauthMigration: { - enableMigrationStart: true, - oauthMigrationPossible: true, - oauthMigrationMandatory: false, - oauthMigrationFinished: "", - oauthMigrationFinalFinish: "", - }, getSchool: { ...mockSchool, officialSchoolNumber: "12345" }, }, { @@ -644,13 +507,6 @@ describe("AdminMigrationSection", () => { it("should not render the card and complete migration", async () => { const { wrapper } = setup( { - getOauthMigration: { - enableMigrationStart: true, - oauthMigrationPossible: true, - oauthMigrationMandatory: false, - oauthMigrationFinished: "", - oauthMigrationFinalFinish: "", - }, getSchool: { ...mockSchool, officialSchoolNumber: "12345" }, }, { @@ -685,13 +541,6 @@ describe("AdminMigrationSection", () => { it("should not render the card and not complete migration", async () => { const { wrapper } = setup( { - getOauthMigration: { - enableMigrationStart: true, - oauthMigrationPossible: true, - oauthMigrationMandatory: false, - oauthMigrationFinished: "", - oauthMigrationFinalFinish: "", - }, getSchool: { ...mockSchool, officialSchoolNumber: "12345" }, }, { @@ -730,13 +579,6 @@ describe("AdminMigrationSection", () => { it("should let agree-button be disabled", async () => { const { wrapper } = setup( { - getOauthMigration: { - enableMigrationStart: true, - oauthMigrationPossible: true, - oauthMigrationMandatory: false, - oauthMigrationFinished: "", - oauthMigrationFinalFinish: "", - }, getSchool: { ...mockSchool, officialSchoolNumber: "12345" }, }, { @@ -764,13 +606,6 @@ describe("AdminMigrationSection", () => { it("should make agree-button be enabled", async () => { const { wrapper } = setup( { - getOauthMigration: { - enableMigrationStart: true, - oauthMigrationPossible: true, - oauthMigrationMandatory: false, - oauthMigrationFinished: "", - oauthMigrationFinalFinish: "", - }, getSchool: { ...mockSchool, officialSchoolNumber: "12345" }, }, { @@ -804,17 +639,8 @@ describe("AdminMigrationSection", () => { it("should exist when migration has been completed", async () => { jest.useFakeTimers(); jest.setSystemTime(new Date(2023, 1, 2)); - const date: string = new Date(2023, 1, 1).toDateString(); - const laterDate: string = new Date(2023, 1, 3).toDateString(); const { wrapper } = setup( { - getOauthMigration: { - enableMigrationStart: true, - oauthMigrationPossible: false, - oauthMigrationMandatory: false, - oauthMigrationFinished: date, - oauthMigrationFinalFinish: laterDate, - }, getSchool: { ...mockSchool, officialSchoolNumber: "12345" }, }, { @@ -840,17 +666,8 @@ describe("AdminMigrationSection", () => { it("should show finalFinish text when migration grace period has expired", async () => { jest.useFakeTimers(); jest.setSystemTime(new Date(2023, 1, 4)); - const date: string = new Date(2023, 1, 1).toDateString(); - const laterDate: string = new Date(2023, 1, 3).toDateString(); const { wrapper } = setup( { - getOauthMigration: { - enableMigrationStart: true, - oauthMigrationPossible: false, - oauthMigrationMandatory: false, - oauthMigrationFinished: date, - oauthMigrationFinalFinish: laterDate, - }, getSchool: { ...mockSchool, officialSchoolNumber: "12345" }, }, { @@ -876,13 +693,6 @@ describe("AdminMigrationSection", () => { it("should not exist when migration has not been completed", async () => { const { wrapper } = setup( { - getOauthMigration: { - enableMigrationStart: true, - oauthMigrationPossible: false, - oauthMigrationMandatory: false, - oauthMigrationFinished: "", - oauthMigrationFinalFinish: "", - }, getSchool: { ...mockSchool, officialSchoolNumber: "12345" }, }, { @@ -1016,13 +826,6 @@ describe("AdminMigrationSection", () => { it("should hide switch button", () => { const { wrapper } = setup( { - getOauthMigration: { - enableMigrationStart: true, - oauthMigrationPossible: false, - oauthMigrationMandatory: false, - oauthMigrationFinished: new Date(2023, 1, 1).toDateString(), - oauthMigrationFinalFinish: new Date(2023, 1, 1).toDateString(), - }, getSchool: { ...mockSchool, officialSchoolNumber: "12345" }, }, { @@ -1052,13 +855,6 @@ describe("AdminMigrationSection", () => { it("should show switch button", () => { const { wrapper } = setup( { - getOauthMigration: { - enableMigrationStart: true, - oauthMigrationPossible: false, - oauthMigrationMandatory: false, - oauthMigrationFinished: "", - oauthMigrationFinalFinish: "", - }, getSchool: { ...mockSchool, officialSchoolNumber: "12345" }, }, { @@ -1079,13 +875,6 @@ describe("AdminMigrationSection", () => { it("should enable the switch", () => { const { wrapper } = setup( { - getOauthMigration: { - enableMigrationStart: true, - oauthMigrationPossible: true, - oauthMigrationMandatory: false, - oauthMigrationFinished: "", - oauthMigrationFinalFinish: "", - }, getSchool: { ...mockSchool, officialSchoolNumber: "12345" }, }, { @@ -1115,13 +904,6 @@ describe("AdminMigrationSection", () => { it("should disable the switch", () => { const { wrapper } = setup( { - getOauthMigration: { - enableMigrationStart: true, - oauthMigrationPossible: false, - oauthMigrationMandatory: false, - oauthMigrationFinished: "", - oauthMigrationFinalFinish: "", - }, getSchool: { ...mockSchool, officialSchoolNumber: "12345" }, }, { @@ -1144,13 +926,6 @@ describe("AdminMigrationSection", () => { it("should disable the switch", () => { const { wrapper } = setup( { - getOauthMigration: { - enableMigrationStart: true, - oauthMigrationPossible: false, - oauthMigrationMandatory: false, - oauthMigrationFinished: new Date(2023, 1, 1).toDateString(), - oauthMigrationFinalFinish: "", - }, getSchool: { ...mockSchool, officialSchoolNumber: "12345" }, }, { @@ -1180,13 +955,6 @@ describe("AdminMigrationSection", () => { it("should call update in schoolsModule", async () => { const { wrapper, schoolsModule } = setup( { - getOauthMigration: { - enableMigrationStart: true, - oauthMigrationPossible: true, - oauthMigrationMandatory: false, - oauthMigrationFinished: "", - oauthMigrationFinalFinish: "", - }, getSchool: { ...mockSchool, officialSchoolNumber: "12345" }, }, { diff --git a/src/components/administration/AdminMigrationSection.vue b/src/components/administration/AdminMigrationSection.vue index cffec9e685..664cd894b4 100644 --- a/src/components/administration/AdminMigrationSection.vue +++ b/src/components/administration/AdminMigrationSection.vue @@ -58,7 +58,7 @@ class="my-4 button-end" color="primary" depressed - :disabled="!oauthMigration.startedAt" + :disabled="!isMigrationActive" data-testid="migration-end-button" @click="onToggleShowEndWarning" > @@ -75,15 +75,15 @@ 'components.administration.adminMigrationSection.mandatorySwitch.label' ) " - :disabled="!oauthMigration.startedAt" + :disabled="!isMigrationActive" :true-value="true" :false-value="false" - :value="oauthMigration.mandatorySince" + :value="isMigrationMandatory" inset dense class="ml-1" data-testid="migration-mandatory-switch" - @change="setMigrationMandatory(!oauthMigration.mandatorySince)" + @change="setMigrationMandatory(!isMigrationMandatory)" /> @@ -104,15 +104,19 @@ />