Skip to content

Commit

Permalink
update tags test
Browse files Browse the repository at this point in the history
  • Loading branch information
shashwatahalder01 committed Nov 15, 2024
1 parent 480ab5d commit 5220725
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 6 deletions.
8 changes: 7 additions & 1 deletion tests/pw/pages/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5229,7 +5229,13 @@ export const selector = {
accommodationBooking: '#\\_is_dokan_accommodation',
productCategory: '#select2-product_cat-container',
productCategoryInput: '.select2-search--dropdown > .select2-search__field',
tags: '.select2-search__field',
// tags
tags: {
tagInput: '//select[@id="product_tag"]/..//input[@class="select2-search__field"]',
searchedTag: (tagName: string) => `//li[@class="select2-results__option select2-results__option--highlighted" and normalize-space(text())="${tagName}"]`,
selectedTags: (tagName: string) => `//li[@class="select2-selection__choice" and contains(., "${tagName}")]`,
removeSelectedTags: (tagName: string) => `//li[@class="select2-selection__choice" and contains(., "${tagName}")]//span[@class="select2-selection__choice__remove"]`,
},

// Accommodation Booking Options
minimumNumberOfNightsAllowedInABooking: '#\\_wc_booking_min_duration',
Expand Down
16 changes: 12 additions & 4 deletions tests/pw/pages/vendorBookingPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -396,13 +396,14 @@ export class BookingPage extends VendorPage {
async addProductTags(productName: string, tags: string[]): Promise<void> {
await this.goToBookingProductEditById(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.clearAndType(bookingProductsVendor.booking.tags.tagInput, tag);
await this.toBeVisible(bookingProductsVendor.booking.tags.searchedTag(tag));
await this.click(bookingProductsVendor.booking.tags.searchedTag(tag));
await this.toBeVisible(bookingProductsVendor.booking.tags.selectedTags(tag));
}
await this.saveProduct();
for (const tag of tags) {
await this.toBeVisible(productsVendor.tags.selectedTags(tag));
await this.toBeVisible(bookingProductsVendor.booking.tags.selectedTags(tag));
}
}

Expand Down Expand Up @@ -949,6 +950,13 @@ export class BookingPage extends VendorPage {
await this.toBeVisible(productsVendor.attribute.savedAttribute(attribute.attributeName));
}

// can't add already added attribute
async cantAddAlreadyAddedAttribute(productName: string, attributeName: string): Promise<void> {
await this.goToBookingProductEditById(productName);
await this.toBeVisible(productsVendor.attribute.savedAttribute(attributeName));
await this.toHaveAttribute(productsVendor.attribute.disabledAttribute(attributeName), 'disabled', 'disabled');
}

// remove product attribute
async removeProductAttribute(productName: string, attribute: string): Promise<void> {
await this.goToBookingProductEditById(productName);
Expand Down
2 changes: 1 addition & 1 deletion tests/pw/tests/e2e/productsDetailsAuction.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ test.describe('Auction Product details functionality test', () => {
});

// todo: refactor below tests

test('vendor can create auction product attribute term', { tag: ['@pro', '@vendor'] }, async () => {
const [, , , attributeName] = await apiUtils.createAttributeTerm(payloads.createAttribute(), payloads.createAttributeTerm(), payloads.adminAuth);
const [, productIdFull] = await apiUtils.createProduct(payloads.createAuctionProductRequiredFields(), payloads.vendorAuth);
Expand Down
3 changes: 3 additions & 0 deletions tests/pw/tests/e2e/productsDetailsBookings.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,17 @@ test.describe('Booking Product details functionality test', () => {
// product tags

test('vendor can add booking product tags', { tag: ['@pro', '@vendor'] }, async () => {
test.skip(true, 'dokan issue option does not work');
await vendor.addProductTags(productIdBasic, data.product.productInfo.tags.tags);
});

test('vendor can remove booking product tags', { tag: ['@pro', '@vendor'] }, async () => {
test.skip(true, 'dokan issue option does not work');
await vendor.removeProductTags(productIdFull, data.product.productInfo.tags.tags);
});

test('vendor can create booking product tags', { tag: ['@pro', '@vendor'] }, async () => {
test.skip(true, 'dokan issue option does not work');
await vendor.addProductTags(productIdFull, data.product.productInfo.tags.randomTags);
});

Expand Down

0 comments on commit 5220725

Please sign in to comment.