2020-02-11 17:23:23 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import {
|
|
|
|
switchUserToAdmin,
|
2020-06-15 14:59:18 +00:00
|
|
|
getEditedPostContent,
|
|
|
|
openDocumentSettingsSidebar,
|
2020-02-11 17:23:23 +00:00
|
|
|
} from '@wordpress/e2e-test-utils';
|
|
|
|
import { clearAndFillInput } from '@woocommerce/e2e-tests/utils';
|
2020-06-15 14:59:18 +00:00
|
|
|
import { visitBlockPage } from '@woocommerce/blocks-test-utils';
|
2020-02-11 17:23:23 +00:00
|
|
|
|
2020-06-15 14:59:18 +00:00
|
|
|
const block = {
|
|
|
|
name: 'Product Search',
|
|
|
|
slug: 'woocommerce/product-search',
|
|
|
|
class: '.wc-block-product-search',
|
|
|
|
};
|
|
|
|
|
|
|
|
describe( `${ block.name } Block`, () => {
|
|
|
|
beforeAll( async () => {
|
2020-02-11 17:23:23 +00:00
|
|
|
await switchUserToAdmin();
|
2020-06-15 14:59:18 +00:00
|
|
|
await visitBlockPage( `${ block.name } Block` );
|
2020-02-11 17:23:23 +00:00
|
|
|
} );
|
|
|
|
|
2020-06-15 14:59:18 +00:00
|
|
|
it( 'renders without crashing', async () => {
|
2020-06-25 13:00:27 +00:00
|
|
|
await expect( page ).toRenderBlock( block );
|
2020-02-11 17:23:23 +00:00
|
|
|
} );
|
|
|
|
|
|
|
|
it( 'can toggle field label', async () => {
|
2020-06-15 14:59:18 +00:00
|
|
|
await openDocumentSettingsSidebar();
|
|
|
|
// we focus on the block
|
|
|
|
await page.click( block.class );
|
2020-02-11 17:23:23 +00:00
|
|
|
await page.click( '.components-form-toggle__input' );
|
|
|
|
await expect( page ).not.toMatchElement(
|
2020-06-15 14:59:18 +00:00
|
|
|
`${ block.class } .wc-block-product-search__label`
|
|
|
|
);
|
|
|
|
await page.click( '.components-form-toggle__input' );
|
|
|
|
await expect( page ).toMatchElement(
|
|
|
|
`${ block.class } .wc-block-product-search__label`
|
2020-02-11 17:23:23 +00:00
|
|
|
);
|
|
|
|
} );
|
|
|
|
|
|
|
|
it( 'can change field labels in editor', async () => {
|
|
|
|
await expect( page ).toFill(
|
|
|
|
'textarea.wc-block-product-search__label',
|
|
|
|
'I am a new label'
|
|
|
|
);
|
|
|
|
|
|
|
|
await expect( page ).toFill(
|
|
|
|
'textarea.wc-block-product-search__field',
|
|
|
|
'I am a new placeholder'
|
|
|
|
);
|
|
|
|
|
|
|
|
await clearAndFillInput(
|
|
|
|
'textarea.wc-block-product-search__label',
|
|
|
|
'The Label'
|
|
|
|
);
|
|
|
|
await clearAndFillInput(
|
|
|
|
'textarea.wc-block-product-search__field',
|
|
|
|
'The Placeholder'
|
|
|
|
);
|
|
|
|
|
|
|
|
expect( await getEditedPostContent() ).toMatchSnapshot();
|
|
|
|
} );
|
|
|
|
} );
|