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

test.describe('Alcohol', () => {
    test('ALC-001 @alcohol: Eligible customer can order', async ({ page, addToCartAndCheckout }) => {
        test.setTimeout(120_000);
        test.skip(!siteConfig.auth.testEmail, 'Test credentials required');
        await loginViaUI(page, siteConfig.auth.testEmail!, siteConfig.auth.testPassword!);
        await addToCartAndCheckout('glenmorangie_lasanta_15');
        // Should see alcohol acknowledgement / age verification
        const alcoholNotice = page.locator(':text("alcohol"), :text("酒"), :text("age"), :text("年齢"), :text("20歳"), :text("twenty"), :text("legal age"), :text("confirmation"), :text("confirm")').first();
        const hasNotice = await alcoholNotice.isVisible().catch(() => false);
        expect(hasNotice, 'ALC-001: Alcohol acknowledgement or age verification should be shown').toBeTruthy();
    });

    test('ALC-002 @alcohol: Not eligible customer blocked', async ({ page, addToCartAndCheckout }) => {
        test.setTimeout(120_000);
        test.skip(true, 'Requires a user account without birthdate');
    });

    test('ALC-003 @alcohol: Cold shipping surcharge', async ({ page, addToCartAndCheckout }) => {
        test.setTimeout(120_000);
        await addToCartAndCheckout('pommery_cuvee_louise_2006');
        const shippingText = page.locator(':text("shipping"), :text("送料"), :text("配送"), :text("cold"), :text("クール"), :text("surcharge"), :text("追加料金")').first();
        await expect(shippingText).toBeVisible({ timeout: 10000 });
        // Cold surcharge should result in higher shipping
    });
});
