woocommerce/plugins/woocommerce-blocks/tests/e2e/specs/backend/checkout.test.js

313 lines
9.6 KiB
JavaScript
Raw Normal View History

/**
* External dependencies
*/
import {
openDocumentSettingsSidebar,
switchUserToAdmin,
openGlobalBlockInserter,
insertBlock,
} from '@wordpress/e2e-test-utils';
import {
findLabelWithText,
visitBlockPage,
selectBlockByName,
switchBlockInspectorTabWhenGutenbergIsInstalled,
} from '@woocommerce/blocks-test-utils';
import { merchant } from '@woocommerce/e2e-utils';
/**
* Internal dependencies
*/
import {
searchForBlock,
openWidgetEditor,
closeModalIfExists,
} from '../../utils.js';
Remove WC Core shipping settings if Cart/Checkout blocks are in use (https://github.com/woocommerce/woocommerce-blocks/pull/8679) * Add CartCheckoutUtils class This class will store reusable methods relating to Cart/Checkout Blocks, i.e. whether they are used on the Cart/Checkout page. * Update ShippingController to use the new CartCheckoutUtils function This will reduce code duplication when checking if the Cart/Checkout blocks are in use on the Cart/Checkout page. * Add filter to remove shipping settings when Cart/Checkout are default * Ensure setting displays correctly if cart is default but not checkout * Add tests to ensure core shipping settings update correctly * Add setCartCheckoutPages function to update set the cart/checkout page * Force shipping to be enabled if the Checkout block is in use. * Add filter to override cost requires address option * Add shippingCostRequiresAddress option * Check if the address is required before showing rates * Show shipping rates in editor * Add shippingCostRequiresAddress attribute to shipping methods block * Update frontend type to show shippingCostRequiresAddress is a prop * Add control to toggle shippingCostRequiresAddress option * Show address notice in the correct scenario * Send shippingCostRequiresAddress to Block in front end context * Add e2e test for editor control * Add e2e tests for shipping options on the front end * Add updateAttributeInSiblingBlock function * Add shippingCostRequiresAddress to shipping method block * Ensure attribute is updated in both blocks when editing * In Shipping Methods Block, show correct component based on block setting * Show correct block in editor * Remove broken test from PR * Clean up updateAttributeInSiblingBlock * Add setCartCheckoutPages function to update set the cart/checkout page * Add tests to ensure core shipping settings update correctly * Add isAddressComplete function Borrowed from woocommerce/woocommerce-blocks#8141 * Check if the address is required before showing rates * Show shipping rates in editor * Show address notice in the correct scenario * Add e2e tests for shipping options on the front end * Ensure errorId is passed to StateInput * Add fullShippingAddressPushed action to wc/store/cart * Add fullShippingAddressPushed case to reducer * Ensure fullShippingAddressPushed is set when initialising cart store * Add fullShippingAddressPushed selector and default state entry * Add shippingAddressHasValidationErrors util function * Do not overwrite addresses when selecting a rate * Set whether full address has been pushed when saving address changes * In Shipping Methods Block, show correct component based on block setting * Don't show from price if rates should be hidden until address entered * Check city validation errors to assert if shipping address is valid * Rename merchant.js to merchant.ts * Move local pickup functions to common merchant util * Update local pickup tests to use common merchant utils * Add test to ensure setting toggles in both blocks * Add navigating to settings and saving in merchant util * Create addPickupLocation merchant util * Add test for local pickup and require full address * Make sure correct conditions are met to show shipping options * Ensure checkbox is checked during local pickup tests * Unset the checkbox when tests are finished running * Update checkout block fixture * Prevent error in unit tests * Import validation store key from constants Required because importing from the index causes the validation data store to register twice * Update checkout terms test to wait for button not to be disabled * Revert "Add isAddressComplete function" This reverts commit 9967dc0d4f10cf638859ae085e6f4cc2901dd299.
2023-03-13 11:49:28 +00:00
import { merchant as merchantUtils } from '../../../utils/merchant';
const block = {
name: 'Checkout',
slug: 'woocommerce/checkout',
class: '.wp-block-woocommerce-checkout',
selectors: {
insertButton: "//button//span[text()='Checkout']",
},
};
if ( process.env.WOOCOMMERCE_BLOCKS_PHASE < 2 ) {
// eslint-disable-next-line jest/no-focused-tests, jest/expect-expect
test.only( `skipping ${ block.name } tests`, () => {} );
}
describe( `${ block.name } Block`, () => {
describe( 'in page editor', () => {
Add dismissible compatibility notice to sidebar when editing Cart and Checkout (https://github.com/woocommerce/woocommerce-blocks/pull/6869) * Add default page notice * show notice all inner blocks * support flow when page isnt saved * switch from where we get the current post id * update lock * fix types * Remove old compatibility notices from Cart and Checkout * Move useCompatibilityNotice to sidebar-compatibility-notice directory * Remove old CartCheckoutCompatibilityNotice * Create sidebar compatibility notice hoc * Add isCartOrCheckoutOrInnerBlock function * Refactor defaultNotice to use new isCartOrCheckoutOrInnerBlock func * Remove BlockSettings from checkout edit and export from checkout-shared * Change so component still renders, it is just hidden with display: none This is required because when it returns null the component gets skipped from being added to the Slot, then when it does return a component, then it gets rendered at the bottom of the Slot. By ensuring it always renders we can have it at the top all the time. * Set the priorities of the hoc filters so compat notice renders first * Make isCartOrCheckoutInnerBlock a hook * Remove old compatibility notice related tests * Remove BlockSettings from Cart * Remove withDefaultNotice hoc * Include DefaultNotice in compatibility notice * Remove DefaultNotice from Checkout * Rename withSidebarCompatibilityNotice to withSidebarNotices This is because it includes the sidebar compatibility notice and the default notices * Remove useIsCartOrCheckoutOrInnerBlock hook * Remove compatibility notice code from tests * Revert DefaultNotice back to the old one * Remove unused components * Remove withBlockSettings HOC and fix TS types This is an abstraction that is no longer required, we can just include BlockSettings in the Cart and Checkout blocks * Remove CartCheckoutFeedbackPrompt from BlockSettings It will be included in sidebar-notices instead * Fix TS Types in DefaultNotice * Add BlockSettings to cart and checkout edit * Editor: Add feedback box to the Cart & Checkout Inner Blocks (https://github.com/woocommerce/woocommerce-blocks/pull/6881) * Show "Feedback prompt" for all inner blocks * Fix the "feedback" notice position for these blocks The "checkout fields", "checkout billing address" and "checkout shipping address" have the addressFields option which gets rerendered and placed at the bottom of the inspector controls. * Tidy up the address-fields hoc * Use correct block name to check for billing or shipping address * Revert "Editor: Add feedback box to the Cart & Checkout Inner Blocks (https://github.com/woocommerce/woocommerce-blocks/pull/6881)" This reverts commit 5f3d6cf15ce08d9c303e62ec3e0d0315ead1281f. * Add hack to get feedback prompt to render last * Fix TS errors for context and attributes * Include CartCheckoutFeedbackPrompt in accountcontrols & addresscontrols * Do not include feedback prompt if on an address block or contact info * Remove unused hoc for address fields Co-authored-by: Nadir Seghir <nadir.seghir@gmail.com> Co-authored-by: Saad Tarhi <saad.trh@gmail.com>
2022-08-12 14:23:08 +00:00
beforeAll( async () => {
await switchUserToAdmin();
await visitBlockPage( `${ block.name } Block` );
} );
Add dismissible compatibility notice to sidebar when editing Cart and Checkout (https://github.com/woocommerce/woocommerce-blocks/pull/6869) * Add default page notice * show notice all inner blocks * support flow when page isnt saved * switch from where we get the current post id * update lock * fix types * Remove old compatibility notices from Cart and Checkout * Move useCompatibilityNotice to sidebar-compatibility-notice directory * Remove old CartCheckoutCompatibilityNotice * Create sidebar compatibility notice hoc * Add isCartOrCheckoutOrInnerBlock function * Refactor defaultNotice to use new isCartOrCheckoutOrInnerBlock func * Remove BlockSettings from checkout edit and export from checkout-shared * Change so component still renders, it is just hidden with display: none This is required because when it returns null the component gets skipped from being added to the Slot, then when it does return a component, then it gets rendered at the bottom of the Slot. By ensuring it always renders we can have it at the top all the time. * Set the priorities of the hoc filters so compat notice renders first * Make isCartOrCheckoutInnerBlock a hook * Remove old compatibility notice related tests * Remove BlockSettings from Cart * Remove withDefaultNotice hoc * Include DefaultNotice in compatibility notice * Remove DefaultNotice from Checkout * Rename withSidebarCompatibilityNotice to withSidebarNotices This is because it includes the sidebar compatibility notice and the default notices * Remove useIsCartOrCheckoutOrInnerBlock hook * Remove compatibility notice code from tests * Revert DefaultNotice back to the old one * Remove unused components * Remove withBlockSettings HOC and fix TS types This is an abstraction that is no longer required, we can just include BlockSettings in the Cart and Checkout blocks * Remove CartCheckoutFeedbackPrompt from BlockSettings It will be included in sidebar-notices instead * Fix TS Types in DefaultNotice * Add BlockSettings to cart and checkout edit * Editor: Add feedback box to the Cart & Checkout Inner Blocks (https://github.com/woocommerce/woocommerce-blocks/pull/6881) * Show "Feedback prompt" for all inner blocks * Fix the "feedback" notice position for these blocks The "checkout fields", "checkout billing address" and "checkout shipping address" have the addressFields option which gets rerendered and placed at the bottom of the inspector controls. * Tidy up the address-fields hoc * Use correct block name to check for billing or shipping address * Revert "Editor: Add feedback box to the Cart & Checkout Inner Blocks (https://github.com/woocommerce/woocommerce-blocks/pull/6881)" This reverts commit 5f3d6cf15ce08d9c303e62ec3e0d0315ead1281f. * Add hack to get feedback prompt to render last * Fix TS errors for context and attributes * Include CartCheckoutFeedbackPrompt in accountcontrols & addresscontrols * Do not include feedback prompt if on an address block or contact info * Remove unused hoc for address fields Co-authored-by: Nadir Seghir <nadir.seghir@gmail.com> Co-authored-by: Saad Tarhi <saad.trh@gmail.com>
2022-08-12 14:23:08 +00:00
it( 'can only be inserted once', async () => {
await openGlobalBlockInserter();
await page.keyboard.type( block.name );
const button = await page.$x( block.selectors.insertButton );
expect( button ).toHaveLength( 0 );
} );
it( 'inner blocks can be added/removed by filters', async () => {
// Begin by removing the block.
await selectBlockByName( block.slug );
const options = await page.$x(
'//div[@class="block-editor-block-toolbar"]//button[@aria-label="Options"]'
);
await options[ 0 ].click();
const removeButton = await page.$x(
'//button[contains(., "Remove Checkout")]'
);
await removeButton[ 0 ].click();
// Expect block to have been removed.
await expect( page ).not.toMatchElement( block.class );
// Register a checkout filter to allow `core/table` block in the Checkout block's inner blocks.
await page.evaluate(
"wc.blocksCheckout.registerCheckoutFilters( 'woo-test-namespace'," +
'{ additionalCartCheckoutInnerBlockTypes: ( value, extensions, { block } ) => {' +
" value.push('core/table');" +
" if ( block === 'woocommerce/checkout-shipping-address-block' ) {" +
" value.push( 'core/audio' );" +
' }' +
' return value;' +
'}' +
'}' +
');'
);
await insertBlock( block.name );
// Select the shipping address block and try to insert a block. Check the Table block is available.
await selectBlockByName(
'woocommerce/checkout-shipping-address-block'
);
const addBlockButton = await page.waitForXPath(
'//div[@data-type="woocommerce/checkout-shipping-address-block"]//button[@aria-label="Add block"]'
);
expect( addBlockButton ).not.toBeNull();
await addBlockButton.click();
const tableButton = await page.waitForXPath(
'//*[@role="option" and contains(., "Table")]'
);
const audioButton = await page.waitForXPath(
'//*[@role="option" and contains(., "Audio")]'
);
expect( tableButton ).not.toBeNull();
expect( audioButton ).not.toBeNull();
// Now check the contact information block and expect only the Table block to be available there.
await selectBlockByName(
'woocommerce/checkout-contact-information-block'
);
const contactInformationAddBlockButton = await page.waitForXPath(
'//div[@data-type="woocommerce/checkout-contact-information-block"]//button[@aria-label="Add block"]'
);
await contactInformationAddBlockButton.click();
const contactInformationTableButton = await page.waitForXPath(
'//*[@role="option" and contains(., "Table")]'
);
const contactInformationAudioButton = await page.$x(
'//*[@role="option" and contains(., "Audio")]'
);
expect( contactInformationTableButton ).not.toBeNull();
expect( contactInformationAudioButton ).toHaveLength( 0 );
} );
Add dismissible compatibility notice to sidebar when editing Cart and Checkout (https://github.com/woocommerce/woocommerce-blocks/pull/6869) * Add default page notice * show notice all inner blocks * support flow when page isnt saved * switch from where we get the current post id * update lock * fix types * Remove old compatibility notices from Cart and Checkout * Move useCompatibilityNotice to sidebar-compatibility-notice directory * Remove old CartCheckoutCompatibilityNotice * Create sidebar compatibility notice hoc * Add isCartOrCheckoutOrInnerBlock function * Refactor defaultNotice to use new isCartOrCheckoutOrInnerBlock func * Remove BlockSettings from checkout edit and export from checkout-shared * Change so component still renders, it is just hidden with display: none This is required because when it returns null the component gets skipped from being added to the Slot, then when it does return a component, then it gets rendered at the bottom of the Slot. By ensuring it always renders we can have it at the top all the time. * Set the priorities of the hoc filters so compat notice renders first * Make isCartOrCheckoutInnerBlock a hook * Remove old compatibility notice related tests * Remove BlockSettings from Cart * Remove withDefaultNotice hoc * Include DefaultNotice in compatibility notice * Remove DefaultNotice from Checkout * Rename withSidebarCompatibilityNotice to withSidebarNotices This is because it includes the sidebar compatibility notice and the default notices * Remove useIsCartOrCheckoutOrInnerBlock hook * Remove compatibility notice code from tests * Revert DefaultNotice back to the old one * Remove unused components * Remove withBlockSettings HOC and fix TS types This is an abstraction that is no longer required, we can just include BlockSettings in the Cart and Checkout blocks * Remove CartCheckoutFeedbackPrompt from BlockSettings It will be included in sidebar-notices instead * Fix TS Types in DefaultNotice * Add BlockSettings to cart and checkout edit * Editor: Add feedback box to the Cart & Checkout Inner Blocks (https://github.com/woocommerce/woocommerce-blocks/pull/6881) * Show "Feedback prompt" for all inner blocks * Fix the "feedback" notice position for these blocks The "checkout fields", "checkout billing address" and "checkout shipping address" have the addressFields option which gets rerendered and placed at the bottom of the inspector controls. * Tidy up the address-fields hoc * Use correct block name to check for billing or shipping address * Revert "Editor: Add feedback box to the Cart & Checkout Inner Blocks (https://github.com/woocommerce/woocommerce-blocks/pull/6881)" This reverts commit 5f3d6cf15ce08d9c303e62ec3e0d0315ead1281f. * Add hack to get feedback prompt to render last * Fix TS errors for context and attributes * Include CartCheckoutFeedbackPrompt in accountcontrols & addresscontrols * Do not include feedback prompt if on an address block or contact info * Remove unused hoc for address fields Co-authored-by: Nadir Seghir <nadir.seghir@gmail.com> Co-authored-by: Saad Tarhi <saad.trh@gmail.com>
2022-08-12 14:23:08 +00:00
it( 'renders without crashing', async () => {
await expect( page ).toRenderBlock( block );
} );
Add dismissible compatibility notice to sidebar when editing Cart and Checkout (https://github.com/woocommerce/woocommerce-blocks/pull/6869) * Add default page notice * show notice all inner blocks * support flow when page isnt saved * switch from where we get the current post id * update lock * fix types * Remove old compatibility notices from Cart and Checkout * Move useCompatibilityNotice to sidebar-compatibility-notice directory * Remove old CartCheckoutCompatibilityNotice * Create sidebar compatibility notice hoc * Add isCartOrCheckoutOrInnerBlock function * Refactor defaultNotice to use new isCartOrCheckoutOrInnerBlock func * Remove BlockSettings from checkout edit and export from checkout-shared * Change so component still renders, it is just hidden with display: none This is required because when it returns null the component gets skipped from being added to the Slot, then when it does return a component, then it gets rendered at the bottom of the Slot. By ensuring it always renders we can have it at the top all the time. * Set the priorities of the hoc filters so compat notice renders first * Make isCartOrCheckoutInnerBlock a hook * Remove old compatibility notice related tests * Remove BlockSettings from Cart * Remove withDefaultNotice hoc * Include DefaultNotice in compatibility notice * Remove DefaultNotice from Checkout * Rename withSidebarCompatibilityNotice to withSidebarNotices This is because it includes the sidebar compatibility notice and the default notices * Remove useIsCartOrCheckoutOrInnerBlock hook * Remove compatibility notice code from tests * Revert DefaultNotice back to the old one * Remove unused components * Remove withBlockSettings HOC and fix TS types This is an abstraction that is no longer required, we can just include BlockSettings in the Cart and Checkout blocks * Remove CartCheckoutFeedbackPrompt from BlockSettings It will be included in sidebar-notices instead * Fix TS Types in DefaultNotice * Add BlockSettings to cart and checkout edit * Editor: Add feedback box to the Cart & Checkout Inner Blocks (https://github.com/woocommerce/woocommerce-blocks/pull/6881) * Show "Feedback prompt" for all inner blocks * Fix the "feedback" notice position for these blocks The "checkout fields", "checkout billing address" and "checkout shipping address" have the addressFields option which gets rerendered and placed at the bottom of the inspector controls. * Tidy up the address-fields hoc * Use correct block name to check for billing or shipping address * Revert "Editor: Add feedback box to the Cart & Checkout Inner Blocks (https://github.com/woocommerce/woocommerce-blocks/pull/6881)" This reverts commit 5f3d6cf15ce08d9c303e62ec3e0d0315ead1281f. * Add hack to get feedback prompt to render last * Fix TS errors for context and attributes * Include CartCheckoutFeedbackPrompt in accountcontrols & addresscontrols * Do not include feedback prompt if on an address block or contact info * Remove unused hoc for address fields Co-authored-by: Nadir Seghir <nadir.seghir@gmail.com> Co-authored-by: Saad Tarhi <saad.trh@gmail.com>
2022-08-12 14:23:08 +00:00
describe( 'attributes', () => {
beforeEach( async () => {
await openDocumentSettingsSidebar();
await switchBlockInspectorTabWhenGutenbergIsInstalled(
'Settings'
);
Add dismissible compatibility notice to sidebar when editing Cart and Checkout (https://github.com/woocommerce/woocommerce-blocks/pull/6869) * Add default page notice * show notice all inner blocks * support flow when page isnt saved * switch from where we get the current post id * update lock * fix types * Remove old compatibility notices from Cart and Checkout * Move useCompatibilityNotice to sidebar-compatibility-notice directory * Remove old CartCheckoutCompatibilityNotice * Create sidebar compatibility notice hoc * Add isCartOrCheckoutOrInnerBlock function * Refactor defaultNotice to use new isCartOrCheckoutOrInnerBlock func * Remove BlockSettings from checkout edit and export from checkout-shared * Change so component still renders, it is just hidden with display: none This is required because when it returns null the component gets skipped from being added to the Slot, then when it does return a component, then it gets rendered at the bottom of the Slot. By ensuring it always renders we can have it at the top all the time. * Set the priorities of the hoc filters so compat notice renders first * Make isCartOrCheckoutInnerBlock a hook * Remove old compatibility notice related tests * Remove BlockSettings from Cart * Remove withDefaultNotice hoc * Include DefaultNotice in compatibility notice * Remove DefaultNotice from Checkout * Rename withSidebarCompatibilityNotice to withSidebarNotices This is because it includes the sidebar compatibility notice and the default notices * Remove useIsCartOrCheckoutOrInnerBlock hook * Remove compatibility notice code from tests * Revert DefaultNotice back to the old one * Remove unused components * Remove withBlockSettings HOC and fix TS types This is an abstraction that is no longer required, we can just include BlockSettings in the Cart and Checkout blocks * Remove CartCheckoutFeedbackPrompt from BlockSettings It will be included in sidebar-notices instead * Fix TS Types in DefaultNotice * Add BlockSettings to cart and checkout edit * Editor: Add feedback box to the Cart & Checkout Inner Blocks (https://github.com/woocommerce/woocommerce-blocks/pull/6881) * Show "Feedback prompt" for all inner blocks * Fix the "feedback" notice position for these blocks The "checkout fields", "checkout billing address" and "checkout shipping address" have the addressFields option which gets rerendered and placed at the bottom of the inspector controls. * Tidy up the address-fields hoc * Use correct block name to check for billing or shipping address * Revert "Editor: Add feedback box to the Cart & Checkout Inner Blocks (https://github.com/woocommerce/woocommerce-blocks/pull/6881)" This reverts commit 5f3d6cf15ce08d9c303e62ec3e0d0315ead1281f. * Add hack to get feedback prompt to render last * Fix TS errors for context and attributes * Include CartCheckoutFeedbackPrompt in accountcontrols & addresscontrols * Do not include feedback prompt if on an address block or contact info * Remove unused hoc for address fields Co-authored-by: Nadir Seghir <nadir.seghir@gmail.com> Co-authored-by: Saad Tarhi <saad.trh@gmail.com>
2022-08-12 14:23:08 +00:00
await selectBlockByName( block.slug );
} );
Remove WC Core shipping settings if Cart/Checkout blocks are in use (https://github.com/woocommerce/woocommerce-blocks/pull/8679) * Add CartCheckoutUtils class This class will store reusable methods relating to Cart/Checkout Blocks, i.e. whether they are used on the Cart/Checkout page. * Update ShippingController to use the new CartCheckoutUtils function This will reduce code duplication when checking if the Cart/Checkout blocks are in use on the Cart/Checkout page. * Add filter to remove shipping settings when Cart/Checkout are default * Ensure setting displays correctly if cart is default but not checkout * Add tests to ensure core shipping settings update correctly * Add setCartCheckoutPages function to update set the cart/checkout page * Force shipping to be enabled if the Checkout block is in use. * Add filter to override cost requires address option * Add shippingCostRequiresAddress option * Check if the address is required before showing rates * Show shipping rates in editor * Add shippingCostRequiresAddress attribute to shipping methods block * Update frontend type to show shippingCostRequiresAddress is a prop * Add control to toggle shippingCostRequiresAddress option * Show address notice in the correct scenario * Send shippingCostRequiresAddress to Block in front end context * Add e2e test for editor control * Add e2e tests for shipping options on the front end * Add updateAttributeInSiblingBlock function * Add shippingCostRequiresAddress to shipping method block * Ensure attribute is updated in both blocks when editing * In Shipping Methods Block, show correct component based on block setting * Show correct block in editor * Remove broken test from PR * Clean up updateAttributeInSiblingBlock * Add setCartCheckoutPages function to update set the cart/checkout page * Add tests to ensure core shipping settings update correctly * Add isAddressComplete function Borrowed from woocommerce/woocommerce-blocks#8141 * Check if the address is required before showing rates * Show shipping rates in editor * Show address notice in the correct scenario * Add e2e tests for shipping options on the front end * Ensure errorId is passed to StateInput * Add fullShippingAddressPushed action to wc/store/cart * Add fullShippingAddressPushed case to reducer * Ensure fullShippingAddressPushed is set when initialising cart store * Add fullShippingAddressPushed selector and default state entry * Add shippingAddressHasValidationErrors util function * Do not overwrite addresses when selecting a rate * Set whether full address has been pushed when saving address changes * In Shipping Methods Block, show correct component based on block setting * Don't show from price if rates should be hidden until address entered * Check city validation errors to assert if shipping address is valid * Rename merchant.js to merchant.ts * Move local pickup functions to common merchant util * Update local pickup tests to use common merchant utils * Add test to ensure setting toggles in both blocks * Add navigating to settings and saving in merchant util * Create addPickupLocation merchant util * Add test for local pickup and require full address * Make sure correct conditions are met to show shipping options * Ensure checkbox is checked during local pickup tests * Unset the checkbox when tests are finished running * Update checkout block fixture * Prevent error in unit tests * Import validation store key from constants Required because importing from the index causes the validation data store to register twice * Update checkout terms test to wait for button not to be disabled * Revert "Add isAddressComplete function" This reverts commit 9967dc0d4f10cf638859ae085e6f4cc2901dd299.
2023-03-13 11:49:28 +00:00
it( 'can toggle "hide shipping costs until an address is entered"', async () => {
await selectBlockByName(
'woocommerce/checkout-shipping-methods-block'
);
const toggleLabel = await findLabelWithText(
'Hide shipping costs until an address is entered'
);
await toggleLabel.click();
const shippingOptionsRequireAddressText = await page.$x(
'//p[contains(text(), "Shipping options will be displayed here after entering your full shipping address.")]'
);
await expect( shippingOptionsRequireAddressText ).toHaveLength(
1
);
await toggleLabel.click();
await expect( page ).toMatchElement(
'.wc-block-components-shipping-rates-control'
);
} );
it( 'toggles the same setting in shipping method and shipping methods blocks', async () => {
await merchantUtils.goToLocalPickupSettingsPage();
await merchantUtils.enableLocalPickup();
await merchantUtils.saveLocalPickupSettingsPageWithRefresh();
await visitBlockPage( `${ block.name } Block` );
await expect( page ).toClick(
'.wc-block-checkout__shipping-method button',
{ text: 'Shipping' }
);
await openDocumentSettingsSidebar();
const toggleLabel = await findLabelWithText(
'Hide shipping costs until an address is entered'
);
await toggleLabel.click();
const [ label ] = await page.$x(
'//label[contains(., "Hide shipping costs until an address is entered")]'
);
const shippingMethodForValue = await page.evaluate(
( passedLabel ) => passedLabel.getAttribute( 'for' ),
label
);
const shippingMethodSettingIsChecked = await page.evaluate(
( passedShippingMethodForValue ) =>
document.getElementById( passedShippingMethodForValue )
.checked,
shippingMethodForValue
);
await expect( shippingMethodSettingIsChecked ).toBe( true );
await selectBlockByName(
'woocommerce/checkout-shipping-methods-block'
);
const [ shippingMethodsLabel ] = await page.$x(
'//label[contains(., "Hide shipping costs until an address is entered")]'
);
const shippingMethodsLabelForValue = await page.evaluate(
( passedShippingMethodsLabel ) =>
passedShippingMethodsLabel.getAttribute( 'for' ),
shippingMethodsLabel
);
const shippingMethodLabelIsChecked = await page.evaluate(
( passedShippingMethodsLabelForValue ) =>
document.getElementById(
passedShippingMethodsLabelForValue
).checked,
shippingMethodsLabelForValue
);
expect( shippingMethodSettingIsChecked ).toBe(
shippingMethodLabelIsChecked
);
} );
Add dismissible compatibility notice to sidebar when editing Cart and Checkout (https://github.com/woocommerce/woocommerce-blocks/pull/6869) * Add default page notice * show notice all inner blocks * support flow when page isnt saved * switch from where we get the current post id * update lock * fix types * Remove old compatibility notices from Cart and Checkout * Move useCompatibilityNotice to sidebar-compatibility-notice directory * Remove old CartCheckoutCompatibilityNotice * Create sidebar compatibility notice hoc * Add isCartOrCheckoutOrInnerBlock function * Refactor defaultNotice to use new isCartOrCheckoutOrInnerBlock func * Remove BlockSettings from checkout edit and export from checkout-shared * Change so component still renders, it is just hidden with display: none This is required because when it returns null the component gets skipped from being added to the Slot, then when it does return a component, then it gets rendered at the bottom of the Slot. By ensuring it always renders we can have it at the top all the time. * Set the priorities of the hoc filters so compat notice renders first * Make isCartOrCheckoutInnerBlock a hook * Remove old compatibility notice related tests * Remove BlockSettings from Cart * Remove withDefaultNotice hoc * Include DefaultNotice in compatibility notice * Remove DefaultNotice from Checkout * Rename withSidebarCompatibilityNotice to withSidebarNotices This is because it includes the sidebar compatibility notice and the default notices * Remove useIsCartOrCheckoutOrInnerBlock hook * Remove compatibility notice code from tests * Revert DefaultNotice back to the old one * Remove unused components * Remove withBlockSettings HOC and fix TS types This is an abstraction that is no longer required, we can just include BlockSettings in the Cart and Checkout blocks * Remove CartCheckoutFeedbackPrompt from BlockSettings It will be included in sidebar-notices instead * Fix TS Types in DefaultNotice * Add BlockSettings to cart and checkout edit * Editor: Add feedback box to the Cart & Checkout Inner Blocks (https://github.com/woocommerce/woocommerce-blocks/pull/6881) * Show "Feedback prompt" for all inner blocks * Fix the "feedback" notice position for these blocks The "checkout fields", "checkout billing address" and "checkout shipping address" have the addressFields option which gets rerendered and placed at the bottom of the inspector controls. * Tidy up the address-fields hoc * Use correct block name to check for billing or shipping address * Revert "Editor: Add feedback box to the Cart & Checkout Inner Blocks (https://github.com/woocommerce/woocommerce-blocks/pull/6881)" This reverts commit 5f3d6cf15ce08d9c303e62ec3e0d0315ead1281f. * Add hack to get feedback prompt to render last * Fix TS errors for context and attributes * Include CartCheckoutFeedbackPrompt in accountcontrols & addresscontrols * Do not include feedback prompt if on an address block or contact info * Remove unused hoc for address fields Co-authored-by: Nadir Seghir <nadir.seghir@gmail.com> Co-authored-by: Saad Tarhi <saad.trh@gmail.com>
2022-08-12 14:23:08 +00:00
it( 'can enable dark mode inputs', async () => {
const toggleLabel = await findLabelWithText(
'Dark mode inputs'
);
await toggleLabel.click();
await expect( page ).toMatchElement(
`.wc-block-checkout.has-dark-controls`
);
await toggleLabel.click();
await expect( page ).not.toMatchElement(
`.wc-block-checkout.has-dark-controls`
);
} );
Add dismissible compatibility notice to sidebar when editing Cart and Checkout (https://github.com/woocommerce/woocommerce-blocks/pull/6869) * Add default page notice * show notice all inner blocks * support flow when page isnt saved * switch from where we get the current post id * update lock * fix types * Remove old compatibility notices from Cart and Checkout * Move useCompatibilityNotice to sidebar-compatibility-notice directory * Remove old CartCheckoutCompatibilityNotice * Create sidebar compatibility notice hoc * Add isCartOrCheckoutOrInnerBlock function * Refactor defaultNotice to use new isCartOrCheckoutOrInnerBlock func * Remove BlockSettings from checkout edit and export from checkout-shared * Change so component still renders, it is just hidden with display: none This is required because when it returns null the component gets skipped from being added to the Slot, then when it does return a component, then it gets rendered at the bottom of the Slot. By ensuring it always renders we can have it at the top all the time. * Set the priorities of the hoc filters so compat notice renders first * Make isCartOrCheckoutInnerBlock a hook * Remove old compatibility notice related tests * Remove BlockSettings from Cart * Remove withDefaultNotice hoc * Include DefaultNotice in compatibility notice * Remove DefaultNotice from Checkout * Rename withSidebarCompatibilityNotice to withSidebarNotices This is because it includes the sidebar compatibility notice and the default notices * Remove useIsCartOrCheckoutOrInnerBlock hook * Remove compatibility notice code from tests * Revert DefaultNotice back to the old one * Remove unused components * Remove withBlockSettings HOC and fix TS types This is an abstraction that is no longer required, we can just include BlockSettings in the Cart and Checkout blocks * Remove CartCheckoutFeedbackPrompt from BlockSettings It will be included in sidebar-notices instead * Fix TS Types in DefaultNotice * Add BlockSettings to cart and checkout edit * Editor: Add feedback box to the Cart & Checkout Inner Blocks (https://github.com/woocommerce/woocommerce-blocks/pull/6881) * Show "Feedback prompt" for all inner blocks * Fix the "feedback" notice position for these blocks The "checkout fields", "checkout billing address" and "checkout shipping address" have the addressFields option which gets rerendered and placed at the bottom of the inspector controls. * Tidy up the address-fields hoc * Use correct block name to check for billing or shipping address * Revert "Editor: Add feedback box to the Cart & Checkout Inner Blocks (https://github.com/woocommerce/woocommerce-blocks/pull/6881)" This reverts commit 5f3d6cf15ce08d9c303e62ec3e0d0315ead1281f. * Add hack to get feedback prompt to render last * Fix TS errors for context and attributes * Include CartCheckoutFeedbackPrompt in accountcontrols & addresscontrols * Do not include feedback prompt if on an address block or contact info * Remove unused hoc for address fields Co-authored-by: Nadir Seghir <nadir.seghir@gmail.com> Co-authored-by: Saad Tarhi <saad.trh@gmail.com>
2022-08-12 14:23:08 +00:00
} );
Add dismissible compatibility notice to sidebar when editing Cart and Checkout (https://github.com/woocommerce/woocommerce-blocks/pull/6869) * Add default page notice * show notice all inner blocks * support flow when page isnt saved * switch from where we get the current post id * update lock * fix types * Remove old compatibility notices from Cart and Checkout * Move useCompatibilityNotice to sidebar-compatibility-notice directory * Remove old CartCheckoutCompatibilityNotice * Create sidebar compatibility notice hoc * Add isCartOrCheckoutOrInnerBlock function * Refactor defaultNotice to use new isCartOrCheckoutOrInnerBlock func * Remove BlockSettings from checkout edit and export from checkout-shared * Change so component still renders, it is just hidden with display: none This is required because when it returns null the component gets skipped from being added to the Slot, then when it does return a component, then it gets rendered at the bottom of the Slot. By ensuring it always renders we can have it at the top all the time. * Set the priorities of the hoc filters so compat notice renders first * Make isCartOrCheckoutInnerBlock a hook * Remove old compatibility notice related tests * Remove BlockSettings from Cart * Remove withDefaultNotice hoc * Include DefaultNotice in compatibility notice * Remove DefaultNotice from Checkout * Rename withSidebarCompatibilityNotice to withSidebarNotices This is because it includes the sidebar compatibility notice and the default notices * Remove useIsCartOrCheckoutOrInnerBlock hook * Remove compatibility notice code from tests * Revert DefaultNotice back to the old one * Remove unused components * Remove withBlockSettings HOC and fix TS types This is an abstraction that is no longer required, we can just include BlockSettings in the Cart and Checkout blocks * Remove CartCheckoutFeedbackPrompt from BlockSettings It will be included in sidebar-notices instead * Fix TS Types in DefaultNotice * Add BlockSettings to cart and checkout edit * Editor: Add feedback box to the Cart & Checkout Inner Blocks (https://github.com/woocommerce/woocommerce-blocks/pull/6881) * Show "Feedback prompt" for all inner blocks * Fix the "feedback" notice position for these blocks The "checkout fields", "checkout billing address" and "checkout shipping address" have the addressFields option which gets rerendered and placed at the bottom of the inspector controls. * Tidy up the address-fields hoc * Use correct block name to check for billing or shipping address * Revert "Editor: Add feedback box to the Cart & Checkout Inner Blocks (https://github.com/woocommerce/woocommerce-blocks/pull/6881)" This reverts commit 5f3d6cf15ce08d9c303e62ec3e0d0315ead1281f. * Add hack to get feedback prompt to render last * Fix TS errors for context and attributes * Include CartCheckoutFeedbackPrompt in accountcontrols & addresscontrols * Do not include feedback prompt if on an address block or contact info * Remove unused hoc for address fields Co-authored-by: Nadir Seghir <nadir.seghir@gmail.com> Co-authored-by: Saad Tarhi <saad.trh@gmail.com>
2022-08-12 14:23:08 +00:00
describe( 'shipping address block attributes', () => {
beforeEach( async () => {
await openDocumentSettingsSidebar();
await switchBlockInspectorTabWhenGutenbergIsInstalled(
'Settings'
);
Add dismissible compatibility notice to sidebar when editing Cart and Checkout (https://github.com/woocommerce/woocommerce-blocks/pull/6869) * Add default page notice * show notice all inner blocks * support flow when page isnt saved * switch from where we get the current post id * update lock * fix types * Remove old compatibility notices from Cart and Checkout * Move useCompatibilityNotice to sidebar-compatibility-notice directory * Remove old CartCheckoutCompatibilityNotice * Create sidebar compatibility notice hoc * Add isCartOrCheckoutOrInnerBlock function * Refactor defaultNotice to use new isCartOrCheckoutOrInnerBlock func * Remove BlockSettings from checkout edit and export from checkout-shared * Change so component still renders, it is just hidden with display: none This is required because when it returns null the component gets skipped from being added to the Slot, then when it does return a component, then it gets rendered at the bottom of the Slot. By ensuring it always renders we can have it at the top all the time. * Set the priorities of the hoc filters so compat notice renders first * Make isCartOrCheckoutInnerBlock a hook * Remove old compatibility notice related tests * Remove BlockSettings from Cart * Remove withDefaultNotice hoc * Include DefaultNotice in compatibility notice * Remove DefaultNotice from Checkout * Rename withSidebarCompatibilityNotice to withSidebarNotices This is because it includes the sidebar compatibility notice and the default notices * Remove useIsCartOrCheckoutOrInnerBlock hook * Remove compatibility notice code from tests * Revert DefaultNotice back to the old one * Remove unused components * Remove withBlockSettings HOC and fix TS types This is an abstraction that is no longer required, we can just include BlockSettings in the Cart and Checkout blocks * Remove CartCheckoutFeedbackPrompt from BlockSettings It will be included in sidebar-notices instead * Fix TS Types in DefaultNotice * Add BlockSettings to cart and checkout edit * Editor: Add feedback box to the Cart & Checkout Inner Blocks (https://github.com/woocommerce/woocommerce-blocks/pull/6881) * Show "Feedback prompt" for all inner blocks * Fix the "feedback" notice position for these blocks The "checkout fields", "checkout billing address" and "checkout shipping address" have the addressFields option which gets rerendered and placed at the bottom of the inspector controls. * Tidy up the address-fields hoc * Use correct block name to check for billing or shipping address * Revert "Editor: Add feedback box to the Cart & Checkout Inner Blocks (https://github.com/woocommerce/woocommerce-blocks/pull/6881)" This reverts commit 5f3d6cf15ce08d9c303e62ec3e0d0315ead1281f. * Add hack to get feedback prompt to render last * Fix TS errors for context and attributes * Include CartCheckoutFeedbackPrompt in accountcontrols & addresscontrols * Do not include feedback prompt if on an address block or contact info * Remove unused hoc for address fields Co-authored-by: Nadir Seghir <nadir.seghir@gmail.com> Co-authored-by: Saad Tarhi <saad.trh@gmail.com>
2022-08-12 14:23:08 +00:00
await selectBlockByName(
'woocommerce/checkout-shipping-address-block'
);
} );
Add dismissible compatibility notice to sidebar when editing Cart and Checkout (https://github.com/woocommerce/woocommerce-blocks/pull/6869) * Add default page notice * show notice all inner blocks * support flow when page isnt saved * switch from where we get the current post id * update lock * fix types * Remove old compatibility notices from Cart and Checkout * Move useCompatibilityNotice to sidebar-compatibility-notice directory * Remove old CartCheckoutCompatibilityNotice * Create sidebar compatibility notice hoc * Add isCartOrCheckoutOrInnerBlock function * Refactor defaultNotice to use new isCartOrCheckoutOrInnerBlock func * Remove BlockSettings from checkout edit and export from checkout-shared * Change so component still renders, it is just hidden with display: none This is required because when it returns null the component gets skipped from being added to the Slot, then when it does return a component, then it gets rendered at the bottom of the Slot. By ensuring it always renders we can have it at the top all the time. * Set the priorities of the hoc filters so compat notice renders first * Make isCartOrCheckoutInnerBlock a hook * Remove old compatibility notice related tests * Remove BlockSettings from Cart * Remove withDefaultNotice hoc * Include DefaultNotice in compatibility notice * Remove DefaultNotice from Checkout * Rename withSidebarCompatibilityNotice to withSidebarNotices This is because it includes the sidebar compatibility notice and the default notices * Remove useIsCartOrCheckoutOrInnerBlock hook * Remove compatibility notice code from tests * Revert DefaultNotice back to the old one * Remove unused components * Remove withBlockSettings HOC and fix TS types This is an abstraction that is no longer required, we can just include BlockSettings in the Cart and Checkout blocks * Remove CartCheckoutFeedbackPrompt from BlockSettings It will be included in sidebar-notices instead * Fix TS Types in DefaultNotice * Add BlockSettings to cart and checkout edit * Editor: Add feedback box to the Cart & Checkout Inner Blocks (https://github.com/woocommerce/woocommerce-blocks/pull/6881) * Show "Feedback prompt" for all inner blocks * Fix the "feedback" notice position for these blocks The "checkout fields", "checkout billing address" and "checkout shipping address" have the addressFields option which gets rerendered and placed at the bottom of the inspector controls. * Tidy up the address-fields hoc * Use correct block name to check for billing or shipping address * Revert "Editor: Add feedback box to the Cart & Checkout Inner Blocks (https://github.com/woocommerce/woocommerce-blocks/pull/6881)" This reverts commit 5f3d6cf15ce08d9c303e62ec3e0d0315ead1281f. * Add hack to get feedback prompt to render last * Fix TS errors for context and attributes * Include CartCheckoutFeedbackPrompt in accountcontrols & addresscontrols * Do not include feedback prompt if on an address block or contact info * Remove unused hoc for address fields Co-authored-by: Nadir Seghir <nadir.seghir@gmail.com> Co-authored-by: Saad Tarhi <saad.trh@gmail.com>
2022-08-12 14:23:08 +00:00
describe( 'Company input', () => {
const selector = `${ block.class } #shipping-company`;
Add dismissible compatibility notice to sidebar when editing Cart and Checkout (https://github.com/woocommerce/woocommerce-blocks/pull/6869) * Add default page notice * show notice all inner blocks * support flow when page isnt saved * switch from where we get the current post id * update lock * fix types * Remove old compatibility notices from Cart and Checkout * Move useCompatibilityNotice to sidebar-compatibility-notice directory * Remove old CartCheckoutCompatibilityNotice * Create sidebar compatibility notice hoc * Add isCartOrCheckoutOrInnerBlock function * Refactor defaultNotice to use new isCartOrCheckoutOrInnerBlock func * Remove BlockSettings from checkout edit and export from checkout-shared * Change so component still renders, it is just hidden with display: none This is required because when it returns null the component gets skipped from being added to the Slot, then when it does return a component, then it gets rendered at the bottom of the Slot. By ensuring it always renders we can have it at the top all the time. * Set the priorities of the hoc filters so compat notice renders first * Make isCartOrCheckoutInnerBlock a hook * Remove old compatibility notice related tests * Remove BlockSettings from Cart * Remove withDefaultNotice hoc * Include DefaultNotice in compatibility notice * Remove DefaultNotice from Checkout * Rename withSidebarCompatibilityNotice to withSidebarNotices This is because it includes the sidebar compatibility notice and the default notices * Remove useIsCartOrCheckoutOrInnerBlock hook * Remove compatibility notice code from tests * Revert DefaultNotice back to the old one * Remove unused components * Remove withBlockSettings HOC and fix TS types This is an abstraction that is no longer required, we can just include BlockSettings in the Cart and Checkout blocks * Remove CartCheckoutFeedbackPrompt from BlockSettings It will be included in sidebar-notices instead * Fix TS Types in DefaultNotice * Add BlockSettings to cart and checkout edit * Editor: Add feedback box to the Cart & Checkout Inner Blocks (https://github.com/woocommerce/woocommerce-blocks/pull/6881) * Show "Feedback prompt" for all inner blocks * Fix the "feedback" notice position for these blocks The "checkout fields", "checkout billing address" and "checkout shipping address" have the addressFields option which gets rerendered and placed at the bottom of the inspector controls. * Tidy up the address-fields hoc * Use correct block name to check for billing or shipping address * Revert "Editor: Add feedback box to the Cart & Checkout Inner Blocks (https://github.com/woocommerce/woocommerce-blocks/pull/6881)" This reverts commit 5f3d6cf15ce08d9c303e62ec3e0d0315ead1281f. * Add hack to get feedback prompt to render last * Fix TS errors for context and attributes * Include CartCheckoutFeedbackPrompt in accountcontrols & addresscontrols * Do not include feedback prompt if on an address block or contact info * Remove unused hoc for address fields Co-authored-by: Nadir Seghir <nadir.seghir@gmail.com> Co-authored-by: Saad Tarhi <saad.trh@gmail.com>
2022-08-12 14:23:08 +00:00
it( 'visibility can be toggled', async () => {
await expect( 'Company' ).toToggleElement( selector );
} );
Add dismissible compatibility notice to sidebar when editing Cart and Checkout (https://github.com/woocommerce/woocommerce-blocks/pull/6869) * Add default page notice * show notice all inner blocks * support flow when page isnt saved * switch from where we get the current post id * update lock * fix types * Remove old compatibility notices from Cart and Checkout * Move useCompatibilityNotice to sidebar-compatibility-notice directory * Remove old CartCheckoutCompatibilityNotice * Create sidebar compatibility notice hoc * Add isCartOrCheckoutOrInnerBlock function * Refactor defaultNotice to use new isCartOrCheckoutOrInnerBlock func * Remove BlockSettings from checkout edit and export from checkout-shared * Change so component still renders, it is just hidden with display: none This is required because when it returns null the component gets skipped from being added to the Slot, then when it does return a component, then it gets rendered at the bottom of the Slot. By ensuring it always renders we can have it at the top all the time. * Set the priorities of the hoc filters so compat notice renders first * Make isCartOrCheckoutInnerBlock a hook * Remove old compatibility notice related tests * Remove BlockSettings from Cart * Remove withDefaultNotice hoc * Include DefaultNotice in compatibility notice * Remove DefaultNotice from Checkout * Rename withSidebarCompatibilityNotice to withSidebarNotices This is because it includes the sidebar compatibility notice and the default notices * Remove useIsCartOrCheckoutOrInnerBlock hook * Remove compatibility notice code from tests * Revert DefaultNotice back to the old one * Remove unused components * Remove withBlockSettings HOC and fix TS types This is an abstraction that is no longer required, we can just include BlockSettings in the Cart and Checkout blocks * Remove CartCheckoutFeedbackPrompt from BlockSettings It will be included in sidebar-notices instead * Fix TS Types in DefaultNotice * Add BlockSettings to cart and checkout edit * Editor: Add feedback box to the Cart & Checkout Inner Blocks (https://github.com/woocommerce/woocommerce-blocks/pull/6881) * Show "Feedback prompt" for all inner blocks * Fix the "feedback" notice position for these blocks The "checkout fields", "checkout billing address" and "checkout shipping address" have the addressFields option which gets rerendered and placed at the bottom of the inspector controls. * Tidy up the address-fields hoc * Use correct block name to check for billing or shipping address * Revert "Editor: Add feedback box to the Cart & Checkout Inner Blocks (https://github.com/woocommerce/woocommerce-blocks/pull/6881)" This reverts commit 5f3d6cf15ce08d9c303e62ec3e0d0315ead1281f. * Add hack to get feedback prompt to render last * Fix TS errors for context and attributes * Include CartCheckoutFeedbackPrompt in accountcontrols & addresscontrols * Do not include feedback prompt if on an address block or contact info * Remove unused hoc for address fields Co-authored-by: Nadir Seghir <nadir.seghir@gmail.com> Co-authored-by: Saad Tarhi <saad.trh@gmail.com>
2022-08-12 14:23:08 +00:00
it( 'required attribute can be toggled', async () => {
// Company is disabled by default, so first we need to enable it.
const toggleLabel = await findLabelWithText( 'Company' );
await toggleLabel.click();
Add dismissible compatibility notice to sidebar when editing Cart and Checkout (https://github.com/woocommerce/woocommerce-blocks/pull/6869) * Add default page notice * show notice all inner blocks * support flow when page isnt saved * switch from where we get the current post id * update lock * fix types * Remove old compatibility notices from Cart and Checkout * Move useCompatibilityNotice to sidebar-compatibility-notice directory * Remove old CartCheckoutCompatibilityNotice * Create sidebar compatibility notice hoc * Add isCartOrCheckoutOrInnerBlock function * Refactor defaultNotice to use new isCartOrCheckoutOrInnerBlock func * Remove BlockSettings from checkout edit and export from checkout-shared * Change so component still renders, it is just hidden with display: none This is required because when it returns null the component gets skipped from being added to the Slot, then when it does return a component, then it gets rendered at the bottom of the Slot. By ensuring it always renders we can have it at the top all the time. * Set the priorities of the hoc filters so compat notice renders first * Make isCartOrCheckoutInnerBlock a hook * Remove old compatibility notice related tests * Remove BlockSettings from Cart * Remove withDefaultNotice hoc * Include DefaultNotice in compatibility notice * Remove DefaultNotice from Checkout * Rename withSidebarCompatibilityNotice to withSidebarNotices This is because it includes the sidebar compatibility notice and the default notices * Remove useIsCartOrCheckoutOrInnerBlock hook * Remove compatibility notice code from tests * Revert DefaultNotice back to the old one * Remove unused components * Remove withBlockSettings HOC and fix TS types This is an abstraction that is no longer required, we can just include BlockSettings in the Cart and Checkout blocks * Remove CartCheckoutFeedbackPrompt from BlockSettings It will be included in sidebar-notices instead * Fix TS Types in DefaultNotice * Add BlockSettings to cart and checkout edit * Editor: Add feedback box to the Cart & Checkout Inner Blocks (https://github.com/woocommerce/woocommerce-blocks/pull/6881) * Show "Feedback prompt" for all inner blocks * Fix the "feedback" notice position for these blocks The "checkout fields", "checkout billing address" and "checkout shipping address" have the addressFields option which gets rerendered and placed at the bottom of the inspector controls. * Tidy up the address-fields hoc * Use correct block name to check for billing or shipping address * Revert "Editor: Add feedback box to the Cart & Checkout Inner Blocks (https://github.com/woocommerce/woocommerce-blocks/pull/6881)" This reverts commit 5f3d6cf15ce08d9c303e62ec3e0d0315ead1281f. * Add hack to get feedback prompt to render last * Fix TS errors for context and attributes * Include CartCheckoutFeedbackPrompt in accountcontrols & addresscontrols * Do not include feedback prompt if on an address block or contact info * Remove unused hoc for address fields Co-authored-by: Nadir Seghir <nadir.seghir@gmail.com> Co-authored-by: Saad Tarhi <saad.trh@gmail.com>
2022-08-12 14:23:08 +00:00
await expect(
'Require company name?'
).toToggleRequiredAttrOf( selector );
} );
} );
Add dismissible compatibility notice to sidebar when editing Cart and Checkout (https://github.com/woocommerce/woocommerce-blocks/pull/6869) * Add default page notice * show notice all inner blocks * support flow when page isnt saved * switch from where we get the current post id * update lock * fix types * Remove old compatibility notices from Cart and Checkout * Move useCompatibilityNotice to sidebar-compatibility-notice directory * Remove old CartCheckoutCompatibilityNotice * Create sidebar compatibility notice hoc * Add isCartOrCheckoutOrInnerBlock function * Refactor defaultNotice to use new isCartOrCheckoutOrInnerBlock func * Remove BlockSettings from checkout edit and export from checkout-shared * Change so component still renders, it is just hidden with display: none This is required because when it returns null the component gets skipped from being added to the Slot, then when it does return a component, then it gets rendered at the bottom of the Slot. By ensuring it always renders we can have it at the top all the time. * Set the priorities of the hoc filters so compat notice renders first * Make isCartOrCheckoutInnerBlock a hook * Remove old compatibility notice related tests * Remove BlockSettings from Cart * Remove withDefaultNotice hoc * Include DefaultNotice in compatibility notice * Remove DefaultNotice from Checkout * Rename withSidebarCompatibilityNotice to withSidebarNotices This is because it includes the sidebar compatibility notice and the default notices * Remove useIsCartOrCheckoutOrInnerBlock hook * Remove compatibility notice code from tests * Revert DefaultNotice back to the old one * Remove unused components * Remove withBlockSettings HOC and fix TS types This is an abstraction that is no longer required, we can just include BlockSettings in the Cart and Checkout blocks * Remove CartCheckoutFeedbackPrompt from BlockSettings It will be included in sidebar-notices instead * Fix TS Types in DefaultNotice * Add BlockSettings to cart and checkout edit * Editor: Add feedback box to the Cart & Checkout Inner Blocks (https://github.com/woocommerce/woocommerce-blocks/pull/6881) * Show "Feedback prompt" for all inner blocks * Fix the "feedback" notice position for these blocks The "checkout fields", "checkout billing address" and "checkout shipping address" have the addressFields option which gets rerendered and placed at the bottom of the inspector controls. * Tidy up the address-fields hoc * Use correct block name to check for billing or shipping address * Revert "Editor: Add feedback box to the Cart & Checkout Inner Blocks (https://github.com/woocommerce/woocommerce-blocks/pull/6881)" This reverts commit 5f3d6cf15ce08d9c303e62ec3e0d0315ead1281f. * Add hack to get feedback prompt to render last * Fix TS errors for context and attributes * Include CartCheckoutFeedbackPrompt in accountcontrols & addresscontrols * Do not include feedback prompt if on an address block or contact info * Remove unused hoc for address fields Co-authored-by: Nadir Seghir <nadir.seghir@gmail.com> Co-authored-by: Saad Tarhi <saad.trh@gmail.com>
2022-08-12 14:23:08 +00:00
describe( 'Apartment input', () => {
it( 'visibility can be toggled', async () => {
const selector = `${ block.class } #shipping-address_2`;
await expect( 'Apartment, suite, etc.' ).toToggleElement(
selector
);
} );
Add dismissible compatibility notice to sidebar when editing Cart and Checkout (https://github.com/woocommerce/woocommerce-blocks/pull/6869) * Add default page notice * show notice all inner blocks * support flow when page isnt saved * switch from where we get the current post id * update lock * fix types * Remove old compatibility notices from Cart and Checkout * Move useCompatibilityNotice to sidebar-compatibility-notice directory * Remove old CartCheckoutCompatibilityNotice * Create sidebar compatibility notice hoc * Add isCartOrCheckoutOrInnerBlock function * Refactor defaultNotice to use new isCartOrCheckoutOrInnerBlock func * Remove BlockSettings from checkout edit and export from checkout-shared * Change so component still renders, it is just hidden with display: none This is required because when it returns null the component gets skipped from being added to the Slot, then when it does return a component, then it gets rendered at the bottom of the Slot. By ensuring it always renders we can have it at the top all the time. * Set the priorities of the hoc filters so compat notice renders first * Make isCartOrCheckoutInnerBlock a hook * Remove old compatibility notice related tests * Remove BlockSettings from Cart * Remove withDefaultNotice hoc * Include DefaultNotice in compatibility notice * Remove DefaultNotice from Checkout * Rename withSidebarCompatibilityNotice to withSidebarNotices This is because it includes the sidebar compatibility notice and the default notices * Remove useIsCartOrCheckoutOrInnerBlock hook * Remove compatibility notice code from tests * Revert DefaultNotice back to the old one * Remove unused components * Remove withBlockSettings HOC and fix TS types This is an abstraction that is no longer required, we can just include BlockSettings in the Cart and Checkout blocks * Remove CartCheckoutFeedbackPrompt from BlockSettings It will be included in sidebar-notices instead * Fix TS Types in DefaultNotice * Add BlockSettings to cart and checkout edit * Editor: Add feedback box to the Cart & Checkout Inner Blocks (https://github.com/woocommerce/woocommerce-blocks/pull/6881) * Show "Feedback prompt" for all inner blocks * Fix the "feedback" notice position for these blocks The "checkout fields", "checkout billing address" and "checkout shipping address" have the addressFields option which gets rerendered and placed at the bottom of the inspector controls. * Tidy up the address-fields hoc * Use correct block name to check for billing or shipping address * Revert "Editor: Add feedback box to the Cart & Checkout Inner Blocks (https://github.com/woocommerce/woocommerce-blocks/pull/6881)" This reverts commit 5f3d6cf15ce08d9c303e62ec3e0d0315ead1281f. * Add hack to get feedback prompt to render last * Fix TS errors for context and attributes * Include CartCheckoutFeedbackPrompt in accountcontrols & addresscontrols * Do not include feedback prompt if on an address block or contact info * Remove unused hoc for address fields Co-authored-by: Nadir Seghir <nadir.seghir@gmail.com> Co-authored-by: Saad Tarhi <saad.trh@gmail.com>
2022-08-12 14:23:08 +00:00
} );
Add dismissible compatibility notice to sidebar when editing Cart and Checkout (https://github.com/woocommerce/woocommerce-blocks/pull/6869) * Add default page notice * show notice all inner blocks * support flow when page isnt saved * switch from where we get the current post id * update lock * fix types * Remove old compatibility notices from Cart and Checkout * Move useCompatibilityNotice to sidebar-compatibility-notice directory * Remove old CartCheckoutCompatibilityNotice * Create sidebar compatibility notice hoc * Add isCartOrCheckoutOrInnerBlock function * Refactor defaultNotice to use new isCartOrCheckoutOrInnerBlock func * Remove BlockSettings from checkout edit and export from checkout-shared * Change so component still renders, it is just hidden with display: none This is required because when it returns null the component gets skipped from being added to the Slot, then when it does return a component, then it gets rendered at the bottom of the Slot. By ensuring it always renders we can have it at the top all the time. * Set the priorities of the hoc filters so compat notice renders first * Make isCartOrCheckoutInnerBlock a hook * Remove old compatibility notice related tests * Remove BlockSettings from Cart * Remove withDefaultNotice hoc * Include DefaultNotice in compatibility notice * Remove DefaultNotice from Checkout * Rename withSidebarCompatibilityNotice to withSidebarNotices This is because it includes the sidebar compatibility notice and the default notices * Remove useIsCartOrCheckoutOrInnerBlock hook * Remove compatibility notice code from tests * Revert DefaultNotice back to the old one * Remove unused components * Remove withBlockSettings HOC and fix TS types This is an abstraction that is no longer required, we can just include BlockSettings in the Cart and Checkout blocks * Remove CartCheckoutFeedbackPrompt from BlockSettings It will be included in sidebar-notices instead * Fix TS Types in DefaultNotice * Add BlockSettings to cart and checkout edit * Editor: Add feedback box to the Cart & Checkout Inner Blocks (https://github.com/woocommerce/woocommerce-blocks/pull/6881) * Show "Feedback prompt" for all inner blocks * Fix the "feedback" notice position for these blocks The "checkout fields", "checkout billing address" and "checkout shipping address" have the addressFields option which gets rerendered and placed at the bottom of the inspector controls. * Tidy up the address-fields hoc * Use correct block name to check for billing or shipping address * Revert "Editor: Add feedback box to the Cart & Checkout Inner Blocks (https://github.com/woocommerce/woocommerce-blocks/pull/6881)" This reverts commit 5f3d6cf15ce08d9c303e62ec3e0d0315ead1281f. * Add hack to get feedback prompt to render last * Fix TS errors for context and attributes * Include CartCheckoutFeedbackPrompt in accountcontrols & addresscontrols * Do not include feedback prompt if on an address block or contact info * Remove unused hoc for address fields Co-authored-by: Nadir Seghir <nadir.seghir@gmail.com> Co-authored-by: Saad Tarhi <saad.trh@gmail.com>
2022-08-12 14:23:08 +00:00
describe( 'Phone input', () => {
const selector = `${ block.class } #shipping-phone`;
Add dismissible compatibility notice to sidebar when editing Cart and Checkout (https://github.com/woocommerce/woocommerce-blocks/pull/6869) * Add default page notice * show notice all inner blocks * support flow when page isnt saved * switch from where we get the current post id * update lock * fix types * Remove old compatibility notices from Cart and Checkout * Move useCompatibilityNotice to sidebar-compatibility-notice directory * Remove old CartCheckoutCompatibilityNotice * Create sidebar compatibility notice hoc * Add isCartOrCheckoutOrInnerBlock function * Refactor defaultNotice to use new isCartOrCheckoutOrInnerBlock func * Remove BlockSettings from checkout edit and export from checkout-shared * Change so component still renders, it is just hidden with display: none This is required because when it returns null the component gets skipped from being added to the Slot, then when it does return a component, then it gets rendered at the bottom of the Slot. By ensuring it always renders we can have it at the top all the time. * Set the priorities of the hoc filters so compat notice renders first * Make isCartOrCheckoutInnerBlock a hook * Remove old compatibility notice related tests * Remove BlockSettings from Cart * Remove withDefaultNotice hoc * Include DefaultNotice in compatibility notice * Remove DefaultNotice from Checkout * Rename withSidebarCompatibilityNotice to withSidebarNotices This is because it includes the sidebar compatibility notice and the default notices * Remove useIsCartOrCheckoutOrInnerBlock hook * Remove compatibility notice code from tests * Revert DefaultNotice back to the old one * Remove unused components * Remove withBlockSettings HOC and fix TS types This is an abstraction that is no longer required, we can just include BlockSettings in the Cart and Checkout blocks * Remove CartCheckoutFeedbackPrompt from BlockSettings It will be included in sidebar-notices instead * Fix TS Types in DefaultNotice * Add BlockSettings to cart and checkout edit * Editor: Add feedback box to the Cart & Checkout Inner Blocks (https://github.com/woocommerce/woocommerce-blocks/pull/6881) * Show "Feedback prompt" for all inner blocks * Fix the "feedback" notice position for these blocks The "checkout fields", "checkout billing address" and "checkout shipping address" have the addressFields option which gets rerendered and placed at the bottom of the inspector controls. * Tidy up the address-fields hoc * Use correct block name to check for billing or shipping address * Revert "Editor: Add feedback box to the Cart & Checkout Inner Blocks (https://github.com/woocommerce/woocommerce-blocks/pull/6881)" This reverts commit 5f3d6cf15ce08d9c303e62ec3e0d0315ead1281f. * Add hack to get feedback prompt to render last * Fix TS errors for context and attributes * Include CartCheckoutFeedbackPrompt in accountcontrols & addresscontrols * Do not include feedback prompt if on an address block or contact info * Remove unused hoc for address fields Co-authored-by: Nadir Seghir <nadir.seghir@gmail.com> Co-authored-by: Saad Tarhi <saad.trh@gmail.com>
2022-08-12 14:23:08 +00:00
it( 'visibility can be toggled', async () => {
await expect( 'Phone' ).toToggleElement( selector );
} );
Add dismissible compatibility notice to sidebar when editing Cart and Checkout (https://github.com/woocommerce/woocommerce-blocks/pull/6869) * Add default page notice * show notice all inner blocks * support flow when page isnt saved * switch from where we get the current post id * update lock * fix types * Remove old compatibility notices from Cart and Checkout * Move useCompatibilityNotice to sidebar-compatibility-notice directory * Remove old CartCheckoutCompatibilityNotice * Create sidebar compatibility notice hoc * Add isCartOrCheckoutOrInnerBlock function * Refactor defaultNotice to use new isCartOrCheckoutOrInnerBlock func * Remove BlockSettings from checkout edit and export from checkout-shared * Change so component still renders, it is just hidden with display: none This is required because when it returns null the component gets skipped from being added to the Slot, then when it does return a component, then it gets rendered at the bottom of the Slot. By ensuring it always renders we can have it at the top all the time. * Set the priorities of the hoc filters so compat notice renders first * Make isCartOrCheckoutInnerBlock a hook * Remove old compatibility notice related tests * Remove BlockSettings from Cart * Remove withDefaultNotice hoc * Include DefaultNotice in compatibility notice * Remove DefaultNotice from Checkout * Rename withSidebarCompatibilityNotice to withSidebarNotices This is because it includes the sidebar compatibility notice and the default notices * Remove useIsCartOrCheckoutOrInnerBlock hook * Remove compatibility notice code from tests * Revert DefaultNotice back to the old one * Remove unused components * Remove withBlockSettings HOC and fix TS types This is an abstraction that is no longer required, we can just include BlockSettings in the Cart and Checkout blocks * Remove CartCheckoutFeedbackPrompt from BlockSettings It will be included in sidebar-notices instead * Fix TS Types in DefaultNotice * Add BlockSettings to cart and checkout edit * Editor: Add feedback box to the Cart & Checkout Inner Blocks (https://github.com/woocommerce/woocommerce-blocks/pull/6881) * Show "Feedback prompt" for all inner blocks * Fix the "feedback" notice position for these blocks The "checkout fields", "checkout billing address" and "checkout shipping address" have the addressFields option which gets rerendered and placed at the bottom of the inspector controls. * Tidy up the address-fields hoc * Use correct block name to check for billing or shipping address * Revert "Editor: Add feedback box to the Cart & Checkout Inner Blocks (https://github.com/woocommerce/woocommerce-blocks/pull/6881)" This reverts commit 5f3d6cf15ce08d9c303e62ec3e0d0315ead1281f. * Add hack to get feedback prompt to render last * Fix TS errors for context and attributes * Include CartCheckoutFeedbackPrompt in accountcontrols & addresscontrols * Do not include feedback prompt if on an address block or contact info * Remove unused hoc for address fields Co-authored-by: Nadir Seghir <nadir.seghir@gmail.com> Co-authored-by: Saad Tarhi <saad.trh@gmail.com>
2022-08-12 14:23:08 +00:00
it( 'required attribute can be toggled', async () => {
await expect(
'Require phone number?'
).toToggleRequiredAttrOf( selector );
} );
} );
Add dismissible compatibility notice to sidebar when editing Cart and Checkout (https://github.com/woocommerce/woocommerce-blocks/pull/6869) * Add default page notice * show notice all inner blocks * support flow when page isnt saved * switch from where we get the current post id * update lock * fix types * Remove old compatibility notices from Cart and Checkout * Move useCompatibilityNotice to sidebar-compatibility-notice directory * Remove old CartCheckoutCompatibilityNotice * Create sidebar compatibility notice hoc * Add isCartOrCheckoutOrInnerBlock function * Refactor defaultNotice to use new isCartOrCheckoutOrInnerBlock func * Remove BlockSettings from checkout edit and export from checkout-shared * Change so component still renders, it is just hidden with display: none This is required because when it returns null the component gets skipped from being added to the Slot, then when it does return a component, then it gets rendered at the bottom of the Slot. By ensuring it always renders we can have it at the top all the time. * Set the priorities of the hoc filters so compat notice renders first * Make isCartOrCheckoutInnerBlock a hook * Remove old compatibility notice related tests * Remove BlockSettings from Cart * Remove withDefaultNotice hoc * Include DefaultNotice in compatibility notice * Remove DefaultNotice from Checkout * Rename withSidebarCompatibilityNotice to withSidebarNotices This is because it includes the sidebar compatibility notice and the default notices * Remove useIsCartOrCheckoutOrInnerBlock hook * Remove compatibility notice code from tests * Revert DefaultNotice back to the old one * Remove unused components * Remove withBlockSettings HOC and fix TS types This is an abstraction that is no longer required, we can just include BlockSettings in the Cart and Checkout blocks * Remove CartCheckoutFeedbackPrompt from BlockSettings It will be included in sidebar-notices instead * Fix TS Types in DefaultNotice * Add BlockSettings to cart and checkout edit * Editor: Add feedback box to the Cart & Checkout Inner Blocks (https://github.com/woocommerce/woocommerce-blocks/pull/6881) * Show "Feedback prompt" for all inner blocks * Fix the "feedback" notice position for these blocks The "checkout fields", "checkout billing address" and "checkout shipping address" have the addressFields option which gets rerendered and placed at the bottom of the inspector controls. * Tidy up the address-fields hoc * Use correct block name to check for billing or shipping address * Revert "Editor: Add feedback box to the Cart & Checkout Inner Blocks (https://github.com/woocommerce/woocommerce-blocks/pull/6881)" This reverts commit 5f3d6cf15ce08d9c303e62ec3e0d0315ead1281f. * Add hack to get feedback prompt to render last * Fix TS errors for context and attributes * Include CartCheckoutFeedbackPrompt in accountcontrols & addresscontrols * Do not include feedback prompt if on an address block or contact info * Remove unused hoc for address fields Co-authored-by: Nadir Seghir <nadir.seghir@gmail.com> Co-authored-by: Saad Tarhi <saad.trh@gmail.com>
2022-08-12 14:23:08 +00:00
} );
describe( 'action block attributes', () => {
beforeEach( async () => {
await openDocumentSettingsSidebar();
await switchBlockInspectorTabWhenGutenbergIsInstalled(
'Settings'
);
Add dismissible compatibility notice to sidebar when editing Cart and Checkout (https://github.com/woocommerce/woocommerce-blocks/pull/6869) * Add default page notice * show notice all inner blocks * support flow when page isnt saved * switch from where we get the current post id * update lock * fix types * Remove old compatibility notices from Cart and Checkout * Move useCompatibilityNotice to sidebar-compatibility-notice directory * Remove old CartCheckoutCompatibilityNotice * Create sidebar compatibility notice hoc * Add isCartOrCheckoutOrInnerBlock function * Refactor defaultNotice to use new isCartOrCheckoutOrInnerBlock func * Remove BlockSettings from checkout edit and export from checkout-shared * Change so component still renders, it is just hidden with display: none This is required because when it returns null the component gets skipped from being added to the Slot, then when it does return a component, then it gets rendered at the bottom of the Slot. By ensuring it always renders we can have it at the top all the time. * Set the priorities of the hoc filters so compat notice renders first * Make isCartOrCheckoutInnerBlock a hook * Remove old compatibility notice related tests * Remove BlockSettings from Cart * Remove withDefaultNotice hoc * Include DefaultNotice in compatibility notice * Remove DefaultNotice from Checkout * Rename withSidebarCompatibilityNotice to withSidebarNotices This is because it includes the sidebar compatibility notice and the default notices * Remove useIsCartOrCheckoutOrInnerBlock hook * Remove compatibility notice code from tests * Revert DefaultNotice back to the old one * Remove unused components * Remove withBlockSettings HOC and fix TS types This is an abstraction that is no longer required, we can just include BlockSettings in the Cart and Checkout blocks * Remove CartCheckoutFeedbackPrompt from BlockSettings It will be included in sidebar-notices instead * Fix TS Types in DefaultNotice * Add BlockSettings to cart and checkout edit * Editor: Add feedback box to the Cart & Checkout Inner Blocks (https://github.com/woocommerce/woocommerce-blocks/pull/6881) * Show "Feedback prompt" for all inner blocks * Fix the "feedback" notice position for these blocks The "checkout fields", "checkout billing address" and "checkout shipping address" have the addressFields option which gets rerendered and placed at the bottom of the inspector controls. * Tidy up the address-fields hoc * Use correct block name to check for billing or shipping address * Revert "Editor: Add feedback box to the Cart & Checkout Inner Blocks (https://github.com/woocommerce/woocommerce-blocks/pull/6881)" This reverts commit 5f3d6cf15ce08d9c303e62ec3e0d0315ead1281f. * Add hack to get feedback prompt to render last * Fix TS errors for context and attributes * Include CartCheckoutFeedbackPrompt in accountcontrols & addresscontrols * Do not include feedback prompt if on an address block or contact info * Remove unused hoc for address fields Co-authored-by: Nadir Seghir <nadir.seghir@gmail.com> Co-authored-by: Saad Tarhi <saad.trh@gmail.com>
2022-08-12 14:23:08 +00:00
await selectBlockByName( 'woocommerce/checkout-actions-block' );
} );
Add dismissible compatibility notice to sidebar when editing Cart and Checkout (https://github.com/woocommerce/woocommerce-blocks/pull/6869) * Add default page notice * show notice all inner blocks * support flow when page isnt saved * switch from where we get the current post id * update lock * fix types * Remove old compatibility notices from Cart and Checkout * Move useCompatibilityNotice to sidebar-compatibility-notice directory * Remove old CartCheckoutCompatibilityNotice * Create sidebar compatibility notice hoc * Add isCartOrCheckoutOrInnerBlock function * Refactor defaultNotice to use new isCartOrCheckoutOrInnerBlock func * Remove BlockSettings from checkout edit and export from checkout-shared * Change so component still renders, it is just hidden with display: none This is required because when it returns null the component gets skipped from being added to the Slot, then when it does return a component, then it gets rendered at the bottom of the Slot. By ensuring it always renders we can have it at the top all the time. * Set the priorities of the hoc filters so compat notice renders first * Make isCartOrCheckoutInnerBlock a hook * Remove old compatibility notice related tests * Remove BlockSettings from Cart * Remove withDefaultNotice hoc * Include DefaultNotice in compatibility notice * Remove DefaultNotice from Checkout * Rename withSidebarCompatibilityNotice to withSidebarNotices This is because it includes the sidebar compatibility notice and the default notices * Remove useIsCartOrCheckoutOrInnerBlock hook * Remove compatibility notice code from tests * Revert DefaultNotice back to the old one * Remove unused components * Remove withBlockSettings HOC and fix TS types This is an abstraction that is no longer required, we can just include BlockSettings in the Cart and Checkout blocks * Remove CartCheckoutFeedbackPrompt from BlockSettings It will be included in sidebar-notices instead * Fix TS Types in DefaultNotice * Add BlockSettings to cart and checkout edit * Editor: Add feedback box to the Cart & Checkout Inner Blocks (https://github.com/woocommerce/woocommerce-blocks/pull/6881) * Show "Feedback prompt" for all inner blocks * Fix the "feedback" notice position for these blocks The "checkout fields", "checkout billing address" and "checkout shipping address" have the addressFields option which gets rerendered and placed at the bottom of the inspector controls. * Tidy up the address-fields hoc * Use correct block name to check for billing or shipping address * Revert "Editor: Add feedback box to the Cart & Checkout Inner Blocks (https://github.com/woocommerce/woocommerce-blocks/pull/6881)" This reverts commit 5f3d6cf15ce08d9c303e62ec3e0d0315ead1281f. * Add hack to get feedback prompt to render last * Fix TS errors for context and attributes * Include CartCheckoutFeedbackPrompt in accountcontrols & addresscontrols * Do not include feedback prompt if on an address block or contact info * Remove unused hoc for address fields Co-authored-by: Nadir Seghir <nadir.seghir@gmail.com> Co-authored-by: Saad Tarhi <saad.trh@gmail.com>
2022-08-12 14:23:08 +00:00
describe( 'Return to cart link', () => {
it( 'visibility can be toggled', async () => {
const selector = `${ block.class } .wc-block-components-checkout-return-to-cart-button`;
const toggleLabel = await findLabelWithText(
'Show a "Return to Cart" link'
);
Add dismissible compatibility notice to sidebar when editing Cart and Checkout (https://github.com/woocommerce/woocommerce-blocks/pull/6869) * Add default page notice * show notice all inner blocks * support flow when page isnt saved * switch from where we get the current post id * update lock * fix types * Remove old compatibility notices from Cart and Checkout * Move useCompatibilityNotice to sidebar-compatibility-notice directory * Remove old CartCheckoutCompatibilityNotice * Create sidebar compatibility notice hoc * Add isCartOrCheckoutOrInnerBlock function * Refactor defaultNotice to use new isCartOrCheckoutOrInnerBlock func * Remove BlockSettings from checkout edit and export from checkout-shared * Change so component still renders, it is just hidden with display: none This is required because when it returns null the component gets skipped from being added to the Slot, then when it does return a component, then it gets rendered at the bottom of the Slot. By ensuring it always renders we can have it at the top all the time. * Set the priorities of the hoc filters so compat notice renders first * Make isCartOrCheckoutInnerBlock a hook * Remove old compatibility notice related tests * Remove BlockSettings from Cart * Remove withDefaultNotice hoc * Include DefaultNotice in compatibility notice * Remove DefaultNotice from Checkout * Rename withSidebarCompatibilityNotice to withSidebarNotices This is because it includes the sidebar compatibility notice and the default notices * Remove useIsCartOrCheckoutOrInnerBlock hook * Remove compatibility notice code from tests * Revert DefaultNotice back to the old one * Remove unused components * Remove withBlockSettings HOC and fix TS types This is an abstraction that is no longer required, we can just include BlockSettings in the Cart and Checkout blocks * Remove CartCheckoutFeedbackPrompt from BlockSettings It will be included in sidebar-notices instead * Fix TS Types in DefaultNotice * Add BlockSettings to cart and checkout edit * Editor: Add feedback box to the Cart & Checkout Inner Blocks (https://github.com/woocommerce/woocommerce-blocks/pull/6881) * Show "Feedback prompt" for all inner blocks * Fix the "feedback" notice position for these blocks The "checkout fields", "checkout billing address" and "checkout shipping address" have the addressFields option which gets rerendered and placed at the bottom of the inspector controls. * Tidy up the address-fields hoc * Use correct block name to check for billing or shipping address * Revert "Editor: Add feedback box to the Cart & Checkout Inner Blocks (https://github.com/woocommerce/woocommerce-blocks/pull/6881)" This reverts commit 5f3d6cf15ce08d9c303e62ec3e0d0315ead1281f. * Add hack to get feedback prompt to render last * Fix TS errors for context and attributes * Include CartCheckoutFeedbackPrompt in accountcontrols & addresscontrols * Do not include feedback prompt if on an address block or contact info * Remove unused hoc for address fields Co-authored-by: Nadir Seghir <nadir.seghir@gmail.com> Co-authored-by: Saad Tarhi <saad.trh@gmail.com>
2022-08-12 14:23:08 +00:00
await expect( toggleLabel ).toToggleElement( selector );
} );
} );
} );
} );
describe( 'in widget editor', () => {
it( "can't be inserted in a widget area", async () => {
await merchant.login();
await openWidgetEditor();
await closeModalIfExists();
await searchForBlock( block.name );
const checkoutButton = await page.$x(
`//button//span[text()='${ block.name }']`
);
expect( checkoutButton ).toHaveLength( 0 );
} );
} );
} );