Skip to content

Commit

Permalink
Merge branch 'develop' into payments
Browse files Browse the repository at this point in the history
  • Loading branch information
shashwatahalder01 committed Oct 3, 2024
2 parents 8d546e4 + 9a21a84 commit e4bd6eb
Show file tree
Hide file tree
Showing 5 changed files with 291 additions and 4 deletions.
20 changes: 19 additions & 1 deletion tests/pw/feature-map/feature-map.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,25 @@
vendor can't add product discount price higher than price [lite]: true
vendor can remove product discount price [lite]: true
vendor can remove product discount schedule [lite]: true

vendor can update product category (single) [lite]: true
vendor can add product category (multiple): true
vendor can remove product category (multiple): true
vendor can add multi-step product category (last category) [lite]: true
vendor can add multi-step product category (any category) [lite]: true
vendor can't add multi-step product category (any category) [lite]: true
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
164 changes: 163 additions & 1 deletion tests/pw/pages/productsPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { AdminPage } from '@pages/adminPage';
import { selector } from '@pages/selectors';
import { data } from '@utils/testData';
import { helpers } from '@utils/helpers';
import { product } from '@utils/interfaces';
import { product, vendor } from '@utils/interfaces';

const { DOKAN_PRO } = process.env;

Expand Down Expand Up @@ -842,6 +842,168 @@ export class ProductsPage extends AdminPage {
}
}

// vendor add product category
async vendorAddProductCategory(category: string, multiple: boolean, neg?: boolean): Promise<void> {
if (!multiple) {
await this.click(productsVendor.category.openCategoryModal);
} else {
await this.click(productsVendor.category.addNewCategory);
await this.click(productsVendor.category.selectACategory);
}
await this.toBeVisible(productsVendor.category.categoryModal);
await this.type(productsVendor.category.searchInput, category);
await this.toContainText(productsVendor.category.searchedResultText, category);
await this.click(productsVendor.category.searchedResult);
await this.click(productsVendor.category.categoryOnList(category));
if (neg) {
await this.toBeDisabled(productsVendor.category.done);
return;
}
await this.click(productsVendor.category.done);

const categoryAlreadySelectedPopup = await this.isVisible(productsVendor.category.categoryAlreadySelectedPopup);
if (categoryAlreadySelectedPopup) {
await this.click(productsVendor.category.categoryAlreadySelectedPopup);
await this.click(productsVendor.category.categoryModalClose);
}
await this.toBeVisible(productsVendor.category.selectedCategory(category));
}

// add product category
async addProductCategory(productName: string, categories: string[], multiple: boolean = false): Promise<void> {
await this.goToProductEdit(productName);
for (const category of categories) {
await this.vendorAddProductCategory(category, multiple);
}
await this.saveProduct();
for (const category of categories) {
await this.toBeVisible(productsVendor.category.selectedCategory(category));
}
}

// remove product category
async removeProductCategory(productName: string, categories: string[]): Promise<void> {
await this.goToProductEdit(productName);
for (const category of categories) {
await this.click(productsVendor.category.removeSelectedCategory(category));
await this.notToBeVisible(productsVendor.category.selectedCategory(category));
}
await this.saveProduct();
for (const category of categories) {
await this.notToBeVisible(productsVendor.category.selectedCategory(category));
}
}

// can't add product category
async cantAddCategory(productName: string, category: string): Promise<void> {
await this.goToProductEdit(productName);
await this.vendorAddProductCategory(category, false, true);
}

// add product tags
async addProductTags(productName: string, tags: string[]): Promise<void> {
await this.goToProductEdit(productName);
for (const tag of tags) {
await this.typeAndWaitForResponse(data.subUrls.ajax, productsVendor.tags.tagInput, tag);
await this.click(productsVendor.tags.searchedTag(tag));
await this.toBeVisible(productsVendor.tags.selectedTags(tag));
}
await this.saveProduct();
for (const tag of tags) {
await this.toBeVisible(productsVendor.tags.selectedTags(tag));
}
}

// remove product tags
async removeProductTags(productName: string, tags: string[]): Promise<void> {
await this.goToProductEdit(productName);
for (const tag of tags) {
await this.click(productsVendor.tags.removeSelectedTags(tag));
await this.press('Escape'); // shift focus from element
}
await this.saveProduct();

for (const tag of tags) {
await this.notToBeVisible(productsVendor.tags.selectedTags(tag));
}
}

// 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
4 changes: 4 additions & 0 deletions tests/pw/tests/e2e/euCompliance.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ test.describe('EU Compliance test', () => {
await productsPage.addProductEuCompliance(euProductName, data.product.productInfo.euCompliance);
});

test.skip('vendor can remove product EU compliance data', { tag: ['@pro', '@vendor'] }, async () => {
await productsPage.addProductEuCompliance(productName, { ...data.product.productInfo.euCompliance, productUnits: '', basePriceUnits: '', freeShipping: false, regularUnitPrice: '', saleUnitPrice: '', optionalMiniDescription: '' });
});

// customer

test('customer can add EU Compliance data on billing address', { tag: ['@pro', '@customer'] }, async () => {
Expand Down
103 changes: 103 additions & 0 deletions tests/pw/tests/e2e/productsDetails.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,107 @@ test.describe('Product details functionality test', () => {
const [, , productName] = await apiUtils.createProduct(payloads.createDiscountProduct(), payloads.vendorAuth);
await vendor.removeDiscount(productName, true);
});

// product category

test('vendor can update product category (single)', { tag: ['@lite', '@vendor'] }, async () => {
await vendor.addProductCategory(productName, [data.product.category.clothings]);
});

test('vendor can add product category (multiple)', { tag: ['@pro', '@vendor'] }, async () => {
await dbUtils.updateOptionValue(dbData.dokan.optionName.selling, { product_category_style: 'multiple' });
await vendor.addProductCategory(productName1, data.product.category.categories, true);
});

test('vendor can remove product category (multiple)', { tag: ['@pro', '@vendor'] }, async () => {
await dbUtils.updateOptionValue(dbData.dokan.optionName.selling, { product_category_style: 'multiple' });
const uncategorizedId = await apiUtils.getCategoryId('Uncategorized', payloads.adminAuth);
const [, , productName] = await apiUtils.createProduct({ ...payloads.createProduct(), categories: [{ id: uncategorizedId }, { id: CATEGORY_ID }] }, payloads.vendorAuth); // need multiple categories
await vendor.removeProductCategory(productName, [data.product.category.clothings]);
});

test('vendor can add multi-step product category (last category)', { tag: ['@lite', '@vendor'] }, async () => {
await vendor.addProductCategory(productName1, [data.product.category.multistepCategories.at(-1)!]);
});

test('vendor can add multi-step product category (any category)', { tag: ['@lite', '@vendor'] }, async () => {
await dbUtils.updateOptionValue(dbData.dokan.optionName.selling, { dokan_any_category_selection: 'on' });
await vendor.addProductCategory(productName, [data.product.category.multistepCategories.at(-2)!]);
});

test("vendor can't add multi-step product category (any category)", { tag: ['@lite', '@vendor'] }, async () => {
await dbUtils.updateOptionValue(dbData.dokan.optionName.selling, { dokan_any_category_selection: 'off' });
await vendor.cantAddCategory(productName, data.product.category.multistepCategories.at(-2)!);
});

// product tags

test('vendor can add product tags', { tag: ['@lite', '@vendor'] }, async () => {
await vendor.addProductTags(productName1, data.product.productInfo.tags.tags);
});

test('vendor can remove product tags', { tag: ['@lite', '@vendor'] }, async () => {
await vendor.removeProductTags(productName, data.product.productInfo.tags.tags);
});

test('vendor can create product tags', { tag: ['@pro', '@vendor'] }, async () => {
await vendor.addProductTags(productName, data.product.productInfo.tags.randomTags);
});

// product cover image

test('vendor can add product cover image', { tag: ['@lite', '@vendor'] }, async () => {
await vendor.addProductCoverImage(productName1, data.product.productInfo.images.cover);
});

test('vendor can update product cover image', { tag: ['@lite', '@vendor'] }, async () => {
// todo: need a product with cover image
await vendor.addProductCoverImage(productName, data.product.productInfo.images.cover);
await vendor.addProductCoverImage(productName, data.product.productInfo.images.cover, true);
});

test('vendor can remove product cover image', { tag: ['@lite', '@vendor'] }, async () => {
// todo: need a product with cover image
await vendor.addProductCoverImage(productName, data.product.productInfo.images.cover, true);
await vendor.removeProductCoverImage(productName);
});

// product gallery image

test('vendor can add product gallery image', { tag: ['@lite', '@vendor'] }, async () => {
await vendor.addProductGalleryImages(productName1, data.product.productInfo.images.gallery);
});

test('vendor can update product gallery image', { tag: ['@lite', '@vendor'] }, async () => {
// todo: need a product with gallery images
await vendor.addProductGalleryImages(productName, data.product.productInfo.images.gallery);
await vendor.addProductGalleryImages(productName, data.product.productInfo.images.gallery, true);
});

test('vendor can remove product gallery image', { tag: ['@lite', '@vendor'] }, async () => {
// todo: need a product with gallery images
await vendor.addProductGalleryImages(productName, data.product.productInfo.images.gallery, true);
await vendor.removeProductGalleryImages(productName);
});

// product short description

test('vendor can add product short description', { tag: ['@lite', '@vendor'] }, async () => {
await vendor.addProductShortDescription(productName1, data.product.productInfo.description.shortDescription);
});

test('vendor can update product short description', { tag: ['@lite', '@vendor'] }, async () => {
await vendor.addProductShortDescription(productName, data.product.productInfo.description.shortDescription);
});

test('vendor can remove product short description', { tag: ['@lite', '@vendor'] }, async () => {
await vendor.addProductShortDescription(productName, '');
});

// product description

test('vendor can update product description', { tag: ['@lite', '@vendor'] }, async () => {
await vendor.addProductDescription(productName, data.product.productInfo.description.description);
});

});
4 changes: 2 additions & 2 deletions tests/pw/utils/payloads.ts
Original file line number Diff line number Diff line change
Expand Up @@ -895,8 +895,8 @@ export const payloads = {
downloadable: true,
regular_price: faker.finance.amount({ min: 100, max: 200, dec: faker.helpers.arrayElement([0, 2]) }),
downloads: [],
// download_limit: 100,
// download_expiry: 100,
download_limit: 100,
download_expiry: 365,
categories: [{}],
}),

Expand Down

0 comments on commit e4bd6eb

Please sign in to comment.