Search Bar TC's new
THEME DEFAULT test(`@Products @REVEX_MembershipThemes @REVEX_CP_ChildApps Verify Search Functionality for product, category, and lesson with description`, async ({ browser, membershipAPI, }) => { let magicLink = await membershipAPI.getMagicLink( contactData.email, MembershipData.cpLocationId, MembershipData.clientPortalUrl, ) const descriptionText = 'Product description ' + fakers.jobDescriptor() await membershipAPI.updateProductsDetails( MembershipData.cpLocationId, product.productId, product.productName, descriptionText, ) const lessonDesc = 'Lesson description ' + fakers.jobDescriptor() await membershipAPI.updateLessonDetails( { locationId: MembershipData.cpLocationId, categoryId: category.categoryId, productId: product.productId, visibility: 'published', description: lessonDesc, }, lesson.lessonIds[0], ) const categoryDesc = 'Category description ' + fakers.jobDescriptor() await membershipAPI.updateCategoryDetails( MembershipData.cpLocationId, category.categoryId, categoryDesc, ) userPage = await browser.newPage() pp = new previewPage(userPage) await pp.CPloginwithMagiclink(magicLink, product.productName) await pp.verifySearchBarElements('abc', MembershipData.placeholderText) await pp.verifySearchBarResults( product.productName, product.productName, descriptionText, ) await pp.verifySearchBarResults( category.categoryName, product.productName, categoryDesc, category.categoryName, ) await pp.verifySearchBarResults( lesson.lessonNames[0], product.productName, lessonDesc, '', lesson.lessonNames[0], ) await pp.verifySearchBarResults( descriptionText, product.productName, descriptionText, ) await pp.verifySearchBarResults( descriptionText.split(' ')[0], product.productName, descriptionText, ) }) test(`@Products @REVEX_MembershipThemes @REVEX_CP_ChildApps Verify Search Functionality for product, category, and lesson without description`, async ({ browser, membershipAPI, }) => { let magicLink = await membershipAPI.getMagicLink( contactData.email, MembershipData.cpLocationId, MembershipData.clientPortalUrl, ) userPage = await browser.newPage() pp = new previewPage(userPage) await pp.CPloginwithMagiclink(magicLink, product.productName) await pp.verifySearchBarElements('abc', MembershipData.placeholderText) await pp.verifySearchBarResults(product.productName, product.productName) await pp.verifySearchBarResults( category.categoryName, product.productName, '', category.categoryName, ) await pp.verifySearchBarResults( lesson.lessonNames[0], product.productName, '', '', lesson.lessonNames[0], ) // Verify partial words and check results await pp.verifySearchBarResults( product.productName.split(' ')[0], product.productName, ) await pp.verifySearchBarResults( category.categoryName.split(' ')[0], product.productName, '', category.categoryName, ) await pp.verifySearchBarResults( lesson.lessonNames[0].split(' ')[0], product.productName, '', '', lesson.lessonNames[0], ) }) THEME CLASSIC test(`@Products @REVEX_MembershipThemes @REVEX_CP_ChildApps Verify Search Functionality for product, category, and lesson with description using classic theme`, async ({ browser, membershipAPI, }) => { let magicLink = await membershipAPI.getMagicLink( contactData.email, MembershipData.cpLocationId, MembershipData.clientPortalUrl, ) const descriptionText = 'Product description ' + fakers.jobDescriptor() await membershipAPI.updateProductsDetails( MembershipData.cpLocationId, product.productId, product.productName, descriptionText, ) const lessonDesc = 'Lesson description ' + fakers.jobDescriptor() await membershipAPI.updateLessonDetails( { locationId: MembershipData.cpLocationId, categoryId: category.categoryId, productId: product.productId, visibility: 'published', description: lessonDesc, }, lesson.lessonIds[0], ) const categoryDesc = 'Category description ' + fakers.jobDescriptor() await membershipAPI.updateCategoryDetails( MembershipData.cpLocationId, category.categoryId, categoryDesc, ) userPage = await browser.newPage() pp = new previewPage(userPage) await pp.CPloginwithMagiclink(magicLink, product.productName) await pp.verifySearchBarElements('abc', MembershipData.placeholderText) await pp.verifySearchBarResults( product.productName, product.productName, descriptionText, ) await pp.verifySearchBarResults( category.categoryName, product.productName, categoryDesc, category.categoryName, ) await pp.verifySearchBarResults( lesson.lessonNames[0], product.productName, lessonDesc, '', lesson.lessonNames[0], ) await pp.verifySearchBarResults( descriptionText, product.productName, descriptionText, ) await pp.verifySearchBarResults( descriptionText.split(' ')[0], product.productName, descriptionText, ) }) test(`@Products @REVEX_MembershipThemes @REVEX_CP_ChildApps Verify Search Functionality for product, category, and lesson without description using classic theme`, async ({ browser, membershipAPI, }) => { let magicLink = await membershipAPI.getMagicLink( contactData.email, MembershipData.cpLocationId, MembershipData.clientPortalUrl, ) userPage = await browser.newPage() pp = new previewPage(userPage) await pp.CPloginwithMagiclink(magicLink, product.productName) await pp.verifySearchBarElements('abc', MembershipData.placeholderText) await pp.verifySearchBarResults(product.productName, product.productName) await pp.verifySearchBarResults( category.categoryName, product.productName, '', category.categoryName, ) await pp.verifySearchBarResults( lesson.lessonNames[0], product.productName, '', '', lesson.lessonNames[0], ) // Verify partial words and check results await pp.verifySearchBarResults( product.productName.split(' ')[0], product.productName, ) await pp.verifySearchBarResults( category.categoryName.split(' ')[0], product.productName, '', category.categoryName, ) await pp.verifySearchBarResults( lesson.lessonNames[0].split(' ')[0], product.productName, '', '', lesson.lessonNames[0], ) }) THEME New YORK test(`@Products @REVEX_MembershipThemes @REVEX_CP_ChildApps Verify Search Functionality for product, category, and lesson with description using new york theme`, async ({ browser, membershipAPI, }) => { let magicLink = await membershipAPI.getMagicLink( contactData.email, MembershipData.cpLocationId, MembershipData.clientPortalUrl, ) const descriptionText = 'Product description ' + fakers.jobDescriptor() await membershipAPI.updateProductsDetails( MembershipData.cpLocationId, product.productId, product.productName, descriptionText, ) const lessonDesc = 'Lesson description ' + fakers.jobDescriptor() await membershipAPI.updateLessonDetails( { locationId: MembershipData.cpLocationId, categoryId: category.categoryId, productId: product.productId, visibility: 'published', description: lessonDesc, }, lesson.lessonIds[0], ) const categoryDesc = 'Category description ' + fakers.jobDescriptor() await membershipAPI.updateCategoryDetails( MembershipData.cpLocationId, category.categoryId, categoryDesc, ) userPage = await browser.newPage() pp = new previewPage(userPage) await pp.CPloginwithMagiclink(magicLink, product.productName) await pp.verifySearchBarElements('abc', MembershipData.placeholderText) await pp.verifySearchBarResults( product.productName, product.productName, descriptionText, ) await pp.verifySearchBarResults( category.categoryName, product.productName, categoryDesc, category.categoryName, '', 'NewYork', ) await pp.verifySearchBarResults( lesson.lessonNames[0], product.productName, lessonDesc, '', lesson.lessonNames[0], 'NewYork', ) await pp.verifySearchBarResults( descriptionText, product.productName, descriptionText, ) await pp.verifySearchBarResults( descriptionText.split(' ')[0], product.productName, descriptionText, ) }) test(`@Products @REVEX_MembershipThemes @REVEX_CP_ChildApps Verify Search Functionality for product, category, and lesson without description using new york theme`, async ({ browser, membershipAPI, }) => { let magicLink = await membershipAPI.getMagicLink( contactData.email, MembershipData.cpLocationId, MembershipData.clientPortalUrl, ) userPage = await browser.newPage() pp = new previewPage(userPage) await pp.CPloginwithMagiclink(magicLink, product.productName) await pp.verifySearchBarElements('abc', MembershipData.placeholderText) await pp.verifySearchBarResults(product.productName, product.productName) await pp.verifySearchBarResults( category.categoryName, product.productName, '', category.categoryName, '', 'NewYork', ) await pp.verifySearchBarResults( lesson.lessonNames[0], product.productName, '', '', lesson.lessonNames[0], 'NewYork', ) // Verify partial words and check results await pp.verifySearchBarResults( product.productName.split(' ')[0], product.productName, ) await pp.verifySearchBarResults( category.categoryName.split(' ')[0], product.productName, '', category.categoryName, '', 'NewYork', ) await pp.verifySearchBarResults( lesson.lessonNames[0].split(' ')[0], product.productName, '', '', lesson.lessonNames[0], 'NewYork', ) }) Theme Neue test(`@Products @REVEX_MembershipThemes @REVEX_CP_ChildApps Verify Search Functionality for product, category, and lesson with description using neue theme`, async ({ browser, membershipAPI, }) => { let magicLink = await membershipAPI.getMagicLink( contactData.email, MembershipData.cpLocationId, MembershipData.clientPortalUrl, ) const descriptionText = 'Product description ' + fakers.jobDescriptor() await membershipAPI.updateProductsDetails( MembershipData.cpLocationId, product.productId, product.productName, descriptionText, ) const lessonDesc = 'Lesson description ' + fakers.jobDescriptor() await membershipAPI.updateLessonDetails( { locationId: MembershipData.cpLocationId, categoryId: category.categoryId, productId: product.productId, visibility: 'published', description: lessonDesc, }, lesson.lessonIds[0], ) const categoryDesc = 'Category description ' + fakers.jobDescriptor() await membershipAPI.updateCategoryDetails( MembershipData.cpLocationId, category.categoryId, categoryDesc, ) userPage = await browser.newPage() pp = new previewPage(userPage) await pp.CPloginwithMagiclink(magicLink, product.productName) await pp.verifySearchBarElements('abc', MembershipData.placeholderText) await pp.verifySearchBarResults( product.productName, product.productName, descriptionText, '', '', 'Neue', ) await pp.verifySearchBarResults( category.categoryName, product.productName, categoryDesc, category.categoryName, '', 'Neue', ) await pp.verifySearchBarResults( lesson.lessonNames[0], product.productName, lessonDesc, '', lesson.lessonNames[0], 'Neue', ) await pp.verifySearchBarResults( descriptionText, product.productName, descriptionText, '', '', 'Neue', ) await pp.verifySearchBarResults( descriptionText.split(' ')[0], product.productName, descriptionText, '', '', 'Neue', ) }) test(`@Products @REVEX_MembershipThemes @REVEX_CP_ChildApps Verify Search Functionality for product, category, and lesson without description using neue theme`, async ({ browser, membershipAPI, }) => { let magicLink = await membershipAPI.getMagicLink( contactData.email, MembershipData.cpLocationId, MembershipData.clientPortalUrl, ) userPage = await browser.newPage() pp = new previewPage(userPage) await pp.CPloginwithMagiclink(magicLink, product.productName) await pp.verifySearchBarElements('abc', MembershipData.placeholderText) await pp.verifySearchBarResults( product.productName, product.productName, '', '', '', 'Neue', ) await pp.verifySearchBarResults( category.categoryName, product.productName, '', category.categoryName, '', 'Neue', ) await pp.verifySearchBarResults( lesson.lessonNames[0], product.productName, '', '', lesson.lessonNames[0], 'Neue', ) // Verify partial words and check results await pp.verifySearchBarResults( product.productName.split(' ')[0], product.productName, '', '', '', 'Neue', ) await pp.verifySearchBarResults( category.categoryName.split(' ')[0], product.productName, '', category.categoryName, '', 'Neue', ) await pp.verifySearchBarResults( lesson.lessonNames[0].split(' ')[0], product.productName, '', '', lesson.lessonNames[0], 'Neue', ) }) THEME NEO CLASSIC test(`@Products @REVEX_MembershipThemes @REVEX_CP_ChildApps Verify Search Functionality for product, category, and lesson with description using neo classic theme`, async ({ browser, membershipAPI, }) => { // let magicLink = await membershipAPI.getMagicLink( // contactData.email, // currLocId, // data.location[1], // ) const descriptionText = 'Product description ' + fakers.jobDescriptor() await membershipAPI.updateProductsDetails( currLocId, product.productId, product.productName, descriptionText, ) const lessonDesc = 'Lesson description ' + fakers.jobDescriptor() await membershipAPI.updateLessonDetails( { locationId: currLocId, categoryId: category.categoryId, productId: product.productId, visibility: 'published', description: lessonDesc, }, lesson.lessonIds[0], ) const categoryDesc = 'Category description ' + fakers.jobDescriptor() await membershipAPI.updateCategoryDetails( currLocId, category.categoryId, categoryDesc, ) userPage = await browser.newPage() pp = new previewPage(userPage) // await pp.CPloginwithMagiclink(magicLink, product.productName) await pp.verifySearchBarElements('abc', MembershipData.placeholderText) await pp.verifySearchBarResults( product.productName, product.productName, descriptionText, '', '', 'NeoClassic', ) await pp.verifySearchBarResults( category.categoryName, product.productName, categoryDesc, category.categoryName, '', 'NeoClassic', ) await pp.verifySearchBarResults( lesson.lessonNames[0], product.productName, lessonDesc, '', lesson.lessonNames[0], 'NeoClassic', ) await pp.verifySearchBarResults( descriptionText, product.productName, descriptionText, '', '', 'NeoClassic', ) await pp.verifySearchBarResults( descriptionText.split(' ')[0], product.productName, descriptionText, '', '', 'NeoClassic', ) }) test(`@Products @REVEX_MembershipThemes @REVEX_CP_ChildApps Verify Search Functionality for product, category, and lesson without description using neo classic theme`, async ({ browser, membershipAPI, }) => { let magicLink = await membershipAPI.getMagicLink( contactData.email, currLocId, data.location[1], ) userPage = await browser.newPage() pp = new previewPage(userPage) await pp.CPloginwithMagiclink(magicLink, product.productName) await pp.verifySearchBarElements('abc', MembershipData.placeholderText) await pp.verifySearchBarResults( product.productName, product.productName, '', '', '', 'NeoClassic', ) await pp.verifySearchBarResults( category.categoryName, product.productName, '', category.categoryName, '', 'NeoClassic', ) await pp.verifySearchBarResults( lesson.lessonNames[0], product.productName, '', '', lesson.lessonNames[0], 'NeoClassic', ) // Verify partial words and check results await pp.verifySearchBarResults( product.productName.split(' ')[0], product.productName, '', '', '', 'NeoClassic', ) await pp.verifySearchBarResults( category.categoryName.split(' ')[0], product.productName, '', category.categoryName, '', 'NeoClassic', ) await pp.verifySearchBarResults( lesson.lessonNames[0].split(' ')[0], product.productName, '', '', lesson.lessonNames[0], 'NeoClassic', ) }) MEMBERSHIP DATA placeholderText : 'Search products, categories and lessons', PREVIEW PAGE FUNCTIONS async lowerCase(text: string): Promise<string> { return text.toLowerCase() } async verifySearchBarElements( seachedString: string, placeholderText: string, ) { await uiActions.isVisible(previewPageObjects.searchIcon, 20000) await uiActions.isVisible(previewPageObjects.searchInput) await uiActions.clearField(previewPageObjects.searchInput) const textInsideSearchbar = await uiActions.getText( previewPageObjects.searchPlaceholderText, ) expect( textInsideSearchbar, 'Place holder text should be present inside search bar', ).toEqual(placeholderText) await uiActions.click(previewPageObjects.searchInput) await uiActions.fillTextBox(previewPageObjects.searchInput, seachedString) await uiActions.isVisible(previewPageObjects.searchList) // Verify "No results" for search bar if (await uiActions.isPresent(previewPageObjects.noResult, 2000)) { const noResultText = await uiActions.getText(previewPageObjects.noResult) expect( noResultText, 'Verify no results text shown for unknown text', ).toContain( `No results for "${seachedString}". Please try another search`, ) } // Verify "Recent Searches" for search bar else if ( await uiActions.isPresent(previewPageObjects.recentSearchestext, 2000) ) { const recentSearchText = await uiActions.getText( previewPageObjects.recentSearchestext, ) expect(recentSearchText, 'Verify Recent Searches text showing').toContain( 'Recent Searches', ) } } async verifySearchBarProductDetails( searchedString: string, productName: string, description?: string, categoryName?: string, lessonName?: string, theme?: string, ): Promise<void> { await this.page.waitForTimeout(1000) // await uiActions.waitForElement(previewPageObjects.instructorCard, { // state: 'visible', // timeout: 5000, // }) let productTitleText if (theme == 'Neue') { if (lessonName) { // If landing on the lesson page productTitleText = await uiActions.getText( previewPageObjects.neueProductTitle, ) const validateLessonName = await uiActions.isVisible( previewPageObjects.LessonNamesList.replace(`REPLACE`, lessonName), 5000, ) expect( validateLessonName, `Match Lesson/Category Name "${lessonName}" on product page`, ).toBeTruthy() if (description) { let lessonDesc = await uiActions.getText( previewPageObjects.searchedLessonDescription, ) expect( lessonDesc, 'Verify the Lesson Description in the Product page', ).toContain(description) } } else if (!categoryName) { productTitleText = await uiActions.getText( previewPageObjects.neueProductTitle, ) } } else if (theme == 'NeoClassic') { if (lessonName) { // If landing on the lesson page productTitleText = await uiActions.getText( previewPageObjects.ProductNameBreadcrumbs.replace( `REPLACE`, productName, ), ) const validateLessonName = await uiActions.isVisible( previewPageObjects.ProductNameBreadcrumbs.replace( `REPLACE`, lessonName, ), 5000, ) expect( validateLessonName, `Match Lesson/Category Name "${lessonName}" on product page`, ).toBeTruthy() if (description) { let lessonDesc = await uiActions.getText( previewPageObjects.searchedLessonDescription, ) expect( lessonDesc, 'Verify the Lesson Description in the Product page', ).toContain(description) } } else if (!categoryName) { // If landing on the Project Title page productTitleText = await uiActions.getText( previewPageObjects.neoThemeProductName.replace( `REPLACE`, productName, ), ) if (description) { const descText = await uiActions.getText( previewPageObjects.neoThemeProductDescription, ) expect( descText, `Verify Product description on product page: "${description}"`, ).toContain(description) } } } else { // 'Default', 'Classic', 'NewYork' theme if (lessonName) { // If landing on the lesson page productTitleText = await uiActions.getText( previewPageObjects.productNameBreadcrumb, ) let validateLessonName if (theme == 'NewYork') { validateLessonName = await uiActions.isVisible( previewPageObjects.newYorkLessonName.replace(`REPLACE`, lessonName), 5000, ) } else { validateLessonName = await uiActions.isVisible( previewPageObjects.searchedProductLessonCat.replace( `REPLACE`, lessonName, ), 5000, ) } expect( validateLessonName, `Match Lesson/Category Name "${lessonName}" on product page`, ).toBeTruthy() if (description) { let lessonDesc = await uiActions.getText( previewPageObjects.searchedLessonDescription, ) expect( lessonDesc, 'Verify the Lesson Description in the Product page', ).toContain(description) } } else if (!categoryName) { // If landing on the Project Title page productTitleText = await uiActions.getText( previewPageObjects.productTitle, ) if (description) { const descText = await uiActions.getText( previewPageObjects.productDescriptionPage, ) expect( descText, `Verify Product description on product page: "${description}"`, ).toContain(description) } } } if (categoryName) { // If landing on the product category page productTitleText = await uiActions.getText( previewPageObjects.productNameBreadcrumb, ) const validateCategoryName = await uiActions.isVisible( previewPageObjects.searchedProductLessonCat.replace( `REPLACE`, categoryName, ), ) expect( validateCategoryName, `Match Lesson/Category Name "${categoryName}" on product page`, ).toBeTruthy() if (description) { let catDesc = await uiActions.getText( previewPageObjects.categoryDescription, ) expect( catDesc, 'Verify the Category Description in the Product page', ).toContain(description) } } expect( productTitleText, `Verify Product title "${productName}" on product page`, ).toContain(productName) } async verifySearchBarResults( searchedString: string, productName: string, description?: string, categoryName?: string, lessonName?: string, theme?: string, ): Promise<void> { await uiActions.clearField(previewPageObjects.searchInput) await uiActions.click(previewPageObjects.searchInput) await uiActions.fillTextBox(previewPageObjects.searchInput, searchedString) await uiActions.waitForElement( previewPageObjects.searchedCourseName.replace(`REPLACE`, productName), { state: 'visible', timeout: 5000, }, ) let validateProductName = await uiActions.isVisible( previewPageObjects.searchedCourseName.replace(`REPLACE`, productName), 1000, ) expect( validateProductName, 'Verify product name in search results', ).toBeTruthy() if (description) { const resultDescription = await uiActions.getText( previewPageObjects.searchResultDescription.replace( `REPLACE`, productName, ), 2000, ) expect( description, 'Verify the Course Description in the searched results', ).toContain(resultDescription) } if (lessonName || categoryName) { let validateLessonCate = await uiActions.isVisible( previewPageObjects.searchedTitle .replace(`REPLACE1`, productName) .replace(`REPLACE2`, lessonName || categoryName), ) expect( validateLessonCate, "Verify lesson's Product name in search results", ).toBeTruthy() await uiActions.click( previewPageObjects.searchedTitle .replace(`REPLACE1`, productName) .replace(`REPLACE2`, lessonName || categoryName), ) } else { await uiActions.click( previewPageObjects.searchedCourseName.replace(`REPLACE`, productName), ) } //Verify product details on the product page await this.verifySearchBarProductDetails( searchedString, productName, description, categoryName, lessonName, theme, ) } OBJECTS //Searchbar searchIcon: '//div[@id="search"]//div[@class="n-input__prefix"]', searchInput: '//div[@id="search"]//input[@class="n-input__input-el"]', searchPlaceholderText: '//div[@id="search"]//div[@class="n-input__placeholder"]/span', searchList: '//div[@id="searchList"]', searchedTitle: `//div[text()="REPLACE1"]//preceding-sibling::div[text()="REPLACE2"]`, searchResultDescription: `(//div[text()="REPLACE"]/ancestor::div/descendant::div[@class="px-0 h-auto mb-2 hl-text-sm-regular"])[1]`, searchedCourseName: `(//div[@id="optionList"]//div[text()="REPLACE"])[1]`, instructorCard: '//div[@id="instructor-card"]', productDescriptionPage: '//div[@id="product-description"]', neoThemeProductDescription: `//div[@id="banner-description"]`, searchedProductLessonCat: `//span//a[contains(text(),"REPLACE")]`, newYorkLessonName: `//div[text()="REPLACE"]`, searchedLessonDescription: '//div[@id="post-description"]', categoryDescription: '//div[@class="whitespace-pre-line"]', recentSearchestext: '//div[@class="text-left"]', noResult: '//div[@id="searchList"]/div[contains(text(),"No results")]', MEMBERSHIP API's async updateCategoryDetails( locationId: string, categoryId: string, desc: string, ) { let params = { description: desc } const response = await marketPlace.put( CommonUtils.constructUriPath( membershipsApiConfig.MembershipsProducts.commentPrivacy, [locationId, categoryId], ), params, ) console.log('update response' + JSON.stringify(response.body)) expect(response.code, { message: `Verification of product details updation`, }).toBe(200) } async updateLessonDetails( params: { locationId: string categoryId: string productId: string visibility: string description: string }, postId: string, ) { const response = await marketPlace.put( CommonUtils.constructUriPath( membershipsApiConfig.MembershipsProducts.updateLesson, [params.locationId, postId], ), params, ) console.log('update response' + JSON.stringify(response.body)) expect(response.code, { message: `Verification of product details updation`, }).toBe(200) } API config updateLesson: `/membership/locations/{locationId}/posts/{postId}`,
Leave a Comment