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 Playwright E2E test to activate deactivate the plugin #8050

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from
Open
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
49 changes: 49 additions & 0 deletions tests/e2e/specs/plugin/activate-deactivate-plugin.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/**
* WordPress dependencies
*/
import { test, expect } from '@wordpress/e2e-test-utils-playwright';

test.describe('Activate Deactivate Plugin', () => {
const pluginSlug = 'hello-dolly';
const pluginRowSelector = `tr[data-slug="${pluginSlug}"]`;

test.beforeEach(async ({ admin }) => {
await admin.visitAdminPage('plugins.php');

Check failure on line 11 in tests/e2e/specs/plugin/activate-deactivate-plugin.test.js

View workflow job for this annotation

GitHub Actions / Test with SCRIPT_DEBUG disabled / Run E2E tests

[chromium] › plugin/activate-deactivate-plugin.test.js:14:9 › Activate Deactivate Plugin › activates the plugin

2) [chromium] › plugin/activate-deactivate-plugin.test.js:14:9 › Activate Deactivate Plugin › activates the plugin Error: Not logged in 9 | 10 | test.beforeEach(async ({ admin }) => { > 11 | await admin.visitAdminPage('plugins.php'); | ^ 12 | }); 13 | 14 | test('activates the plugin', async ({ admin, page }) => { at Admin.visitAdminPage (/home/runner/work/wordpress-develop/wordpress-develop/node_modules/@wordpress/e2e-test-utils-playwright/src/admin/visit-admin-page.ts:36:9) at /home/runner/work/wordpress-develop/wordpress-develop/tests/e2e/specs/plugin/activate-deactivate-plugin.test.js:11:9

Check failure on line 11 in tests/e2e/specs/plugin/activate-deactivate-plugin.test.js

View workflow job for this annotation

GitHub Actions / Test with SCRIPT_DEBUG disabled / Run E2E tests

[chromium] › plugin/activate-deactivate-plugin.test.js:14:9 › Activate Deactivate Plugin › activates the plugin

2) [chromium] › plugin/activate-deactivate-plugin.test.js:14:9 › Activate Deactivate Plugin › activates the plugin Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── Error: Not logged in 9 | 10 | test.beforeEach(async ({ admin }) => { > 11 | await admin.visitAdminPage('plugins.php'); | ^ 12 | }); 13 | 14 | test('activates the plugin', async ({ admin, page }) => { at Admin.visitAdminPage (/home/runner/work/wordpress-develop/wordpress-develop/node_modules/@wordpress/e2e-test-utils-playwright/src/admin/visit-admin-page.ts:36:9) at /home/runner/work/wordpress-develop/wordpress-develop/tests/e2e/specs/plugin/activate-deactivate-plugin.test.js:11:9

Check failure on line 11 in tests/e2e/specs/plugin/activate-deactivate-plugin.test.js

View workflow job for this annotation

GitHub Actions / Test with SCRIPT_DEBUG enabled / Run E2E tests

[chromium] › plugin/activate-deactivate-plugin.test.js:14:9 › Activate Deactivate Plugin › activates the plugin

2) [chromium] › plugin/activate-deactivate-plugin.test.js:14:9 › Activate Deactivate Plugin › activates the plugin Error: Not logged in 9 | 10 | test.beforeEach(async ({ admin }) => { > 11 | await admin.visitAdminPage('plugins.php'); | ^ 12 | }); 13 | 14 | test('activates the plugin', async ({ admin, page }) => { at Admin.visitAdminPage (/home/runner/work/wordpress-develop/wordpress-develop/node_modules/@wordpress/e2e-test-utils-playwright/src/admin/visit-admin-page.ts:36:9) at /home/runner/work/wordpress-develop/wordpress-develop/tests/e2e/specs/plugin/activate-deactivate-plugin.test.js:11:9
});

test('activates the plugin', async ({ admin, page }) => {
const activateLink = page.locator(`${pluginRowSelector} .activate a`);
const deactivateLink = page.locator(`${pluginRowSelector} .deactivate a`);

// Check if the plugin is already activated
if (await deactivateLink.isVisible()) {
console.log(`${pluginSlug} is already activated.`);
return;
}

// Activate the plugin
await activateLink.click();

// Verify the plugin is activated
await expect(deactivateLink).toBeVisible();
console.log(`${pluginSlug} has been activated successfully.`);
});

test('deactivates the plugin', async ({ admin, page }) => {
const activateLink = page.locator(`${pluginRowSelector} .activate a`);
const deactivateLink = page.locator(`${pluginRowSelector} .deactivate a`);

// Check if the plugin is already deactivated
if (await activateLink.isVisible()) {
console.log(`${pluginSlug} is already deactivated.`);
return;
}

// Deactivate the plugin
await deactivateLink.click();

// Verify the plugin is deactivated
await expect(activateLink).toBeVisible();
console.log(`${pluginSlug} has been deactivated successfully.`);
});
});
Loading