Skip to main content

Test environment

Test the API on a local store with sample data and never against a production store. This repository includes a WordPress + WooCommerce store in Docker with the plugin mounted and the sample store "Smash House": 12 products, extras, hours, tables and loyalty.

ItemValue
Sitehttp://127.0.0.1:8096
API base URLhttp://127.0.0.1:8096/wp-json/notiwoo/v1
Administratordocs / docs-local-only
Customerana / docs-local-only
Currency and countryCOP, Colombia (Bogotá)
Local use only

These credentials are public and only work on the local store. The container listens only on 127.0.0.1. Do not expose it to the internet or reuse these passwords.

Requirements​

  • Docker with Docker Compose.
  • The NotiWoo-Docs and notiwoo-plugin repositories in the same folder, or the NOTIWOO_PLUGIN_PATH variable pointing to the plugin.

Start the store​

From the root of this repository:

docker compose -f scripts/screenshots/wp/compose.yml up -d

The first time, install WordPress and load the sample data with the cli service:

WP="docker compose -f scripts/screenshots/wp/compose.yml run --rm cli"
$WP core install --url=http://127.0.0.1:8096 --title="Smash House" \
--admin_user=docs --admin_password=docs-local-only --admin_email=docs@example.test --skip-email
$WP plugin install woocommerce --activate
$WP plugin activate notiwoo-plugin
$WP language core install es_CO en_US
$WP eval-file /fixtures/seed.php
$WP eval-file /fixtures/enrich.php
$WP eval-file /fixtures/images.php

Stop the store with docker compose -f scripts/screenshots/wp/compose.yml down. Data is kept in Docker volumes. To start from scratch, add --volumes.

First call​

curl http://127.0.0.1:8096/wp-json/notiwoo/v1/status

Get a token​

curl -X POST http://127.0.0.1:8096/wp-json/notiwoo/v1/auth/token \
-H "Content-Type: application/json" \
-d '{"username": "docs", "password": "docs-local-only"}'

Save the value of data.token and use it in the following calls:

TOKEN="paste-the-token-here"
curl "http://127.0.0.1:8096/wp-json/notiwoo/v1/orders?per_page=5" \
-H "Authorization: Bearer $TOKEN"

To test with an application password:

docker compose -f scripts/screenshots/wp/compose.yml run --rm cli \
user application-password create docs api-tests --porcelain
curl -u "docs:<generated-password>" http://127.0.0.1:8096/wp-json/notiwoo/v1/auth/me

In the local environment, WordPress allows application passwords without HTTPS.

Test walkthrough​

  1. GET /schedule/delivery/status: check that delivery is open.
  2. GET /products with a token: pick a product.
  3. POST /cart/validate: validate a cart with extras. See Hours, delivery and cart.
  4. POST /bulk/preview: preview a price increase without applying it. See Bulk changes.
  5. DELETE /auth/token: revoke the token when you finish.

Good practices​

  • Always use made-up data, with the example.test domain for emails and URLs.
  • Do not copy real customer data or Google, WhatsApp or payment gateway keys into this store.
  • Delete test application passwords with user application-password delete docs --all.