-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-without-plugin.js
More file actions
81 lines (67 loc) · 3.08 KB
/
test-without-plugin.js
File metadata and controls
81 lines (67 loc) · 3.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
const { chromium } = require('playwright');
(async () => {
const browser = await chromium.launch({ headless: true });
const context = await browser.newContext();
const page = await context.newPage();
// Login
console.log('🔐 Logging into WordPress...');
await page.goto('http://localhost:8080/wp-login.php');
await page.fill('#user_login', 'admin');
await page.fill('#user_pass', '!3cTXkh)9iDHhV5o*N');
await page.click('#wp-submit');
await page.waitForURL('**/wp-admin/**');
console.log('✅ Logged in');
// Deactivate the plugin
console.log('\n🔌 Deactivating wp-content-flow plugin...');
await page.goto('http://localhost:8080/wp-admin/plugins.php');
await page.waitForTimeout(2000);
// Find and click deactivate link for our plugin
const deactivateLink = page.locator('tr[data-plugin="wp-content-flow/wp-content-flow.php"] .deactivate a, a[href*="action=deactivate"][href*="wp-content-flow"]').first();
if (await deactivateLink.isVisible()) {
await deactivateLink.click();
console.log('✅ Plugin deactivated');
await page.waitForTimeout(2000);
} else {
console.log('⚠️ Plugin not found or already deactivated');
}
// Create new post WITHOUT plugin
console.log('\n📝 Creating new post (plugin deactivated)...');
await page.goto('http://localhost:8080/wp-admin/post-new.php');
await page.waitForTimeout(2000);
// Add title
await page.fill('[aria-label="Add title"]', `Test Post Without Plugin ${Date.now()}`);
// Add content
await page.keyboard.type('This is test content without the plugin active.');
await page.keyboard.press('Enter');
await page.keyboard.type('Another paragraph here.');
// Try to save
console.log('\n💾 Testing save WITHOUT plugin...');
let saveSuccess = false;
page.on('response', response => {
if (response.url().includes('/wp-json/wp/v2/posts')) {
console.log(` API Response: ${response.status()}`);
if (response.status() === 200 || response.status() === 201) {
saveSuccess = true;
}
}
});
await page.keyboard.press('Control+s');
await page.waitForTimeout(3000);
if (saveSuccess) {
console.log('✅ Save WITHOUT plugin SUCCEEDED!');
console.log(' This confirms the 500 error is caused by the plugin');
} else {
console.log('❌ Save WITHOUT plugin also failed');
console.log(' The issue may be with WordPress itself, not the plugin');
}
// Re-activate the plugin
console.log('\n🔌 Re-activating plugin...');
await page.goto('http://localhost:8080/wp-admin/plugins.php');
await page.waitForTimeout(2000);
const activateLink = page.locator('tr[data-plugin="wp-content-flow/wp-content-flow.php"] .activate a, a[href*="action=activate"][href*="wp-content-flow"]').first();
if (await activateLink.isVisible()) {
await activateLink.click();
console.log('✅ Plugin re-activated');
}
await browser.close();
})();