Skip to content

Commit

Permalink
Add E2E tests for merchant on-boarding (#7955)
Browse files Browse the repository at this point in the history
Co-authored-by: Brian Borman <[email protected]>
Co-authored-by: Achyuth Ajoy <[email protected]>
  • Loading branch information
3 people authored Jan 24, 2024
1 parent e9e5be3 commit fbecab2
Show file tree
Hide file tree
Showing 11 changed files with 450 additions and 4 deletions.
1 change: 1 addition & 0 deletions .github/actions/e2e/run-log-tests/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ runs:
with:
name: wp(${{ env.E2E_WP_VERSION }})-wc(${{ env.E2E_WC_VERSION }})-${{ env.E2E_GROUP }}-${{ env.E2E_BRANCH }}
path: |
screenshots
tests/e2e/screenshots
tests/e2e/docker/wordpress/wp-content/debug.log
${{ env.E2E_RESULT_FILEPATH }}
Expand Down
4 changes: 4 additions & 0 deletions changelog/e2e-7347-merchant-on-boarding
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: dev

E2E test - Merchant facing multi-currency on-boarding screen.
Original file line number Diff line number Diff line change
Expand Up @@ -173,13 +173,14 @@ const AddCurrenciesTask = () => {
);
} );

const displayCurrencyCheckbox = ( code ) =>
const displayCurrencyCheckbox = ( code, testId = '' ) =>
availableCurrencyCodes.length && (
<EnabledCurrenciesModalCheckbox
key={ 'currency-checkbox-' + availableCurrencies[ code ].id }
checked={ selectedCurrencyCodes.includes( code ) }
onChange={ handleChange }
currency={ availableCurrencies[ code ] }
testId={ _.isString( testId ) ? testId : null }
/>
);

Expand Down Expand Up @@ -284,7 +285,11 @@ const AddCurrenciesTask = () => {
</h4>
</li>
{ visibleRecommendedCurrencyCodes.map(
displayCurrencyCheckbox
( code ) =>
displayCurrencyCheckbox(
code,
'recommended-currency'
)
) }
<li
className={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ exports[`Multi-Currency enabled currencies list add currencies task renders corr
</li>
<li
class="enabled-currency-checkbox"
data-testid="recommended-currency"
>
<div
class="components-base-control components-checkbox-control css-wdf2ti-Wrapper ej5x27r4"
Expand Down Expand Up @@ -171,6 +172,7 @@ exports[`Multi-Currency enabled currencies list add currencies task renders corr
</li>
<li
class="enabled-currency-checkbox"
data-testid="recommended-currency"
>
<div
class="components-base-control components-checkbox-control css-wdf2ti-Wrapper ej5x27r4"
Expand Down Expand Up @@ -232,6 +234,7 @@ exports[`Multi-Currency enabled currencies list add currencies task renders corr
</li>
<li
class="enabled-currency-checkbox"
data-testid="recommended-currency"
>
<div
class="components-base-control components-checkbox-control css-wdf2ti-Wrapper ej5x27r4"
Expand Down Expand Up @@ -293,6 +296,7 @@ exports[`Multi-Currency enabled currencies list add currencies task renders corr
</li>
<li
class="enabled-currency-checkbox"
data-testid="recommended-currency"
>
<div
class="components-base-control components-checkbox-control css-wdf2ti-Wrapper ej5x27r4"
Expand Down Expand Up @@ -354,6 +358,7 @@ exports[`Multi-Currency enabled currencies list add currencies task renders corr
</li>
<li
class="enabled-currency-checkbox"
data-testid="recommended-currency"
>
<div
class="components-base-control components-checkbox-control css-wdf2ti-Wrapper ej5x27r4"
Expand Down Expand Up @@ -415,6 +420,7 @@ exports[`Multi-Currency enabled currencies list add currencies task renders corr
</li>
<li
class="enabled-currency-checkbox"
data-testid="recommended-currency"
>
<div
class="components-base-control components-checkbox-control css-wdf2ti-Wrapper ej5x27r4"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const EnabledCurrenciesModalCheckbox = ( {
onChange,
checked = false,
currency: { flag, symbol, code, name },
testId = null,
} ) => {
const handleChange = useCallback(
( enabled ) => {
Expand All @@ -20,7 +21,7 @@ const EnabledCurrenciesModalCheckbox = ( {
);

return (
<li className="enabled-currency-checkbox">
<li className="enabled-currency-checkbox" data-testid={ testId }>
<CheckboxControl
code={ code }
checked={ checked }
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"test:e2e-up": "./tests/e2e/env/up.sh",
"test:e2e-cleanup": "./tests/e2e/env/cleanup.sh",
"test:e2e-reset": "npm run test:e2e-down && npm run test:e2e-cleanup",
"test:e2e": "NODE_CONFIG_DIR='tests/e2e/config' wp-scripts test-e2e --config tests/e2e/config/jest.config.js",
"test:e2e": "NODE_CONFIG_DIR='tests/e2e/config' JEST_PUPPETEER_CONFIG='tests/e2e/config/jest-puppeteer-headless.config.js' wp-scripts test-e2e --config tests/e2e/config/jest.config.js",
"test:e2e-dev": "NODE_CONFIG_DIR='tests/e2e/config' JEST_PUPPETEER_CONFIG='tests/e2e/config/jest-puppeteer.config.js' wp-scripts test-e2e --config tests/e2e/config/jest.config.js --puppeteer-interactive",
"test:e2e-performance": "NODE_CONFIG_DIR='tests/e2e/config' wp-scripts test-e2e --config tests/e2e/config/jest.performance.config.js",
"test:update-snapshots": "npm run test:js -- --updateSnapshot",
Expand Down
17 changes: 17 additions & 0 deletions tests/e2e/config/jest-puppeteer-headless.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const { jestPuppeteerConfig } = require( '@woocommerce/e2e-environment' );

// Add arg to allow accessing the payments iframes in interactive mode ({ headles: false }).
// https://github.com/puppeteer/puppeteer/issues/4960#issuecomment-535729011
jestPuppeteerConfig.launch.args.push( '--disable-features=site-per-process' );
jestPuppeteerConfig.launch.args.push( '--disable-web-security' );
jestPuppeteerConfig.launch.args.push( '--disable-features=IsolateOrigins' );
jestPuppeteerConfig.launch.args.push( '--disable-site-isolation-trials' );

// Set a real User Agent so the "Add block" button isn't disabled in Gutenberg during -dev tests.
// Also keeping the "puppeteer-debug" value coming from @automattic.puppeteer
jestPuppeteerConfig.launch.args.push(
// eslint-disable-next-line max-len
'--user-agent=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.55 Safari/537.36 puppeteer-debug'
);

module.exports = jestPuppeteerConfig;
Loading

0 comments on commit fbecab2

Please sign in to comment.