Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Archive Templates - Compatibility Layer: fix E2E tests #11273

Merged
merged 2 commits into from
Oct 17, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* External dependencies
*/
import { test as base, expect } from '@woocommerce/e2e-playwright-utils';
import { deleteAllTemplates } from '@wordpress/e2e-test-utils';
import {
installPluginFromPHPFile,
uninstallPluginFromPHPFile,
Expand Down Expand Up @@ -51,7 +50,7 @@ const multipleOccurranceScenarios: Scenario[] = [
{
title: 'Before Shop Loop Item Title',
dataTestId: 'woocommerce_before_shop_loop_item_title',
content: 'Hook: woocommerce_before_shop_loop_item_title',
content: ' Hook: woocommerce_before_shop_loop_item_title',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think whitespace was added by mistake 🙌

amount: 16,
},
{
Expand Down Expand Up @@ -115,39 +114,44 @@ test.describe( 'Compatibility Layer with Product Collection block', () => {
await pageObject.goToProductCatalogFrontend();
} );

// eslint-disable-next-line playwright/no-skipped-test
test.skip( 'Hooks are attached to the page', async ( {
pageObject,
} ) => {
singleOccurranceScenarios.forEach(
async ( { title, dataTestId, content, amount } ) => {
await test.step( title, async () => {
const hooks =
pageObject.locateByTestId( dataTestId );
await expect( hooks ).toHaveCount( amount );
await expect( hooks ).toHaveText( content );
} );
}
);
for ( const scenario of singleOccurranceScenarios ) {
test( `${ scenario.title } is attached to the page`, async ( {
pageObject,
} ) => {
await test.step( scenario.title, async () => {
const hooks = pageObject.locateByTestId(
scenario.dataTestId
);

multipleOccurranceScenarios.forEach(
async ( { title, dataTestId, content, amount } ) => {
await test.step( title, async () => {
const hooks =
pageObject.locateByTestId( dataTestId );
await expect( hooks ).toHaveCount( amount );
await expect( hooks.first() ).toHaveText( content );
} );
}
);
} );
await expect( hooks ).toHaveCount( scenario.amount );
await expect( hooks ).toHaveText( scenario.content );
} );
} );
}

for ( const scenario of multipleOccurranceScenarios ) {
test( `${ scenario.title } is attached to the page`, async ( {
pageObject,
} ) => {
await test.step( scenario.title, async () => {
const hooks = pageObject.locateByTestId(
scenario.dataTestId
);

await expect( hooks ).toHaveCount( scenario.amount );
await expect( hooks.first() ).toHaveText(
scenario.content
);
} );
} );
}
}
);

test.afterAll( async () => {
test.afterAll( async ( { requestUtils } ) => {
await uninstallPluginFromPHPFile(
`${ __dirname }/${ compatiblityPluginFileName }`
);
await deleteAllTemplates( 'wp_template' );
await requestUtils.deleteAllTemplates( 'wp_template' );
} );
} );
Loading