-
Notifications
You must be signed in to change notification settings - Fork 205
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ce345d5
commit e29b0bb
Showing
6 changed files
with
169 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
import { Page } from '@playwright/test'; | ||
import { AdminPage } from '@pages/adminPage'; | ||
import { selector } from '@pages/selectors'; | ||
import { data } from '@utils/testData'; | ||
import { helpers } from '@utils/helpers'; | ||
|
||
export class GeolocationPage extends AdminPage { | ||
constructor(page: Page) { | ||
super(page); | ||
} | ||
|
||
async goToProductDetails(productName: string): Promise<void> { | ||
await this.gotoUntilNetworkidle(data.subUrls.frontend.productDetails(helpers.slugify(productName))); | ||
} | ||
|
||
// view map position | ||
async viewMapPosition(position: 'top' | 'left' | 'right'): Promise<void> { | ||
await this.gotoUntilNetworkidle(data.subUrls.frontend.storeListing); | ||
switch (position) { | ||
case 'top': | ||
await this.toHaveAttribute(selector.customer.cStoreList.map.locationMap, 'class', 'dokan-geolocation-locations-map-top'); | ||
break; | ||
|
||
case 'left': | ||
await this.toHaveAttribute(selector.customer.cStoreList.map.locationMap, 'class', 'dokan-geolocation-locations-map-left'); | ||
break; | ||
|
||
case 'right': | ||
await this.toHaveAttribute(selector.customer.cStoreList.map.locationMap, 'class', 'dokan-geolocation-locations-map-right'); | ||
break; | ||
|
||
default: | ||
break; | ||
} | ||
} | ||
|
||
// view map | ||
async viewMap(position: 'all' | 'store_listing' | 'shop'): Promise<void> { | ||
switch (position) { | ||
case 'all': | ||
await this.gotoUntilNetworkidle(data.subUrls.frontend.shop); | ||
await this.toBeVisible(selector.customer.cStoreList.map.locationMap); | ||
await this.gotoUntilNetworkidle(data.subUrls.frontend.storeListing); | ||
await this.toBeVisible(selector.customer.cStoreList.map.locationMap); | ||
break; | ||
|
||
case 'store_listing': | ||
await this.gotoUntilNetworkidle(data.subUrls.frontend.shop); | ||
await this.notToBeVisible(selector.customer.cStoreList.map.locationMap); | ||
await this.gotoUntilNetworkidle(data.subUrls.frontend.storeListing); | ||
await this.toBeVisible(selector.customer.cStoreList.map.locationMap); | ||
break; | ||
|
||
case 'shop': | ||
await this.gotoUntilNetworkidle(data.subUrls.frontend.shop); | ||
await this.toBeVisible(selector.customer.cStoreList.map.locationMap); | ||
await this.gotoUntilNetworkidle(data.subUrls.frontend.storeListing); | ||
await this.notToBeVisible(selector.customer.cStoreList.map.locationMap); | ||
break; | ||
|
||
default: | ||
break; | ||
} | ||
} | ||
|
||
// view map filters | ||
async viewMapFilters(status: 'enable' | 'disable'): Promise<void> { | ||
await this.gotoUntilNetworkidle(data.subUrls.frontend.shop); | ||
switch (status) { | ||
case 'enable': | ||
await this.toBeVisible(selector.customer.cShop.filters.filterDiv); | ||
break; | ||
|
||
case 'disable': | ||
await this.notToBeVisible(selector.customer.cShop.filters.filterDiv); | ||
break; | ||
|
||
default: | ||
break; | ||
} | ||
} | ||
|
||
// view product location | ||
async viewProductLocationTab(productName: string, status: 'enable' | 'disable'): Promise<void> { | ||
switch (status) { | ||
case 'enable': | ||
await this.goToProductDetails(productName); | ||
await this.toBeVisible(selector.customer.cSingleProduct.menus.location); | ||
break; | ||
|
||
case 'disable': | ||
await this.goToProductDetails(productName); | ||
await this.notToBeVisible(selector.customer.cSingleProduct.menus.location); | ||
break; | ||
|
||
default: | ||
break; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { test, Page } from '@playwright/test'; | ||
import { GeolocationPage } from '@pages/geolocationPage'; | ||
import { dbData } from '@utils/dbData'; | ||
import { dbUtils } from '@utils/dbUtils'; | ||
import { data } from '@utils/testData'; | ||
|
||
test.describe('Geolocation test', () => { | ||
let admin: GeolocationPage; | ||
let aPage: Page; | ||
|
||
test.beforeAll(async ({ browser }) => { | ||
const adminContext = await browser.newContext(data.auth.adminAuth); | ||
aPage = await adminContext.newPage(); | ||
admin = new GeolocationPage(aPage); | ||
}); | ||
|
||
test.afterAll(async () => { | ||
await dbUtils.setOptionValue(dbData.dokan.optionName.geolocation, dbData.dokan.geolocationSettings); | ||
await aPage.close(); | ||
}); | ||
|
||
['top', 'left', 'right'].forEach((position: string) => { | ||
test(`admin can set map position (${position})`, { tag: ['@pro', '@admin'] }, async () => { | ||
await dbUtils.updateOptionValue(dbData.dokan.optionName.geolocation, { show_locations_map: position }); | ||
await admin.viewMapPosition(position as 'top' | 'left' | 'right'); | ||
}); | ||
}); | ||
|
||
['all', 'store_listing', 'shop'].forEach((place: string) => { | ||
test(`admin can set map display page (${place})`, { tag: ['@pro', '@admin'] }, async () => { | ||
await dbUtils.updateOptionValue(dbData.dokan.optionName.geolocation, { show_location_map_pages: place }); | ||
await admin.viewMap(place as 'all' | 'store_listing' | 'shop'); | ||
}); | ||
}); | ||
|
||
['enable', 'disable'].forEach((status: string) => { | ||
test(`admin can ${status} filters before location map`, { tag: ['@pro', '@admin'] }, async () => { | ||
await dbUtils.updateOptionValue(dbData.dokan.optionName.geolocation, { show_filters_before_locations_map: status === 'enable' ? 'on' : 'off' }); | ||
await admin.viewMapFilters(status as 'enable' | 'disable'); | ||
}); | ||
}); | ||
|
||
['enable', 'disable'].forEach((status: string) => { | ||
test(`admin can ${status} product location tab on single product page`, { tag: ['@pro', '@admin'] }, async () => { | ||
await dbUtils.updateOptionValue(dbData.dokan.optionName.geolocation, { show_product_location_in_wc_tab: status === 'enable' ? 'on' : 'off' }); | ||
await admin.viewProductLocationTab(data.predefined.simpleProduct.product1.name, status as 'enable' | 'disable'); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters