Skip to content

Commit

Permalink
Protect: add E2E tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nateweller committed Mar 5, 2025
1 parent 5831528 commit 23c9811
Show file tree
Hide file tree
Showing 7 changed files with 109 additions and 0 deletions.
15 changes: 15 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions projects/plugins/protect/tests/e2e/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/node_modules
/config/local*
/config/tmp/*
/output
plan-data.txt
e2e_tunnels.txt
jetpack-private-options.txt
/allure-results
storage.json
/tmp
1 change: 1 addition & 0 deletions projects/plugins/protect/tests/e2e/config/default.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require( '_jetpack-e2e-commons/config/default.cjs' );
3 changes: 3 additions & 0 deletions projects/plugins/protect/tests/e2e/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { makeE2eConfig } from '_jetpack-e2e-commons/eslint.config.mjs';

export default [ ...makeE2eConfig( import.meta.url ) ];
45 changes: 45 additions & 0 deletions projects/plugins/protect/tests/e2e/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"private": true,
"type": "module",
"description": "Security tools that keep your site safe and sound, from posts to plugins.",
"homepage": "https://jetpack.com",
"bugs": {
"url": "https://github.com/Automattic/jetpack/labels/[Plugin] Protect"
},
"repository": {
"type": "git",
"url": "https://github.com/Automattic/jetpack.git",
"directory": "projects/plugins/protect"
},
"license": "GPL-2.0-or-later",
"author": "Automattic",
"scripts": {
"build": "pnpm jetpack build plugins/protect plugins/jetpack -v --no-pnpm-install --production",
"clean": "rm -rf output",
"config:decrypt": "openssl enc -md sha1 -aes-256-cbc -d -pass env:CONFIG_KEY -in ./node_modules/_jetpack-e2e-commons/config/encrypted.enc -out ./config/local.cjs",
"distclean": "rm -rf node_modules",
"env:up": "e2e-env start --activate-plugins protect",
"env:down": "e2e-env stop",
"env:reset": "e2e-env reset --activate-plugins protect",
"tunnel:up": "tunnel up",
"tunnel:reset": "tunnel reset",
"tunnel:down": "tunnel down",
"pretest:run": "pnpm run clean",
"test:run": ". ./node_modules/_jetpack-e2e-commons/bin/app-password.sh && playwright install --with-deps chromium && NODE_CONFIG_DIR='./config' ALLURE_RESULTS_DIR=./output/allure-results NODE_PATH=\"$PWD/node_modules\" playwright test --config=./playwright.config.mjs"
},
"devDependencies": {
"@playwright/test": "1.48.2",
"allure-playwright": "2.9.2",
"config": "3.3.12",
"_jetpack-e2e-commons": "workspace:*"
},
"browserslist": [],
"ci": {
"targets": [
"plugins/protect",
"tools/e2e-commons"
],
"pluginSlug": "protect",
"mirrorName": "jetpack-protect-plugin"
}
}
1 change: 1 addition & 0 deletions projects/plugins/protect/tests/e2e/playwright.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from '_jetpack-e2e-commons/config/playwright.config.default.mjs';
34 changes: 34 additions & 0 deletions projects/plugins/protect/tests/e2e/specs/start.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { prerequisitesBuilder } from '_jetpack-e2e-commons/env/prerequisites.js';
import { expect, test } from '_jetpack-e2e-commons/fixtures/base-test.js';
import logger from '_jetpack-e2e-commons/logger.js';

test.describe( 'Jetpack Protect plugin', () => {
test.beforeEach( async ( { page } ) => {
await prerequisitesBuilder( page )
.withCleanEnv()
.withActivePlugins( [ 'protect' ] )
.withLoggedIn( true )
.build();
} );

test( 'Jetpack Protect admin page', async ( { page, admin } ) => {
logger.action( 'Visit the Jetpack Protect admin page' );

await admin.visitAdminPage( 'admin.php', 'page=jetpack-protect' );

logger.action( 'Checking for heading "Stay one step ahead of threats"' );
await expect(
page.getByRole( 'heading', { name: 'Stay one step ahead of threats' } )
).toBeVisible();

logger.action( 'Checking for button "Get Jetpack Protect"' );
const getJetpackProtectButton = page.getByRole( 'button', { name: 'Get Jetpack Protect' } );
await expect( getJetpackProtectButton ).toBeVisible();
await expect( getJetpackProtectButton ).toBeEnabled();

logger.action( 'Checking for button "Start for free"' );
const startForFreeButton = page.getByRole( 'button', { name: 'Start for free' } );
await expect( startForFreeButton ).toBeVisible();
await expect( startForFreeButton ).toBeEnabled();
} );
} );

0 comments on commit 23c9811

Please sign in to comment.