3340fd11ca
- 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
31 lines
1023 B
TypeScript
31 lines
1023 B
TypeScript
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 }));
|
|
});
|
|
}); |