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 Geolocation tests #2445

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
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
25 changes: 15 additions & 10 deletions tests/pw/feature-map/feature-map.yml
Original file line number Diff line number Diff line change
Expand Up @@ -814,7 +814,7 @@
- page: 'Geolocation'
features:
admin:
# admin can set Dokan geolocation settings [duplicate]: false
# admin can set Dokan geolocation settings [duplicate]: true
admin can set map location position (top): true
admin can set map location position (left): true
admin can set map location position (right): true
Expand All @@ -825,17 +825,19 @@
admin can disable filters before location map: true
admin can enable product location tab on single product page: true
admin can disable product location tab on single product page: true
admin can set map radius search unit and distance: false
admin can set map zoom level: false
admin can set map default location: false
admin can add geolocation widget (product location) widget: false
admin can add geolocation widget (store location) widget: false
admin can add geolocation widget (geolocation filter form) widget: false
# admin can add geolocation filters shortcode [duplicate]: false
# vendor:
admin can set map radius search unit and distance (km): true
admin can set map radius search unit and distance (miles): true
# admin can set map zoom level: false
# admin can set map default location: false
# admin can add geolocation widget (product location) widget: false
# admin can add geolocation widget (store location) widget: false
# admin can add geolocation widget (geolocation filter form) widget: false
# admin can add geolocation filters shortcode [duplicate]: true
# vendor:
# vendor can add location to store [duplicate]: false
# vendor can add location to product [duplicate]: false
# customer:
customer:
customer can slide map radius bar: true
# customer can view map on shop page [duplicate]: false
# customer can view map on store list page [duplicate]: false
# customer can view map on single product page [duplicate]: false
Expand Down Expand Up @@ -1105,6 +1107,9 @@
- page: 'ShipStation Integration'
features:
vendor:
# vendor can view Shipstation settings menu page: true
vendor can generate shipStation credentials: false
vendor can revoke shipStation credentials: false
vendor can set shipStation settings: true

- page: 'Single Product Multiple Vendor (SPMV)'
Expand Down
28 changes: 28 additions & 0 deletions tests/pw/pages/geolocationPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,32 @@ export class GeolocationPage extends AdminPage {
break;
}
}

// view map radius unit and distance
async viewMapRadiusSearchUnitAndDistance(unit: 'km' | 'miles', distance: { min: string; max: string }): Promise<void> {
await this.gotoUntilNetworkidle(data.subUrls.frontend.shop);

switch (unit) {
case 'km':
await this.toContainText(selector.customer.cShop.radiusSearch.radiusUnit, `Radius ${distance.max}km`);
break;

case 'miles':
await this.toContainText(selector.customer.cShop.radiusSearch.radiusUnit, `Radius ${distance.max}miles`);
break;

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

async slideMapRadiusBar(slideUnit: string): Promise<void> {
await this.gotoUntilNetworkidle(data.subUrls.frontend.shop);
await this.focus(selector.customer.cShop.radiusSearch.slider);
await this.setAttributeValue(selector.customer.cShop.radiusSearch.slider, 'value', '0');
for (let i = 0; i < Number(slideUnit); i++) {
await this.press('ArrowRight');
}
await this.toHaveValue(selector.customer.cShop.radiusSearch.slider, slideUnit);
}
shashwatahalder01 marked this conversation as resolved.
Show resolved Hide resolved
}
2 changes: 1 addition & 1 deletion tests/pw/pages/noticeAndPromotionPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export class NoticeAndPromotionPage extends AdminPage {
await this.notToBeVisible(selector.admin.dokan.diagnostic.noticeDiv);
}

// allow diagnostic tracking
// disallow diagnostic tracking
async disallowDiagnosticTracking() {
await this.goIfNotThere(data.subUrls.backend.adminDashboard, 'networkidle');
await this.clickAndWaitForLoadState(selector.admin.dokan.diagnostic.disallowCollectData);
Expand Down
5 changes: 5 additions & 0 deletions tests/pw/pages/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7010,6 +7010,11 @@ export const selector = {
},
},

radiusSearch: {
radiusUnit: 'span.dokan-range-slider-value',
slider: 'input.dokan-range-slider',
},

// Filter
filters: {
filterDiv: 'form.dokan-geolocation-location-filters',
Expand Down
3 changes: 3 additions & 0 deletions tests/pw/tests/e2e/commission.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,7 @@ test.describe('Commission test', () => {
const [, , orderId] = await apiUtils.createOrderWithStatus(PRODUCT_ID, payloads.createOrder, data.order.orderStatus.onhold, payloads.vendorAuth);
await admin.viewCommissionMetaBox(orderId);
});

// todo: admin can view commission on product list, order list, and order details, sub order details on parent order
// todo: vendor can view earning on product list, product details, order list, and order details
});
15 changes: 15 additions & 0 deletions tests/pw/tests/e2e/geolocation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ test.describe('Geolocation test', () => {
admin = new GeolocationPage(aPage);
});

test.beforeEach(async () => {
await dbUtils.setOptionValue(dbData.dokan.optionName.geolocation, dbData.dokan.geolocationSettings);
});

test.afterAll(async () => {
await dbUtils.setOptionValue(dbData.dokan.optionName.geolocation, dbData.dokan.geolocationSettings);
await aPage.close();
Expand Down Expand Up @@ -46,4 +50,15 @@ test.describe('Geolocation test', () => {
await admin.viewProductLocationTab(data.predefined.simpleProduct.product1.name, status as 'enable' | 'disable');
});
});

['km', 'miles'].forEach((unit: string) => {
test(`admin can set map radius search unit and distance ${unit} `, { tag: ['@pro', '@admin'] }, async () => {
await dbUtils.updateOptionValue(dbData.dokan.optionName.geolocation, { distance_unit: unit, distance_min: '0', distance_max: '10' });
await admin.viewMapRadiusSearchUnitAndDistance(unit as 'km' | 'miles', { min: '0', max: '10' });
});
});

test('customer can slide map radius bar', { tag: ['@pro', '@customer'] }, async () => {
await admin.slideMapRadiusBar('5');
});
});
4 changes: 2 additions & 2 deletions tests/pw/tests/e2e/plugin.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ test.describe.skip('Plugin functionality test', () => {
});

test.skip('admin can delete Dokan pro plugin', { tag: ['@pro', '@admin', '@serial'] }, async () => {
await admin.activatePlugin(data.plugin.pluginName.dokanLite);
// await admin.deletePlugin(data.plugin.pluginName.dokanLite);
});

test.skip('admin can delete Dokan plugin', { tag: ['@lite', '@admin', '@serial'] }, async () => {
await admin.activatePlugin(data.plugin.pluginName.dokanLite);
// await admin.deletePlugin(data.plugin.pluginName.dokanLite);
});

//todo: replace (one zip with another) plugin test
Expand Down
2 changes: 1 addition & 1 deletion tests/pw/utils/dbData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1043,7 +1043,7 @@ export const dbData = {
show_location_map_pages: 'all', // all, store_listing, shop
show_filters_before_locations_map: 'on', // on, off
show_product_location_in_wc_tab: 'on', // on, off
distance_unit: 'km',
distance_unit: 'km', // km, miles
distance_min: '0',
distance_max: '10',
map_zoom: '11',
Expand Down
Loading