|
@@ -1,11 +1,5 @@
|
|
|
/* @vitest-environment node */
|
|
/* @vitest-environment node */
|
|
|
|
|
|
|
|
-// ---------------------------------------------------------------------------
|
|
|
|
|
-// Folder: lib/frontend
|
|
|
|
|
-// File: authMessages.test.js
|
|
|
|
|
-// Relative Path: lib/frontend/authMessages.test.js
|
|
|
|
|
-// ---------------------------------------------------------------------------
|
|
|
|
|
-
|
|
|
|
|
import { describe, it, expect } from "vitest";
|
|
import { describe, it, expect } from "vitest";
|
|
|
import { ApiClientError } from "@/lib/frontend/apiClient";
|
|
import { ApiClientError } from "@/lib/frontend/apiClient";
|
|
|
import { LOGIN_REASONS } from "@/lib/frontend/authRedirect";
|
|
import { LOGIN_REASONS } from "@/lib/frontend/authRedirect";
|
|
@@ -15,15 +9,16 @@ describe("lib/frontend/authMessages", () => {
|
|
|
describe("getLoginReasonAlert", () => {
|
|
describe("getLoginReasonAlert", () => {
|
|
|
it("returns alert copy for reason=expired", () => {
|
|
it("returns alert copy for reason=expired", () => {
|
|
|
expect(getLoginReasonAlert(LOGIN_REASONS.EXPIRED)).toEqual({
|
|
expect(getLoginReasonAlert(LOGIN_REASONS.EXPIRED)).toEqual({
|
|
|
- title: "Session expired",
|
|
|
|
|
- description: "Your session has expired. Please log in again.",
|
|
|
|
|
|
|
+ title: "Sitzung abgelaufen",
|
|
|
|
|
+ description:
|
|
|
|
|
+ "Ihre Sitzung ist abgelaufen. Bitte melden Sie sich erneut an.",
|
|
|
});
|
|
});
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
it("returns alert copy for reason=logged-out", () => {
|
|
it("returns alert copy for reason=logged-out", () => {
|
|
|
expect(getLoginReasonAlert(LOGIN_REASONS.LOGGED_OUT)).toEqual({
|
|
expect(getLoginReasonAlert(LOGIN_REASONS.LOGGED_OUT)).toEqual({
|
|
|
- title: "Logged out",
|
|
|
|
|
- description: "You have been logged out successfully.",
|
|
|
|
|
|
|
+ title: "Abgemeldet",
|
|
|
|
|
+ description: "Sie wurden erfolgreich abgemeldet.",
|
|
|
});
|
|
});
|
|
|
});
|
|
});
|
|
|
|
|
|
|
@@ -41,7 +36,9 @@ describe("lib/frontend/authMessages", () => {
|
|
|
message: "Invalid credentials",
|
|
message: "Invalid credentials",
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
- expect(getLoginErrorMessage(err)).toBe("Invalid username or password.");
|
|
|
|
|
|
|
+ expect(getLoginErrorMessage(err)).toBe(
|
|
|
|
|
+ "Benutzername oder Passwort ist falsch."
|
|
|
|
|
+ );
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
it("maps CLIENT_NETWORK_ERROR to a friendly message", () => {
|
|
it("maps CLIENT_NETWORK_ERROR to a friendly message", () => {
|
|
@@ -52,13 +49,13 @@ describe("lib/frontend/authMessages", () => {
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
expect(getLoginErrorMessage(err)).toBe(
|
|
expect(getLoginErrorMessage(err)).toBe(
|
|
|
- "Network error. Please check your connection and try again."
|
|
|
|
|
|
|
+ "Netzwerkfehler. Bitte prüfen Sie Ihre Verbindung und versuchen Sie es erneut."
|
|
|
);
|
|
);
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
it("uses a generic message for other errors", () => {
|
|
it("uses a generic message for other errors", () => {
|
|
|
expect(getLoginErrorMessage(new Error("boom"))).toBe(
|
|
expect(getLoginErrorMessage(new Error("boom"))).toBe(
|
|
|
- "Login failed. Please try again."
|
|
|
|
|
|
|
+ "Anmeldung fehlgeschlagen. Bitte erneut versuchen."
|
|
|
);
|
|
);
|
|
|
});
|
|
});
|
|
|
});
|
|
});
|