merged tests
This commit is contained in:
parent
4be45f8f7c
commit
67ffe6a823
7 changed files with 212 additions and 599 deletions
|
|
@ -2,73 +2,40 @@ 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 }) => {
|
||||
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");
|
||||
|
||||
await page.goto("/admin/price-history");
|
||||
// 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");
|
||||
|
||||
// Page title should be visible
|
||||
// Test page structure
|
||||
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
|
||||
// Test fetching price
|
||||
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
|
||||
// Verify fetched data
|
||||
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 }) => {
|
||||
// Test regular user cannot access
|
||||
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 (regular users go to /exchange)
|
||||
await expect(page).toHaveURL("/exchange");
|
||||
});
|
||||
|
||||
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");
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue