HEX
Server: Apache/2
System: Linux server-27-254-144-72.da.direct 5.10.0-33-amd64 #1 SMP Debian 5.10.226-1 (2024-10-03) x86_64
User: pokaorgani (1114)
PHP: 8.1.33
Disabled: exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Upload Files
File: /home/pokaorgani/public_html/wp-content/themes/sydney/tests/woocommerce/ajax-add-to-cart.spec.js
// @ts-check
const { test, expect } = require('@playwright/test');

// Ajax add to cart on shop catalog
test('Ajax add to cart on shop catalog', async ({ page }) => {
    await page.goto('http://tests.local/?post_type=product');
    await page.locator( 'body.woocommerce-shop .site-main .products .product' ).first().hover();
    await page.locator( 'body.woocommerce-shop .site-main .products .product .add_to_cart_button' ).first().click();

    const responsePromise = page.waitForResponse('http://tests.local/?wc-ajax=add_to_cart');
    const response = await responsePromise;

    await expect( response.status() ).toBe( 200 );
});

// Ajax add to cart on search page (with results as grid)
test('Ajax add to cart on search page (with results as grid)', async ({ page }) => {
    await page.goto('http://tests.local/?s=a&post_type=product');
    await page.locator( 'body.search .site-main .products .product' ).first().hover();
    await page.locator( 'body.search .site-main .products .product .add_to_cart_button' ).first().click();

    const responsePromise = page.waitForResponse('http://tests.local/?wc-ajax=add_to_cart');
    const response = await responsePromise;

    await expect( response.status() ).toBe( 200 );
});