From 4cd2872d6aa20a91e355c7da52fbc41e05127e79 Mon Sep 17 00:00:00 2001 From: counterweight Date: Fri, 26 Dec 2025 22:39:18 +0100 Subject: [PATCH] Merge related e2e tests to reduce redundancy - Merge 'admin can access pricing page and UI elements are correct' with 'can view current pricing configuration' into single test - Merge 'can update pricing configuration' with 'form fields update correctly when values change' into single test - Reduced from 9 tests to 7 tests while maintaining same coverage - All 40 e2e tests still passing --- frontend/e2e/admin-pricing.spec.ts | 65 +++++++++--------------------- 1 file changed, 18 insertions(+), 47 deletions(-) diff --git a/frontend/e2e/admin-pricing.spec.ts b/frontend/e2e/admin-pricing.spec.ts index 6db91d8..9bf73ee 100644 --- a/frontend/e2e/admin-pricing.spec.ts +++ b/frontend/e2e/admin-pricing.spec.ts @@ -17,7 +17,9 @@ test.describe("Admin Pricing Page - Admin Access", () => { await loginUser(page, ADMIN_USER.email, ADMIN_USER.password); }); - test("admin can access pricing page and UI elements are correct", async ({ page }) => { + test("admin can access pricing page, view UI elements and current configuration", async ({ + page, + }) => { // Test navigation link await page.goto("/admin/trades"); const pricingLink = page.locator('a[href="/admin/pricing"]'); @@ -51,24 +53,9 @@ test.describe("Admin Pricing Page - Admin Access", () => { // Check save button is present await expect(page.getByRole("button", { name: /Save Changes/i })).toBeVisible(); - }); - test("can view current pricing configuration", async ({ page }) => { - // Set up response listener before navigation - const responsePromise = page.waitForResponse( - (resp) => resp.url().includes("/api/admin/pricing") && resp.request().method() === "GET" - ); - await page.goto("/admin/pricing"); - - // Wait for API call to complete and form to render - await responsePromise; - await expect(page.getByRole("heading", { name: "Pricing Configuration" })).toBeVisible({ - timeout: 10000, - }); - - // Wait for inputs to be visible + // Check that form fields have loaded values const inputs = page.locator('input[type="number"]'); - await expect(inputs.first()).toBeVisible({ timeout: 5000 }); const count = await inputs.count(); expect(count).toBeGreaterThan(0); @@ -80,7 +67,7 @@ test.describe("Admin Pricing Page - Admin Access", () => { expect(sellValue).not.toBe(""); }); - test("can update pricing configuration", async ({ page }) => { + test("can update pricing configuration and form fields update correctly", async ({ page }) => { // Set up response listener before navigation const responsePromise = page.waitForResponse( (resp) => resp.url().includes("/api/admin/pricing") && resp.request().method() === "GET" @@ -96,6 +83,19 @@ test.describe("Admin Pricing Page - Admin Access", () => { // Wait for inputs to be visible const inputs = page.locator('input[type="number"]'); await expect(inputs.first()).toBeVisible({ timeout: 5000 }); + + // Test that form fields update correctly when values change + const smallTradeThresholdInput = inputs.nth(2); + const currentThreshold = await smallTradeThresholdInput.inputValue(); + const newThreshold = currentThreshold === "200" ? "250" : "200"; + await smallTradeThresholdInput.clear(); + await smallTradeThresholdInput.fill(newThreshold); + + // Verify the value is set immediately + const updatedThreshold = await smallTradeThresholdInput.inputValue(); + expect(updatedThreshold).toBe(newThreshold); + + // Now test updating and saving a different field const premiumBuyInput = inputs.nth(0); const currentBuyValue = await premiumBuyInput.inputValue(); const newBuyValue = currentBuyValue === "5" ? "6" : "5"; @@ -188,35 +188,6 @@ test.describe("Admin Pricing Page - Admin Access", () => { timeout: 2000, }); }); - - test("form fields update correctly when values change", async ({ page }) => { - // Set up response listener before navigation - const responsePromise = page.waitForResponse( - (resp) => resp.url().includes("/api/admin/pricing") && resp.request().method() === "GET" - ); - await page.goto("/admin/pricing"); - - // Wait for API call to complete and form to render - await responsePromise; - await expect(page.getByRole("heading", { name: "Pricing Configuration" })).toBeVisible({ - timeout: 10000, - }); - - // Wait for inputs to be visible - const inputs = page.locator('input[type="number"]'); - await expect(inputs.first()).toBeVisible({ timeout: 5000 }); - const smallTradeThresholdInput = inputs.nth(2); - const currentThreshold = await smallTradeThresholdInput.inputValue(); - - // Update threshold - const newThreshold = currentThreshold === "200" ? "250" : "200"; - await smallTradeThresholdInput.clear(); - await smallTradeThresholdInput.fill(newThreshold); - - // Verify the value is set - const updatedThreshold = await smallTradeThresholdInput.inputValue(); - expect(updatedThreshold).toBe(newThreshold); - }); }); test.describe("Admin Pricing Page - Access Control", () => {