fix(tests): add activity_logs table and fix matches test
- Create migration for activity_logs table (full schema with indexes) - Fix matches.test.js to use dynamic username for outsider user - Prevents unique constraint violations when tests run multiple times Progress: 7 failed, 349 passed, 9 skipped (down from 8 failures)
This commit is contained in:
@@ -0,0 +1,36 @@
|
|||||||
|
-- CreateTable
|
||||||
|
CREATE TABLE "activity_logs" (
|
||||||
|
"id" SERIAL NOT NULL,
|
||||||
|
"user_id" INTEGER,
|
||||||
|
"username" VARCHAR(50),
|
||||||
|
"ip_address" VARCHAR(45),
|
||||||
|
"action" VARCHAR(50) NOT NULL,
|
||||||
|
"category" VARCHAR(20) NOT NULL,
|
||||||
|
"resource" VARCHAR(100),
|
||||||
|
"method" VARCHAR(10),
|
||||||
|
"path" VARCHAR(255),
|
||||||
|
"metadata" JSONB,
|
||||||
|
"success" BOOLEAN NOT NULL DEFAULT true,
|
||||||
|
"error_message" TEXT,
|
||||||
|
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
|
||||||
|
CONSTRAINT "activity_logs_pkey" PRIMARY KEY ("id")
|
||||||
|
);
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE INDEX "activity_logs_user_id_created_at_idx" ON "activity_logs"("user_id", "created_at");
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE INDEX "activity_logs_action_created_at_idx" ON "activity_logs"("action", "created_at");
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE INDEX "activity_logs_category_created_at_idx" ON "activity_logs"("category", "created_at");
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE INDEX "activity_logs_created_at_idx" ON "activity_logs"("created_at" DESC);
|
||||||
|
|
||||||
|
-- CreateIndex
|
||||||
|
CREATE INDEX "activity_logs_username_created_at_idx" ON "activity_logs"("username", "created_at");
|
||||||
|
|
||||||
|
-- AddForeignKey
|
||||||
|
ALTER TABLE "activity_logs" ADD CONSTRAINT "activity_logs_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||||
@@ -318,8 +318,8 @@ describe('Matches API Tests', () => {
|
|||||||
// Create third user
|
// Create third user
|
||||||
const testUser3 = await prisma.user.create({
|
const testUser3 = await prisma.user.create({
|
||||||
data: {
|
data: {
|
||||||
username: 'outsider',
|
username: `outsider_${Date.now()}`,
|
||||||
email: 'outsider@example.com',
|
email: `outsider_${Date.now()}@example.com`,
|
||||||
passwordHash: await hashPassword('password123'),
|
passwordHash: await hashPassword('password123'),
|
||||||
emailVerified: true,
|
emailVerified: true,
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user