How to use the @wordpress/e2e-test-utils.visitAdminPage function in @wordpress/e2e-test-utils

To help you get started, we’ve selected a few @wordpress/e2e-test-utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ampproject / amp-wp / tests / e2e / specs / stories-editor / story-templates.js View on Github external
it( 'should display non-template reusable blocks in the reusable blocks management screen', async () => {
				const titleSelector = '.page-title .row-title';

				await visitAdminPage( 'edit.php', 'post_type=wp_block' );
				await page.waitForSelector( titleSelector );

				// Check that it is untitled
				const title = await page.$eval(
					titleSelector,
					( element ) => element.innerText,
				);
				expect( title ).toBe( 'Untitled Reusable Block' );
			} );
github gocodebox / lifterlms / packages / llms-e2e-test-utils / src / enroll-student.js View on Github external
export async function enrollStudent( postId, studentId ) {

	await visitAdminPage( 'post.php', `post=${ postId }&action=edit` );

	await setSelect2Option( '#llms-add-student-select', studentId );

	await click( '#llms-enroll-students' );

	// Lazy waiting for ajax save.
	await page.waitFor( 2000 );

}
github WordPress / gutenberg / packages / e2e-tests / config / setup-test-framework.js View on Github external
async function trashExistingPosts() {
	await switchUserToAdmin();
	// Visit `/wp-admin/edit.php` so we can see a list of posts and delete them.
	await visitAdminPage( 'edit.php' );

	// If this selector doesn't exist there are no posts for us to delete.
	const bulkSelector = await page.$( '#bulk-action-selector-top' );
	if ( ! bulkSelector ) {
		return;
	}

	// Select all posts.
	await page.waitForSelector( '#cb-select-all-1' );
	await page.click( '#cb-select-all-1' );
	// Select the "bulk actions" > "trash" option.
	await page.select( '#bulk-action-selector-top', 'trash' );
	// Submit the form to send all draft/scheduled/published posts to the trash.
	await page.click( '#doaction' );
	await page.waitForXPath(
		'//*[contains(@class, "updated notice")]/p[contains(text(), "moved to the Trash.")]'
github gocodebox / lifterlms / packages / llms-e2e-test-utils / src / create-access-plan.js View on Github external
export async function createAccessPlan( { postId = null, price = 0.00, title = 'Test Plan' } ) {

	postId = postId || await createCourse();

	await visitAdminPage( 'post.php', `post=${ postId }&action=edit` );

	await click( '#llms-new-access-plan' );

	await page.waitFor( 500 );

	const selector = '#llms-access-plans .llms-access-plan';

	await fillField( `${ selector }:last-child input.llms-plan-title`, title );

	if ( price > 0 ) {
		await fillField( `${ selector }:last-child input.llms-plan-price`, price );
	} else {
		await click( `${ selector }:last-child input[type="checkbox"][data-controller-id="llms-plan-is-free"]` );
	}

	await clickAndWait( '#llms-save-access-plans' );
github gocodebox / lifterlms / packages / llms-e2e-test-utils / src / create-coupon.js View on Github external
export async function createCoupon( { code = null, discount = '10%' } ) {

	code = code || Math.random().toString( 36 ).slice( 2 );

	await visitAdminPage( 'post-new.php', `post_type=llms_coupon&post_title=${ code }` );

	await page.select( '#_llms_discount_type', discount.includes( '%' ) ? 'percent' : 'dollar' );

	await fillField( '#_llms_coupon_amount', discount.replace( '%', '' ).replace( '$', '' ) );

	await clickAndWait( '#publish' );

	return code;

}
github gocodebox / lifterlms / packages / llms-e2e-test-utils / src / create-user.js View on Github external
export async function createUser( opts ) {

	await visitAdminPage( 'user-new.php' );

	const login = `mock_${ Math.random().toString( 36 ).slice( 2 ) }`;
	opts = Object.assign( {
		user_login: login,
		email: `${login}@mock.tld`,
		role: 'student',
		password: `${ Math.random().toString( 36 ).slice( 2 ) }${ Math.random().toString( 36 ).slice( 2 ) }`
	}, opts );

	await forEach( opts, async ( key, val ) => {

		if ( 'role' === key ) {

			await page.select( '#role', val );

		} else if ( 'password' === key ) {
github ampproject / amp-wp / tests / e2e / utils / deactivate-experience.js View on Github external
export async function deactivateExperience( experience ) {
	await visitAdminPage( 'admin.php', 'page=amp-options' );

	const selector = `#${ experience }_experience`;
	const isChecked = await page.$eval( selector, ( el ) => el.matches( `:checked` ) );

	if ( ! isChecked ) {
		return;
	}

	await page.click( selector );
	await Promise.all( [
		page.click( '#submit' ),
		page.waitForNavigation(),
	] );
}
github ampproject / amp-wp / tests / e2e / utils / onboarding-wizard-utils.js View on Github external
export async function goToOnboardingWizard() {
	await visitAdminPage( 'index.php' );
	await expect( page ).not.toMatchElement( '#amp-onboarding-wizard' );
	await visitAdminPage( 'admin.php', 'page=amp-onboarding-wizard' );
	await expect( page ).toMatchElement( '#amp-onboarding-wizard' );
}
github gocodebox / lifterlms / packages / llms-e2e-test-utils / src / visit-settings-page.js View on Github external
export async function visitSettingsPage( { tab = null, section = null } = {} ) {

	await visitAdminPage( 'admin.php', new URLSearchParams( { page: 'llms-settings', tab, section } ).toString() );

}