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

Add: add vendor payment tests #53

Merged
merged 5 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
24 changes: 19 additions & 5 deletions tests/pw/feature-map/feature-map.yml
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,16 @@
vendor can add product tags [lite]: true
vendor can remove product tags [lite]: true
vendor can create product tags: true
vendor can add product cover image [lite]: true
vendor can update product cover image [lite]: true
vendor can remove product cover image [lite]: true
vendor can add product gallery image [lite]: true
vendor can update product gallery image [lite]: true
vendor can remove product gallery image [lite]: true
vendor can add product short description [lite]: true
vendor can update product short description [lite]: true
vendor can remove product short description [lite]: true
vendor can update product description [lite]: true

- page: 'MyOrders'
features:
Expand Down Expand Up @@ -174,13 +184,17 @@
vendor:
vendor can view payment settings menu page [lite]: true
vendor can add paypal payment method [lite]: true
vendor can update paypal payment method [lite]: true
vendor can remove paypal payment method [lite]: true
vendor can add bank payment method [lite]: true
vendor can add Skrill payment method: true
vendor can update bank payment method [lite]: true
vendor can remove bank payment method [lite]: true
vendor can add skrill payment method: true
vendor can update skrill payment method: true
vendor can remove skrill payment method: true
vendor can add custom payment method: true
vendor can disconnect paypal payment method: true
vendor can disconnect bank payment method: true
vendor can disconnect Skrill payment method: true
vendor can disconnect custom payment method: true
vendor can update custom payment method: true
vendor can remove custom payment method: true

- page: 'Shop'
features:
Expand Down
82 changes: 31 additions & 51 deletions tests/pw/pages/paymentsPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ export class PaymentsPage extends AdminPage {

// payment methods

async goToPaymentSettings() {
async goToWcPaymentSettings() {
await this.goIfNotThere(data.subUrls.backend.wc.paymentSettings);
}

// admin setup basic payment methods
async setupBasicPaymentMethods(payment: payment) {
await this.goToPaymentSettings();
await this.goToWcPaymentSettings();

// bank transfer
await this.enablePaymentMethod(paymentSettingsAdmin.enableDirectBankTransfer);
Expand All @@ -38,7 +38,7 @@ export class PaymentsPage extends AdminPage {

// admin setup stripe sonnect
async setupStripeConnect(payment: payment) {
await this.goToPaymentSettings();
await this.goToWcPaymentSettings();

await this.click(paymentSettingsAdmin.setupDokanStripeConnect);
// setup strip connect
Expand All @@ -63,7 +63,7 @@ export class PaymentsPage extends AdminPage {

// admin setup dokan paypal marketplace
async setupPaypalMarketPlace(payment: payment) {
await this.goToPaymentSettings();
await this.goToWcPaymentSettings();

await this.click(paymentSettingsAdmin.setupDokanPayPalMarketplace);
// setup paypal marketplace
Expand Down Expand Up @@ -91,7 +91,7 @@ export class PaymentsPage extends AdminPage {

// admin setup mangopay
async setupMangoPay(payment: payment) {
await this.goToPaymentSettings();
await this.goToWcPaymentSettings();

await this.click(paymentSettingsAdmin.setupDokanMangoPay);
// setup mangopay
Expand Down Expand Up @@ -138,7 +138,7 @@ export class PaymentsPage extends AdminPage {

// admin setup razorpay
async setupRazorpay(payment: payment) {
await this.goToPaymentSettings();
await this.goToWcPaymentSettings();

await this.click(paymentSettingsAdmin.setupDokanRazorpay);
// setup razorpay
Expand All @@ -162,7 +162,7 @@ export class PaymentsPage extends AdminPage {

// admin setup stripe express
async setupStripeExpress(payment: payment) {
await this.goToPaymentSettings();
await this.goToWcPaymentSettings();

await this.click(paymentSettingsAdmin.setupDokanStripeExpress);

Expand Down Expand Up @@ -217,46 +217,53 @@ export class PaymentsPage extends AdminPage {
// paymentMethods dropdown is visible
await this.toBeVisible(paymentSettingsVendor.paymentMethods.addPaymentMethodDropDown);

await this.notToHaveCount(paymentSettingsVendor.paymentMethods.noOfPaymentMethods, 0);
// await this.notToHaveCount(paymentSettingsVendor.paymentMethods.noOfPaymentMethods, 0);
}

// vendor set basic payment settings
async setBasicPaymentSettings(payment: vendor['payment']): Promise<void> {
await this.setBasicPayment({ ...data.vendor.payment, methodName: 'paypal' });
await this.setBankTransfer(payment);
await this.setBasicPayment({ ...data.vendor.payment, methodName: 'skrill' });
await this.setBasicPayment({ ...data.vendor.payment, methodName: 'custom' });
}

// set basic payment method [paypal, skrill, custom ]
async setBasicPayment(paymentMethod: vendor['payment']): Promise<void> {
switch (paymentMethod.methodName) {
// goto payment settings
async goToPaymentSettings(methodName: string): Promise<void> {
switch (methodName) {
case 'paypal':
await this.goIfNotThere(data.subUrls.frontend.vDashboard.paypal);
await this.goto(data.subUrls.frontend.vDashboard.paypal);
break;

case 'bank':
await this.goto(data.subUrls.frontend.vDashboard.bankTransfer);
break;

case 'skrill':
await this.goIfNotThere(data.subUrls.frontend.vDashboard.skrill);
await this.goto(data.subUrls.frontend.vDashboard.skrill);
break;

case 'custom':
await this.goIfNotThere(data.subUrls.frontend.vDashboard.customPayment);
await this.goto(data.subUrls.frontend.vDashboard.customPayment);
break;

default:
break;
}
}
shashwatahalder01 marked this conversation as resolved.
Show resolved Hide resolved

// set basic payment method [paypal, skrill, custom ]
async addBasicPayment(paymentMethod: vendor['payment']): Promise<void> {
await this.goToPaymentSettings(paymentMethod.methodName);
await this.clearAndType(paymentSettingsVendor.paymentEmail, paymentMethod.email());
await this.clickAndWaitForResponse(data.subUrls.ajax, paymentSettingsVendor.updateSettings);
await this.toContainText(paymentSettingsVendor.updateSettingsSuccessMessage, paymentMethod.saveSuccessMessage);
}

// disconnect basic payment method [paypal, skrill, custom ]
async removeBasicPayment(paymentMethod: vendor['payment']): Promise<void> {
await this.goToPaymentSettings(paymentMethod.methodName);
await this.clickAndWaitForResponse(data.subUrls.ajax, paymentSettingsVendor.disconnectPayment);
await this.toContainText(paymentSettingsVendor.updateSettingsSuccessMessage, paymentMethod.saveSuccessMessage);
}

// bank transfer payment settings
async setBankTransfer(paymentMethod: vendor['payment']): Promise<void> {
async addBankTransfer(paymentMethod: vendor['payment']): Promise<void> {
await this.goIfNotThere(data.subUrls.frontend.vDashboard.bankTransfer);

await this.clickIfVisible(paymentSettingsVendor.disconnectAccount);
// await this.clickIfVisible(paymentSettingsVendor.disconnectAccount);
await this.clearAndType(paymentSettingsVendor.bankAccountName, paymentMethod.bankAccountName);
await this.selectByValue(paymentSettingsVendor.bankAccountType, paymentMethod.bankAccountType);
await this.clearAndType(paymentSettingsVendor.bankAccountNumber, paymentMethod.bankAccountNumber);
Expand All @@ -270,31 +277,4 @@ export class PaymentsPage extends AdminPage {
await this.clickAndWaitForResponse(data.subUrls.ajax, paymentSettingsVendor.addAccount);
await this.toContainText(paymentSettingsVendor.updateSettingsSuccessMessage, paymentMethod.saveSuccessMessage);
}

// disconnect basic payment method [paypal, skrill, custom ]
async disconnectBasicPayment(paymentMethod: vendor['payment']): Promise<void> {
switch (paymentMethod.methodName) {
case 'paypal':
await this.goIfNotThere(data.subUrls.frontend.vDashboard.paypal);
break;

case 'bank':
await this.goIfNotThere(data.subUrls.frontend.vDashboard.bankTransfer);
break;

case 'skrill':
await this.goIfNotThere(data.subUrls.frontend.vDashboard.skrill);
break;

case 'custom':
await this.goIfNotThere(data.subUrls.frontend.vDashboard.customPayment);
break;

default:
break;
}

await this.clickAndWaitForResponse(data.subUrls.ajax, paymentSettingsVendor.disconnectPayment);
await this.toContainText(paymentSettingsVendor.updateSettingsSuccessMessage, paymentMethod.saveSuccessMessage);
}
}
76 changes: 76 additions & 0 deletions tests/pw/pages/productsPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -928,6 +928,82 @@ export class ProductsPage extends AdminPage {
}
}

// add product cover image
async addProductCoverImage(productName: string, coverImage: string, removePrevious: boolean = false): Promise<void> {
await this.goToProductEdit(productName);
// remove previous cover image
if (removePrevious) {
await this.hover(productsVendor.image.coverImageDiv);
await this.click(productsVendor.image.removeFeatureImage);
await this.toBeVisible(productsVendor.image.uploadImageText);
}
await this.click(productsVendor.image.cover);
await this.uploadMedia(coverImage);
await this.saveProduct();
await this.toHaveAttribute(productsVendor.image.uploadedFeatureImage, 'src', /.+/); // Ensures 'src' has any non-falsy value
await this.notToBeVisible(productsVendor.image.uploadImageText);
}

// remove product cover image
async removeProductCoverImage(productName: string): Promise<void> {
await this.goToProductEdit(productName);
await this.hover(productsVendor.image.coverImageDiv);
await this.click(productsVendor.image.removeFeatureImage);
await this.saveProduct();
await this.toHaveAttribute(productsVendor.image.uploadedFeatureImage, 'src', /^$/);
await this.toBeVisible(productsVendor.image.uploadImageText);
}

// add product gallery images
async addProductGalleryImages(productName: string, galleryImages: string[], removePrevious: boolean = false): Promise<void> {
await this.goToProductEdit(productName);
// remove previous gallery images
if (removePrevious) {
const imageCount = await this.getElementCount(productsVendor.image.uploadedGalleryImage);
for (let i = 0; i < imageCount; i++) {
await this.hover(productsVendor.image.galleryImageDiv);
await this.click(productsVendor.image.removeGalleryImage);
}
await this.toHaveCount(productsVendor.image.uploadedGalleryImage, 0);
}

for (const galleryImage of galleryImages) {
await this.click(productsVendor.image.gallery);
await this.uploadMedia(galleryImage);
}
await this.saveProduct();
await this.toHaveCount(productsVendor.image.uploadedGalleryImage, galleryImages.length);
}

// remove product gallery images
async removeProductGalleryImages(productName: string): Promise<void> {
await this.goToProductEdit(productName);
const imageCount = await this.getElementCount(productsVendor.image.uploadedGalleryImage);
for (let i = 0; i < imageCount; i++) {
await this.hover(productsVendor.image.galleryImageDiv);
await this.click(productsVendor.image.removeGalleryImage);
}
await this.saveProduct();
await this.toHaveCount(productsVendor.image.uploadedGalleryImage, 0);
}

// add product short description
async addProductShortDescription(productName: string, shortDescription: string): Promise<void> {
await this.goToProductEdit(productName);
await this.typeFrameSelector(productsVendor.shortDescription.shortDescriptionIframe, productsVendor.shortDescription.shortDescriptionHtmlBody, shortDescription);
await this.saveProduct();
await this.toContainTextFrameLocator(productsVendor.shortDescription.shortDescriptionIframe, productsVendor.shortDescription.shortDescriptionHtmlBody, shortDescription);
}

// add product description
async addProductDescription(productName: string, description: string): Promise<void> {
await this.goToProductEdit(productName);
await this.typeFrameSelector(productsVendor.description.descriptionIframe, productsVendor.description.descriptionHtmlBody, description);
await this.saveProduct();
await this.toContainTextFrameLocator(productsVendor.description.descriptionIframe, productsVendor.description.descriptionHtmlBody, description);
}


// add product catalog mode
async addProductCatalogMode(productName: string, hidePrice: boolean = false): Promise<void> {
await this.goToProductEdit(productName);
Expand Down
Loading
Loading