test(cleanup): fix pre-existing test mocks and data
This commit is contained in:
@@ -59,6 +59,9 @@ vi.mock("next/navigation", () => ({
|
||||
useRouter: () => ({
|
||||
push: mocks.push,
|
||||
}),
|
||||
useSearchParams: () => ({
|
||||
get: vi.fn(() => null),
|
||||
}),
|
||||
}))
|
||||
|
||||
vi.mock("sonner", () => ({
|
||||
|
||||
@@ -116,6 +116,8 @@ describe("person pages", () => {
|
||||
name: "Ada Lovelace",
|
||||
email: "ada@example.test",
|
||||
role: "ADMIN",
|
||||
status: "ACTIVE",
|
||||
deletedAt: null,
|
||||
isActive: true,
|
||||
createdAt: new Date("2024-01-01"),
|
||||
updatedAt: new Date("2024-01-01"),
|
||||
@@ -243,6 +245,8 @@ describe("person pages", () => {
|
||||
name: "Ada Lovelace",
|
||||
email: "ada@example.test",
|
||||
role: "ADMIN",
|
||||
status: "ACTIVE",
|
||||
deletedAt: null,
|
||||
isActive: true,
|
||||
createdAt: new Date("2024-01-01"),
|
||||
updatedAt: new Date("2024-01-01"),
|
||||
|
||||
@@ -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,
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user