PluginProbe
SureDonation – Donation Forms, Fundraising Campaigns & Donor Management / 1.1.0
SureDonation – Donation Forms, Fundraising Campaigns & Donor Management v1.1.0
1.6.0 1.5.1 1.5.0 1.4.0 1.3.0 trunk 0.0.1 1.0.0 1.1.0 1.1.1 1.1.2 1.2.0
suredonation / specs / utils / helpers.js

helpers.js in SureDonation – Donation Forms, Fundraising Campaigns & Donor Management 1.1.0, at specs/utils/helpers.js

48 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /**
2 * Shared test helpers for SureDonation E2E tests.
3 *
4 * SPA-specific utilities that complement @wordpress/e2e-test-utils-playwright.
5 *
6 * @package SureDonation
7 */
8
9 /**
10 * Plugin admin page URL (React SPA root).
11 */
12 const ADMIN_PAGE_URL = '/wp-admin/admin.php?page=suredonation';
13
14 /**
15 * Navigate to the SureDonation admin SPA and wait for the React app to mount.
16 *
17 * @param {import('@playwright/test').Page} page Playwright page.
18 * @param {string} hash Hash route (e.g., '/donations').
19 * @return {Promise<void>}
20 */
21 async function navigateToAdminPage( page, hash = '' ) {
22 const url = hash ? `${ ADMIN_PAGE_URL }#${ hash }` : ADMIN_PAGE_URL;
23 await page.goto( url, { waitUntil: 'domcontentloaded' } );
24 await page.waitForSelector( '#suredonation-admin-root', {
25 state: 'attached',
26 timeout: 15_000,
27 } );
28 }
29
30 /**
31 * Wait for SPA navigation to settle after a route change.
32 *
33 * @param {import('@playwright/test').Page} page Playwright page.
34 * @param {number} ms Max time to wait.
35 * @return {Promise<void>}
36 */
37 async function waitForSPANavigation( page, ms = 5000 ) {
38 await page
39 .waitForLoadState( 'networkidle', { timeout: ms } )
40 .catch( () => {} );
41 }
42
43 module.exports = {
44 ADMIN_PAGE_URL,
45 navigateToAdminPage,
46 waitForSPANavigation,
47 };
48