-
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.
* Add live search tests * Add widget api methods * Fix widger dbdata * Fix: e2e coverage issue * Fix pr reviews
- Loading branch information
1 parent
476a85d
commit f31aa2c
Showing
10 changed files
with
256 additions
and
53 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
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,30 @@ | ||
import { Page } from '@playwright/test'; | ||
import { BasePage } from '@pages/basePage'; | ||
import { selector } from '@pages/selectors'; | ||
import { data } from '@utils/testData'; | ||
|
||
// selectors | ||
const liveSearchCustomer = selector.customer.cLiveSearch; | ||
|
||
export class LiveSearch extends BasePage { | ||
constructor(page: Page) { | ||
super(page); | ||
} | ||
|
||
async searchByLiveSearch(productName: string, autoload = false, categoryName?: string) { | ||
await this.gotoUntilNetworkidle(data.subUrls.frontend.myAccount); | ||
|
||
if (!autoload) { | ||
if (categoryName) await this.selectByValueAndWaitForResponse(data.subUrls.ajax, liveSearchCustomer.liveSearchCategory, categoryName.toLowerCase()); | ||
await this.fill(liveSearchCustomer.liveSearchInput, productName); // to reduce type time | ||
await this.typeByPageAndWaitForResponse(data.subUrls.ajax, liveSearchCustomer.liveSearchInput, ' ', 200, false); | ||
await this.toBeVisible(liveSearchCustomer.searchedResult(productName)); | ||
if (categoryName) await this.toBeVisible(liveSearchCustomer.searchResultWithCategory(productName, categoryName)); | ||
} else { | ||
if (categoryName) await this.selectByValueAndWaitForLoadState(liveSearchCustomer.liveSearchCategory, categoryName.toLowerCase()); | ||
await this.fill(liveSearchCustomer.liveSearchInput, productName); // to reduce type time | ||
await this.typeByPageAndWaitForLoadState(liveSearchCustomer.liveSearchInput, ' ', false); | ||
await this.toBeVisible(selector.customer.cShop.productTitleByName(productName)); | ||
} | ||
} | ||
} |
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,48 @@ | ||
import { test, Page, request } from '@playwright/test'; | ||
import { LiveSearch } from '@pages/liveSearchPage'; | ||
import { ApiUtils } from '@utils/apiUtils'; | ||
import { dbUtils } from '@utils/dbUtils'; | ||
import { data } from '@utils/testData'; | ||
import { dbData } from '@utils/dbData'; | ||
|
||
test.describe('Live search test', () => { | ||
let customer: LiveSearch; | ||
let cPage: Page; | ||
let apiUtils: ApiUtils; | ||
|
||
test.beforeAll(async ({ browser }) => { | ||
const customerContext = await browser.newContext(data.auth.customerAuth); | ||
cPage = await customerContext.newPage(); | ||
customer = new LiveSearch(cPage); | ||
|
||
apiUtils = new ApiUtils(await request.newContext()); | ||
|
||
await dbUtils.updateOptionValue('widget_dokna_product_search', dbData.liveSearchWidget); | ||
await dbUtils.updateOptionValue('sidebars_widgets', { ...dbData.sidebarWidgets, 'sidebar-1': ['dokna_product_search-2'] }); | ||
}); | ||
|
||
test.afterAll(async () => { | ||
await dbUtils.setOptionValue(dbData.dokan.optionName.liveSearch, dbData.dokan.liveSearchSettings); | ||
await cPage.close(); | ||
}); | ||
|
||
// customer | ||
|
||
test('customer can search product using live search (suggestion box)', { tag: ['@pro', '@customer'] }, async () => { | ||
await customer.searchByLiveSearch(data.predefined.simpleProduct.product1.name); | ||
}); | ||
|
||
test('customer can search product with category using live search (suggestion box)', { tag: ['@pro', '@customer'] }, async () => { | ||
await customer.searchByLiveSearch(data.predefined.simpleProduct.product1.name, false, data.predefined.categories.uncategorized); | ||
}); | ||
|
||
test('customer can search product using live search (autoload content)', { tag: ['@pro', '@customer'] }, async () => { | ||
await dbUtils.updateOptionValue(dbData.dokan.optionName.liveSearch, { live_search_option: 'old_live_search' }); | ||
await customer.searchByLiveSearch(data.predefined.simpleProduct.product1.name, true); | ||
}); | ||
|
||
test('customer can search product with category using live search (autoload content)', { tag: ['@pro', '@customer'] }, async () => { | ||
await dbUtils.updateOptionValue(dbData.dokan.optionName.liveSearch, { live_search_option: 'old_live_search' }); | ||
await customer.searchByLiveSearch(data.predefined.simpleProduct.product1.name, true, data.predefined.categories.uncategorized); | ||
}); | ||
}); |
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
Oops, something went wrong.