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

GitHub Codespaces support #72

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
9 changes: 7 additions & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,20 @@
"remoteEnv": {
"CYPRESS_BASE_URL": "http://localhost"
},
"forwardPorts": [80],
"forwardPorts": [8000],
"portsAttributes": {
"80": {
"8000": {
"label": "WordPress",
"onAutoForward": "notify",
"requireLocalPort": false
}
},
"otherPortsAttributes": {
"onAutoForward": "silent"
},
"postAttachCommand": "bin/devcontainer-postattach",
"postCreateCommand": "bin/devcontainer-postcreate",
"features": {
"github-cli": "latest"
}
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
/tests/node_modules/
/tests/cypress/screenshots/
/tests/cypress/videos/
/tmp/
6 changes: 6 additions & 0 deletions bin/devcontainer-postattach
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh

set -e

mkdir -p /workspaces/komoju-woocommerce/tmp
echo "$CODESPACE_NAME" > /workspaces/komoju-woocommerce/tmp/codespace-name.txt
9 changes: 9 additions & 0 deletions bin/devcontainer-postcreate
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh

set -e

./bin/devcontainer-postattach
cd tests
npm install
./node_modules/.bin/cypress install
./node_modules/.bin/cypress run --spec cypress/integration/setuponly.spec.js
11 changes: 8 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,14 @@ services:
WORDPRESS_CONFIG_EXTRA: |
define( 'WPLANG', '${WPLANG}');
define( 'UPLOADS', '/var/www/html/wp-content/uploads' );
define( 'WP_DEBUG_LOG', '/tmp/wp-errors.log');
define( 'WP_SITEURL', 'http://' . $$_SERVER['HTTP_HOST']);
define( 'WP_HOME', 'http://' . $$_SERVER['HTTP_HOST']);
define( 'WP_DEBUG', true);
define( 'WP_DEBUG_LOG', '/var/www/html/wp-content/wp-errors.log');

if (getenv('CODESPACES') === 'true') {
$$host = trim(file_get_contents("/tmp/codespace-name.txt")) . '-8000.githubpreview.dev';
define( 'WP_SITEURL', 'https://' . $$host);
define( 'WP_HOME', 'https://' . $$host);
}
volumes:
- .:/var/www/html/wp-content/plugins/komoju-woocommerce
volumes:
Expand Down
5 changes: 1 addition & 4 deletions tests/cypress/integration/admin.spec.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
describe('KOMOJU for WooCommerce: Admin', () => {
beforeEach(() => {
cy.installWordpress();
cy.signinToWordpress();
cy.installWooCommerce();
cy.installKomoju();
cy.fullSetup();

cy.visit('/wp-admin/admin.php?page=wc-settings&tab=komoju_settings&section=api_settings');
cy.get('.komoju-endpoint-field').contains('Reset').click();
Expand Down
5 changes: 1 addition & 4 deletions tests/cypress/integration/checkout.spec.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
describe('KOMOJU for WooCommerce: Checkout', () => {
beforeEach(() => {
cy.installWordpress();
cy.signinToWordpress();
cy.installWooCommerce();
cy.installKomoju();
cy.fullSetup();
})

it('lets me make a payment using the KOMOJU gateway', () => {
Expand Down
5 changes: 5 additions & 0 deletions tests/cypress/integration/setuponly.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
describe('KOMOJU for WooCommerce setup', () => {
it('I can install WordPress, WC, and KOMOJU', () => {
cy.fullSetup();
});
});
7 changes: 7 additions & 0 deletions tests/cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })

Cypress.Commands.add('fullSetup', () => {
cy.installWordpress();
cy.signinToWordpress();
cy.installWooCommerce();
cy.installKomoju();
});

Cypress.Commands.add('installWordpress', () => {
cy.visit('/wp-admin');

Expand Down
Loading