✨ Translate notifications (#581)
Co-authored-by: Monta <monta@HP-ProBook-445-14-inch-G9-Notebook-PC-505aadfc.localdomain> Co-authored-by: Eric Doughty-Papassideris <edoughtypapassideris@linagora.com>
This commit is contained in:
@@ -2,6 +2,7 @@ import { describe, beforeEach, it, expect, afterAll, jest } from "@jest/globals"
|
||||
import { init, TestPlatform } from "../setup";
|
||||
import UserApi from "../common/user-api";
|
||||
import { DocumentsEngine } from "../../../src/services/documents/services/engine";
|
||||
import EmailPusherClass from "../../../src/core/platform/services/email-pusher";
|
||||
import { deserialize } from "class-transformer";
|
||||
import { File } from "../../../src/services/files/entities/file";
|
||||
import { ResourceUpdateResponse } from "../../../src/utils/types";
|
||||
@@ -14,6 +15,8 @@ describe("the Drive feature", () => {
|
||||
DocumentsEngine.prototype,
|
||||
"notifyDocumentVersionUpdated",
|
||||
);
|
||||
const DispatchDocumentEvent = jest.spyOn(DocumentsEngine.prototype, "DispatchDocumentEvent");
|
||||
const buildEmailSpy = jest.spyOn(EmailPusherClass.prototype, "build");
|
||||
let currentUser: UserApi;
|
||||
|
||||
beforeEach(async () => {
|
||||
@@ -35,6 +38,7 @@ describe("the Drive feature", () => {
|
||||
"statistics",
|
||||
"platform-services",
|
||||
"documents",
|
||||
"email-pusher"
|
||||
],
|
||||
});
|
||||
currentUser = await UserApi.getInstance(platform);
|
||||
@@ -126,4 +130,39 @@ describe("the Drive feature", () => {
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
// Test the email language based on the user's language and the email subject
|
||||
it("Did notify the user after sharing a file in the user's language.", async () => {
|
||||
const oneUser = await UserApi.getInstance(platform, true, { companyRole: "admin", preferences: { language: "en" } });
|
||||
const anotherUser = await UserApi.getInstance(platform, true, { companyRole: "admin", preferences: { language: "fr" }});
|
||||
//upload files
|
||||
const doc = await oneUser.uploadRandomFileAndCreateDocument();
|
||||
const doc2 = await anotherUser.uploadRandomFileAndCreateDocument();
|
||||
|
||||
// shared the file
|
||||
await oneUser.shareWithPermissions(doc, anotherUser.user.id, "read");
|
||||
|
||||
// expect the email to be sent in the receiver's language "fr"
|
||||
expect(buildEmailSpy).toHaveBeenCalledWith(
|
||||
// ignore the template name
|
||||
expect.any(String),
|
||||
// expect the language to be the receiver's language
|
||||
anotherUser.user.preferences?.language || "fr",
|
||||
// ignore the email context
|
||||
expect.any(Object),
|
||||
);
|
||||
|
||||
// do the same for the other user
|
||||
await anotherUser.shareWithPermissions(doc2, oneUser.user.id, "read");
|
||||
|
||||
// expect the email to be sent in the receiver's language "en"
|
||||
expect(buildEmailSpy).toHaveBeenCalledWith(
|
||||
// ignore the template name
|
||||
expect.any(String),
|
||||
// expect the language to be the receiver's language
|
||||
anotherUser.user.preferences?.language || "en",
|
||||
// ignore the email context
|
||||
expect.any(Object),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user