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

Add e2e test for the plugin action link #403

Merged
merged 2 commits into from
Sep 27, 2021
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
12 changes: 6 additions & 6 deletions tests/e2e/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ See this post for more infomation: https://make.wordpress.org/core/2019/06/27/in

- Provision the back end

- Make sure [`docker-compose` is installed](https://docs.docker.com/compose/install/).
- From the top-level directory, run:
- Make sure [`docker` is installed](https://docs.docker.com/engine/install/).
- From the `wp-content/plugins/wp-parsely` directory, run:

`docker-compose -f tests/e2e/docker-compose.yml up`
`docker compose -f tests/e2e/docker-compose.yml up`

Tip: if you `cd` into this directory, you can simply run `docker-compose` and omit the `-f tests/e2e/docker-compose.yml` from these commands
Tip: if you `cd` into this directory, you can simply run `docker compose` and omit the `-f tests/e2e/docker-compose.yml` from these commands.

- Once you see a line that says:

Expand All @@ -35,7 +35,7 @@ See this post for more infomation: https://make.wordpress.org/core/2019/06/27/in

`npm run test:e2e`

This will run the test suite using a headless browser.
...in a different terminal window. This will run the test suite using a headless browser.

- For debugging purpose, you might want to follow the test visually. You can do so by running the tests in an interactive mode:

Expand All @@ -49,7 +49,7 @@ See this post for more infomation: https://make.wordpress.org/core/2019/06/27/in

- The tests currently expect a "pristine" WordPress environment, so if you want to run them multiple times, you'll need to recreate the WordPress environment like so:

`docker-compose -f tests/e2e/docker-compose.yml run cli /var/www/html/wp-content/plugins/wp-parsely/tests/e2e/init-e2e.sh reset`
`docker compose -f tests/e2e/docker-compose.yml run cli /var/www/html/wp-content/plugins/wp-parsely/tests/e2e/init-e2e.sh reset`

In the future, this will likely be built into the test suite set up to enable easier test development.

Expand Down
24 changes: 24 additions & 0 deletions tests/e2e/specs/plugin-action-link.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import {
activatePlugin,
loginUser,
visitAdminPage,
} from '@wordpress/e2e-test-utils';

const waitForWpAdmin = () => page.waitForSelector( 'body.wp-admin' );

describe( 'Plugin action link', () => {
jest.setTimeout( 30000 );
it( 'Should link to plugin settings page', async () => {
await loginUser();
await activatePlugin( 'wp-parsely' );
await visitAdminPage( '/plugins.php' );

await waitForWpAdmin();

await expect(page).toClick( '[data-slug=wp-parsely] .settings>a', { text: 'Settings' } );
await waitForWpAdmin();

const versionText = await page.$eval( '#wp-parsely_version', ( el ) => el.innerText );
await expect( versionText ).toMatch( /^Version \d+.\d+/ );
} );
} );