import { test, expect } from '../../fixtures/test-base';
import { siteConfig } from '../../config/siteConfig';

test.describe('Coupons', () => {
    test('CPN-018 @coupons: Guest promo code not shown', async ({ page, addToCartAndCheckout }) => {
        test.setTimeout(120_000);
        await addToCartAndCheckout('cotton_knit_cardigan_swing');
        const promoSection = page.locator(':text("Promo"), :text("Coupon"), :text("クーポン"), input[placeholder*="coupon" i], input[placeholder*="promo" i]').first();
        const hasPromo = await promoSection.isVisible().catch(() => false);
        expect(hasPromo, 'CPN-018: Promo code section should NOT be shown for guest').toBeFalsy();
    });

    test('CPN-019 @coupons: Invalid coupon code', async ({ page, addToCartAndCheckout }) => {
        test.setTimeout(120_000);
        test.skip(!siteConfig.auth.testEmail, 'Need logged-in user for coupon input');
        // Logged in user should see coupon input
    });

    test('CPN-020 @coupons: Remove a coupon', async ({ page }) => {
        test.setTimeout(120_000);
        test.skip(true, 'Requires applying then removing a valid coupon');
    });

    test('CPN-021 @coupons: Coupon + points together', async ({ page }) => {
        test.setTimeout(120_000);
        test.skip(!siteConfig.auth.testEmail, 'Requires logged-in user with points');
    });
});
