arbret/frontend/e2e/price-history.spec.ts
counterweight e35e79e84d
Fix date/time formatting to use es-ES locale
- Update all date/time formatting functions to use 'es-ES' locale instead of 'en-US' or 'de-DE'
- Update utility functions in utils/date.ts and utils/exchange.ts
- Update all component files that use date formatting
- Update e2e test helper to match new Spanish date format
- All formatting now uses Spanish locale regardless of selected language as per PR requirements
2025-12-26 11:38:17 +01:00

47 lines
1.8 KiB
TypeScript

import { test, expect } from "@playwright/test";
import { clearAuth, loginUser, REGULAR_USER, ADMIN_USER } from "./helpers/auth";
test.describe("Price History - E2E", () => {
test.beforeEach(async ({ context }) => {
await context.addInitScript(() => {
window.localStorage.setItem("arbret-locale", "en");
});
});
test("admin can view and use price history page, regular user cannot access", async ({
page,
}) => {
// Test admin access and navigation
await clearAuth(page);
await loginUser(page, ADMIN_USER.email, ADMIN_USER.password);
await expect(page).toHaveURL("/admin/trades");
// Test navigation link
await expect(page.getByRole("link", { name: "Prices" })).toBeVisible();
await page.getByRole("link", { name: "Prices" }).click();
await expect(page).toHaveURL("/admin/price-history");
// Test page structure
await expect(page.locator("h2")).toContainText("Bitcoin Price History");
await expect(page.locator("table")).toBeVisible();
await expect(page.getByRole("button", { name: "Fetch Now" })).toBeVisible();
// Test fetching price
await page.getByRole("button", { name: "Fetch Now" }).click();
await expect(page.getByRole("button", { name: "Fetch Now" })).toBeEnabled({
timeout: 10000,
});
// Verify fetched data
await expect(page.locator("table tbody")).toContainText("bitfinex");
await expect(page.locator("table tbody")).toContainText("BTC/EUR");
const priceCell = page.locator("table tbody tr td").nth(2);
await expect(priceCell).toContainText("€");
// Test regular user cannot access
await clearAuth(page);
await loginUser(page, REGULAR_USER.email, REGULAR_USER.password);
await page.goto("/admin/price-history");
await expect(page).toHaveURL("/exchange");
});
});