[Blocks]: remove skipped tests (#46594)
* remove skipped tests * Add changefile(s) from automation for the following project(s): woocommerce-blocks --------- Co-authored-by: github-actions <github-actions@github.com>
This commit is contained in:
parent
fb481bdce5
commit
7d41472206
|
@ -1,68 +0,0 @@
|
|||
/**
|
||||
* External dependencies
|
||||
*/
|
||||
import {
|
||||
switchBlockInspectorTab,
|
||||
switchUserToAdmin,
|
||||
} from '@wordpress/e2e-test-utils';
|
||||
import {
|
||||
visitBlockPage,
|
||||
selectBlockByName,
|
||||
} from '@woocommerce/blocks-test-utils';
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
import { openSettingsSidebar } from '../../utils.js';
|
||||
|
||||
const block = {
|
||||
name: 'Active Filters',
|
||||
slug: 'woocommerce/active-filters',
|
||||
class: '.wc-block-active-filters',
|
||||
title: 'Active filters',
|
||||
};
|
||||
|
||||
describe.skip( `${ 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 () => {
|
||||
await openSettingsSidebar();
|
||||
await selectBlockByName( block.slug );
|
||||
await switchBlockInspectorTab( 'Settings' );
|
||||
} );
|
||||
|
||||
it( "allows changing the block's title", async () => {
|
||||
const textareaSelector =
|
||||
'.wp-block-woocommerce-filter-wrapper .wp-block-heading';
|
||||
await expect( page ).toFill( textareaSelector, 'New Title' );
|
||||
await expect( page ).toMatchElement(
|
||||
'.wp-block-woocommerce-filter-wrapper .wp-block-heading',
|
||||
{ text: 'New Title' }
|
||||
);
|
||||
// reset
|
||||
await expect( page ).toFill( textareaSelector, block.title );
|
||||
} );
|
||||
|
||||
it( 'allows changing the Display Style', async () => {
|
||||
// Click the button to convert the display style to Chips.
|
||||
await expect( page ).toClick( 'button', { text: 'Chips' } );
|
||||
await expect( page ).toMatchElement(
|
||||
'.wc-block-active-filters__list.wc-block-active-filters__list--chips'
|
||||
);
|
||||
|
||||
// Click the button to convert the display style to List.
|
||||
await expect( page ).toClick( 'button', { text: 'List' } );
|
||||
await expect( page ).not.toMatchElement(
|
||||
'.wc-block-active-filters__list.wc-block-active-filters__list--chips'
|
||||
);
|
||||
} );
|
||||
} );
|
||||
} );
|
|
@ -1,68 +0,0 @@
|
|||
/**
|
||||
* External dependencies
|
||||
*/
|
||||
import {
|
||||
getAllBlocks,
|
||||
switchUserToAdmin,
|
||||
canvas,
|
||||
openListView,
|
||||
} from '@wordpress/e2e-test-utils';
|
||||
import { visitBlockPage } from '@woocommerce/blocks-test-utils';
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
import {
|
||||
insertBlockDontWaitForInsertClose,
|
||||
openSettingsSidebar,
|
||||
} from '../../utils';
|
||||
|
||||
const block = {
|
||||
name: 'Products (Beta)',
|
||||
slug: 'woocommerce/product-query',
|
||||
class: '.wp-block-query',
|
||||
};
|
||||
|
||||
// These tests are skipped and previously relied on GUTENBERG_EDITOR_CONTEXT.
|
||||
describe.skip( `${ block.name } Block`, () => {
|
||||
beforeAll( async () => {
|
||||
await switchUserToAdmin();
|
||||
await visitBlockPage( `${ block.name } Block` );
|
||||
} );
|
||||
|
||||
it( 'can be inserted more than once', async () => {
|
||||
await insertBlockDontWaitForInsertClose( block.name );
|
||||
expect( await getAllBlocks() ).toHaveLength( 2 );
|
||||
} );
|
||||
|
||||
it( 'renders without crashing', async () => {
|
||||
await expect( page ).toRenderBlock( block );
|
||||
} );
|
||||
|
||||
/**
|
||||
* We changed the “Show only products on sale” from a top-level toggle
|
||||
* setting to a product filter, but tests for them haven't been updated
|
||||
* yet. We will fix these tests in a follow-up PR.
|
||||
*/
|
||||
it.skip( 'Editor preview shows only on sale products after enabling `Show only products on sale`', async () => {
|
||||
await visitBlockPage( `${ block.name } Block` );
|
||||
const canvasEl = canvas();
|
||||
await openSettingsSidebar();
|
||||
await openListView();
|
||||
await page.click(
|
||||
'.block-editor-list-view-block__contents-container a.components-button'
|
||||
);
|
||||
const [ onSaleToggle ] = await page.$x(
|
||||
'//label[text()="Show only products on sale"]'
|
||||
);
|
||||
await onSaleToggle.click();
|
||||
await canvasEl.waitForSelector( `${ block.class } > p` );
|
||||
await canvasEl.waitForSelector(
|
||||
`${ block.class } > ul.wp-block-post-template`
|
||||
);
|
||||
const products = await canvasEl.$$(
|
||||
`${ block.class } ul.wp-block-post-template > li.block-editor-block-preview__live-content`
|
||||
);
|
||||
expect( products ).toHaveLength( 1 );
|
||||
} );
|
||||
} );
|
|
@ -1,153 +0,0 @@
|
|||
/**
|
||||
* External dependencies
|
||||
*/
|
||||
import { ensureSidebarOpened, canvas } from '@wordpress/e2e-test-utils';
|
||||
import {
|
||||
saveOrPublish,
|
||||
selectBlockByName,
|
||||
findToolsPanelWithTitle,
|
||||
getFixtureProductsData,
|
||||
shopper,
|
||||
getToggleIdByLabel,
|
||||
} from '@woocommerce/blocks-test-utils';
|
||||
import { ElementHandle } from 'puppeteer';
|
||||
import { setCheckbox } from '@woocommerce/e2e-utils';
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
import {
|
||||
block,
|
||||
SELECTORS,
|
||||
resetProductQueryBlockPage,
|
||||
toggleAdvancedFilter,
|
||||
getPreviewProducts,
|
||||
getFrontEndProducts,
|
||||
clearSelectedTokens,
|
||||
selectToken,
|
||||
} from './common';
|
||||
|
||||
// These tests are skipped and previously relied on GUTENBERG_EDITOR_CONTEXT.
|
||||
describe.skip( `${ block.name } > Advanced Filters`, () => {
|
||||
let $productFiltersPanel: ElementHandle< Node >;
|
||||
const defaultCount = getFixtureProductsData().length;
|
||||
const saleCount = getFixtureProductsData( 'sale_price' ).length;
|
||||
const outOfStockCount = getFixtureProductsData( 'stock_status' ).filter(
|
||||
( status: string ) => status === 'outofstock'
|
||||
).length;
|
||||
|
||||
beforeEach( async () => {
|
||||
/**
|
||||
* Reset the block page before each test to ensure the block is
|
||||
* inserted in a known state. This is also needed to ensure each
|
||||
* test can be run individually.
|
||||
*/
|
||||
await resetProductQueryBlockPage();
|
||||
await ensureSidebarOpened();
|
||||
await selectBlockByName( block.slug );
|
||||
$productFiltersPanel = await findToolsPanelWithTitle(
|
||||
'Advanced Filters'
|
||||
);
|
||||
} );
|
||||
|
||||
/**
|
||||
* Reset the content of Product Query Block page after this test suite
|
||||
* to avoid breaking other tests.
|
||||
*/
|
||||
afterAll( async () => {
|
||||
await resetProductQueryBlockPage();
|
||||
} );
|
||||
|
||||
it( 'Editor preview shows all products by default', async () => {
|
||||
expect( await getPreviewProducts() ).toHaveLength( defaultCount );
|
||||
} );
|
||||
|
||||
it( 'On the front end, blocks shows all products by default', async () => {
|
||||
expect( await getPreviewProducts() ).toHaveLength( defaultCount );
|
||||
} );
|
||||
|
||||
describe( 'Sale Status', () => {
|
||||
it( 'Sale status is disabled by default', async () => {
|
||||
await expect( $productFiltersPanel ).not.toMatch(
|
||||
'Show only products on sale'
|
||||
);
|
||||
} );
|
||||
|
||||
it( 'Can add and remove Sale Status filter', async () => {
|
||||
await toggleAdvancedFilter( 'Sale status' );
|
||||
await expect( $productFiltersPanel ).toMatch(
|
||||
'Show only products on sale'
|
||||
);
|
||||
await toggleAdvancedFilter( 'Sale status' );
|
||||
await expect( $productFiltersPanel ).not.toMatch(
|
||||
'Show only products on sale'
|
||||
);
|
||||
} );
|
||||
|
||||
it( 'Enable Sale Status > Editor preview shows only on sale products', async () => {
|
||||
await toggleAdvancedFilter( 'Sale status' );
|
||||
await setCheckbox(
|
||||
await getToggleIdByLabel( 'Show only products on sale' )
|
||||
);
|
||||
expect( await getPreviewProducts() ).toHaveLength( saleCount );
|
||||
} );
|
||||
|
||||
it( 'Enable Sale Status > On the front end, block shows only on sale products', async () => {
|
||||
await toggleAdvancedFilter( 'Sale status' );
|
||||
await setCheckbox(
|
||||
await getToggleIdByLabel( 'Show only products on sale' )
|
||||
);
|
||||
await canvas().waitForSelector( SELECTORS.productsGrid );
|
||||
await saveOrPublish();
|
||||
await shopper.block.goToBlockPage( block.name );
|
||||
expect( await getFrontEndProducts() ).toHaveLength( saleCount );
|
||||
} );
|
||||
} );
|
||||
|
||||
describe( 'Stock Status', () => {
|
||||
it( 'Stock status is enabled by default', async () => {
|
||||
await expect( $productFiltersPanel ).toMatchElement(
|
||||
SELECTORS.formTokenField.label,
|
||||
{ text: 'Stock status' }
|
||||
);
|
||||
} );
|
||||
|
||||
it( 'Can add and remove Stock Status filter', async () => {
|
||||
await toggleAdvancedFilter( 'Stock status' );
|
||||
await expect( $productFiltersPanel ).not.toMatchElement(
|
||||
SELECTORS.formTokenField.label,
|
||||
{ text: 'Stock status' }
|
||||
);
|
||||
await toggleAdvancedFilter( 'Stock status' );
|
||||
await expect( $productFiltersPanel ).toMatchElement(
|
||||
SELECTORS.formTokenField.label,
|
||||
{ text: 'Stock status' }
|
||||
);
|
||||
} );
|
||||
|
||||
it( 'All statuses are enabled by default', async () => {
|
||||
await expect( $productFiltersPanel ).toMatch( 'In stock' );
|
||||
await expect( $productFiltersPanel ).toMatch( 'Out of stock' );
|
||||
await expect( $productFiltersPanel ).toMatch( 'On backorder' );
|
||||
} );
|
||||
|
||||
it( 'Set Stock status to Out of stock > Editor preview shows only out-of-stock products', async () => {
|
||||
await clearSelectedTokens( $productFiltersPanel );
|
||||
await selectToken( 'Stock status', 'Out of stock' );
|
||||
expect( await getPreviewProducts() ).toHaveLength(
|
||||
outOfStockCount
|
||||
);
|
||||
} );
|
||||
|
||||
it( 'Set Stock status to Out of stock > On the front end, block shows only out-of-stock products', async () => {
|
||||
await clearSelectedTokens( $productFiltersPanel );
|
||||
await selectToken( 'Stock status', 'Out of stock' );
|
||||
await canvas().waitForSelector( SELECTORS.productsGrid );
|
||||
await saveOrPublish();
|
||||
await shopper.block.goToBlockPage( block.name );
|
||||
expect( await getFrontEndProducts() ).toHaveLength(
|
||||
outOfStockCount
|
||||
);
|
||||
} );
|
||||
} );
|
||||
} );
|
|
@ -1,94 +0,0 @@
|
|||
/**
|
||||
* External dependencies
|
||||
*/
|
||||
import { canvas } from '@wordpress/e2e-test-utils';
|
||||
import {
|
||||
saveOrPublish,
|
||||
shopper,
|
||||
insertInnerBlock,
|
||||
getFixtureProductsData,
|
||||
} from '@woocommerce/blocks-test-utils';
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
import {
|
||||
block,
|
||||
SELECTORS,
|
||||
resetProductQueryBlockPage,
|
||||
getProductElementNodesCount,
|
||||
getEditorProductElementNodesCount,
|
||||
} from './common';
|
||||
|
||||
// These tests are skipped and previously relied on GUTENBERG_EDITOR_CONTEXT.
|
||||
describe.skip( `${ block.name } > Atomic blocks`, () => {
|
||||
beforeEach( async () => {
|
||||
await resetProductQueryBlockPage();
|
||||
} );
|
||||
|
||||
afterAll( async () => {
|
||||
await resetProductQueryBlockPage();
|
||||
} );
|
||||
|
||||
it( 'Can add the Add to Cart Button block and render it on the front end', async () => {
|
||||
await page.waitForSelector( SELECTORS.productButton );
|
||||
await expect( canvas() ).toMatchElement( SELECTORS.productButton, {
|
||||
text: 'Add to cart',
|
||||
} );
|
||||
await insertInnerBlock( 'Add to Cart Button', 'core/post-template' );
|
||||
expect(
|
||||
await getEditorProductElementNodesCount( SELECTORS.productButton )
|
||||
).toEqual( 2 );
|
||||
|
||||
await shopper.block.goToBlockPage( block.name );
|
||||
await page.waitForSelector( SELECTORS.productButton );
|
||||
await expect( page ).toClick( 'button', {
|
||||
text: 'Add to cart',
|
||||
} );
|
||||
await shopper.block.goToCart();
|
||||
await page.waitForSelector( '.wc-block-cart-items__row' );
|
||||
expect(
|
||||
await getProductElementNodesCount( SELECTORS.cartItemRow )
|
||||
).toEqual( 1 );
|
||||
} );
|
||||
|
||||
it( 'Can add the Product Image block', async () => {
|
||||
await page.waitForSelector( SELECTORS.productImage );
|
||||
await insertInnerBlock( 'Product Image', 'core/post-template' );
|
||||
expect(
|
||||
await getEditorProductElementNodesCount( SELECTORS.productImage )
|
||||
).toEqual( 2 );
|
||||
} );
|
||||
|
||||
it( 'Can add the Product Price block and render it on the front end', async () => {
|
||||
const fixturePrices = getFixtureProductsData( 'regular_price' );
|
||||
const testPrice =
|
||||
fixturePrices[ Math.floor( Math.random() * fixturePrices.length ) ];
|
||||
await page.waitForSelector( SELECTORS.productPrice );
|
||||
await expect( canvas() ).toMatchElement( SELECTORS.productPrice, {
|
||||
text: testPrice,
|
||||
} );
|
||||
await insertInnerBlock( 'Product Price', 'core/post-template' );
|
||||
expect(
|
||||
await getEditorProductElementNodesCount( SELECTORS.productPrice )
|
||||
).toEqual( 2 );
|
||||
|
||||
await shopper.block.goToBlockPage( block.name );
|
||||
await page.waitForSelector( SELECTORS.productPrice );
|
||||
await expect( page ).toMatchElement( SELECTORS.productPrice, {
|
||||
text: testPrice,
|
||||
} );
|
||||
} );
|
||||
|
||||
it( 'Can add the Product Ratings block and render it on the front end', async () => {
|
||||
await insertInnerBlock( 'Product Rating', 'core/post-template' );
|
||||
expect(
|
||||
await getEditorProductElementNodesCount( SELECTORS.productRating )
|
||||
).toEqual( 1 );
|
||||
await saveOrPublish();
|
||||
await shopper.block.goToBlockPage( block.name );
|
||||
expect(
|
||||
await getProductElementNodesCount( SELECTORS.productRating )
|
||||
).toEqual( getFixtureProductsData().length );
|
||||
} );
|
||||
} );
|
|
@ -1,204 +0,0 @@
|
|||
/**
|
||||
* We choose to name this file as common instead of splitting it to multiple
|
||||
* files like constants.ts and utils.ts because we want to keep the file
|
||||
* structure as simple as possible. We also want to distinguish the local
|
||||
* utilities like resetProductQueryBlockPage with our e2e utilites in
|
||||
* `@woocommerce/blocks-test-utils`. We think exporting local utilites from
|
||||
* a different file name is an simple but effective way to achieve that goal.
|
||||
*/
|
||||
|
||||
/**
|
||||
* External dependencies
|
||||
*/
|
||||
import { canvas, setPostContent } from '@wordpress/e2e-test-utils';
|
||||
import {
|
||||
shopper,
|
||||
visitBlockPage,
|
||||
saveOrPublish,
|
||||
findToolsPanelWithTitle,
|
||||
getFormElementIdByLabel,
|
||||
insertShortcodeBlock,
|
||||
} from '@woocommerce/blocks-test-utils';
|
||||
import { ElementHandle } from 'puppeteer';
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
import { waitForCanvas } from '../../../utils';
|
||||
import fixture from '../__fixtures__/products-beta.fixture.json';
|
||||
|
||||
export const block = {
|
||||
name: 'Products (Beta)',
|
||||
slug: 'core/query',
|
||||
class: '.wp-block-query',
|
||||
};
|
||||
|
||||
/**
|
||||
* Selectors used for interacting with the blocks. These selectors can be
|
||||
* changed upstream in Gutenberg, so we scope them here for maintainability.
|
||||
*
|
||||
* There are also some labels that are used repeatedly, but we don't scope them
|
||||
* in favor of readability. Unlike selectors, those label are visible to end
|
||||
* users, so it's easier to understand what's going on if we don't scope them.
|
||||
* Those labels can get upated in the future, but the tests will fail and we'll
|
||||
* know to update them, again the update process is easier than selector as the
|
||||
* label is visible to end users.
|
||||
*/
|
||||
export const SELECTORS = {
|
||||
advancedFiltersDropdownButton: (
|
||||
{ expanded }: { expanded: boolean } = { expanded: false }
|
||||
) =>
|
||||
`.components-tools-panel-header .components-dropdown-menu button[aria-expanded="${ expanded }"]`,
|
||||
advancedFiltersDropdown:
|
||||
'.components-dropdown-menu__menu[aria-label="Advanced Filters options"]',
|
||||
advancedFiltersDropdownItem: '.components-menu-item__button',
|
||||
productsGrid: `${ block.class } ul.wp-block-post-template`,
|
||||
productsGridLoading: `${ block.class } p.wp-block-post-template`,
|
||||
productsGridItem: `${ block.class } ul.wp-block-post-template > li`,
|
||||
formTokenField: {
|
||||
label: '.components-form-token-field__label',
|
||||
removeToken: '.components-form-token-field__remove-token',
|
||||
suggestionsList: '.components-form-token-field__suggestions-list',
|
||||
firstSuggestion:
|
||||
'.components-form-token-field__suggestions-list > li:first-child',
|
||||
},
|
||||
productButton: '.wc-block-components-product-button',
|
||||
productPrice: '.wc-block-components-product-price',
|
||||
productRating: '.wc-block-components-product-rating',
|
||||
productImage: '.wc-block-components-product-image',
|
||||
cartItemRow: '.wc-block-cart-items__row',
|
||||
shortcodeProductsGrid: `${ block.class } ul.wp-block-post-template`,
|
||||
shortcodeProductsGridItem: `${ block.class } ul.wp-block-post-template > li`,
|
||||
customSelectControl: {
|
||||
button: '.components-custom-select-control__button',
|
||||
menu: ( { hidden }: { hidden: boolean } = { hidden: true } ) =>
|
||||
`.components-custom-select-control__menu[aria-hidden="${ hidden }"]`,
|
||||
},
|
||||
visuallyHiddenComponents: '.components-visually-hidden',
|
||||
};
|
||||
|
||||
export const goToProductQueryBlockPage = async () => {
|
||||
await shopper.block.goToBlockPage( block.name );
|
||||
};
|
||||
|
||||
export const resetProductQueryBlockPage = async () => {
|
||||
await visitBlockPage( `${ block.name } Block` );
|
||||
await waitForCanvas();
|
||||
await setPostContent( fixture.pageContent );
|
||||
await canvas().waitForSelector( SELECTORS.productsGrid );
|
||||
await saveOrPublish();
|
||||
};
|
||||
|
||||
export const getPreviewProducts = async (): Promise< ElementHandle[] > => {
|
||||
await canvas().waitForSelector( SELECTORS.productsGrid );
|
||||
return await canvas().$$(
|
||||
`${ SELECTORS.productsGridItem }.block-editor-block-preview__live-content`
|
||||
);
|
||||
};
|
||||
|
||||
export const getFrontEndProducts = async (): Promise< ElementHandle[] > => {
|
||||
await canvas().waitForSelector( SELECTORS.productsGrid );
|
||||
return await canvas().$$( SELECTORS.productsGridItem );
|
||||
};
|
||||
|
||||
export const getShortcodeProducts = async (): Promise< ElementHandle[] > => {
|
||||
await canvas().waitForSelector( SELECTORS.shortcodeProductsGrid );
|
||||
return await canvas().$$( SELECTORS.shortcodeProductsGridItem );
|
||||
};
|
||||
|
||||
export const toggleAdvancedFilter = async ( filterName: string ) => {
|
||||
const $advancedFiltersPanel = await findToolsPanelWithTitle(
|
||||
'Advanced Filters'
|
||||
);
|
||||
await expect( $advancedFiltersPanel ).toClick(
|
||||
SELECTORS.advancedFiltersDropdownButton()
|
||||
);
|
||||
await canvas().waitForSelector( SELECTORS.advancedFiltersDropdown );
|
||||
await expect( canvas() ).toClick( SELECTORS.advancedFiltersDropdownItem, {
|
||||
text: filterName,
|
||||
} );
|
||||
await expect( $advancedFiltersPanel ).toClick(
|
||||
SELECTORS.advancedFiltersDropdownButton( { expanded: true } )
|
||||
);
|
||||
};
|
||||
|
||||
export const clearSelectedTokens = async ( $panel: ElementHandle< Node > ) => {
|
||||
const tokenRemoveButtons = await $panel.$$(
|
||||
SELECTORS.formTokenField.removeToken
|
||||
);
|
||||
for ( const el of tokenRemoveButtons ) {
|
||||
await el.click();
|
||||
}
|
||||
};
|
||||
|
||||
export const selectToken = async ( formLabel: string, optionLabel: string ) => {
|
||||
const $stockStatusInput = await canvas().$(
|
||||
await getFormElementIdByLabel(
|
||||
formLabel,
|
||||
SELECTORS.formTokenField.label
|
||||
)
|
||||
);
|
||||
await $stockStatusInput.focus();
|
||||
await canvas().keyboard.type( optionLabel );
|
||||
const firstSuggestion = await canvas().waitForSelector(
|
||||
SELECTORS.formTokenField.firstSuggestion
|
||||
);
|
||||
await firstSuggestion.click();
|
||||
await canvas().waitForSelector( SELECTORS.productsGrid );
|
||||
};
|
||||
|
||||
export const getProductElementNodesCount = async ( selector: string ) => {
|
||||
return await page.$$eval( selector, ( elements ) => elements.length );
|
||||
};
|
||||
|
||||
export const getEditorProductElementNodesCount = async ( selector: string ) => {
|
||||
return await getProductElementNodesCount(
|
||||
`li.block-editor-block-list__layout ${ selector }`
|
||||
);
|
||||
};
|
||||
|
||||
export const getProductTitle = async (
|
||||
product: ElementHandle
|
||||
): Promise< string > => {
|
||||
return (
|
||||
( await product.$eval(
|
||||
'.wp-block-post-title',
|
||||
( el ) => el.textContent
|
||||
) ) || ''
|
||||
);
|
||||
};
|
||||
|
||||
export const setupEditorFrontendComparison = async () => {
|
||||
const previewProducts = await Promise.all(
|
||||
(
|
||||
await getPreviewProducts()
|
||||
).map( async ( product ) => await getProductTitle( product ) )
|
||||
);
|
||||
await goToProductQueryBlockPage();
|
||||
await canvas().waitForSelector( SELECTORS.productsGrid );
|
||||
const frontEndProducts = await Promise.all(
|
||||
(
|
||||
await getFrontEndProducts()
|
||||
).map( async ( product ) => await getProductTitle( product ) )
|
||||
);
|
||||
return { previewProducts, frontEndProducts };
|
||||
};
|
||||
|
||||
export const setupProductQueryShortcodeComparison = async (
|
||||
shortcode: string
|
||||
) => {
|
||||
await insertShortcodeBlock( shortcode );
|
||||
await saveOrPublish();
|
||||
await goToProductQueryBlockPage();
|
||||
const productQueryProducts = await Promise.all(
|
||||
(
|
||||
await getFrontEndProducts()
|
||||
).map( async ( product ) => await getProductTitle( product ) )
|
||||
);
|
||||
const shortcodeProducts = await Promise.all(
|
||||
(
|
||||
await getShortcodeProducts()
|
||||
).map( async ( product ) => await getProductTitle( product ) )
|
||||
);
|
||||
return { productQueryProducts, shortcodeProducts };
|
||||
};
|
|
@ -1,155 +0,0 @@
|
|||
/**
|
||||
* External dependencies
|
||||
*/
|
||||
import { ElementHandle } from 'puppeteer';
|
||||
import {
|
||||
canvas,
|
||||
ensureSidebarOpened,
|
||||
findSidebarPanelWithTitle,
|
||||
} from '@wordpress/e2e-test-utils';
|
||||
import {
|
||||
selectBlockByName,
|
||||
visitBlockPage,
|
||||
saveOrPublish,
|
||||
} from '@woocommerce/blocks-test-utils';
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
import {
|
||||
block,
|
||||
SELECTORS,
|
||||
resetProductQueryBlockPage,
|
||||
setupProductQueryShortcodeComparison,
|
||||
setupEditorFrontendComparison,
|
||||
} from './common';
|
||||
|
||||
const getPopularFilterPanel = async () => {
|
||||
await ensureSidebarOpened();
|
||||
await selectBlockByName( block.slug );
|
||||
return await findSidebarPanelWithTitle( 'Popular Filters' );
|
||||
};
|
||||
|
||||
const getCurrentPopularFilter = async ( $panel: ElementHandle< Node > ) => {
|
||||
const $selectedFilter = await $panel.$(
|
||||
SELECTORS.customSelectControl.button
|
||||
);
|
||||
if ( ! $selectedFilter ) {
|
||||
throw new Error( 'Can not find selected filter.' );
|
||||
}
|
||||
return await page.evaluate( ( el ) => el.textContent, $selectedFilter );
|
||||
};
|
||||
|
||||
const selectPopularFilter = async ( filter: string ) => {
|
||||
let $panel = await getPopularFilterPanel();
|
||||
const $toggleButton = await $panel.$(
|
||||
SELECTORS.customSelectControl.button
|
||||
);
|
||||
await $toggleButton.click();
|
||||
await $panel.waitForSelector(
|
||||
SELECTORS.customSelectControl.menu( { hidden: false } )
|
||||
);
|
||||
const [ $filter ] = await $panel.$x(
|
||||
`//li[contains(text(), "${ filter }")]`
|
||||
);
|
||||
if ( ! $filter ) {
|
||||
throw new Error(
|
||||
`Filter "${ filter }" not found among Popular Filters options`
|
||||
);
|
||||
}
|
||||
await $filter.click();
|
||||
/**
|
||||
* We use try with empty catch block here to avoid the race condition
|
||||
* between the block loading and the test execution. After user actions,
|
||||
* the products may or may not finish loading at the time we try to wait for
|
||||
* the loading class.
|
||||
*/
|
||||
try {
|
||||
await canvas().waitForSelector( SELECTORS.productsGridLoading );
|
||||
} catch ( ok ) {}
|
||||
await canvas().waitForSelector( SELECTORS.productsGrid );
|
||||
await saveOrPublish();
|
||||
|
||||
// Verify if filter is selected or try again.
|
||||
await visitBlockPage( `${ block.name } Block` );
|
||||
$panel = await getPopularFilterPanel();
|
||||
const currentSelectedFilter = await getCurrentPopularFilter( $panel );
|
||||
if ( currentSelectedFilter !== filter ) {
|
||||
await selectPopularFilter( filter );
|
||||
}
|
||||
};
|
||||
|
||||
// These tests are skipped and previously relied on GUTENBERG_EDITOR_CONTEXT.
|
||||
describe.skip( 'Product Query > Popular Filters', () => {
|
||||
let $popularFiltersPanel: ElementHandle< Node >;
|
||||
beforeEach( async () => {
|
||||
/**
|
||||
* Reset the block page before each test to ensure the block is
|
||||
* inserted in a known state. This is also needed to ensure each
|
||||
* test can be run individually.
|
||||
*/
|
||||
await resetProductQueryBlockPage();
|
||||
$popularFiltersPanel = await getPopularFilterPanel();
|
||||
} );
|
||||
|
||||
/**
|
||||
* Reset the content of Product Query Block page after this test suite
|
||||
* to avoid breaking other tests.
|
||||
*/
|
||||
afterAll( async () => {
|
||||
await resetProductQueryBlockPage();
|
||||
} );
|
||||
|
||||
it( 'Popular Filters is expanded by default', async () => {
|
||||
await expect( $popularFiltersPanel ).toMatch(
|
||||
'Arrange products by popular pre-sets.'
|
||||
);
|
||||
} );
|
||||
|
||||
it( 'Sorted by title is the default preset', async () => {
|
||||
const currentFilter = await getCurrentPopularFilter(
|
||||
$popularFiltersPanel
|
||||
);
|
||||
expect( currentFilter ).toEqual( 'Sorted by title' );
|
||||
} );
|
||||
|
||||
describe.each( [
|
||||
{
|
||||
filter: 'Sorted by title',
|
||||
shortcode: '[products orderby="title" order="ASC" limit="9"]',
|
||||
},
|
||||
{
|
||||
filter: 'Newest',
|
||||
shortcode: '[products orderby="date" order="DESC" limit="9"]',
|
||||
},
|
||||
/**
|
||||
* The following tests are commented out because they are flaky
|
||||
* due to the lack of orders and reviews in the test environment.
|
||||
*
|
||||
* @see https://github.com/woocommerce/woocommerce-blocks/issues/8116
|
||||
*/
|
||||
// {
|
||||
// filter: 'Best Selling',
|
||||
// shortcode: '[products best_selling="true" limit="9"]',
|
||||
// },
|
||||
// {
|
||||
// filter: 'Top Rated',
|
||||
// shortcode: '[products top_rated="true" limit="9"]',
|
||||
// },
|
||||
] )( '$filter', ( { filter, shortcode } ) => {
|
||||
beforeEach( async () => {
|
||||
await selectPopularFilter( filter );
|
||||
} );
|
||||
it( 'Editor preview and block frontend display the same products', async () => {
|
||||
const { previewProducts, frontEndProducts } =
|
||||
await setupEditorFrontendComparison();
|
||||
expect( frontEndProducts ).toEqual( previewProducts );
|
||||
} );
|
||||
|
||||
it( 'Products are displayed in the correct order', async () => {
|
||||
const { productQueryProducts, shortcodeProducts } =
|
||||
await setupProductQueryShortcodeComparison( shortcode );
|
||||
expect( productQueryProducts ).toEqual( shortcodeProducts );
|
||||
} );
|
||||
} );
|
||||
} );
|
|
@ -1,34 +0,0 @@
|
|||
/**
|
||||
* External dependencies
|
||||
*/
|
||||
import { switchUserToAdmin } from '@wordpress/e2e-test-utils';
|
||||
import { visitBlockPage } from '@woocommerce/blocks-test-utils';
|
||||
|
||||
// These tests are skipped and previously relied on GUTENBERG_EDITOR_CONTEXT.
|
||||
describe.skip( 'Product Search Legacy Block', () => {
|
||||
beforeAll( async () => {
|
||||
await switchUserToAdmin();
|
||||
await visitBlockPage( 'Product Search Legacy Block' );
|
||||
} );
|
||||
|
||||
it( 'render the upgrade prompt', async () => {
|
||||
await expect( page ).toMatch(
|
||||
'This version of the Product Search block is outdated. Upgrade to continue using.'
|
||||
);
|
||||
await expect( page ).toMatch( 'Upgrade Block' );
|
||||
} );
|
||||
|
||||
it( 'clicking the upgrade button convert the legacy block to core/search variation', async () => {
|
||||
await page.click( '.block-editor-warning__action button' );
|
||||
|
||||
await expect( page ).toMatchElement( '.wp-block-search' );
|
||||
|
||||
await expect( page ).toMatchElement( '.wp-block-search__label', {
|
||||
text: 'Search',
|
||||
} );
|
||||
|
||||
await expect( page ).toMatchElement(
|
||||
'.wp-block-search__input[value="Search products…"]'
|
||||
);
|
||||
} );
|
||||
} );
|
|
@ -1,39 +0,0 @@
|
|||
/**
|
||||
* External dependencies
|
||||
*/
|
||||
import {
|
||||
switchUserToAdmin,
|
||||
createNewPost,
|
||||
insertBlock,
|
||||
} from '@wordpress/e2e-test-utils';
|
||||
|
||||
const block = {
|
||||
name: 'Product Search',
|
||||
slug: 'core/search',
|
||||
class: '.wp-block-search',
|
||||
};
|
||||
|
||||
// These tests are skipped and previously relied on GUTENBERG_EDITOR_CONTEXT.
|
||||
describe.skip( `${ block.name } Block`, () => {
|
||||
it( 'inserting Product Search block renders the core/search variation', async () => {
|
||||
await switchUserToAdmin();
|
||||
|
||||
await createNewPost( {
|
||||
postType: 'page',
|
||||
} );
|
||||
|
||||
await insertBlock( block.name );
|
||||
|
||||
await page.waitForSelector( block.class );
|
||||
|
||||
await expect( page ).toRenderBlock( block );
|
||||
|
||||
await expect( page ).toMatchElement( '.wp-block-search__label', {
|
||||
text: 'Search',
|
||||
} );
|
||||
|
||||
await expect( page ).toMatchElement(
|
||||
'.wp-block-search__input[value="Search products…"]'
|
||||
);
|
||||
} );
|
||||
} );
|
|
@ -1,362 +0,0 @@
|
|||
/**
|
||||
* External dependencies
|
||||
*/
|
||||
import {
|
||||
insertBlock,
|
||||
deleteAllTemplates,
|
||||
canvas,
|
||||
createNewPost,
|
||||
switchUserToAdmin,
|
||||
publishPost,
|
||||
} from '@wordpress/e2e-test-utils';
|
||||
import { SHOP_PAGE } from '@woocommerce/e2e-utils';
|
||||
import { Frame, Page } from 'puppeteer';
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
import {
|
||||
goToTemplateEditor,
|
||||
insertAllProductsBlock,
|
||||
useTheme,
|
||||
saveTemplate,
|
||||
waitForAllProductsBlockLoaded,
|
||||
} from '../../utils';
|
||||
import {
|
||||
clickLink,
|
||||
shopper,
|
||||
SIMPLE_PHYSICAL_PRODUCT_NAME,
|
||||
} from '../../../utils';
|
||||
|
||||
const block = {
|
||||
name: 'Active Filters',
|
||||
slug: 'woocommerce/active-filters',
|
||||
class: '.wp-block-woocommerce-active-filters',
|
||||
selectors: {
|
||||
editor: {
|
||||
firstAttributeInTheList:
|
||||
'.woocommerce-search-list__list > li > label > input.woocommerce-search-list__item-input',
|
||||
filterButtonToggle: "//label[text()='Filter button']",
|
||||
doneButton: '.wc-block-attribute-filter__selection > button',
|
||||
},
|
||||
frontend: {
|
||||
activeFilterType: '.wc-block-active-filters__list-item-type',
|
||||
activeFilterName: '.wc-block-active-filters__list-item-name',
|
||||
removeFilterButton: '.wc-block-active-filters__list-item-remove',
|
||||
removeAllFiltersButton: '.wc-block-active-filters__clear-all',
|
||||
stockFilterBlock: '.wc-block-stock-filter-list',
|
||||
attributeFilterBlock: '.wc-block-attribute-filter-list',
|
||||
productsList: '.wc-block-grid__products > li',
|
||||
productsBlockProducts: '.wp-block-post-template > li',
|
||||
classicProductsList: '.products.columns-3 > li',
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const FILTER_STOCK_STATUS_TITLE = 'Stock Status';
|
||||
const FILTER_STOCK_STATUS_PROPERTY = 'In stock';
|
||||
const FILTER_CAPACITY_TITLE = 'Capacity:';
|
||||
const FILTER_CAPACITY_PROPERTY = '128gb';
|
||||
|
||||
const { selectors } = block;
|
||||
|
||||
const insertBlocks = async () => {
|
||||
await insertBlock( 'Filter by Price' );
|
||||
await insertBlock( 'Filter by Stock' );
|
||||
await insertBlock( 'Filter by Attribute' );
|
||||
await insertBlock( block.name );
|
||||
};
|
||||
|
||||
const configureAttributeFilterBlock = async ( pageOrCanvas: Page | Frame ) => {
|
||||
await pageOrCanvas.$eval(
|
||||
selectors.editor.firstAttributeInTheList,
|
||||
( el ) => ( el as HTMLElement ).click()
|
||||
);
|
||||
await pageOrCanvas.click( selectors.editor.doneButton );
|
||||
};
|
||||
|
||||
const getActiveFilterTypeText = () =>
|
||||
page.$eval(
|
||||
selectors.frontend.activeFilterType,
|
||||
( el ) => ( el as HTMLElement ).innerText
|
||||
);
|
||||
|
||||
const getActiveFilterNameText = () =>
|
||||
page.$eval(
|
||||
selectors.frontend.activeFilterName,
|
||||
( el ) => ( el as HTMLElement ).childNodes[ 1 ].textContent
|
||||
);
|
||||
|
||||
describe.skip( 'Shopper → Active Filters Block', () => {
|
||||
describe( 'With All Products block', () => {
|
||||
beforeAll( async () => {
|
||||
await switchUserToAdmin();
|
||||
await createNewPost( {
|
||||
postType: 'post',
|
||||
title: block.name,
|
||||
} );
|
||||
|
||||
await insertBlocks();
|
||||
await insertAllProductsBlock();
|
||||
await configureAttributeFilterBlock( page );
|
||||
await publishPost();
|
||||
|
||||
const link = await page.evaluate( () =>
|
||||
wp.data.select( 'core/editor' ).getPermalink()
|
||||
);
|
||||
await page.goto( link );
|
||||
} );
|
||||
|
||||
beforeEach( async () => {
|
||||
await page.reload();
|
||||
} );
|
||||
|
||||
it( 'Active Filters is hidden if there is no filter selected', async () => {
|
||||
expect( page ).not.toMatch( 'Active Filters' );
|
||||
} );
|
||||
|
||||
it.skip( 'Shows selected filters', async () => {
|
||||
const isRefreshed = jest.fn( () => void 0 );
|
||||
|
||||
await page.waitForSelector( block.class );
|
||||
await page.waitForSelector(
|
||||
selectors.frontend.attributeFilterBlock + '.is-loading',
|
||||
{ hidden: true }
|
||||
);
|
||||
|
||||
await page.waitForSelector( selectors.frontend.stockFilterBlock );
|
||||
|
||||
await expect( page ).toClick( 'label', {
|
||||
text: FILTER_CAPACITY_PROPERTY,
|
||||
} );
|
||||
|
||||
const activeFilterType = await getActiveFilterTypeText();
|
||||
|
||||
expect( activeFilterType ).toBe(
|
||||
FILTER_CAPACITY_TITLE.toUpperCase()
|
||||
);
|
||||
|
||||
await waitForAllProductsBlockLoaded();
|
||||
|
||||
await expect( page ).toClick( 'label', {
|
||||
text: FILTER_STOCK_STATUS_PROPERTY,
|
||||
} );
|
||||
|
||||
await expect( page ).toMatch( FILTER_STOCK_STATUS_TITLE );
|
||||
|
||||
const activeFilterNameText = await getActiveFilterNameText();
|
||||
|
||||
expect( activeFilterNameText ).toBe( FILTER_STOCK_STATUS_PROPERTY );
|
||||
|
||||
await waitForAllProductsBlockLoaded();
|
||||
|
||||
const products = await page.$$( selectors.frontend.productsList );
|
||||
expect( products ).toHaveLength( 1 );
|
||||
expect( isRefreshed ).not.toHaveBeenCalled();
|
||||
await expect( page ).toMatch( SIMPLE_PHYSICAL_PRODUCT_NAME );
|
||||
} );
|
||||
|
||||
it.skip( 'When clicking the X on a filter it removes a filter', async () => {
|
||||
const isRefreshed = jest.fn( () => void 0 );
|
||||
await page.waitForSelector( block.class );
|
||||
await page.waitForSelector(
|
||||
selectors.frontend.attributeFilterBlock + '.is-loading',
|
||||
{
|
||||
hidden: true,
|
||||
}
|
||||
);
|
||||
|
||||
await expect( page ).toClick( 'label', {
|
||||
text: FILTER_CAPACITY_PROPERTY,
|
||||
} );
|
||||
|
||||
await expect( page ).toClick(
|
||||
selectors.frontend.removeFilterButton
|
||||
);
|
||||
|
||||
expect( page ).not.toMatch( 'Active Filters' );
|
||||
|
||||
await waitForAllProductsBlockLoaded();
|
||||
|
||||
const products = await page.$$( selectors.frontend.productsList );
|
||||
expect( products ).toHaveLength( 5 );
|
||||
expect( isRefreshed ).not.toHaveBeenCalled();
|
||||
} );
|
||||
|
||||
it.skip( 'Clicking "Clear All" button removes all active filters', async () => {
|
||||
const isRefreshed = jest.fn( () => void 0 );
|
||||
await page.waitForSelector( block.class );
|
||||
await page.waitForSelector(
|
||||
selectors.frontend.attributeFilterBlock + '.is-loading',
|
||||
{ hidden: true }
|
||||
);
|
||||
await page.waitForSelector( selectors.frontend.stockFilterBlock );
|
||||
|
||||
await expect( page ).toClick( 'label', {
|
||||
text: FILTER_STOCK_STATUS_PROPERTY,
|
||||
} );
|
||||
|
||||
await expect( page ).toClick( 'label', {
|
||||
text: FILTER_CAPACITY_PROPERTY,
|
||||
} );
|
||||
|
||||
await page.click( selectors.frontend.removeAllFiltersButton );
|
||||
|
||||
await waitForAllProductsBlockLoaded();
|
||||
|
||||
const products = await page.$$( selectors.frontend.productsList );
|
||||
|
||||
expect( products ).toHaveLength( 5 );
|
||||
expect( isRefreshed ).not.toHaveBeenCalled();
|
||||
} );
|
||||
} );
|
||||
describe.skip( 'With PHP Templates (Products Block and Classic Template Block)', () => {
|
||||
useTheme( 'emptytheme' );
|
||||
beforeAll( async () => {
|
||||
await deleteAllTemplates( 'wp_template_part' );
|
||||
await deleteAllTemplates( 'wp_template' );
|
||||
await goToTemplateEditor( {
|
||||
postId: 'woocommerce/woocommerce//archive-product',
|
||||
} );
|
||||
|
||||
await insertBlock( 'WooCommerce Product Grid Block' );
|
||||
await insertBlocks();
|
||||
|
||||
const canvasEl = canvas();
|
||||
await configureAttributeFilterBlock( canvasEl );
|
||||
await saveTemplate();
|
||||
} );
|
||||
|
||||
beforeEach( async () => {
|
||||
await shopper.goToShop();
|
||||
} );
|
||||
|
||||
afterAll( async () => {
|
||||
await deleteAllTemplates( 'wp_template' );
|
||||
await deleteAllTemplates( 'wp_template_part' );
|
||||
} );
|
||||
|
||||
it( 'Active Filters is hidden if there is no filter selected', async () => {
|
||||
expect( page ).not.toMatch( 'Active Filters' );
|
||||
} );
|
||||
|
||||
it( 'Shows selected filters', async () => {
|
||||
const isRefreshed = jest.fn( () => void 0 );
|
||||
page.on( 'load', isRefreshed );
|
||||
await page.waitForSelector( block.class );
|
||||
await page.waitForSelector(
|
||||
selectors.frontend.attributeFilterBlock + '.is-loading',
|
||||
{ hidden: true }
|
||||
);
|
||||
|
||||
await expect( page ).toClick( 'label', {
|
||||
text: FILTER_CAPACITY_PROPERTY,
|
||||
} );
|
||||
|
||||
await page.waitForNavigation( { waitUntil: 'networkidle0' } );
|
||||
|
||||
await page.waitForSelector( block.class );
|
||||
|
||||
const activeFilterType = await getActiveFilterTypeText();
|
||||
|
||||
expect( activeFilterType ).toBe(
|
||||
FILTER_CAPACITY_TITLE.toUpperCase()
|
||||
);
|
||||
await page.waitForSelector( selectors.frontend.stockFilterBlock );
|
||||
|
||||
await expect( page ).toClick( 'label', {
|
||||
text: FILTER_STOCK_STATUS_PROPERTY,
|
||||
} );
|
||||
|
||||
await page.waitForNavigation( { waitUntil: 'networkidle0' } );
|
||||
|
||||
await page.waitForSelector( block.class );
|
||||
|
||||
const activeFilterNameText = await getActiveFilterNameText();
|
||||
expect( activeFilterNameText ).toBe( FILTER_STOCK_STATUS_PROPERTY );
|
||||
|
||||
const classicProductsList = await page.$$(
|
||||
selectors.frontend.classicProductsList
|
||||
);
|
||||
|
||||
const products = await page.$$(
|
||||
selectors.frontend.productsBlockProducts
|
||||
);
|
||||
|
||||
expect( isRefreshed ).toHaveBeenCalledTimes( 2 );
|
||||
expect( products ).toHaveLength( 1 );
|
||||
expect( classicProductsList ).toHaveLength( 1 );
|
||||
await expect( page ).toMatch( SIMPLE_PHYSICAL_PRODUCT_NAME );
|
||||
} );
|
||||
|
||||
it( 'When clicking the X on a filter it removes a filter and triggers a page refresh', async () => {
|
||||
const isRefreshed = jest.fn( () => void 0 );
|
||||
page.on( 'load', isRefreshed );
|
||||
await page.waitForSelector( selectors.frontend.stockFilterBlock );
|
||||
|
||||
expect( isRefreshed ).not.toHaveBeenCalled();
|
||||
await expect( page ).toClick( 'label', {
|
||||
text: FILTER_STOCK_STATUS_PROPERTY,
|
||||
} );
|
||||
|
||||
await page.waitForNavigation( { waitUntil: 'networkidle0' } );
|
||||
|
||||
await page.waitForSelector( block.class );
|
||||
|
||||
await expect( page ).toClick( 'label', {
|
||||
text: FILTER_CAPACITY_PROPERTY,
|
||||
} );
|
||||
|
||||
await page.waitForNavigation( { waitUntil: 'networkidle0' } );
|
||||
|
||||
await page.waitForSelector( block.class );
|
||||
|
||||
await clickLink( selectors.frontend.removeFilterButton );
|
||||
|
||||
const classicProductsList = await page.$$(
|
||||
selectors.frontend.classicProductsList
|
||||
);
|
||||
|
||||
const products = await page.$$(
|
||||
selectors.frontend.productsBlockProducts
|
||||
);
|
||||
|
||||
expect( page.url() ).not.toMatch( 'instock' );
|
||||
expect( page.url() ).toMatch( FILTER_CAPACITY_PROPERTY );
|
||||
expect( isRefreshed ).toHaveBeenCalledTimes( 3 );
|
||||
expect( products ).toHaveLength( 1 );
|
||||
expect( classicProductsList ).toHaveLength( 1 );
|
||||
await expect( page ).toMatch( SIMPLE_PHYSICAL_PRODUCT_NAME );
|
||||
} );
|
||||
|
||||
it( 'Clicking "Clear All" button removes all active filters and the page redirects to the base URL', async () => {
|
||||
const isRefreshed = jest.fn( () => void 0 );
|
||||
page.on( 'load', isRefreshed );
|
||||
await page.waitForSelector( selectors.frontend.stockFilterBlock );
|
||||
|
||||
await expect( page ).toClick( 'label', {
|
||||
text: FILTER_STOCK_STATUS_PROPERTY,
|
||||
} );
|
||||
|
||||
await page.waitForNavigation( { waitUntil: 'networkidle0' } );
|
||||
|
||||
await page.waitForSelector( block.class );
|
||||
|
||||
await clickLink( selectors.frontend.removeAllFiltersButton );
|
||||
|
||||
const classicProductsList = await page.$$(
|
||||
selectors.frontend.classicProductsList
|
||||
);
|
||||
|
||||
const products = await page.$$(
|
||||
selectors.frontend.productsBlockProducts
|
||||
);
|
||||
|
||||
expect( page.url() ).not.toMatch( 'instock' );
|
||||
expect( page.url() ).toMatch( SHOP_PAGE );
|
||||
expect( isRefreshed ).toHaveBeenCalledTimes( 2 );
|
||||
expect( classicProductsList ).toHaveLength( 5 );
|
||||
expect( products ).toHaveLength( 5 );
|
||||
} );
|
||||
} );
|
||||
} );
|
|
@ -1,40 +0,0 @@
|
|||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
import { shopper } from '../../../utils';
|
||||
import { getTextContent } from '../../page-utils';
|
||||
|
||||
// These tests are skipped and previously relied on GUTENBERG_EDITOR_CONTEXT.
|
||||
describe.skip( `Shopper → Product Search`, () => {
|
||||
beforeEach( async () => {
|
||||
await shopper.block.goToBlockPage( 'Product Search' );
|
||||
await page.waitForSelector( '.wp-block-search' );
|
||||
} );
|
||||
|
||||
it( 'should render product variation', async () => {
|
||||
const [ postType ] = await getTextContent(
|
||||
'.wp-block-search input[name="post_type"]'
|
||||
);
|
||||
await expect( postType ).toBe( 'product' );
|
||||
} );
|
||||
|
||||
it( 'should be able to search for products', async () => {
|
||||
await page.type( '.wp-block-search input[name="s"]', 'Stick' );
|
||||
|
||||
await Promise.all( [
|
||||
page.waitForNavigation(),
|
||||
page.keyboard.press( 'Enter' ),
|
||||
] );
|
||||
|
||||
const products = await page.$$( 'ul.products.columns-3 > li' );
|
||||
|
||||
expect( products ).toHaveLength( 2 );
|
||||
|
||||
const productTitles = await getTextContent(
|
||||
'ul.products.columns-3 .woocommerce-loop-product__title'
|
||||
);
|
||||
|
||||
expect( productTitles ).toContain( '32GB USB Stick' );
|
||||
expect( productTitles ).toContain( '128GB USB Stick' );
|
||||
} );
|
||||
} );
|
|
@ -0,0 +1,4 @@
|
|||
Significance: patch
|
||||
Type: dev
|
||||
Comment: Removed skipped tests.
|
||||
|
Loading…
Reference in New Issue