Skip to content

Commit

Permalink
Merge branch 'develop' into storeAppearance
Browse files Browse the repository at this point in the history
  • Loading branch information
shashwatahalder01 committed Dec 5, 2024
2 parents 236c4cb + 490a380 commit 1c4e7da
Show file tree
Hide file tree
Showing 14 changed files with 95 additions and 34 deletions.
10 changes: 5 additions & 5 deletions tests/pw/feature-map/feature-map.yml
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@
features:
customer:
customer can view single store page [lite]: true
customer can view store open-close time on single store [lite]: false
customer can view store open-close time on single store [lite]: true
customer can search product on single store [lite]: true
customer can sort products on single store [lite]: true
customer can view store terms and conditions [lite]: true
Expand Down Expand Up @@ -325,9 +325,9 @@
customer can search store [lite]: true
customer can filter stores by category: true
customer can filter stores by location: true
customer can filter stores by ratings: false
customer can filter stores by ratings: true
customer can filter featured stores: true
customer can filter open now stores: false
customer can filter open now stores: true
customer can view stores on map: true
customer can go to single store from store list [lite]: true

Expand Down Expand Up @@ -1315,8 +1315,8 @@
- page: 'Store Reviews'
features:
admin:
admin can enable store reviews module: false
admin can disable store reviews module: false
admin can enable store reviews module: true
admin can disable store reviews module: true
admin can view store reviews menu page: true
admin can view store review: true
admin can edit store review: true
Expand Down
8 changes: 8 additions & 0 deletions tests/pw/pages/basePage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1610,6 +1610,14 @@ export class BasePage {
expect(exists).toBe(false);
}

// assert two element to have same count
async toHaveEqualCount(selector1: string, selector2: string, options?: { timeout?: number; intervals?: number[] }) {
await this.toPass(async () => {
const [selector1Count, selector2Count] = await Promise.all([await this.getElementCount(selector1), await this.getElementCount(selector2)]);
expect(selector1Count).toBe(selector2Count);
}, options);
}

// assert element not to be visible
async notToBeVisible(selector: string) {
await expect(this.page.locator(selector)).toBeHidden();
Expand Down
7 changes: 4 additions & 3 deletions tests/pw/pages/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -800,6 +800,7 @@ export const selector = {

// Store Reviews
storeReviews: {
storeReviewsDiv: 'div.dokan-store-reviews',
storeReviewsText: '.dokan-store-reviews h1',

// Nav Tabs
Expand Down Expand Up @@ -7468,10 +7469,10 @@ export const selector = {
// Pagination
pagination: '.dokan-pagination',

// Review
review: {
// Reviews
reviews: {
close: 'button.icon-close',
noReviewsFound: '//span[normalize-space()="No Reviews found"]',
noReviewsFound: '//span[normalize-space()="No Reviews Found"]',
write: '//button[normalize-space()="Write a Review"]',
// write: '.add-review-btn',
edit: '.edit-review-btn',
Expand Down
13 changes: 13 additions & 0 deletions tests/pw/pages/storeListingPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,19 @@ export class StoreListingPage extends CustomerPage {

await this.clickAndWaitForResponse(data.subUrls.frontend.storeListing, storeList.filters.filterDetails.apply);
await this.notToHaveCount(storeList.storeCard.storeCardDiv, 0);

switch (filterBy) {
case 'featured':
await this.toHaveEqualCount(storeList.storeCard.storeCardDiv, storeList.storeCard.featuredLabel);
break;

case 'open-now':
await this.toHaveEqualCount(storeList.storeCard.storeCardDiv, storeList.storeCard.openCloseStatus);
break;

default:
break;
}
}

// stores on map
Expand Down
26 changes: 25 additions & 1 deletion tests/pw/pages/storeReviewsPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ import { data } from '@utils/testData';
import { storeReview } from '@utils/interfaces';

// selectors
const dokanAdmin = selector.admin.dokan;
const storeReviewsAdmin = selector.admin.dokan.storeReviews;
const storeReviewsCustomer = selector.customer.cSingleStore.review;
const storeReviewsCustomer = selector.customer.cSingleStore.reviews;

export class StoreReviewsPage extends AdminPage {
constructor(page: Page) {
Expand All @@ -16,6 +17,29 @@ export class StoreReviewsPage extends AdminPage {

// store reviews

// enable store reviews
async enableStoreReviewsModule(storeName: string) {
await this.goto(data.subUrls.backend.dokan.dokan);
await this.toBeVisible(dokanAdmin.menus.storeReviews);

await this.goIfNotThere(data.subUrls.frontend.vendorDetails(helpers.slugify(storeName)), 'networkidle');
await this.toBeVisible(selector.customer.cSingleStore.storeTabs.reviews);
}

// disable store reviews
async disableStoreReviewsModule(storeName: string) {
await this.goto(data.subUrls.backend.dokan.dokan, { waitUntil: 'domcontentloaded' }, true);
await this.notToBeVisible(dokanAdmin.menus.storeReviews);

// no reviews table is visible
await this.goIfNotThere(data.subUrls.backend.dokan.storeReviews);
await this.notToBeVisible(dokanAdmin.storeReviews.storeReviewsDiv);

// reviews is visible
await this.goIfNotThere(data.subUrls.frontend.storeReviews(helpers.slugify(storeName)));
await this.toBeVisible(selector.customer.cSingleStore.reviews.noReviewsFound);
}

// store reviews render properly
async adminStoreReviewsRenderProperly() {
await this.goIfNotThere(data.subUrls.backend.dokan.storeReviews);
Expand Down
2 changes: 1 addition & 1 deletion tests/pw/tests/api/modules.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ test.describe('modules api test', () => {
});

test.afterAll(async () => {
await apiUtils.activateModules([randomModule]);
await apiUtils.activateModules(randomModule);
await apiUtils.dispose();
});

Expand Down
2 changes: 1 addition & 1 deletion tests/pw/tests/e2e/modules.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ test.describe('Modules test', () => {
});

test('admin can activate module', { tag: ['@pro', '@admin'] }, async () => {
await apiUtils.deactivateModules([payloads.moduleIds.auction], payloads.adminAuth);
await apiUtils.deactivateModules(payloads.moduleIds.auction, payloads.adminAuth);
await admin.activateDeactivateModule(data.modules.modulesName.auctionIntegration);
});

Expand Down
1 change: 0 additions & 1 deletion tests/pw/tests/e2e/singleStore.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ test.describe('Single store functionality test', () => {
});

test.skip('customer can view store open-close time on single store', { tag: ['@lite', '@customer'] }, async () => {
// todo: pre: need store open close time
await customer.storeOpenCloseTime(data.predefined.vendorStores.vendor1);
});

Expand Down
10 changes: 10 additions & 0 deletions tests/pw/tests/e2e/storeReviews.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ test.describe('Store Reviews test', () => {
});

test.afterAll(async () => {
await apiUtils.activateModules(payloads.moduleIds.storeReviews, payloads.adminAuth);
await aPage.close();
await vPage.close();
await cPage.close();
Expand All @@ -43,6 +44,10 @@ test.describe('Store Reviews test', () => {

//admin

test('admin can enable store reviews module', { tag: ['@pro', '@exploratory', '@admin'] }, async () => {
await admin.enableStoreReviewsModule(data.predefined.vendorStores.vendor1);
});

test('admin can view store reviews menu page', { tag: ['@pro', '@exploratory', '@admin'] }, async () => {
await admin.adminStoreReviewsRenderProperly();
});
Expand Down Expand Up @@ -95,4 +100,9 @@ test.describe('Store Reviews test', () => {
test("vendor can't review own store", { tag: ['@pro', '@vendor'] }, async () => {
await vendor.cantReviewOwnStore(data.predefined.vendorStores.vendor1);
});

test('admin can disable store reviews module', { tag: ['@pro', '@exploratory', '@admin'] }, async () => {
await apiUtils.deactivateModules(payloads.moduleIds.storeReviews, payloads.adminAuth);
await admin.disableStoreReviewsModule(data.predefined.vendorStores.vendor1);
});
});
7 changes: 3 additions & 4 deletions tests/pw/tests/e2e/storelisting.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,19 @@ test.describe('Store list functionality test', () => {
await customer.filterStores('by-location', 'New York, NY, USA');
});

test.skip('customer can filter stores by ratings', { tag: ['@pro', '@customer'] }, async () => {
await customer.filterStores('by-ratings', '1');
test('customer can filter stores by ratings', { tag: ['@pro', '@customer'] }, async () => {
await customer.filterStores('by-ratings', '5');
});

test('customer can filter featured stores', { tag: ['@pro', '@customer'] }, async () => {
await customer.filterStores('featured');
});

test.skip('customer can filter open now stores', { tag: ['@pro', '@customer'] }, async () => {
test('customer can filter open now stores', { tag: ['@pro', '@customer'] }, async () => {
await customer.filterStores('open-now');
});

test('customer can view stores on map', { tag: ['@pro', '@customer'] }, async () => {
// test.skip(true, '@todo fix this test');
await customer.storeOnMap();
});

Expand Down
10 changes: 8 additions & 2 deletions tests/pw/utils/apiUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -864,13 +864,19 @@ export class ApiUtils {
}

// get activate modules
async activateModules(moduleIds: string[], auth?: auth): Promise<[APIResponse, responseBody]> {
async activateModules(moduleIds: string | string[], auth?: auth): Promise<[APIResponse, responseBody]> {
if (!Array.isArray(moduleIds)) {
moduleIds = [moduleIds];
}
const [response, responseBody] = await this.put(endPoints.activateModule, { data: { module: moduleIds }, headers: auth });
return [response, responseBody];
}

// get deactivated modules
async deactivateModules(moduleIds: string[], auth?: auth): Promise<[APIResponse, responseBody]> {
async deactivateModules(moduleIds: string | string[], auth?: auth): Promise<[APIResponse, responseBody]> {
if (!Array.isArray(moduleIds)) {
moduleIds = [moduleIds];
}
const [response, responseBody] = await this.put(endPoints.deactivateModule, { data: { module: moduleIds }, headers: auth });
return [response, responseBody];
}
Expand Down
2 changes: 1 addition & 1 deletion tests/pw/utils/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1514,7 +1514,7 @@ export interface modules {

modulesName: {
auctionIntegration: string;
colorSchemeCustomize: string;
colorSchemeCustomizer: string;
deliveryTime: string;
elementor: string;
eUComplianceFields: string;
Expand Down
29 changes: 15 additions & 14 deletions tests/pw/utils/payloads.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3558,8 +3558,9 @@ export const payloads = {
// module

moduleIds: {
auction: 'auction',
booking: 'booking',
colorSchemeCustomize: 'color_scheme_customizer',
colorSchemeCustomizer: 'color_scheme_customizer',
deliveryTime: 'delivery_time',
elementor: 'elementor',
exportImport: 'export_import',
Expand All @@ -3568,41 +3569,41 @@ export const payloads = {
germanized: 'germanized',
liveChat: 'live_chat',
liveSearch: 'live_search',
mangopay: 'mangopay',
moip: 'moip',
orderMinMax: 'order_min_max',
paypalMarketplace: 'paypal_marketplace',
printful: 'printful',
productAddon: 'product_addon',
productAdvertising: 'product_advertising',
productEnquiry: 'product_enquiry',
productSubscription: 'product_subscription',
rankMath: 'rank_math',
reportAbuse: 'report_abuse',
requestForQuotation: 'request_for_quotation',
rma: 'rma',
sellerBadge: 'seller_badge',
sellerVacation: 'seller_vacation',
shipStation: 'shipstation',
auction: 'auction',
spmv: 'spmv',
storeReviews: 'store_reviews',
storeSupport: 'store_support',
stripe: 'stripe',
productAdvertising: 'product_advertising',
productSubscription: 'product_subscription',
stripeExpress: 'stripe_express',
tableRateShipping: 'table_rate_shipping',
vendorAnalytics: 'vendor_analytics',
vendorStaff: 'vendor_staff',
vsp: 'vsp',
vendorVerification: 'vendor_verification',
vsp: 'vsp',
wholesale: 'wholesale',
rankMath: 'rank_math',
tableRateShipping: 'table_rate_shipping',
mangopay: 'mangopay',
orderMinMax: 'order_min_max',
sellerBadge: 'seller_badge',
stripeExpress: 'stripe_express',
requestForQuotation: 'request_for_quotation',
},

deactivateModule: {
module: ['booking'],
module: 'booking',
},

activateModule: {
module: ['booking'],
module: 'booking',
},

// announcement
Expand Down
2 changes: 1 addition & 1 deletion tests/pw/utils/testData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2099,7 +2099,7 @@ export const data = {

modulesName: {
auctionIntegration: 'Auction Integration',
colorSchemeCustomize: 'Color Scheme Customize',
colorSchemeCustomizer: 'Color Scheme Customize',
deliveryTime: 'Delivery Time',
elementor: 'Elementor',
eUComplianceFields: 'EU Compliance Fields',
Expand Down

0 comments on commit 1c4e7da

Please sign in to comment.