|
| 1 | +/** |
| 2 | + * External dependencies |
| 3 | + */ |
| 4 | +import { test, expect } from '@playwright/test'; |
| 5 | +/** |
| 6 | + * Internal dependencies |
| 7 | + */ |
| 8 | +import { useMerchant } from '../../utils/helpers'; |
| 9 | +import { goToWooPaymentsSettings } from '../../utils/merchant-navigation'; |
| 10 | + |
| 11 | +test.describe( |
| 12 | + 'As a merchant, I should be prompted a confirmation modal when I try to activate the manual capture', |
| 13 | + () => { |
| 14 | + useMerchant(); |
| 15 | + |
| 16 | + test.beforeEach( async ( { page } ) => { |
| 17 | + await goToWooPaymentsSettings( page ); |
| 18 | + await page.getByTestId( 'capture-later-checkbox' ).click(); |
| 19 | + } ); |
| 20 | + |
| 21 | + test( 'should show the confirmation dialog when enabling the manual capture', async ( { |
| 22 | + page, |
| 23 | + } ) => { |
| 24 | + await expect( |
| 25 | + page.getByText( |
| 26 | + 'Payments must be captured within 7 days or the authorization will expire and money will be returned to the shopper' |
| 27 | + ) |
| 28 | + ).toBeVisible( { |
| 29 | + timeout: 10000, |
| 30 | + } ); |
| 31 | + } ); |
| 32 | + |
| 33 | + test( 'should not show the confirmation dialog when disabling the manual capture', async ( { |
| 34 | + page, |
| 35 | + } ) => { |
| 36 | + await page |
| 37 | + .getByRole( 'button', { name: 'Enable manual capture' } ) |
| 38 | + .click(); |
| 39 | + await page.getByTestId( 'capture-later-checkbox' ).click(); |
| 40 | + await expect( page.locator( '.wcpay-modal' ) ).not.toBeVisible(); |
| 41 | + } ); |
| 42 | + |
| 43 | + test( 'should show the non-card methods disabled when manual capture is enabled', async ( { |
| 44 | + page, |
| 45 | + } ) => { |
| 46 | + await page |
| 47 | + .getByRole( 'button', { name: 'Enable manual capture' } ) |
| 48 | + .click(); |
| 49 | + const paymentMethodWarningIconElement = await page |
| 50 | + .getByTestId( 'loadable-checkbox-icon-warning' ) |
| 51 | + .first(); |
| 52 | + await expect( paymentMethodWarningIconElement ).toHaveText( |
| 53 | + /cannot be enabled at checkout/ |
| 54 | + ); |
| 55 | + } ); |
| 56 | + } |
| 57 | +); |
0 commit comments