2022-12-22 15:01:01 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import {
|
2023-04-03 13:02:36 +00:00
|
|
|
switchBlockInspectorTab,
|
2022-12-22 15:01:01 +00:00
|
|
|
switchUserToAdmin,
|
|
|
|
} from '@wordpress/e2e-test-utils';
|
2023-04-03 13:02:36 +00:00
|
|
|
import { visitBlockPage } from '@woocommerce/blocks-test-utils';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
import { openSettingsSidebar } from '../../utils.js';
|
2022-12-22 15:01:01 +00:00
|
|
|
|
|
|
|
const block = {
|
|
|
|
name: 'Customer account',
|
|
|
|
slug: 'woocommerce/customer-account',
|
|
|
|
class: '.wc-block-customer-account',
|
|
|
|
};
|
|
|
|
|
|
|
|
const SELECTORS = {
|
|
|
|
icon: '.wp-block-woocommerce-customer-account svg',
|
|
|
|
label: '.wp-block-woocommerce-customer-account .label',
|
|
|
|
iconToggle: '.wc-block-customer-account__icon-style-toggle',
|
|
|
|
displayDropdown: '.customer-account-display-style select',
|
|
|
|
};
|
|
|
|
|
|
|
|
describe( `${ block.name } Block`, () => {
|
|
|
|
beforeAll( async () => {
|
|
|
|
await switchUserToAdmin();
|
|
|
|
await visitBlockPage( `${ block.name } Block` );
|
|
|
|
} );
|
|
|
|
|
|
|
|
it( 'renders without crashing', async () => {
|
|
|
|
await expect( page ).toRenderBlock( block );
|
|
|
|
} );
|
|
|
|
|
|
|
|
describe( 'attributes', () => {
|
|
|
|
beforeEach( async () => {
|
2023-04-03 13:02:36 +00:00
|
|
|
await openSettingsSidebar();
|
|
|
|
await switchBlockInspectorTab( 'Settings' );
|
2022-12-22 15:01:01 +00:00
|
|
|
await page.click( block.class );
|
|
|
|
} );
|
|
|
|
|
|
|
|
it( 'icon options can be set to Text-only', async () => {
|
|
|
|
await expect( page ).toSelect(
|
|
|
|
SELECTORS.displayDropdown,
|
|
|
|
'Text-only'
|
|
|
|
);
|
|
|
|
await expect( page ).not.toMatchElement( SELECTORS.iconToggle );
|
|
|
|
|
|
|
|
await expect( page ).not.toMatchElement( SELECTORS.icon );
|
|
|
|
await expect( page ).toMatchElement( SELECTORS.label );
|
|
|
|
} );
|
|
|
|
|
|
|
|
it( 'icon options can be set to Icon-only', async () => {
|
|
|
|
await expect( page ).toSelect(
|
|
|
|
SELECTORS.displayDropdown,
|
|
|
|
'Icon-only'
|
|
|
|
);
|
|
|
|
await expect( page ).toMatchElement( SELECTORS.iconToggle );
|
|
|
|
|
|
|
|
await expect( page ).toMatchElement( SELECTORS.icon );
|
|
|
|
await expect( page ).not.toMatchElement( SELECTORS.label );
|
|
|
|
} );
|
|
|
|
|
|
|
|
it( 'icon options can be set to Icon and text', async () => {
|
|
|
|
await expect( page ).toSelect(
|
|
|
|
SELECTORS.displayDropdown,
|
|
|
|
'Icon and text'
|
|
|
|
);
|
|
|
|
await expect( page ).toMatchElement( SELECTORS.iconToggle );
|
|
|
|
|
|
|
|
await expect( page ).toMatchElement( SELECTORS.icon );
|
|
|
|
await expect( page ).toMatchElement( SELECTORS.label );
|
|
|
|
} );
|
|
|
|
} );
|
|
|
|
} );
|