fix(tests): align maskEmail test assertions with new less-aggressive masking behavior

Updated mask-email.test.mjs and model-sync-route.test.mjs to match
the revised maskEmail function that preserves full domain names for
account differentiation (die********@gmail.com vs old di*********@g****.com).
This commit is contained in:
diegosouzapw
2026-04-11 12:09:20 -03:00
parent 86fc7841b8
commit e89015649e
3 changed files with 6 additions and 6 deletions

View File

@@ -5,7 +5,7 @@
* to prevent identity exposure in dashboards and logs.
*
* @example
* maskEmail("diego.souza@gmail.com") // "di*********@g****.com"
* maskEmail("diego.souza@gmail.com") // "die********@gmail.com"
* maskEmail("a@b.com") // "a@b.com" (too short to mask)
*/
export function maskEmail(email: string | null | undefined, visibleChars = 3): string {

View File

@@ -8,7 +8,7 @@ import {
describe("maskEmail", () => {
it("masks standard email correctly", () => {
assert.equal(maskEmail("diego.souza@gmail.com"), "di*********@g****.com");
assert.equal(maskEmail("diego.souza@gmail.com"), "die********@gmail.com");
});
it("masks email with short username (exactly visibleChars)", () => {
@@ -18,7 +18,7 @@ describe("maskEmail", () => {
it("masks email with longer username", () => {
const result = maskEmail("hello@example.com");
assert.equal(result, "he***@e******.com");
assert.equal(result, "hel**@example.com");
});
it("returns empty string for null", () => {
@@ -54,14 +54,14 @@ describe("maskEmail", () => {
});
it("masks email-like values stored in generic labels", () => {
assert.equal(maskEmailLikeValue("person@example.com"), "pe****@e******.com");
assert.equal(maskEmailLikeValue("person@example.com"), "per***@example.com");
assert.equal(maskEmailLikeValue("Work Account"), "Work Account");
});
it("picks the first non-empty masked display value", () => {
assert.equal(
pickMaskedDisplayValue(["", "person@example.com", "fallback"], "fallback"),
"pe****@e******.com"
"per***@example.com"
);
assert.equal(pickMaskedDisplayValue([null, "Workspace"], "fallback"), "Workspace");
});

View File

@@ -435,7 +435,7 @@ test("model sync route records added, removed, and updated model diffs with fall
assert.equal(logs.length, 1);
assert.equal(logs[0].status, 200);
assert.equal(logs[0].provider, "openrouter");
assert.ok(logs[0].account.includes("**"), `Expected masked email, got: ${logs[0].account}`);
assert.ok(logs[0].account.includes("*"), `Expected masked email, got: ${logs[0].account}`);
});
test("model sync route accepts external API-key auth, forwards cookies, filters built-ins, and syncs aliases", async () => {