feat(tests): update Alpaca API tests to include range parameters and improve stock database cleanup
Run Tests / test (push) Failing after 8s
Run Tests / test (push) Failing after 8s
- Modified Alpaca Historical Bars tests to include range parameters in API requests. - Updated test descriptions for clarity. - Added cleanup step to delete test ticker after verification in stock database tests. - Adjusted Vitest configuration to exclude test files from coverage.
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
import { test, expect } from "@playwright/test";
|
||||
|
||||
test.describe("Alpaca Historical Bars", () => {
|
||||
test("should return bars for AAPL with 1D timeframe", async ({ page }) => {
|
||||
const response = await page.request.get("/api/alpaca/quote/AAPL");
|
||||
test("should return bars for AAPL with 1D timeframe and 1M range", async ({ page }) => {
|
||||
const response = await page.request.get("/api/alpaca/quote/AAPL?range=1M");
|
||||
expect(response.ok()).toBeTruthy();
|
||||
|
||||
const data = await response.json();
|
||||
@@ -18,8 +18,8 @@ test.describe("Alpaca Historical Bars", () => {
|
||||
expect(bar.c).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
test("should return bars for AAPL with 5Min timeframe", async ({ page }) => {
|
||||
const response = await page.request.get("/api/alpaca/quote/AAPL?timeframe=5Min&limit=5");
|
||||
test("should return bars for AAPL with 5Min timeframe and 1W range", async ({ page }) => {
|
||||
const response = await page.request.get("/api/alpaca/quote/AAPL?timeframe=5Min&range=1W");
|
||||
expect(response.ok()).toBeTruthy();
|
||||
|
||||
const data = await response.json();
|
||||
@@ -27,8 +27,8 @@ test.describe("Alpaca Historical Bars", () => {
|
||||
expect(data.bars.length).toBeGreaterThanOrEqual(0);
|
||||
});
|
||||
|
||||
test("should return bars for AAPL with 1H timeframe", async ({ page }) => {
|
||||
const response = await page.request.get("/api/alpaca/quote/AAPL?timeframe=1H&limit=10");
|
||||
test("should return bars for AAPL with 1H timeframe and ALL range", async ({ page }) => {
|
||||
const response = await page.request.get("/api/alpaca/quote/AAPL?timeframe=1H&range=ALL");
|
||||
expect(response.ok()).toBeTruthy();
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
@@ -13,6 +13,12 @@ test.describe("Stock Database", () => {
|
||||
const listRes = await page.request.get("/api/stocks");
|
||||
const stocks = await listRes.json();
|
||||
expect(stocks).toContainEqual(expect.objectContaining({ ticker: uniqueTicker }));
|
||||
|
||||
// Cleanup: delete the test ticker
|
||||
await page.request.post("/api/stocks", {
|
||||
data: new URLSearchParams({ ticker: uniqueTicker, _method: "DELETE" }).toString(),
|
||||
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
||||
});
|
||||
});
|
||||
|
||||
test("should delete stock from database", async ({ page }) => {
|
||||
|
||||
Reference in New Issue
Block a user