instantiate AdminEdit object

This commit is contained in:
Ron Rennick 2021-09-10 18:42:06 -03:00
parent d2a94ba5d9
commit 21470315fa
4 changed files with 11 additions and 8 deletions

View File

@ -41,13 +41,14 @@ const runCreateCouponTest = () => {
await expect(page).toFill('#coupon_amount', '100');
// Publish coupon, verify that it was published.
await AdminEdit.verifyPublish(
const adminEdit = new AdminEdit();
await adminEdit.verifyPublish(
'#publish',
'.notice',
'Coupon updated.',
);
// Delete the coupon
const couponId = await AdminEdit.getId();
const couponId = await adminEdit.getId();
if ( couponId ) {
const repository = Coupon.restRepository( factories.api.withDefaultPermalinks );
await repository.delete( couponId );

View File

@ -40,4 +40,4 @@ export const itIf = ( condition ) =>
*/
export const waitForTimeout = async ( timeout ) => {
await new Promise( ( resolve ) => setTimeout( resolve, timeout ) );
}
};

View File

@ -123,9 +123,11 @@ export const waitForSelectorWithoutThrow = async ( selector, timeoutInSeconds =
*/
export const verifyPublishAndTrash = async ( button, publishNotice, publishVerification, trashVerification ) => {
if ( button === '.order_actions li .save_order' ) {
await OrderEdit.verifyPublish( button, publishNotice, publishVerification );
const orderEdit = new OrderEdit();
await orderEdit.verifyPublish( button, publishNotice, publishVerification );
} else {
await AdminEdit.verifyPublish( button, publishNotice, publishVerification );
const adminEdit = new AdminEdit();
await adminEdit.verifyPublish( button, publishNotice, publishVerification );
}
// Trash

View File

@ -1,4 +1,4 @@
import { utils } from '../flows';
import { waitForTimeout } from '../flows/utils';
export class AdminEdit {
@ -12,7 +12,7 @@ export class AdminEdit {
*/
async verifyPublish( button, publishNotice, publishVerification ) {
// Wait for auto save
await utils.waitForTimeout( 2000 );
await waitForTimeout( 2000 );
// Publish and verify
await expect( page ).toClick( button );
@ -42,7 +42,7 @@ export class OrderEdit extends AdminEdit {
* @returns {Promise<void>}
*/
async verifyPublish( button, publishNotice, publishVerification ) {
AdminEdit.verifyPublish( button, publishNotice, publishVerification );
super.verifyPublish( button, publishNotice, publishVerification );
await expect( page ).toMatchElement( '#select2-order_status-container', { text: 'Processing' } );
await expect( page ).toMatchElement(