more merging
This commit is contained in:
parent
67ffe6a823
commit
d6f955d2d9
5 changed files with 107 additions and 251 deletions
|
|
@ -40,7 +40,7 @@ test.describe("Exchange Page - Regular User Access", () => {
|
|||
await loginUser(page, REGULAR_USER.email, REGULAR_USER.password);
|
||||
});
|
||||
|
||||
test("regular user can access exchange page and all UI elements are visible", async ({
|
||||
test("regular user can access exchange page, all UI elements work, and buy/sell toggle functions", async ({
|
||||
page,
|
||||
}) => {
|
||||
// Test navigation
|
||||
|
|
@ -56,10 +56,15 @@ test.describe("Exchange Page - Regular User Access", () => {
|
|||
await expect(page.getByText("Market:")).toBeVisible();
|
||||
await expect(page.getByText("Our price:")).toBeVisible();
|
||||
|
||||
// Test buy/sell toggle
|
||||
await expect(page.getByRole("button", { name: "Buy BTC" })).toBeVisible();
|
||||
// Test buy/sell toggle visibility and functionality
|
||||
const buyButton = page.getByRole("button", { name: "Buy BTC" });
|
||||
await expect(buyButton).toBeVisible();
|
||||
await expect(page.getByRole("button", { name: "Sell BTC" })).toBeVisible();
|
||||
|
||||
// Test clicking buy/sell changes direction
|
||||
await page.getByRole("button", { name: "Sell BTC" }).click();
|
||||
await expect(page.getByText(/You buy €\d/)).toBeVisible();
|
||||
|
||||
// Test payment method selector
|
||||
await expect(page.getByText("Payment Method")).toBeVisible();
|
||||
await expect(page.getByRole("button", { name: /Onchain/ })).toBeVisible();
|
||||
|
|
@ -68,33 +73,10 @@ test.describe("Exchange Page - Regular User Access", () => {
|
|||
// Test amount slider
|
||||
await expect(page.getByText("Amount")).toBeVisible();
|
||||
await expect(page.locator('input[type="range"]')).toBeVisible();
|
||||
});
|
||||
|
||||
test("clicking buy/sell changes direction", async ({ page }) => {
|
||||
await page.goto("/exchange");
|
||||
|
||||
// Initially in buy mode - summary shows BTC first: "You buy [sats], you sell €X"
|
||||
// Verify buy mode is initially active
|
||||
const buyButton = page.getByRole("button", { name: "Buy BTC" });
|
||||
await expect(buyButton).toBeVisible();
|
||||
|
||||
// Click Sell BTC to switch direction
|
||||
await page.getByRole("button", { name: "Sell BTC" }).click();
|
||||
|
||||
// In sell mode, the summary shows EUR first: "You buy €X, you sell [sats]"
|
||||
// We can verify by checking the summary text contains "You buy €" (EUR comes first)
|
||||
await expect(page.getByText(/You buy €\d/)).toBeVisible();
|
||||
});
|
||||
|
||||
test("exchange page shows date selection after continue", async ({ page }) => {
|
||||
await page.goto("/exchange");
|
||||
|
||||
// Step 1: Click "Continue to Booking" to proceed to step 2
|
||||
// Test date selection appears after continue
|
||||
await page.getByRole("button", { name: "Continue to Booking" }).click();
|
||||
|
||||
// Step 2: Now date selection should be visible
|
||||
await expect(page.getByRole("heading", { name: "Select a Date" })).toBeVisible();
|
||||
// Should see multiple date buttons
|
||||
const dateButtons = page
|
||||
.locator("button")
|
||||
.filter({ hasText: /^(Mon|Tue|Wed|Thu|Fri|Sat|Sun)/ });
|
||||
|
|
@ -163,10 +145,10 @@ test.describe("Exchange Page - With Availability", () => {
|
|||
await expect(page.getByText("Payment:")).toBeVisible();
|
||||
});
|
||||
|
||||
test("payment method selector works", async ({ page }) => {
|
||||
test("payment method selector works and lightning disabled above threshold", async ({ page }) => {
|
||||
await page.goto("/exchange");
|
||||
|
||||
// Default should be Onchain
|
||||
// Test payment method selector
|
||||
const onchainButton = page.getByRole("button", { name: /Onchain/ });
|
||||
const lightningButton = page.getByRole("button", { name: /Lightning/ });
|
||||
await expect(onchainButton).toHaveCSS("border-color", "rgb(167, 139, 250)");
|
||||
|
|
@ -179,20 +161,11 @@ test.describe("Exchange Page - With Availability", () => {
|
|||
// Click back to Onchain
|
||||
await onchainButton.click();
|
||||
await expect(onchainButton).toHaveCSS("border-color", "rgb(167, 139, 250)");
|
||||
});
|
||||
|
||||
test("lightning disabled above threshold", async ({ page }) => {
|
||||
await page.goto("/exchange");
|
||||
|
||||
// Set amount above threshold (€1000 = 100000 cents)
|
||||
// Test lightning disabled above threshold
|
||||
const amountInput = page.locator('input[type="text"]').filter({ hasText: "" });
|
||||
await amountInput.fill("1100");
|
||||
|
||||
// Lightning button should be disabled
|
||||
const lightningButton = page.getByRole("button", { name: /Lightning/ });
|
||||
await expect(lightningButton).toBeDisabled();
|
||||
|
||||
// Should show threshold message
|
||||
await expect(page.getByText(/Lightning payments are only available/)).toBeVisible();
|
||||
});
|
||||
});
|
||||
|
|
@ -249,27 +222,18 @@ test.describe("Admin Trades Page", () => {
|
|||
await loginUser(page, ADMIN_USER.email, ADMIN_USER.password);
|
||||
});
|
||||
|
||||
test("admin can access trades page", async ({ page }) => {
|
||||
test("admin can access trades page with tabs, regular user cannot", async ({ page }) => {
|
||||
// Test admin access
|
||||
await page.goto("/admin/trades");
|
||||
|
||||
await expect(page).toHaveURL("/admin/trades");
|
||||
await expect(page.getByRole("heading", { name: "Trades" })).toBeVisible();
|
||||
});
|
||||
|
||||
test("admin trades page shows tabs", async ({ page }) => {
|
||||
await page.goto("/admin/trades");
|
||||
|
||||
await expect(page.getByRole("button", { name: /Upcoming/ })).toBeVisible();
|
||||
await expect(page.getByRole("button", { name: /History/ })).toBeVisible();
|
||||
});
|
||||
|
||||
test("regular user cannot access admin trades page", async ({ page }) => {
|
||||
// Test regular user cannot access
|
||||
await clearAuth(page);
|
||||
await loginUser(page, REGULAR_USER.email, REGULAR_USER.password);
|
||||
|
||||
await page.goto("/admin/trades");
|
||||
|
||||
// Should be redirected away
|
||||
await expect(page).not.toHaveURL("/admin/trades");
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue