Deleted deprecated files: - backend/routes/booking.py - frontend/app/admin/appointments/, booking/, appointments/, sum/, audit/ - frontend/app/utils/appointment.ts - frontend/e2e/booking.spec.ts, appointments.spec.ts Updated references: - exchange/page.tsx: Use /api/exchange/slots instead of /api/booking/slots - useRequireAuth.ts: Redirect to /admin/trades and /exchange - profile.tsx, invites.tsx: Update fallback redirect - E2E tests: Update all /audit references to /admin/trades - profile.test.tsx: Update admin redirect test
74 lines
2.7 KiB
TypeScript
74 lines
2.7 KiB
TypeScript
import { test, expect } from "@playwright/test";
|
|
import { clearAuth, loginUser, REGULAR_USER, ADMIN_USER } from "./helpers/auth";
|
|
|
|
test.describe("Price History - E2E", () => {
|
|
test("admin can view price history page", async ({ page }) => {
|
|
await clearAuth(page);
|
|
await loginUser(page, ADMIN_USER.email, ADMIN_USER.password);
|
|
|
|
await page.goto("/admin/price-history");
|
|
await expect(page).toHaveURL("/admin/price-history");
|
|
|
|
// Page title should be visible
|
|
await expect(page.locator("h2")).toContainText("Bitcoin Price History");
|
|
|
|
// Table should exist
|
|
await expect(page.locator("table")).toBeVisible();
|
|
|
|
// Fetch Now button should exist
|
|
await expect(page.getByRole("button", { name: "Fetch Now" })).toBeVisible();
|
|
});
|
|
|
|
test("admin can manually fetch price from Bitfinex", async ({ page }) => {
|
|
await clearAuth(page);
|
|
await loginUser(page, ADMIN_USER.email, ADMIN_USER.password);
|
|
|
|
await page.goto("/admin/price-history");
|
|
await expect(page).toHaveURL("/admin/price-history");
|
|
|
|
// Click the Fetch Now button
|
|
await page.getByRole("button", { name: "Fetch Now" }).click();
|
|
|
|
// Wait for the button to become enabled again (fetch completed)
|
|
await expect(page.getByRole("button", { name: "Fetch Now" })).toBeEnabled({
|
|
timeout: 10000,
|
|
});
|
|
|
|
// The table should now contain a record with bitfinex as source
|
|
await expect(page.locator("table tbody")).toContainText("bitfinex");
|
|
|
|
// Should have BTC/EUR pair
|
|
await expect(page.locator("table tbody")).toContainText("BTC/EUR");
|
|
|
|
// Price should be visible and formatted as EUR
|
|
// The price cell should contain a € symbol
|
|
const priceCell = page.locator("table tbody tr td").nth(2);
|
|
await expect(priceCell).toContainText("€");
|
|
});
|
|
|
|
test("regular user cannot access price history page", async ({ page }) => {
|
|
await clearAuth(page);
|
|
await loginUser(page, REGULAR_USER.email, REGULAR_USER.password);
|
|
|
|
// Try to navigate directly to the admin page
|
|
await page.goto("/admin/price-history");
|
|
|
|
// Should be redirected away (to "/" since fallbackRedirect is "/")
|
|
await expect(page).toHaveURL("/");
|
|
});
|
|
|
|
test("price history shows in navigation for admin", async ({ page }) => {
|
|
await clearAuth(page);
|
|
await loginUser(page, ADMIN_USER.email, ADMIN_USER.password);
|
|
|
|
// Admin should be on admin trades page by default
|
|
await expect(page).toHaveURL("/admin/trades");
|
|
|
|
// Prices nav link should be visible
|
|
await expect(page.getByRole("link", { name: "Prices" })).toBeVisible();
|
|
|
|
// Click on Prices link
|
|
await page.getByRole("link", { name: "Prices" }).click();
|
|
await expect(page).toHaveURL("/admin/price-history");
|
|
});
|
|
});
|