feat: add stock database with prisma for portfolio persistence
- Initialize Prisma with SQLite and Stock model - Create database service layer with singleton client - Add API routes for stock CRUD operations - Integrate database with analyze page to persist ticker entries - Add Playwright tests for stock database functionality
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
import { test, expect } from "@playwright/test";
|
||||
|
||||
test.describe("Stock Database", () => {
|
||||
test("should add and list stocks", async ({ request }) => {
|
||||
const uniqueTicker = `TEST${Date.now()}`;
|
||||
|
||||
const createRes = await request.post("/api/stocks", {
|
||||
form: { ticker: uniqueTicker },
|
||||
});
|
||||
expect(createRes.ok()).toBeTruthy();
|
||||
|
||||
const listRes = await request.get("/api/stocks");
|
||||
const stocks = await listRes.json();
|
||||
expect(stocks).toContainEqual(expect.objectContaining({ ticker: uniqueTicker }));
|
||||
});
|
||||
|
||||
test("should persist tickers after page reload", async ({ request, page }) => {
|
||||
const uniqueTicker = `PERSIST${Date.now()}`;
|
||||
|
||||
await request.post("/api/stocks", {
|
||||
form: { ticker: uniqueTicker },
|
||||
});
|
||||
|
||||
await page.goto("/stocks");
|
||||
await page.waitForLoadState("networkidle");
|
||||
|
||||
const listRes = await request.get("/api/stocks");
|
||||
const stocks = await listRes.json();
|
||||
expect(stocks).toContainEqual(expect.objectContaining({ ticker: uniqueTicker }));
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user