Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…into BC-8584-refactor-board-menu
  • Loading branch information
hoeppner-dataport committed Jan 13, 2025
2 parents 7e1c771 + e02c986 commit 0c10db3
Show file tree
Hide file tree
Showing 52 changed files with 1,636 additions and 954 deletions.
5 changes: 2 additions & 3 deletions config/webpack/vue-i18n-loader.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { generateJSON, generateJavaScript } = require("@intlify/bundle-utils");
const { generateJavaScript } = require("@intlify/bundle-utils");

const loader = function (source, sourceMap) {
// eslint-disable-next-line @typescript-eslint/no-this-alias
Expand All @@ -10,8 +10,7 @@ const loader = function (source, sourceMap) {
inSourceMap: sourceMap,
forceStringify: false,
useClassComponent: false,
strictMessage: false,
escapeHtml: false,
strictMessage: true, // DO NOT set this to false. We do not allow HTML in messages.
env: loaderContext.mode,
type: "plain",
isGlobal: false,
Expand Down
75 changes: 45 additions & 30 deletions src/components/administration/AdminMigrationSection.unit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import {
} from "@@/tests/test-utils/setup";
import { mount } from "@vue/test-utils";
import { nextTick } from "vue";
import vueDompurifyHTMLPlugin from "vue-dompurify-html";

describe("AdminMigrationSection", () => {
let schoolsModule: jest.Mocked<SchoolsModule>;
Expand Down Expand Up @@ -68,11 +67,7 @@ describe("AdminMigrationSection", () => {

const wrapper = mount(AdminMigrationSection, {
global: {
plugins: [
createTestingVuetify(),
createTestingI18n(),
vueDompurifyHTMLPlugin,
],
plugins: [createTestingVuetify(), createTestingI18n()],
provide: {
[SCHOOLS_MODULE_KEY.valueOf()]: schoolsModule,
[USER_LOGIN_MIGRATION_MODULE_KEY.valueOf()]: userLoginMigrationModule,
Expand Down Expand Up @@ -181,11 +176,20 @@ describe("AdminMigrationSection", () => {
}
);

const renderHtmls = wrapper.findAllComponents({ name: "RenderHTML" });

expect(renderHtmls[1].props("html")).toStrictEqual(
"components.administration.adminMigrationSection.infoText"
);
const infoText = wrapper.get('[data-testId="migration-info-text"]');
const expectedText = [
"firstParagraph",
"secondParagraph",
"thirdParagraph",
"fourthParagraph",
]
.map(
(text) =>
`components.administration.adminMigrationSection.infoText.${text}`
)
.join("");

expect(infoText.text()).toEqual(expectedText);
});

it("should display the info text activeMigration when the admin activated the migration", () => {
Expand All @@ -203,9 +207,9 @@ describe("AdminMigrationSection", () => {
}
);

const renderHtmls = wrapper.findAllComponents({ name: "RenderHTML" });
const infoText = wrapper.get('[data-testId="migration-active-status"]');

expect(renderHtmls[1].props("html")).toStrictEqual(
expect(infoText.text()).toStrictEqual(
"components.administration.adminMigrationSection.migrationActive"
);
});
Expand Down Expand Up @@ -368,7 +372,7 @@ describe("AdminMigrationSection", () => {

const buttonComponent = wrapper.findComponent({ name: "v-btn" });
const switchComponent = wrapper.findComponent({ name: "v-switch" });
await buttonComponent.vm.$emit("click");
await buttonComponent.trigger("click");

expect(buttonComponent.exists()).toBe(false);
expect(switchComponent.isVisible()).toBe(false);
Expand Down Expand Up @@ -440,7 +444,7 @@ describe("AdminMigrationSection", () => {

const buttonComponent = wrapper.findComponent({ name: "v-btn" });
const switchComponent = wrapper.findComponent({ name: "v-switch" });
await buttonComponent.vm.$emit("click");
await buttonComponent.trigger("click");

expect(buttonComponent.exists()).toBe(false);
expect(switchComponent.isVisible()).toBe(false);
Expand All @@ -460,7 +464,7 @@ describe("AdminMigrationSection", () => {
);

const buttonComponent = wrapper.findComponent({ name: "v-btn" });
await buttonComponent.vm.$emit("click");
await buttonComponent.trigger("click");

const cardComponent = wrapper.findComponent({ name: "v-card" });

Expand All @@ -478,7 +482,7 @@ describe("AdminMigrationSection", () => {
}
);
const buttonComponent = wrapper.findComponent({ name: "v-btn" });
await buttonComponent.vm.$emit("click");
await buttonComponent.trigger("click");

const cardComponent = wrapper.findComponent({ name: "v-card" });
const cardButtonAgree = cardComponent.find("[data-testId=agree-btn]");
Expand Down Expand Up @@ -506,7 +510,7 @@ describe("AdminMigrationSection", () => {
}
);
const buttonComponent = wrapper.findComponent({ name: "v-btn" });
await buttonComponent.vm.$emit("click");
await buttonComponent.trigger("click");

const cardComponent = wrapper.findComponent({ name: "v-card" });
const cardButtonDisagree = cardComponent.find(
Expand Down Expand Up @@ -540,7 +544,7 @@ describe("AdminMigrationSection", () => {
);

const buttonComponent = wrapper.findComponent({ name: "v-btn" });
await buttonComponent.vm.$emit("click");
await buttonComponent.trigger("click");

const cardComponent = wrapper.findComponent({ name: "v-card" });

Expand All @@ -567,7 +571,7 @@ describe("AdminMigrationSection", () => {
);

const buttonComponent = wrapper.findComponent({ name: "v-btn" });
await buttonComponent.vm.$emit("click");
await buttonComponent.trigger("click");

const warningCards = wrapper.findAllComponents({
name: "migration-warning-card",
Expand Down Expand Up @@ -602,7 +606,7 @@ describe("AdminMigrationSection", () => {
}
);
const buttonComponent = wrapper.findComponent({ name: "v-btn" });
await buttonComponent.vm.$emit("click");
await buttonComponent.trigger("click");

const cardComponent = wrapper.findComponent({ name: "v-card" });
const cardButtonDisagree = cardComponent.find(
Expand Down Expand Up @@ -643,11 +647,18 @@ describe("AdminMigrationSection", () => {
}
);

const renderHtmls = wrapper.findAllComponents({ name: "RenderHTML" });

expect(renderHtmls[2].props("html")).toContain(
"components.administration.adminMigrationSection.oauthMigrationFinished.text"
const dateParagraph = wrapper.get(
"[data-testid=migration-finished-timestamp]"
);

const expectedText = ["firstParagraph", "secondParagraph"]
.map(
(paragraph) =>
`components.administration.adminMigrationSection.oauthMigrationFinished.text.${paragraph}`
)
.join("");

expect(dateParagraph.text()).toBe(expectedText);
});

it("should show finalFinish text when migration grace period has expired", async () => {
Expand All @@ -669,12 +680,16 @@ describe("AdminMigrationSection", () => {
}
);

const renderHtml = wrapper.findComponent({ name: "RenderHTML" });

expect(renderHtml.props()).toHaveProperty("html");
expect(renderHtml.props("html")).toContain(
"components.administration.adminMigrationSection.oauthMigrationFinished.textComplete"
const paragraph = wrapper.get(
"[data-testid=migration-finished-timestamp]"
);

const expectedText = [
"components.administration.adminMigrationSection.oauthMigrationFinished.text.firstParagraph",
"components.administration.adminMigrationSection.oauthMigrationFinished.textComplete.secondParagraph",
].join("");

expect(paragraph.text()).toBe(expectedText);
});

it("should not exist when migration has not been completed", async () => {
Expand Down
Loading

0 comments on commit 0c10db3

Please sign in to comment.