Skip to content

Commit 2707cf4

Browse files
committed
debug
1 parent 1fe1691 commit 2707cf4

File tree

1 file changed

+12
-22
lines changed

1 file changed

+12
-22
lines changed

tests/e2e/code-snippets.spec.ts

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ test.describe('Code Snippets Admin Page @admin', () => {
66
test.beforeEach(async ({ page }) => {
77
await page.goto('/wp-admin/admin.php?page=snippets');
88
await page.waitForLoadState('networkidle');
9-
9+
1010
// Wait for WordPress admin content to be fully loaded
1111
await page.waitForSelector('#wpbody-content, .wrap, #wpcontent', { timeout: 10000 });
12-
12+
1313
// Debug: Check if we're actually logged in and on the right page
1414
const currentUrl = page.url();
1515
console.log('Current URL:', currentUrl);
16-
16+
1717
// If we're redirected to login, something is wrong with auth
1818
if (currentUrl.includes('wp-login.php')) {
1919
throw new Error('Authentication failed - redirected to login page');
@@ -24,35 +24,25 @@ test.describe('Code Snippets Admin Page @admin', () => {
2424
// Simple test to verify we can access the admin
2525
const title = await page.title();
2626
console.log('Page title:', title);
27-
27+
2828
// Check if we're actually on the snippets page
2929
const url = page.url();
3030
console.log('Current URL:', url);
31-
31+
3232
// Verify the page has some expected content
3333
const bodyText = await page.textContent('body');
3434
const hasSnippetsContent = bodyText?.includes('Snippets') || bodyText?.includes('snippet');
3535
console.log('Has snippets content:', hasSnippetsContent);
36-
36+
3737
expect(url).toContain('page=snippets');
3838
});
3939

4040
test('Can add a new snippet', async ({ page }) => {
41-
// Wait for the actual snippets page content to load
42-
await page.waitForSelector('.wrap h1, .page-title, .wp-heading-inline', { timeout: 10000 });
43-
44-
// Debug: Check what's actually on the page
45-
const pageContent = await page.textContent('body');
46-
console.log('Page content preview:', pageContent?.substring(0, 500));
47-
48-
// Check if Add New button exists and is visible
49-
const addNewButton = page.locator('text=Add New').first();
50-
await addNewButton.waitFor({ state: 'visible', timeout: 10000 });
51-
52-
const buttonCount = await page.locator('text=Add New').count();
53-
console.log('Add New button count:', buttonCount);
41+
// Wait for the page to load
42+
await page.waitForSelector('h1, .page-title', { timeout: 10000 });
5443

55-
await page.click('text=Add New');
44+
// Click the correct "Add New" button (should be in the page header, not admin menu)
45+
await page.click('.page-title-action, .wrap .page-title-action');
5646
await page.waitForLoadState('networkidle');
5747

5848
// Wait for the form to be ready
@@ -72,7 +62,7 @@ test.describe('Code Snippets Admin Page @admin', () => {
7262
await page.waitForSelector(`text=${TEST_SNIPPET_NAME}`);
7363
await page.click(`text=${TEST_SNIPPET_NAME}`);
7464
await page.waitForLoadState('networkidle');
75-
65+
7666
await page.click('text=Save and Activate');
7767
await expect(page.locator('#message.notice p')).toContainText('Snippet updated and activated.');
7868
await page.click('text=Save and Deactivate');
@@ -84,7 +74,7 @@ test.describe('Code Snippets Admin Page @admin', () => {
8474
await page.waitForSelector(`text=${TEST_SNIPPET_NAME}`);
8575
await page.click(`text=${TEST_SNIPPET_NAME}`);
8676
await page.waitForLoadState('networkidle');
87-
77+
8878
await page.click('text=Delete');
8979
await page.click('button.components-button.is-destructive.is-primary'); // Confirm dialog
9080
await expect(page.locator('body')).not.toContainText(TEST_SNIPPET_NAME);

0 commit comments

Comments
 (0)