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 product form tests (gallery, description) #2385

Merged
merged 1 commit into from
Oct 2, 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
10 changes: 10 additions & 0 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
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
56 changes: 56 additions & 0 deletions tests/pw/tests/e2e/productsDetails.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,4 +156,60 @@ test.describe('Product details functionality test', () => {
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);
});

});
Loading