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

test.describe('Gift Wrapping', () => {
    test('GW-001 @gift-wrapping: Box + Kinchaku pairable', async ({ page, addToCartAndCheckout }) => {
        test.setTimeout(120_000);
        await addToCartAndCheckout('radiant_touch_2');
        const giftWrap = page.locator(':text("Gift"), :text("ギフト"), :text("wrapping"), :text("ラッピング")').first();
        const hasWrap = await giftWrap.isVisible().catch(() => false);
        test.skip(!hasWrap, 'Gift wrapping not available on checkout');
        expect(hasWrap, 'GW-001: Gift wrapping should be available for Radiant Touch').toBeTruthy();
    });

    test('GW-002 @gift-wrapping: NOT pairable product', async ({ page, addToCartAndCheckout }) => {
        test.setTimeout(120_000);
        await addToCartAndCheckout('genifique_30ml_trial_kit');
        const giftWrap = page.locator(':text("Gift"), :text("ギフト"), :text("wrapping"), :text("ラッピング")').first();
        const hasWrap = await giftWrap.isVisible().catch(() => false);
        test.skip(!hasWrap, 'Gift wrapping not available');
    });

    test('GW-003 @gift-wrapping: Kinchaku only pairable', async ({ page, addToCartAndCheckout }) => {
        test.setTimeout(120_000);
        await addToCartAndCheckout('cosme_decorte_facial_cotton');
        const giftWrap = page.locator(':text("Gift"), :text("ギフト"), :text("wrapping"), :text("ラッピング")').first();
        await expect(giftWrap).toBeVisible({ timeout: 15000 });
    });

    test('GW-004 @gift-wrapping: Bottle bag only', async ({ page, addToCartAndCheckout }) => {
        test.setTimeout(120_000);
        await addToCartAndCheckout('lillet_blanc_750ml');
        const giftWrap = page.locator(':text("Gift"), :text("ギフト"), :text("wrapping"), :text("ラッピング")').first();
        const hasWrap = await giftWrap.isVisible().catch(() => false);
        test.skip(!hasWrap, 'Gift wrapping not available');
    });

    test('GW-005 @gift-wrapping: Sender name required', async ({ page, addToCartAndCheckout }) => {
        test.setTimeout(120_000);
        await addToCartAndCheckout('radiant_touch_2');
        // Enable gift wrapping but leave sender blank, try to place order
        test.skip(true, 'Requires interactive gift wrapping UI testing');
    });

    test('GW-006 @gift-wrapping: Pair 2 items', async ({ page, addToCart, addToCartAndCheckout }) => {
        test.setTimeout(120_000);
        // Add same product twice
        await addToCart('radiant_touch_2');
        await addToCartAndCheckout('radiant_touch_2');
        const giftWrap = page.locator(':text("Gift"), :text("ギフト")').first();
        test.skip(!(await giftWrap.isVisible().catch(() => false)), 'Gift wrapping not visible');
    });

    test('GW-007 @gift-wrapping: Cannot pair more than 2', async ({ page }) => {
        test.skip(true, 'Requires adding 4 items and testing pair limit UI');
    });

    test('GW-008 @gift-wrapping: Qty 2 shows 2 wrapping lines', async ({ page }) => {
        test.skip(true, 'Requires qty=2 and verifying wrapping line count');
    });

    test('GW-009 @gift-wrapping: Remove wrapped item', async ({ page }) => {
        test.skip(true, 'Requires wrapping an item then removing from cart');
    });

    test('GW-010 @gift-wrapping: Decrease qty breaks pair', async ({ page }) => {
        test.skip(true, 'Requires qty=2 paired, then decrease to 1');
    });

    test('GW-011 @gift-wrapping: Shopping bag checkbox', async ({ page }) => {
        test.skip(true, 'Requires interactive shopping bag checkbox testing');
    });

    test('GW-012 @gift-wrapping: Wrapping persists after refresh', async ({ page }) => {
        test.skip(true, 'Requires setting wrapping, refreshing, verifying');
    });

    test('GW-013 @gift-wrapping: New order starts fresh', async ({ page }) => {
        test.skip(true, 'Requires completing one order then starting new');
    });
});
