-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #404 from woocommerce/fix/register-timing
- Loading branch information
Showing
3 changed files
with
82 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
const { test, expect } = require( '@playwright/test' ); | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { | ||
createSimpleProduct, | ||
setSettings, | ||
clearSettings, | ||
} from '../../utils/api'; | ||
|
||
test.describe( '`woocommerce-google-analytics-integration`', () => { | ||
test.beforeAll( async () => { | ||
await setSettings(); | ||
} ); | ||
|
||
test.afterAll( async () => { | ||
await clearSettings(); | ||
} ); | ||
|
||
/* | ||
* This test requires a PHP snippet that adds inline script | ||
* on `'wp'` to `'woocommerce-google-analytics-integration'` | ||
* that sets `document.currentScript.__test__inlineSnippet = "works";` | ||
* | ||
* Some themes may change the execution sequence of WP actions against the traditional theme like Storefront. | ||
* Make sure the theme you're testing runs `wp_enqueue_scripts` after the hook used in the snippet - `wp`. | ||
*/ | ||
test( 'Is registered early enough to attach some data to it on `woocommerce_after_single_product`', async ( { | ||
page, | ||
} ) => { | ||
const simpleProductID = await createSimpleProduct(); | ||
await page.goto( `?p=${ simpleProductID }&add_inline_to_wp_hook=1` ); | ||
|
||
await expect( | ||
page.locator( '#woocommerce-google-analytics-integration-js-after' ) | ||
).toBeAttached(); | ||
|
||
await expect( | ||
page.locator( '#woocommerce-google-analytics-integration-js-after' ) | ||
).toHaveJSProperty( '__test__inlineSnippet', 'works' ); | ||
} ); | ||
} ); |
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