| 1 |
import { expect, test } from '../fixtures'; |
| 2 |
|
| 3 |
const categoriesStub = [ |
| 4 |
{ id: 8, slug: 'hero', name: 'Hero' }, |
| 5 |
{ id: 6, slug: 'content', name: 'Content' }, |
| 6 |
]; |
| 7 |
|
| 8 |
const patternsStub = [ |
| 9 |
{ |
| 10 |
id: '1-stub-hero', |
| 11 |
slug: 'stub-hero', |
| 12 |
name: 'Stub Hero', |
| 13 |
code: '<!-- wp:paragraph --><p>Stub pattern</p><!-- /wp:paragraph -->', |
| 14 |
categories: ['hero'], |
| 15 |
}, |
| 16 |
]; |
| 17 |
|
| 18 |
test.beforeEach(async ({ page, requestUtils }) => { |
| 19 |
await requestUtils.login(); |
| 20 |
|
| 21 |
await page.route(/\/api\/categories/, (route) => |
| 22 |
route.fulfill({ status: 200, json: categoriesStub }), |
| 23 |
); |
| 24 |
await page.route(/\/api\/patterns/, (route) => |
| 25 |
route.fulfill({ status: 200, json: patternsStub }), |
| 26 |
); |
| 27 |
}); |
| 28 |
|
| 29 |
test('Help Center editor-page button opens the modal after closing Library', async ({ |
| 30 |
admin, |
| 31 |
page, |
| 32 |
}) => { |
| 33 |
await admin.visitAdminPage('post-new.php', 'post_type=page'); |
| 34 |
|
| 35 |
// Library auto-opens on the page editor (default openOnNewPage when a |
| 36 |
// partner-id is set and disableLibraryAutoOpen is not). |
| 37 |
const libraryModal = page.locator('.extendify-library-modal'); |
| 38 |
await expect(libraryModal).toBeVisible({ timeout: 15_000 }); |
| 39 |
|
| 40 |
await page.getByTestId('modal-close-button').click(); |
| 41 |
await expect(libraryModal).toHaveCount(0); |
| 42 |
|
| 43 |
const hcButton = page.getByTestId('help-center-editor-page-button'); |
| 44 |
await expect(hcButton).toBeVisible(); |
| 45 |
await hcButton.click(); |
| 46 |
|
| 47 |
// `toBeAttached()` matches the HC convention — sidesteps the |
| 48 |
// framer-motion initial-opacity issue on the Dialog wrapper. |
| 49 |
await expect(page.getByTestId('help-center-modal')).toBeAttached(); |
| 50 |
}); |
| 51 |
|