woocommerce/plugins/woocommerce-beta-tester
Paul Sealock d4e19d6c51
Beta Tester: Update composer lock file (#34086)
* Update Beta Tester lock file

* changelog
2022-07-29 09:11:04 +12:00
..
.github Add GitHub templates for issues and PRs 2021-12-24 16:45:52 +00:00
.wordpress-org .org assets 2018-06-07 15:01:32 +01:00
api Log tracks events after they have been validated (#34030) 2022-07-27 14:01:18 -04:00
assets build zip for release 2022-06-08 14:14:45 +12:00
bin Fixed WooCommerce Beta Tester Zip Build (#33728) 2022-07-06 11:28:56 +12:00
changelog Beta Tester: Update composer lock file (#34086) 2022-07-29 09:11:04 +12:00
images Move admin tester folders to root 2022-06-07 15:18:37 +12:00
includes Lower case string comparison for versions (https://github.com/woocommerce/woocommerce-beta-tester/pull/105) 2021-11-18 13:49:46 +01:00
src Run linter on all js files 2022-06-08 13:58:25 +12:00
.distignore build zip for release 2022-06-08 14:14:45 +12:00
.editorconfig Introduced .editorconfig 2018-06-04 16:06:33 -03:00
.eslintignore Copy eslint ignores to beta-tester 2022-06-07 15:13:14 +12:00
.eslintrc Clean up eslintrc in favour of defaults 2022-06-08 14:03:16 +12:00
.gitignore Copy git ignores to beta-tester 2022-06-07 15:14:21 +12:00
.travis.yml Install composer packages on Travis build to be able to use phpcs 2019-03-13 16:42:52 -03:00
CHANGELOG.md Beta Tester: Prep for release (#33463) 2022-06-22 07:26:15 +12:00
README.md Move plugin.php and readme 2022-06-07 15:55:26 +12:00
composer.json Changelogger: Fix PHPCS violations (#33664) 2022-07-07 08:54:48 +12:00
composer.lock Beta Tester: Update composer lock file (#34086) 2022-07-29 09:11:04 +12:00
package.json Move all woocommerce-beta-tester release config into woorelease (#33799) 2022-07-12 13:36:05 +12:00
plugin.php Move plugin.php and readme 2022-06-07 15:55:26 +12:00
readme.txt Beta Tester: Prep for release (#33463) 2022-06-22 07:26:15 +12:00
webpack.config.js Move admin tester folders to root 2022-06-07 15:18:37 +12:00
woocommerce-beta-tester.php Beta Tester: Prep for release (#33463) 2022-06-22 07:26:15 +12:00

README.md

WooCommerce Admin Test Helper

A plugin that makes it easier to test the WooCommerce Admin plugin.

Development

To get started, run the following commands:

npm install
npm start

See wp-scripts for more usage information.

Extending

There are two client-side filters available if you want to extend the test helper with your own plugin's test setup code.

This example adds a new tab:

import { addFilter } from '@wordpress/hooks';

const SuperSekret = () => (
	<>
		<h2>Super sekret</h2>
		<p>This section contains super sekret tools.</p>
		<NewTool/>
	</>
);
addFilter(
	'woocommerce_admin_test_helper_tabs',
	'wath',
	( tabs ) => [
		...tabs,
		{
			name: 'super-sekret',
			title: 'Super sekret',
			content: <SuperSekret/>,
		}
	]
);

This example adds a new tool to the existing Options tab:

import { addFilter } from '@wordpress/hooks';

const NewTool = () => (
	<>
		<strong>New tool</strong>
		<p>Description</p>
		<button>Execute</button>
	</>
);
addFilter(
	'woocommerce_admin_test_helper_tab_options',
	'wath',
	( entries ) => [
		...entries,
		<NewTool/>
	]
);

Register a REST API endpoint to perform server-side actions in the usual way:

add_action( 'rest_api_init', function() {
    register_rest_route(
        'your-plugin/v1',
        '/area/action',
        array(
            'methods' => 'POST',
            'callback' => 'your_plugin_area_action',
            'permission_callback' => function( $request ) {
                if ( ! wc_rest_check_manager_permissions( 'settings', 'edit ) ) {
                    return new \WP_Error(
                        'woocommerce_rest_cannot_edit',
                        __( 'Sorry, you cannot perform this action', 'your-plugin' )
                    );
                }
                return true;
            }
        )
    );
} );

function your_plugin_area_action() {
    return [];
}

This would be used on the client like this:

import apiFetch from '@wordpress/api-fetch';
...
const response = await apiFetch( {
    path: '/your-plugin/v1/area/action',
    method: 'POST',
} );

Deploying

Prerequisites:

  • Hub
  • Write access to this repository

You can create a test ZIP of the plugin using this command:

npm run build

This creates woocommerce-admin-test-helper.zip in the project root.

We release the plugin using GitHub Releases. There is a script to automate this:

  1. Make sure the version is updated in woocommerce-admin-test-helper.php and package.json
  2. Commit and push to trunk
  3. Run npm run release
  4. Make sure you provide the correct version number when prompted
  5. That's it!