This repository has been archived by the owner on Feb 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 221
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
e2e tests for cart and checkout templates (#9939)
* Merge branch 'trunk' into poc/cart_and_checkout_fse_templates * Merge branch 'trunk' into add/9288_cart-checkout-order-received_fse_templates * Resolve merge conflicts * Add e2e for permalink settings * Test that templates exist * Add test to check that templates can be edited * Add tests to confirm templates can be edited * Ensure cart has contents before running tests on frontend views * Commend out problem test * Make sure search has multiple results * Remove useThrottle - bad rebase * Revert changes to docs after rebase * Revert function call for noReviewsPlaceholder * Bad rebase * Reverts * Remove revertTemplate * Spacing * Wait for networkidle after navigation * Always wait for network * Use button roles in site editor * More specific button locator * Update option comparison * Fix template content * Disable failing tests * Disable failing classic template tests * Use enterEditMode * More enterEditMode usage * enterEditMode * Use test.skip * More robust selectors * Alt iframe selector --------- Co-authored-by: Paulo Arromba <17236129+wavvves@users.noreply.github.com>
- Loading branch information
1 parent
36388e4
commit 8881473
Showing
14 changed files
with
382 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
95 changes: 95 additions & 0 deletions
95
tests/e2e-pw/tests/permalink-settings/permalink-settings.block_theme.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { test, expect } from '@woocommerce/e2e-playwright-utils'; | ||
import { cli } from '@woocommerce/e2e-utils'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { goToShop, addToCart } from '../../utils'; | ||
|
||
test.describe( | ||
'Tests permalink settings for the cart and checkout templates', | ||
async () => { | ||
test.afterAll( async () => { | ||
await cli( | ||
'npm run wp-env run tests-cli "wp option update woocommerce_cart_page_endpoint cart"' | ||
); | ||
await cli( | ||
'npm run wp-env run tests-cli "wp option update woocommerce_checkout_page_endpoint checkout"' | ||
); | ||
} ); | ||
|
||
test.describe( 'Settings page', () => { | ||
test( 'Load advanced settings', async ( { page } ) => { | ||
await page.goto( | ||
'/wp-admin/admin.php?page=wc-settings&tab=advanced' | ||
); | ||
const title = page | ||
.locator( 'div.wrap.woocommerce > form > h2' ) | ||
.first(); | ||
await expect( title ).toHaveText( 'Page setup' ); | ||
} ); | ||
test( 'Permlink settings exist', async ( { page } ) => { | ||
await page.goto( | ||
'/wp-admin/admin.php?page=wc-settings&tab=advanced' | ||
); | ||
const cartInput = page.getByLabel( 'Cart page', { | ||
exact: true, | ||
} ); | ||
const checkoutInput = page.getByLabel( 'Checkout page', { | ||
exact: true, | ||
} ); | ||
|
||
await expect( cartInput ).toBeVisible(); | ||
await expect( checkoutInput ).toBeVisible(); | ||
} ); | ||
} ); | ||
|
||
test.describe( 'Frontend templates are updated', () => { | ||
test.beforeEach( async ( { page } ) => { | ||
await goToShop( page ); | ||
await addToCart( page ); | ||
} ); | ||
|
||
test( 'Changing cart permalink works', async ( { page } ) => { | ||
await page.goto( | ||
'/wp-admin/admin.php?page=wc-settings&tab=advanced' | ||
); | ||
const cartInput = page.getByLabel( 'Cart page', { | ||
exact: true, | ||
} ); | ||
cartInput.fill( 'updated-cart-permalink' ); | ||
await page.click( 'button[name="save"]' ); | ||
await page.waitForLoadState( 'networkidle' ); | ||
|
||
// Visit the updated page. | ||
await page.goto( '/updated-cart-permalink', { | ||
waitUntil: 'networkidle', | ||
} ); | ||
const cartText = await page.getByText( 'Proceed to checkout' ); | ||
expect( cartText ).toBeVisible(); | ||
} ); | ||
|
||
test( 'Changing checkout permalink works', async ( { page } ) => { | ||
await page.goto( | ||
'/wp-admin/admin.php?page=wc-settings&tab=advanced' | ||
); | ||
const checkoutInput = page.getByLabel( 'Checkout page', { | ||
exact: true, | ||
} ); | ||
checkoutInput.fill( 'updated-checkout-permalink' ); | ||
await page.click( 'button[name="save"]' ); | ||
await page.waitForLoadState( 'networkidle' ); | ||
|
||
// Visit the updated page. | ||
await page.goto( '/updated-checkout-permalink', { | ||
waitUntil: 'networkidle', | ||
} ); | ||
const cartText = await page.getByText( 'Place Order' ); | ||
expect( cartText ).toBeVisible(); | ||
} ); | ||
} ); | ||
} | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
tests/e2e-pw/tests/templates/cart-template.block_theme.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { test, expect } from '@woocommerce/e2e-playwright-utils'; | ||
|
||
const permalink = '/cart'; | ||
const templatePath = 'woocommerce/woocommerce//cart'; | ||
const templateType = 'wp_template'; | ||
|
||
test.describe( 'Test the cart template', async () => { | ||
test.afterAll( async ( { requestUtils } ) => { | ||
await requestUtils.deleteAllTemplates( 'wp_template' ); | ||
await requestUtils.deleteAllTemplates( 'wp_template_part' ); | ||
} ); | ||
|
||
test( 'Template can be opened in the site editor', async ( { | ||
page, | ||
editorUtils, | ||
} ) => { | ||
await page.goto( '/wp-admin/site-editor.php' ); | ||
await page.getByRole( 'button', { name: /Templates/i } ).click(); | ||
await page.getByRole( 'button', { name: /Cart/i } ).click(); | ||
await editorUtils.enterEditMode(); | ||
|
||
await expect( | ||
page | ||
.frameLocator( 'iframe' ) | ||
.locator( 'button:has-text("Proceed to checkout")' ) | ||
.first() | ||
).toBeVisible(); | ||
} ); | ||
|
||
test( 'Template can be modified', async ( { | ||
page, | ||
admin, | ||
editor, | ||
editorUtils, | ||
} ) => { | ||
await admin.visitSiteEditor( { | ||
postId: templatePath, | ||
postType: templateType, | ||
} ); | ||
await editorUtils.enterEditMode(); | ||
await editor.insertBlock( { | ||
name: 'core/paragraph', | ||
attributes: { content: 'Hello World' }, | ||
} ); | ||
await editor.saveSiteEditorEntities(); | ||
await page.goto( permalink, { waitUntil: 'networkidle' } ); | ||
|
||
await expect( page.getByText( 'Hello World' ).first() ).toBeVisible(); | ||
} ); | ||
} ); |
Oops, something went wrong.