Skip to content

Commit

Permalink
N21-1785-do not show wizard button when migration is finished (#3215)
Browse files Browse the repository at this point in the history
* N21-1785-do not show wizard button when migration is finished
  • Loading branch information
IgorCapCoder authored Apr 22, 2024
1 parent 602efc8 commit 348fd97
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 8 deletions.
32 changes: 29 additions & 3 deletions src/components/administration/AdminMigrationSection.unit.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import AdminMigrationSection from "@/components/administration/AdminMigrationSection.vue";
import * as useUserLoginMigrationMappingsComposable from "@/composables/user-login-migration-mappings.composable";
import { ConfigResponse } from "@/serverApi/v3/api";
import EnvConfigModule from "@/store/env-config";
import SchoolsModule from "@/store/schools";
import { ConfigResponse } from "@/serverApi/v3/api";
import UserLoginMigrationModule from "@/store/user-login-migrations";
import {
ENV_CONFIG_MODULE_KEY,
SCHOOLS_MODULE_KEY,
USER_LOGIN_MIGRATION_MODULE_KEY,
} from "@/utils/inject";
import { createModuleMocks } from "@/utils/mock-store-module";
import { businessErrorFactory } from "@@/tests/test-utils";
import { mockSchool } from "@@/tests/test-utils/mockObjects";
import {
createTestingI18n,
Expand All @@ -17,8 +19,6 @@ import {
import { mount } from "@vue/test-utils";
import { nextTick } from "vue";
import vueDompurifyHTMLPlugin from "vue-dompurify-html";
import * as useUserLoginMigrationMappingsComposable from "@/composables/user-login-migration-mappings.composable";
import { businessErrorFactory } from "@@/tests/test-utils";

describe("AdminMigrationSection", () => {
let schoolsModule: jest.Mocked<SchoolsModule>;
Expand Down Expand Up @@ -1046,6 +1046,32 @@ describe("AdminMigrationSection", () => {
});
});

describe("when the migration has been finished", () => {
it("should not be visible", () => {
const { wrapper } = setup(
{},
{
getUserLoginMigration: {
sourceSystemId: "sourceSystemId",
targetSystemId: "targetSystemId",
startedAt: new Date(2023, 1, 1),
closedAt: new Date(2023, 1, 2),
finishedAt: new Date(2023, 1, 3),
mandatorySince: undefined,
},
},
{
getEnv: { FEATURE_SHOW_MIGRATION_WIZARD: true } as ConfigResponse,
}
);

const migrationWizardButton = wrapper.find(
'[data-testid="migration-wizard-button]'
);
expect(migrationWizardButton.exists()).toBeFalsy();
});
});

describe("when the school has not been migrated", () => {
it("should be disabled", () => {
const { wrapper } = setup(
Expand Down
15 changes: 10 additions & 5 deletions src/components/administration/AdminMigrationSection.vue
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
@update:model-value="setSchoolFeatures"
/>

<template v-if="showMigrationWizard">
<template v-if="showMigrationWizard && !isMigrationFinished">
<v-btn
:disabled="!isMigrationActive || !isSchoolMigrated"
class="my-4"
Expand Down Expand Up @@ -201,7 +201,9 @@
</template>

<script lang="ts">
import { mdiCheck, mdiAlertCircle } from "@/components/icons/material";
import { mdiAlertCircle, mdiCheck } from "@/components/icons/material";
import { useUserLoginMigrationMappings } from "@/composables/user-login-migration-mappings.composable";
import { BusinessError } from "@/store/types/commons";
import { School } from "@/store/types/schools";
import { UserLoginMigration } from "@/store/user-login-migration";
import {
Expand All @@ -210,6 +212,7 @@ import {
SCHOOLS_MODULE_KEY,
USER_LOGIN_MIGRATION_MODULE_KEY,
} from "@/utils/inject";
import { mapSchoolFeatureObjectToArray } from "@/utils/school-features";
import { RenderHTML } from "@feature-render-html";
import dayjs from "dayjs";
import {
Expand All @@ -222,9 +225,6 @@ import {
} from "vue";
import { useI18n } from "vue-i18n";
import MigrationWarningCard from "./MigrationWarningCard.vue";
import { mapSchoolFeatureObjectToArray } from "@/utils/school-features";
import { useUserLoginMigrationMappings } from "@/composables/user-login-migration-mappings.composable";
import { BusinessError } from "@/store/types/commons";
export default defineComponent({
name: "AdminMigrationSection",
Expand Down Expand Up @@ -375,6 +375,10 @@ export default defineComponent({
() => !!envConfigModule.getEnv.FEATURE_SHOW_MIGRATION_WIZARD
);
const isMigrationFinished: ComputedRef<boolean> = computed(
() => !!userLoginMigration.value?.finishedAt
);
const setSchoolFeatures = async () => {
await schoolsModule.update({
id: school.value.id,
Expand Down Expand Up @@ -410,6 +414,7 @@ export default defineComponent({
isMigrationMandatory,
mdiCheck,
showMigrationWizard,
isMigrationFinished,
isSchoolMigrated,
error,
getBusinessErrorTranslationKey,
Expand Down

0 comments on commit 348fd97

Please sign in to comment.