A customizable, open-source ecommerce platform built on WordPress. Build any commerce solution you can imagine.
Go to file
moon d85acf8251 Bump version to 0.7.5 2022-05-26 12:38:31 -07:00
.github Add issue & pr templates 2022-04-15 11:36:31 +08:00
.husky Set up husky and lint-staged 2022-04-15 11:34:20 +08:00
api Set default vlaue for the option 2022-04-15 06:58:24 -07:00
bin update version, fix release script 2021-05-12 13:40:10 +10:00
images/admin-notes Modified admin notes images 2021-04-27 12:04:10 -03:00
src Add Delete btn 2022-05-20 14:11:39 -07:00
.editorconfig Add .editorconfig 2022-04-15 11:18:24 +08:00
.eslintignore Add wp prettier 2022-02-22 11:25:17 -08:00
.eslintrc.js set up empty plugin 2021-02-22 12:16:59 +10:00
.gitignore tweak gitignore 2021-05-12 13:41:00 +10:00
.nvmrc Add .nvmrc 2022-04-15 11:36:54 +08:00
.prettierrc.js Use .prettierrc.js 2022-04-19 11:34:17 +08:00
README.md update deploy instructions 2021-11-29 13:02:44 +10:00
package-lock.json Update package-lock.json 2022-04-19 11:34:18 +08:00
package.json Bump version to 0.7.5 2022-05-26 12:38:31 -07:00
plugin.php A feature tab to toggle features 2022-03-15 11:09:40 -03:00
webpack.config.js set up empty plugin 2021-02-22 12:16:59 +10:00
woocommerce-admin-test-helper.php Bump version to 0.7.5 2022-05-26 12:38:31 -07: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!