From 266449c7878306da9347e61303772ad55d0c037e Mon Sep 17 00:00:00 2001 From: shashwata Date: Fri, 19 Apr 2024 16:20:23 +0600 Subject: [PATCH] update: refactor some tests --- tests/pw/pages/loginPage.ts | 3 ++- tests/pw/pages/productAddonsPage.ts | 4 ++-- tests/pw/pages/selectors.ts | 6 +++--- tests/pw/pages/vendorBookingPage.ts | 2 +- tests/pw/utils/testData.ts | 2 +- 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/tests/pw/pages/loginPage.ts b/tests/pw/pages/loginPage.ts index e45185c6c2..cab20056c8 100644 --- a/tests/pw/pages/loginPage.ts +++ b/tests/pw/pages/loginPage.ts @@ -79,7 +79,8 @@ export class LoginPage extends BasePage { async logoutBackend(): Promise { await this.goIfNotThere(data.subUrls.backend.adminLogin); await this.hover(selector.backend.userMenu); - await this.clickAndWaitForResponseAndLoadState(data.subUrls.backend.adminLogout, selector.backend.logout, 302); + await this.clickAndWaitForResponseAndLoadState(data.subUrls.backend.adminLogout, selector.backend.logout); + await this.toContainText(selector.backend.logoutSuccessMessage, 'You are now logged out.') const loggedInUser = await this.getCurrentUser(); expect(loggedInUser).toBeUndefined(); } diff --git a/tests/pw/pages/productAddonsPage.ts b/tests/pw/pages/productAddonsPage.ts index d993c3f15e..16a58a07ca 100644 --- a/tests/pw/pages/productAddonsPage.ts +++ b/tests/pw/pages/productAddonsPage.ts @@ -32,7 +32,7 @@ export class ProductAddonsPage extends VendorPage { await this.multipleElementVisible(addonsVendor.table); await this.clickAndWaitForLoadState(addonsVendor.createNewAddon); - await this.click(addonsVendor.addon.addField); + await this.clickAndWaitForResponse(data.subUrls.ajax, addonsVendor.addon.addField); await this.check(addonsVendor.addon.enableDescription); // product addon fields elements are visible @@ -53,7 +53,7 @@ export class ProductAddonsPage extends VendorPage { await this.toContainText(addonsVendor.addon.result, addon.category); await this.press(data.key.enter); - add ? await this.click(addonsVendor.addon.addField) : await this.click(addonsVendor.addon.addonFieldsRow('Add-on Title')); + add ? await this.clickAndWaitForResponse(data.subUrls.ajax, addonsVendor.addon.addField) : await this.click(addonsVendor.addon.addonFieldsRow('Add-on Title')); await this.selectByValue(addonsVendor.addon.type, addon.type); await this.selectByValue(addonsVendor.addon.displayAs, addon.displayAs); diff --git a/tests/pw/pages/selectors.ts b/tests/pw/pages/selectors.ts index 0fd04dcdfe..5ef9c66322 100644 --- a/tests/pw/pages/selectors.ts +++ b/tests/pw/pages/selectors.ts @@ -74,11 +74,11 @@ export const selector = { dashboardText: '.wrap h1', // Admin Logout - userMenu: '#wp-admin-bar-my-account', - logout: '#wp-admin-bar-logout a', + userMenu: 'li#wp-admin-bar-my-account', + logout: 'li#wp-admin-bar-logout', // Logout Message - logoutSuccessMessage: '#login p', + logoutSuccessMessage: 'div#login-message p', // Login Error loginError: '#login_error', diff --git a/tests/pw/pages/vendorBookingPage.ts b/tests/pw/pages/vendorBookingPage.ts index 9b0ecb6229..24d3cefbf7 100644 --- a/tests/pw/pages/vendorBookingPage.ts +++ b/tests/pw/pages/vendorBookingPage.ts @@ -185,7 +185,7 @@ export class BookingPage extends VendorPage { await this.clickAndWaitForLoadState(bookingProductsVendor.view(productName)); // booking product elements are visible - const { bookingCalendar, bookNow, getSupport, ...viewBooking } = bookingProductsVendor.viewBooking; + const { bookingCalendar, bookNow, getSupport, price, ...viewBooking } = bookingProductsVendor.viewBooking; await this.multipleElementVisible(viewBooking); // todo: actual value can be asserted } diff --git a/tests/pw/utils/testData.ts b/tests/pw/utils/testData.ts index b8743282d5..15dc0a70c7 100644 --- a/tests/pw/utils/testData.ts +++ b/tests/pw/utils/testData.ts @@ -782,7 +782,7 @@ export const data = { backend: { login: 'wp-login.php', adminLogin: 'wp-admin', - adminLogout: 'wp-login.php?action=logout', + adminLogout: 'wp-login.php?loggedout=true', adminDashboard: 'wp-admin', user: 'wp-admin/user-edit.php', setupWP: 'wp-admin/install.php',