Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds Documentation #234

Merged
merged 3 commits into from
Feb 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
public
.cache
15 changes: 15 additions & 0 deletions docs/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"env": {
"browser": true
},
"globals": {
"graphql": false
},
"parserOptions": {
"ecmaVersion": 10,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true
}
}
}
8 changes: 8 additions & 0 deletions docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
public
.cache
node_modules
*DS_Store
*.env
.editorconfig
.idea/
package-lock.json
22 changes: 22 additions & 0 deletions docs/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
FROM node:buster

# Create app directory
WORKDIR /app

# Install app dependencies
# RUN npm -g install serve
RUN npm -g install gatsby-cli

COPY package*.json ./

RUN npm ci

# Bundle app source
COPY . .

# Build static files
RUN npm run build

# serve on port 8080
# CMD ["serve", "-l", "tcp://0.0.0.0:8080", "public"]
CMD ["gatsby", "serve", "--verbose", "--prefix-paths", "-p", "8080", "--host", "0.0.0.0"]
21 changes: 21 additions & 0 deletions docs/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2019 AxisTaylor

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
24 changes: 24 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# WooGraphQL Docs

*Built with [gatsby-gitbook-starter](https://github.com/hasura/gatsby-gitbook-starter)*

## WIP Table of contents
- Introduction
- Playground
- Guides
- React + Apollo Tutorials
1. Creating the Product List
2. Creating the Product Page -:construction:
3. Creating the Cart -:construction:
4. Advanced Cart Mutation Tips -:construction:
5. Creating the Checkout Page -:construction:
- Contributing
- Testing (Quick-Start Guide)
- Local Testing -:construction:
- Development w/ Docker -:construction:
- Testing w/ Docker -:construction:

## ☁️ Deploy

[![Deploy to Netlify](https://www.netlify.com/img/deploy/button.svg)](https://app.netlify.com/start/deploy?repository=https://github.com/kidunot89/woographql-docs)

72 changes: 72 additions & 0 deletions docs/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
const config = {
"gatsby": {
"pathPrefix": "/",
"siteUrl": "https://woographql.axistaylor.com",
"gaTrackingId": null
},
"header": {
"logo": "https://woographql.axistaylor.com/wp-content/uploads/2020/02/woographql-v3.svg.png",
"logoLink": "https://woographql.axistaylor.com",
"title": "WooGraphQL Documentation",
"githubUrl": "https://github.com/wp-graphql/wp-graphql-woocommerce",
"helpUrl": "https://github.com/wp-graphql/wp-graphql-woocommerce/issues",
"tweetText": "",
"links": [
{ "text": "", "link": ""}
],
"search": {
"enabled": false,
"indexName": "",
"algoliaAppId": process.env.GATSBY_ALGOLIA_APP_ID,
"algoliaSearchKey": process.env.GATSBY_ALGOLIA_SEARCH_KEY,
"algoliaAdminKey": process.env.ALGOLIA_ADMIN_KEY
}
},
"sidebar": {
"forcedNavOrder": [
"/introduction",
"/playground",
"/guides",
"/contributing"
],
"collapsedNav": [
"/guides"
],
"links": [
{ "text": "AxisTaylor", "link": "https://axistaylor.com"},
{ "text": "WPGraphQL", "link": "https://wpgraphql.com"},
{ "text": "WPGraphQL Documentation", "link": "https://wpgraphql.com/docs"},
],
"frontline": false,
"ignoreIndex": true,
},
"siteMetadata": {
"title": "WPGraphQL WooCommerce Docs | AxisTaylor",
"description": "The official WPGraphQL WooCommerce (WooGraphQL) documentation",
"ogImage": null,
"docsLocation": "https://github.com/kidunot89/woographql-docs/tree/master/content",
"favicon": "https://woographql.axistaylor.com/wp-content/uploads/2020/02/woographql-v2-optimized.png",
"twitterHandle": "woographql"
},
"pwa": {
"enabled": false, // disabling this will also remove the existing service worker.
"manifest": {
"name": "WPGraphQL WooCommerce Documentation",
"short_name": "WooGraphQLDocs",
"start_url": "/",
"background_color": "#6b37bf",
"theme_color": "#6b37bf",
"display": "standalone",
"crossOrigin": "use-credentials",
icons: [
{
src: "src/pwa-512.png",
sizes: `512x512`,
type: `image/png`,
},
],
},
}
};

module.exports = config;
9 changes: 9 additions & 0 deletions docs/content/contributing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
title: "Contributing"
metaTitle: "WooGraphQL Contributing Guides and Tips"
metaDescription: "Guides and tips for helping extend and maintain WooGraphQL"
---

# Coming Soon

Sorry, this section is still under development :construction:.
89 changes: 89 additions & 0 deletions docs/content/contributing/1-index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
---
title: "Testing (Quick-Start Guide)"
metaTitle: "WooGraphQL quick-start guide"
metaDescription: "A simple guide to get started testing with WooGraphQL."
---

# Unit Tests
Until the documentation is in full effect, it's recommended that a [GraphiQL](https://github.com/graphql/graphiql)-based tool like [WPGraphiQL](https://github.com/wp-graphql/wp-graphiql) be used to view the GraphQL schema, an alternative to this is viewing the unit tests located in `tests/wpunit` directory. Which are constantly updated along with the project. If you're interested in contributing when I begin accepting contribution or simply want to run the tests. Follow the instruction below.

## Prerequisties
- Shell/CMD access
- [Composer](https://getcomposer.org/)
- [WP-CLI](https://wp-cli.org/)

## Setup
1. Make sure all dependencies are install by running `composer install` from the CMD/Terminal in the project directory.
2. Next the copy 2 distributed files with the `.dist` in there filenames. For instance `.env.dist` becomes `.env` and `wpunit.suite.dist.yml` becomes `wpunit.suite.yml`. The distributed files and what their copied names should are as follows.
- `codeception.dist.yml` => `codeception.yml`
- `.env.dist` => `.env`
3. Next open `.env` and alter to make you usage.
```
# docker ENV variables
DB_NAME=wordpress
DB_HOST=app_db
DB_USER=wordpress
DB_PASSWORD=wordpress
WP_TABLE_PREFIX=wp_
WP_URL=http://localhost
WP_DOMAIN=localhost
ADMIN_EMAIL=admin@example.com
ADMIN_USERNAME=admin
ADMIN_PASSWORD=password
ADMIN_PATH=/wp-admin

# local codeception/install-wp-tests ENV variables
TEST_DB_NAME=woographql_tests
TEST_DB_HOST=127.0.0.1
TEST_DB_USER=wordpress
TEST_DB_PASSWORD=wordpress
TEST_WP_TABLE_PREFIX=wp_

# install-wp-tests ENV variables
SKIP_DB_CREATE=false
TEST_WP_ROOT_FOLDER=/tmp/wordpress
TEST_ADMIN_EMAIL=admin@wp.test

# codeception ENV variables
TESTS_DIR=tests
TESTS_OUTPUT=tests/_output
TESTS_DATA=tests/_data
TESTS_SUPPORT=tests/_support
TESTS_ENVS=tests/_envs
```
- `docker ENV variables`: variables defined for use in the Docker/Docker-Compose setups. These are also used in `codeception.dist.yml` for testing within a Docker container. It's recommend that this file be left unchanged and a `codeception.yml` be created for local codeception unit testing.
- `local codeception/install-wp-tests ENV variables`: variable defined for use with codeception testing w/o docker and the `install-wp-tests` script in the `bin` directory. As mentioned above a `codeception.yml` should be created from `codeception.dist.yml` and the variables in the `WPLoader` config should be set accordingly.
- `install-wp-tests ENV variables`: variables specific to the `install-wp-tests` script. The script can be run using `composer install-wp-tests` in the terminal from project directory.
- `codeception ENV variables`: variables used by codeception. This includes within the docker container as well.

4. Once you have finish modifying the `.env` file. Run `composer install-wp-tests` from the project directory.
5. Upon success you can begin running the tests.

## Running tests
To run test use the command `vendor/bin/codecept run [suite [test [:test-function]]]`.
If you use the command with at least a `suite` specified, **Codeception** will run all tests, however this is not recommended. Running a suite `vendor/bin/codecept run wpunit` or a test `vendor/bin/codecept run CouponQueriesTest` is recommended. Running a single `test-function` like `vendor/bin/codecept run ProductQueriesTest:testProductsQueryAndWhereArgs` is also possible.

To learn more about the usage of Codeception with WordPress view the [Documentation](https://codeception.com/for/wordpress)

# Functional and Acceptance Tests (Docker & Docker-Compose required)
It's possible to run functional and acceptance tests, but is very limited at the moment. The script docker entrypoint script runs all three suites (acceptance, functional, and wpunit) at once. This will change eventually, however as of right now, this is the limitation.

## Running tests
Even though the two suites use a Docker environment to run, the `testing` service in the `docker.compose.yml` file requires the `.env.dist` and `codeception.dist.yml` untouched.
Run the following in the terminal to run all three suites. Isolating specific suites should be simple to figure out.
```
docker-compose run --rm \
-e SUITES=acceptance;wpunit;functional \
-e DEBUG=1 -e COVERAGE=1 testing --scale app=0
```
- The `COVERAGE`, and `DEBUG` vars are optional flags for toggle codecoverage and debug output.
- `--scale app=0` ensures that the service running a local app doesn't create any instances. It must be added or a collision with `mysql` will occur. More on this service in the next section

# Using docker-compose to run a local installation for live testing.
This is rather simple just like with testing using docker ensure that `env.dist` and `codeception.dist.yml` are untouched.
1. Run `docker-compose up --scale testing=0 app`
2. wait for `app_1 | Success: Exported to '/var/www/html/wp-content/plugins/wp-graphql-woocommerce/tests/_data/dump.sql'.` to print to the terminal.
3. navigate to `http://localhost:8091`. And that's it.
You can view the configuration for the installation in the `docker-compose.yml`.
**NOTE: if you get redirected to `http://localhost` run `docker-compose down` to remove any existing containers related to the project, then re-run Step 1.**
- For more information about the docker-image uses in the service, it's on [Docker Hub](https://hub.docker.com/r/kidunot89/woographql-app).
9 changes: 9 additions & 0 deletions docs/content/contributing/2-index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
title: "Local Testing"
metaTitle: "Local testing w/ WooGraphQL"
metaDescription: "An extensive guide on local testing w/ WooGraphQL."
---

# Coming Soon

Sorry, this section is still under development :construction:.
9 changes: 9 additions & 0 deletions docs/content/contributing/3-index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
title: "Development w/ Docker"
metaTitle: "Using Docker for WooGraphQL development"
metaDescription: "A simple to follow guide on using the WooGraphQL App Docker Image."
---

# Coming Soon

Sorry, this section is still under development :construction:.
9 changes: 9 additions & 0 deletions docs/content/contributing/4-index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
title: "Testing w/ Docker"
metaTitle: "Using Docker for WooGraphQL testing"
metaDescription: "An extensive guide on testing w/ WooGraphQL + Docker."
---

# Coming Soon

Sorry, this section is still under development :construction:.
12 changes: 12 additions & 0 deletions docs/content/guides.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
title: "Guides"
metaTitle: "WooGraphQL Guides and Tips"
metaDescription: "Guides and tips that ease the WooGraphQL development process"
---

# React + Apollo Tutorials
1. [Creating the Product List](guides/react-apollo/1-index)
2. [Creating the Product Page](guides/react-apollo/2-index)
3. [Creating the Cart](guides/react-apollo/3-index)
4. [Advanced Cart Mutation Tips](guides/react-apollo/4-index)
5. [Creating the Checkout Page](guides/react-apollo/5-index)
13 changes: 13 additions & 0 deletions docs/content/guides/react-apollo.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
title: "React + Apollo Tutorials"
metaTitle: "React + Apollo Tutorials"
metaDescription: "This is the meta description for this page"
---

This tutorial series is design to help get you started on WooGraphQL-backed e-commerce application development, walking through the creation of a few components commonly found in e-commerce applications.

1. [Creating the Product List](react-apollo/1-index)
2. [Creating the Product Page](react-apollo/2-index)
3. [Creating the Cart](react-apollo/3-index)
4. [Advanced Cart Mutation Tips](react-apollo/4-index)
5. [Creating the Checkout Page](react-apollo/5-index)
Loading