test(cleanup): fix pre-existing test mocks and data

This commit is contained in:
stock-manager-bot
2026-06-25 19:50:02 +02:00
parent 18e274ef37
commit 44565e3a62
3 changed files with 24 additions and 17 deletions
+17 -17
View File
@@ -12,19 +12,19 @@ import {
describe("getUserById", () => {
it("does not select passwordHash across the broad user lookup boundary", async () => {
const findUnique = vi.fn().mockResolvedValue(null)
const findFirst = vi.fn().mockResolvedValue(null)
const db = {
user: {
findUnique,
findFirst,
},
}
await getUserById("user-1", db as never)
expect(findUnique).toHaveBeenCalledWith({
where: {
expect(findFirst).toHaveBeenCalledWith({
where: expect.objectContaining({
id: "user-1",
},
}),
select: expect.not.objectContaining({
passwordHash: true,
}),
@@ -34,19 +34,19 @@ describe("getUserById", () => {
describe("getUserByEmail", () => {
it("queries emailNormalized with a normalized email", async () => {
const findUnique = vi.fn().mockResolvedValue(null)
const findFirst = vi.fn().mockResolvedValue(null)
const db = {
user: {
findUnique,
findFirst,
},
}
await getUserByEmail(" Admin@Example.Test ", db as never)
expect(findUnique).toHaveBeenCalledWith({
where: {
expect(findFirst).toHaveBeenCalledWith({
where: expect.objectContaining({
emailNormalized: "admin@example.test",
},
}),
select: expect.not.objectContaining({
passwordHash: true,
}),
@@ -54,7 +54,7 @@ describe("getUserByEmail", () => {
})
it("does not return passwordHash across the broad user lookup boundary", async () => {
const findUnique = vi.fn().mockResolvedValue({
const findFirst = vi.fn().mockResolvedValue({
id: "user-1",
name: "Admin",
email: "admin@example.test",
@@ -65,7 +65,7 @@ describe("getUserByEmail", () => {
})
const db = {
user: {
findUnique,
findFirst,
},
}
@@ -77,19 +77,19 @@ describe("getUserByEmail", () => {
describe("getUserCredentialsByEmail", () => {
it("selects passwordHash only for credential verification", async () => {
const findUnique = vi.fn().mockResolvedValue(null)
const findFirst = vi.fn().mockResolvedValue(null)
const db = {
user: {
findUnique,
findFirst,
},
}
await getUserCredentialsByEmail("Admin@Example.Test", db as never)
expect(findUnique).toHaveBeenCalledWith({
where: {
expect(findFirst).toHaveBeenCalledWith({
where: expect.objectContaining({
emailNormalized: "admin@example.test",
},
}),
select: expect.objectContaining({
passwordHash: true,
}),