Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update: update test suite for WooCommerce 8.3 Cart and Checkout Blocks #2090

Merged
merged 23 commits into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions tests/pw/pages/announcementsPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,13 @@ export class AnnouncementsPage extends AdminPage {

case 'restore':
await this.clickAndWaitForResponse(data.subUrls.api.dokan.announcements, selector.admin.dokan.announcements.navTabs.trash);
await this.hover(selector.admin.dokan.announcements.announcementCell(announcementTitle));
await this.hover(selector.admin.dokan.announcements.announcementCellPublished(announcementTitle));
await this.clickAndWaitForResponse(data.subUrls.api.dokan.announcements, selector.admin.dokan.announcements.announcementRestore(announcementTitle));
break;

case 'permanently-delete':
await this.clickAndWaitForResponse(data.subUrls.api.dokan.announcements, selector.admin.dokan.announcements.navTabs.trash);
await this.hover(selector.admin.dokan.announcements.announcementCell(announcementTitle));
await this.hover(selector.admin.dokan.announcements.announcementCellPublished(announcementTitle));
await this.clickAndWaitForResponse(data.subUrls.api.dokan.announcements, selector.admin.dokan.announcements.announcementPermanentlyDelete(announcementTitle));
break;

Expand Down
10 changes: 5 additions & 5 deletions tests/pw/pages/customerPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,13 +250,13 @@ export class CustomerPage extends BasePage {
// clear cart
async clearCart(): Promise<void> {
await this.goToCart();
const cartProductIsVisible = await this.isVisible(selector.customer.cCart.firstProductCrossIcon);
const cartProductIsVisible = await this.isVisible(selector.customer.cCart.removeFirstItem);
if (cartProductIsVisible) {
await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.cart, selector.customer.cCart.firstProductCrossIcon);
await this.toContainText(selector.customer.cWooSelector.wooCommerceSuccessMessage, 'removed. Undo?');
await this.clickAndWaitForResponseAndLoadState(data.subUrls.api.wc.store, selector.customer.cCart.removeFirstItem, 207);
// await this.toContainText(selector.customer.cWooSelector.wooCommerceSuccessMessage, 'removed. Undo?'); //todo: remove in future
await this.clearCart();
} else {
await this.toContainText(selector.customer.cCart.cartEmptyMessage, 'Your cart is currently empty.');
await this.toContainText(selector.customer.cCart.cartEmptyMessage, 'Your cart is currently empty!');
}
}

Expand Down Expand Up @@ -323,7 +323,7 @@ export class CustomerPage extends BasePage {
default:
break;
}

await this.focusOnLocator(selector.customer.cCheckout.placeOrder);
await this.clickAndWaitForResponseAndLoadState(data.subUrls.frontend.orderReceived, selector.customer.cCheckout.placeOrder);
await this.toBeVisible(selector.customer.cOrderReceived.orderReceivedSuccessMessage);

Expand Down
9 changes: 7 additions & 2 deletions tests/pw/pages/proPromoPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,13 @@ export class ProPromoPage extends AdminPage {
// dokan promo banner
await this.goIfNotThere(data.subUrls.backend.dokan.dokan);

// promo banner elements are visible
await this.multipleElementVisible(selector.admin.dokan.promoBanner);
const isProPromotionVisible = await this.isVisible(selector.admin.dokan.promoBanner.promoBanner);
if (isProPromotionVisible) {
// promo banner elements are visible
await this.multipleElementVisible(selector.admin.dokan.promoBanner);
} else {
console.log('No Pro promotion exists');
}

// dokan lite modules
await this.goIfNotThere(data.subUrls.backend.dokan.liteModules);
Expand Down
28 changes: 14 additions & 14 deletions tests/pw/pages/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ export const selector = {
// dokan promotion
promotion: {
promotion: '.dokan-notice-slides .dokan-promotion',
joinTheSale: '//a[contains(text(),"Join the Sale! →")]',
message: '.dokan-promotion .dokan-message',
},

// dokan notice
Expand Down Expand Up @@ -1145,8 +1145,8 @@ export const selector = {
announcementStatusScheduled: (title: string) => `//a[contains(text(),'${title}')]/../../..//td[@class="column status"]//span[@class="future"]`,
announcementEdit: (title: string) => `//a[contains(text(),'${title}')]/../..//span[@class="edit"]`,
announcementDelete: (title: string) => `//strong[contains(text(),'${title}')]/../..//span[@class="trash"]`,
announcementPermanentlyDelete: (title: string) => `//a[contains(text(),'${title}')]/../..//span[@class="delete"]`,
announcementRestore: (title: string) => `//a[contains(text(),'${title}')]/../..//span[@class="restore"]`,
announcementPermanentlyDelete: (title: string) => `//strong[contains(text(),'${title}')]/../..//span[@class="delete"]`,
announcementRestore: (title: string) => `//strong[contains(text(),'${title}')]/../..//span[@class="restore"]`,

// add announcement
addAnnouncement: {
Expand Down Expand Up @@ -6924,7 +6924,7 @@ export const selector = {
cartPageHeader: 'h1.entry-title',

// Edit Cart
cartItem: (productName: string) => `//td[@class='product-name']//a[contains(text(),'${productName}')]`,
cartItem: (productName: string) => `//tr[@class='wc-block-cart-items__row']//a[@class= 'wc-block-components-product-name' and contains(text(),'${productName}')]`,
removeItem: (productName: string) => `//a[contains(text(),'${productName}')]/../..//a[@class='remove']`,
quantity: (productName: string) => `//a[contains(text(),'${productName}')]/../..//input[@class='input-text qty text']`,
couponCode: '#coupon_code',
Expand All @@ -6944,12 +6944,12 @@ export const selector = {
vendorShippingMethod: (shippingMethod: string) => `//label[contains(text(),'${shippingMethod}')]/..//input`, // For Unique Shipping Method

// Proceed to Checkout
proceedToCheckout: '.checkout-button.button.wc-forward',
proceedToCheckout: '.checkout-button.button.wc-forward, .wp-block-woocommerce-proceed-to-checkout-block a',

// Remove All Item
productCrossIcon: '.product-remove a',
firstProductCrossIcon: '(//td[@class="product-remove"]//a)[1]',
cartEmptyMessage: '.cart-empty.woocommerce-info',
removeFirstItem: '(//button[@class="wc-block-cart-item__remove-link"])[1]',
cartEmptyMessage: '.wp-block-woocommerce-empty-cart-block .wc-block-cart__empty-cart__title',
},

cWholesale: {
Expand Down Expand Up @@ -7028,17 +7028,17 @@ export const selector = {
vendorShippingMethod: (shippingMethod: string) => `//label[contains(text(),'${shippingMethod}')]/..//input`, // For Unique Shipping Method

// Payment Methods
directBankTransfer: '.payment_method_bacs label',
checkPayments: '.payment_method_cheque label',
cashOnDelivery: '.payment_method_cod label',
directBankTransfer: '.payment_method_bacs label, label[for="radio-control-wc-payment-method-options-bacs"]',
checkPayments: '.payment_method_cheque label, label[for="radio-control-wc-payment-method-options-cheque"]',
cashOnDelivery: '.payment_method_cod label, label[for="radio-control-wc-payment-method-options-cod"]',
paypalAdaptive: '.payment_method_dokan_paypal_adaptive label',
stripeConnect: '.wc_payment_method.payment_method_dokan-stripe-connect label[for="payment_method_dokan-stripe-connect"]',
wireCardCreditCard: '.payment_method_dokan-moip-connect label',
paypalMarketPlace: '.wc_payment_method.payment_method_dokan_paypal_marketplace label',
stripeExpress: '.wc_payment_method.payment_method_dokan_stripe_express label',

// Place Order
placeOrder: '#place_order',
placeOrder: '#place_order, div.wc-block-checkout__actions_row button.wc-block-components-checkout-place-order-button',
},

cPayWithStripe: {
Expand Down Expand Up @@ -7211,9 +7211,9 @@ export const selector = {
},

cWooSelector: {
wooCommerceSuccessMessage: 'div.woocommerce .woocommerce-message',
wooCommerceError: '.woocommerce .woocommerce-error',
wooCommerceInfo: '.woocommerce .woocommerce-info',
wooCommerceSuccessMessage: '.woocommerce .is-success',
wooCommerceError: '.woocommerce .is-error',
wooCommerceInfo: '.woocommerce .is-info',
},
},
};
25 changes: 12 additions & 13 deletions tests/pw/tests/api/announcements.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ import { payloads } from '@utils/payloads';
test.describe('announcements api test', () => {
let apiUtils: ApiUtils;
let announcementId: string;
let announcementNoticeId: string;

test.beforeAll(async ({ request }) => {
apiUtils = new ApiUtils(request);
[, announcementId] = await apiUtils.createAnnouncement(payloads.createAnnouncement());
announcementNoticeId = await apiUtils.getAnnouncementNoticeId(payloads.vendorAuth);
});

test('get all announcements @pro', async () => {
Expand All @@ -32,25 +34,25 @@ test.describe('announcements api test', () => {
expect(responseBody).toBeTruthy();
});

test('create a announcement @pro', async () => {
test('create an announcement @pro', async () => {
const [response, responseBody] = await apiUtils.post(endPoints.createAnnouncement, { data: payloads.createAnnouncement() });
expect(response.ok()).toBeTruthy();
expect(responseBody).toBeTruthy();
});

test('update a announcement @pro', async () => {
test('update an announcement @pro', async () => {
const [response, responseBody] = await apiUtils.post(endPoints.updateAnnouncement(announcementId), { data: payloads.updateAnnouncement });
expect(response.ok()).toBeTruthy();
expect(responseBody).toBeTruthy();
});

test('delete a announcement @pro', async () => {
test('trash an announcement @pro', async () => {
const [response, responseBody] = await apiUtils.delete(endPoints.deleteAnnouncement(announcementId));
expect(response.ok()).toBeTruthy();
expect(responseBody).toBeTruthy();
});

test('restore a deleted announcement @pro', async () => {
test('restore a trashed announcement @pro', async () => {
const [response, responseBody] = await apiUtils.put(endPoints.restoreDeletedAnnouncement(announcementId));
expect(response.ok()).toBeTruthy();
expect(responseBody).toBeTruthy();
Expand All @@ -68,24 +70,21 @@ test.describe('announcements api test', () => {

// announcement notice

test.skip('get single announcement notice @pro', async () => {
const [response, responseBody] = await apiUtils.get(endPoints.getSingleAnnouncementNotice(noticeId), { headers: payloads.vendorAuth });
test('get single announcement notice @pro', async () => {
const [response, responseBody] = await apiUtils.get(endPoints.getSingleAnnouncementNotice(announcementNoticeId), { headers: payloads.vendorAuth });
expect(response.ok()).toBeTruthy();
expect(responseBody).toBeTruthy();
console.log(responseBody);
});

test.skip('update a announcement notice @pro', async () => {
const [response, responseBody] = await apiUtils.post(endPoints.updateAnnouncementNotice(noticeId), { data: payloads.updateAnnouncementNotice, headers: payloads.vendorAuth });
test('update an announcement notice @pro', async () => {
const [response, responseBody] = await apiUtils.post(endPoints.updateAnnouncementNotice(announcementNoticeId), { data: payloads.updateAnnouncementNotice, headers: payloads.vendorAuth });
expect(response.ok()).toBeTruthy();
expect(responseBody).toBeTruthy();
console.log(responseBody);
});

test.skip('delete a announcement notice @pro', async () => {
const [response, responseBody] = await apiUtils.delete(endPoints.deleteAnnouncementNotice(noticeId), { headers: payloads.vendorAuth });
test('delete an announcement notice @pro', async () => {
const [response, responseBody] = await apiUtils.delete(endPoints.deleteAnnouncementNotice(announcementNoticeId), { headers: payloads.vendorAuth });
expect(response.ok()).toBeTruthy();
expect(responseBody).toBeTruthy();
console.log(responseBody);
});
});
3 changes: 1 addition & 2 deletions tests/pw/tests/api/rankMath.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ test.describe.skip('rank math api test', () => {
[, productId] = await apiUtils.createProduct(payloads.createProduct());
});

test('rank math @pro', async () => {
test.skip(!!process.env.CI, 'feature not merged yet!');
test.skip('rank math @pro', async () => {
const [response, responseBody] = await apiUtils.post(endPoints.rankMath(productId), { data: {} });
expect(response.ok()).toBeTruthy();
expect(responseBody).toBeTruthy();
Expand Down
14 changes: 14 additions & 0 deletions tests/pw/tests/api/withdraws.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,18 @@ test.describe('withdraw api test', () => {
expect(response.ok()).toBeTruthy();
expect(responseBody).toBeTruthy();
});

test('get all withdraw method charges @lite', async () => {
test.skip(true, 'feature not merged yet');
const [response, responseBody] = await apiUtils.get(endPoints.getAllWithdrawMethodCharges);
expect(response.ok()).toBeTruthy();
expect(responseBody).toBeTruthy();
});

test('get withdraw charge details @lite', async () => {
test.skip(true, 'feature not merged yet');
const [response, responseBody] = await apiUtils.get(endPoints.getWithdrawCharge, { params: payloads.withdrawCharge });
expect(response.ok()).toBeTruthy();
expect(responseBody).toBeTruthy();
});
});
1 change: 0 additions & 1 deletion tests/pw/tests/e2e/_auth.setup.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ setup.describe('authenticate users & set permalink', () => {
await apiUtils.updateCustomer(sellerId, payloads.updateAddress, payloads.adminAuth);
console.log('VENDOR2_ID:', sellerId);
(global as any).VENDOR2_ID = sellerId;
// helpers.writeEnvJson('VENDOR2_ID', sellerId);
});

setup('authenticate customer @lite', async ({ page }) => {
Expand Down
8 changes: 5 additions & 3 deletions tests/pw/tests/e2e/announcements.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ test.describe('Announcements test', () => {
await admin.adminAnnouncementsRenderProperly();
});

test('admin can add announcement @pro', async () => {
test('admin can send announcement @pro', async () => {
await admin.addAnnouncement({ ...data.announcement, title: data.announcement.randomTitle() });
});

Expand All @@ -44,12 +44,14 @@ test.describe('Announcements test', () => {
});

test('admin can restore announcement @pro', async () => {
const [, , announcementTitle] = await apiUtils.createAnnouncement({ ...payloads.createAnnouncement(), status: 'trash' }, payloads.adminAuth);
const [, announcementId, announcementTitle] = await apiUtils.createAnnouncement(payloads.createAnnouncement(), payloads.adminAuth);
await apiUtils.deleteAnnouncement(announcementId,payloads.adminAuth);
await admin.updateAnnouncement(announcementTitle, 'restore');
});

test('admin can permanently delete announcement @pro', async () => {
const [, , announcementTitle] = await apiUtils.createAnnouncement({ ...payloads.createAnnouncement(), status: 'trash' }, payloads.adminAuth);
const [, announcementId, announcementTitle] = await apiUtils.createAnnouncement(payloads.createAnnouncement(), payloads.adminAuth);
await apiUtils.deleteAnnouncement(announcementId,payloads.adminAuth);
await admin.updateAnnouncement(announcementTitle, 'permanently-delete');
});

Expand Down
2 changes: 2 additions & 0 deletions tests/pw/utils/apiEndPoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ export const endPoints = {
updateWithdraw: (withdrawId: string) => `${SERVER_URL}/dokan/v1/withdraw/${withdrawId}`,
cancelWithdraw: (withdrawId: string) => `${SERVER_URL}/dokan/v1/withdraw/${withdrawId}`,
updateBatchWithdraws: `${SERVER_URL}/dokan/v1/withdraw/batch`, // method: approved, pending, delete, cancelled
getAllWithdrawMethodCharges: `${SERVER_URL}/dokan/v1/withdraw/charges`,
getWithdrawCharge: `${SERVER_URL}/dokan/v1/withdraw/charge`,

// store settings
getSettings: `${SERVER_URL}/dokan/v1/settings`,
Expand Down
18 changes: 18 additions & 0 deletions tests/pw/utils/dbData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,24 @@ export const dbData = {
},
withdraw_method_name: 'Bksh',
withdraw_method_type: 'Phone',
withdraw_charges: {
paypal: {
fixed: '0',
percentage: '0',
},
bank: {
fixed: '0',
percentage: '0',
},
skrill: {
fixed: '0',
percentage: '0',
},
dokan_custom: {
fixed: '0',
percentage: '0',
},
},
withdraw_limit: '5',
withdraw_order_status: {
'wc-completed': 'wc-completed',
Expand Down
5 changes: 5 additions & 0 deletions tests/pw/utils/payloads.ts
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,11 @@ export const payloads = {
method: 'paypal',
},

withdrawCharge: {
method: 'paypal',
amount: '100',
},

// settings

updateSettings: {
Expand Down
1 change: 1 addition & 0 deletions tests/pw/utils/testData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -897,6 +897,7 @@ export const data = {

wc: {
wcProducts: 'wc/v3/products',
store: 'wc/store'
},
},
},
Expand Down
Loading