Skip to content

Commit

Permalink
Create E2E action (#599)
Browse files Browse the repository at this point in the history
* Create E2E action

* Setup PHP and Node

* Ensure frontend process doesn't hang

* Don't use docker compose in exec scripts

* Add sleep for DB to accept connections

* Add working directory to setup tests step

* Use Allow root wp cli

* Setup chrome

* Fix chrome version step syntax

* Chrome/ChromeDriver is already installed on action

* Add chrome driver args for GH Actions

* e2e Click preview link and determine if correct preview page is fetched

* Revert preview link href assertion removal

* Wait for previewlinks.js to modify button href before checking preview link
  • Loading branch information
blakewilson authored Oct 21, 2021
1 parent 81d6162 commit 7d75c11
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 19 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/e2e-test-plugin.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: E2E Test Plugin
on: pull_request
jobs:
e2e_test_plugin:
timeout-minutes: 10
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: '16'
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
- name: Setup Frontend
working-directory: examples/next/getting-started
run: |
npm install
NEXT_PUBLIC_WORDPRESS_URL=http://localhost:8080 WP_HEADLESS_SECRET=00000000-0000-0000-0000-000000000001 npm run dev &
- name: Composer install
working-directory: plugins/faustwp
run: composer install
- name: Setup Containers
working-directory: plugins/faustwp
run: docker-compose up -d
- name: Sleep 15 seconds
run: sleep 15
- name: Install WP GraphQL
working-directory: plugins/faustwp
run: |
docker exec --workdir=/var/www/html/wp-content/plugins/faustwp $(docker-compose ps -q wordpress) wp plugin install wp-graphql --activate --allow-root
- name: Setup testing data
working-directory: plugins/faustwp
run: |
docker exec --workdir=/var/www/html/wp-content/plugins/faustwp $(docker-compose ps -q wordpress) wp db export tests/_data/dump.sql --allow-root
- name: Copy env file
working-directory: plugins/faustwp
run: cp .env.testing.example .env.testing
- name: Run test
working-directory: plugins/faustwp
run: vendor/bin/codecept run acceptance
16 changes: 0 additions & 16 deletions plugins/faustwp/.env.testing.example
Original file line number Diff line number Diff line change
@@ -1,25 +1,9 @@
WP_ROOT_FOLDER=/var/www/html

# Use the following for mysql socket connections
# TEST_SITE_DB_DSN=mysql:unix_socket=/path/to/unit/mysql.sock;dbname=local

TEST_SITE_DB_DSN=mysql:host=127.0.0.1:33066;dbname=wordpress
TEST_SITE_DB_HOST=127.0.0.1:33066
TEST_SITE_DB_NAME=wordpress
TEST_SITE_DB_USER=root
TEST_SITE_DB_PASSWORD=wordpress
TEST_SITE_TABLE_PREFIX=wp_
TEST_SITE_ADMIN_USERNAME=admin
TEST_SITE_ADMIN_PASSWORD=password
TEST_SITE_WP_ADMIN_PATH=/wp-admin

TEST_DB_HOST=127.0.0.1:3306
TEST_DB_NAME=wordpress
TEST_DB_USER=root
TEST_DB_PASSWORD=wordpress
TEST_TABLE_PREFIX=wp_
TEST_SITE_WP_URL=http://localhost:8080
TEST_SITE_WP_DOMAIN=localhost:8080
[email protected]

HEADLESS_SITE_URL=http://localhost:3000
2 changes: 1 addition & 1 deletion plugins/faustwp/tests/acceptance.suite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ modules:
window_size: false
capabilities:
chromeOptions:
args: ["disable-gpu"]
args: ["headless", "no-sandbox", "disable-gpu"]
5 changes: 3 additions & 2 deletions plugins/faustwp/tests/acceptance/PostPreviewCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,15 @@ public function i_can_view_the_post_preview_link(AcceptanceTester $I)
$I->amEditingPostWithId($post_id);
$I->click('div.components-guide .components-modal__header button.components-button');
$I->click('button.block-editor-post-preview__button-toggle');
$I->wait(4); // Wait for previewlinks.js to modify button href.
$I->seeLink(
'Preview in new tab',
"${front_end_url}/${post_name}/?preview=true",
"${front_end_url}/${post_name}/?preview=true&p=${post_id}",
);

$I->click('Preview in new tab');
$I->switchToNextTab();
$I->wait(2); // Wait for authentication
$I->wait(8); // Wait for authentication
$I->see($post_title, 'section h1');
$I->see($post_content, 'main.content-single .wrap p');
}
Expand Down

0 comments on commit 7d75c11

Please sign in to comment.