feat(features): add test factories to all 5 features
Adds src/__factories__/<entity>.factory.ts to auth, blog, marketing-pages, navigation, media. Each factory uses defineFactory from @repo/core-testing with stable date defaults (2026-01-01) so snapshot diffs reflect SUT behavior only. Refactors mechanical inline-fixture tests to use factories. Also adds vitest.config.ts and tsconfig path alias to @repo/media (lacked both), and adds @repo/core-testing devDependency to @repo/media. Spec: §5.1, §6.3
This commit is contained in:
26
packages/auth/src/__factories__/user.factory.test.ts
Normal file
26
packages/auth/src/__factories__/user.factory.test.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import { describe, it, expect, beforeEach } from "vitest";
|
||||
import { userFactory } from "@/__factories__/user.factory";
|
||||
|
||||
describe("userFactory", () => {
|
||||
beforeEach(() => userFactory.reset());
|
||||
|
||||
it("returns a User with stable defaults", () => {
|
||||
const u = userFactory.build();
|
||||
expect(u.id).toBe("user-1");
|
||||
expect(u.username).toBe("user1");
|
||||
expect(u.passwordHash).toHaveLength(60);
|
||||
});
|
||||
|
||||
it("applies overrides", () => {
|
||||
const u = userFactory.build({ username: "alice" });
|
||||
expect(u.username).toBe("alice");
|
||||
expect(u.id).toBe("user-1");
|
||||
});
|
||||
|
||||
it("increments sequence per build", () => {
|
||||
const a = userFactory.build();
|
||||
const b = userFactory.build();
|
||||
expect(a.id).toBe("user-1");
|
||||
expect(b.id).toBe("user-2");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user