Skip to content

Commit eb8b29e

Browse files
author
Shay
committed
Merge branch '108-finish-mainmenu-page-ts-functions' into 'main'
Resolve "Finish mainmenu.page.ts functions" See merge request elgentos/magento2-playwright!42
2 parents b2cacaf + 94d7f02 commit eb8b29e

File tree

7 files changed

+355
-53
lines changed

7 files changed

+355
-53
lines changed

tests/account.spec.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ test.describe('Account information actions', {annotation: {type: 'Account Dashbo
103103
let randomNumberforEmail = Math.floor(Math.random() * 101);
104104
let originalEmail = `emailupdate-${randomNumberforEmail}-${browserEngine}@example.com`;
105105
let updatedEmail = `updated-${randomNumberforEmail}-${browserEngine}@example.com`;
106-
// let passwordInputValue = process.env.MAGENTO_EXISTING_ACCOUNT_PASSWORD;
107106
let passwordInputValue = requireEnv('MAGENTO_EXISTING_ACCOUNT_PASSWORD');
108107

109108
if(await page.getByRole('link', { name: UIReference.mainMenu.myAccountLogoutItem }).isVisible()) {

tests/config/element-identifiers.json

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,9 +201,17 @@
201201
"usernameFieldLabel": "Username"
202202
},
203203
"mainMenu": {
204+
"addressBookButtonLabel" : "Address Book",
205+
"createAccountButtonLabel" : "Create an Account",
206+
"fitnessEquipmentLinkLabel" : "Fitness Equipment",
207+
"gearCategoryItemText" : "Gear",
208+
"loginButtonLabel" : "Sign In",
204209
"miniCartLabel": "Toggle minicart",
205210
"myAccountButtonLabel": "My Account",
206-
"myAccountLogoutItem": "Sign Out"
211+
"myAccountLogoutItem": "Sign Out",
212+
"myOrdersButtonLabel" : "My Orders",
213+
"searchButtonLabel" : "Toggle search form",
214+
"wishListButtonLabel" : "My Wish List"
207215
},
208216
"miniCart": {
209217
"checkOutButtonLabel": "Checkout",
@@ -220,9 +228,15 @@
220228
"toCartLinkLabel": "View and Edit Cart"
221229
},
222230
"search": {
231+
"searchBoxPlaceholderText" : "Search entire store here...",
223232
"searchToggleLocator": "#menu-search-icon",
224233
"searchInputLocator": "#search",
225-
"suggestionBoxLocator": "#search_autocomplete"
234+
"suggestionBoxLocator": "#search_autocomplete",
235+
"searchResultsTitle": "Search results for:",
236+
"searchTermDropdownText" : "Search terms"
237+
},
238+
"orderHistoryPage" : {
239+
"orderHistoryTitle": "My Orders"
226240
},
227241
"personalInformation": {
228242
"changePasswordCheckLabel": "Change Password",
@@ -232,6 +246,7 @@
232246
},
233247
"wishListPage": {
234248
"wishListItemGridLabel": "#wishlist-view-form",
249+
"wishListTitle" : "My Wish List",
235250
"updateCompareListButtonLabel": "Update Wish List"
236251
}
237252
}

tests/config/outcome-markers.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"accountPageTitle": "Account Information",
55
"addressBookTitle": "Customer Address",
66
"changedPasswordNotificationText": "You saved the account",
7+
"createAccountHeaderText" : "Create New Customer Account",
78
"newsletterRemovedNotification": "We have removed your newsletter subscription.",
89
"newsletterSavedNotification": "We have saved your subscription.",
910
"newsletterSubscriptionTitle": "Newsletter Subscription",
@@ -20,6 +21,9 @@
2021
"incorrectCouponCodeNotificationTwo": "is not valid.",
2122
"priceReducedSymbols": "- $"
2223
},
24+
"categoryPage" : {
25+
"fitnessEquipmentTitle" : "Fitness Equipment"
26+
},
2327
"checkout": {
2428
"checkoutPriceReducedSymbol": "-$",
2529
"couponAppliedNotification": "Your coupon was successfully applied",
@@ -66,6 +70,7 @@
6670
"simpleProductAddedNotification": "You added"
6771
},
6872
"login": {
73+
"loginHeaderText" : "Login",
6974
"invalidCredentialsMessage": "The account sign-in was incorrect or your account is disabled temporarily. Please wait and try again later."
7075
},
7176
"search": {

tests/config/slugs.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"addressNewSlug": "customer/address/new",
77
"accountEditSlug": "/customer/account/edit/",
88
"changePasswordSlug": "/customer/account/edit/changepass/1/",
9-
"createAccountSlug": "/customer/account/create",
9+
"createAccountSlug": "/customer/account/create/",
1010
"loginSlug": "/customer/account/login/",
1111
"orderHistorySlug": "/sales/order/history/"
1212
},
@@ -15,7 +15,8 @@
1515
"cartSlug": "/checkout/cart/"
1616
},
1717
"categoryPage": {
18-
"categorySlug": "/women.html"
18+
"categorySlug": "/women.html",
19+
"fitnessEquipmentSlug" : "/gear/fitness-equipment.html"
1920
},
2021
"checkout": {
2122
"checkoutSlug": "/checkout/",
@@ -33,7 +34,8 @@
3334
"search": {
3435
"resultsSlug": "/catalogsearch/result/"
3536
},
36-
"wishlist": {
37+
"wishList": {
38+
"wishListSlug": "wishlist/",
3739
"wishListRegex": ".*wishlist.*"
3840
}
3941
}

tests/mainmenu.spec.ts

Lines changed: 168 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// @ts-check
22

33
import { test } from '@playwright/test';
4-
import { UIReference, slugs } from '@config';
4+
import {UIReference, slugs, inputValues} from '@config';
55

66
import LoginPage from '@poms/frontend/login.page';
77
import MainMenuPage from '@poms/frontend/mainmenu.page';
@@ -10,42 +10,179 @@ import { requireEnv } from '@utils/env.utils';
1010

1111
// no resetting storageState, mainmenu has more functionalities when logged in.
1212

13-
// Before each test, log in
14-
test.beforeEach(async ({ page, browserName }) => {
15-
const browserEngine = browserName?.toUpperCase() || "UNKNOWN";
16-
const emailInputValue = requireEnv(`MAGENTO_EXISTING_ACCOUNT_EMAIL_${browserEngine}`);
17-
const passwordInputValue = requireEnv('MAGENTO_EXISTING_ACCOUNT_PASSWORD');
13+
test.describe('Guest tests (not logged in)', () => {
14+
/**
15+
* @feature Navigate to login page
16+
* @scenario user clicks 'log in' button in main menu
17+
* @given I am not logged in
18+
* @and I am on any Magento 2 page
19+
* @when I click on the user icon in the main menu
20+
* @and I click the 'sign in' button
21+
* @then I should navigate to the login page
22+
*/
23+
test('User_navigates_to_login', { tag: ['@mainmenu', '@cold'] }, async ({page}) => {
24+
const mainMenu = new MainMenuPage(page);
25+
await mainMenu.goToLoginPage();
26+
});
1827

19-
const loginPage = new LoginPage(page);
20-
await loginPage.login(emailInputValue, passwordInputValue);
21-
});
28+
/**
29+
* @feature Navigate to create account page
30+
* @scenario user clicks 'create an account' button in main menu
31+
* @given I am not logged in
32+
* @and I am on any Magento 2 page
33+
* @when I click on the user icon in the main menu
34+
* @and I click the 'create an account' button
35+
* @then I should navigate to the create account page
36+
*/
37+
test('User_navigates_to_create_account', { tag: ['@mainmenu', '@cold'] }, async ({page}) => {
38+
const mainMenu = new MainMenuPage(page);
39+
await mainMenu.goToCreateAccountPage();
40+
});
2241

23-
/**
24-
* @feature Logout
25-
* @scenario The user can log out
26-
* @given I am logged in
27-
* @and I am on any Magento 2 page
28-
* @when I open the account menu
29-
* @and I click the Logout option
30-
* @then I should see a message confirming I am logged out
31-
*/
32-
test('User_logs_out', { tag: ['@mainmenu', '@hot'] }, async ({page}) => {
33-
const mainMenu = new MainMenuPage(page);
34-
await mainMenu.logout();
35-
});
42+
/**
43+
* @feature Navigate to subcategory page
44+
* @scenario User hover over menu link to navigate to category page
45+
* @given I am not logged in
46+
* @and I am on any Magento 2 page
47+
* @when I hover over an item in the main menu
48+
* @then A dropdown menu should appear
49+
* @when I click an item
50+
* @then I should navigate to the page
51+
*/
52+
test('Navigate_to_category_page', { tag: ['@mainmenu', '@cold'] }, async ({page}) => {
53+
const mainMenu = new MainMenuPage(page);
54+
await mainMenu.goToCategoryPage();
55+
});
56+
57+
/**
58+
* @feature Navigate to category page
59+
* @scenario User hover over menu link to navigate to category page
60+
* @given I am not logged in
61+
* @and I am on any Magento 2 page
62+
* @when I hover over an item in the main menu
63+
* @then A dropdown menu should appear
64+
* @when I click an item
65+
* @then I should navigate to the page
66+
*/
67+
test('Navigate_to_subcategory_page', { tag: ['@mainmenu', '@cold'] }, async ({page}) => {
68+
const mainMenu = new MainMenuPage(page);
69+
await mainMenu.goToSubCategoryPage();
70+
});
3671

72+
/**
73+
* @feature open the minicart
74+
* @scenario guest opens the minicart
75+
* @given I am on any page
76+
* @when I click the minicart button
77+
* @then the minicart should show up
78+
*/
79+
test('Open_the_minicart', { tag: ['@mainmenu', '@cold'] }, async ({page}) => {
80+
const mainMenu = new MainMenuPage(page);
81+
await mainMenu.openMiniCart();
82+
});
3783

38-
test('Navigate_to_account_page', { tag: ['@mainmenu', '@hot'] }, async ({page}) => {
39-
const mainMenu = new MainMenuPage(page);
40-
await mainMenu.gotoMyAccount();
84+
/**
85+
* @feature Search Field
86+
* @scenario guest uses the search field
87+
* @given I am on any page
88+
* @when I click the search button
89+
* @then a search field should show up
90+
* @when I type in a search term
91+
* @and I click search
92+
* @then I should be navigated to a results page
93+
* @and I should see my search term in the title of the page
94+
*/
95+
test('User_searches_for_product', { tag: ['@mainmenu', '@cold'] }, async ({page}) => {
96+
const mainMenu = new MainMenuPage(page);
97+
await mainMenu.searchForProduct(inputValues.search.queryMultipleResults);
98+
});
4199
});
42100

43-
test('Open_the_minicart', { tag: ['@mainmenu', '@cold'] }, async ({page}, testInfo) => {
44-
testInfo.annotations.push({ type: 'WARNING (FIREFOX)', description: `The minicart icon does not lose its aria-disabled=true flag when the first product is added. This prevents Playwright from clicking it. A fix will be added in the future.`});
101+
test.describe('User tests (logged in)', () => {
102+
// Before each test, log in
103+
test.beforeEach(async ({ page, browserName }) => {
104+
const browserEngine = browserName?.toUpperCase() || "UNKNOWN";
105+
const emailInputValue = requireEnv(`MAGENTO_EXISTING_ACCOUNT_EMAIL_${browserEngine}`);
106+
const passwordInputValue = requireEnv('MAGENTO_EXISTING_ACCOUNT_PASSWORD');
107+
108+
const loginPage = new LoginPage(page);
109+
await loginPage.login(emailInputValue, passwordInputValue);
110+
});
111+
112+
/**
113+
* @feature Logout
114+
* @scenario The user can log out
115+
* @given I am logged in
116+
* @and I am on any Magento 2 page
117+
* @when I open the account menu
118+
* @and I click the Logout option
119+
* @then I should see a message confirming I am logged out
120+
*/
121+
test('User_logs_out', { tag: ['@mainmenu', '@hot'] }, async ({page}) => {
122+
const mainMenu = new MainMenuPage(page);
123+
await mainMenu.logout();
124+
});
125+
126+
/**
127+
* @feature Navigate to account page
128+
* @scenario user navigates to account page
129+
* @given I am logged in
130+
* @and I am on any magento 2 page
131+
* @when I open the account menu
132+
* @and I click the account button
133+
* @and I click the 'my account' button
134+
* @then I should be navigated to my account
135+
*/
136+
test('Navigate_to_account_page', { tag: ['@mainmenu', '@hot'] }, async ({page}) => {
137+
const mainMenu = new MainMenuPage(page);
138+
await mainMenu.gotoMyAccount();
139+
});
45140

46-
const mainMenu = new MainMenuPage(page);
47-
const productPage = new ProductPage(page);
141+
/**
142+
* @feature Navigate to wishlist
143+
* @scenario user navigates to their wishlist
144+
* @given I am logged in
145+
* @and I am on any magento 2 page
146+
* @when I open the account menu
147+
* @and I click on the wishlist button
148+
* @then I should be navigated to the wishlist page
149+
*/
150+
test('Navigate_to_wishlist', { tag: ['@mainmenu', '@hot'] }, async ({page}) => {
151+
const mainMenu = new MainMenuPage(page);
152+
await mainMenu.goToWishList();
153+
});
48154

49-
await productPage.addSimpleProductToCart(UIReference.productPage.simpleProductTitle, slugs.productPage.simpleProductSlug);
50-
await mainMenu.openMiniCart();
155+
/**
156+
* @feature Navigate to orders overview
157+
* @scenario user navigates to their order history
158+
* @given I am logged in
159+
* @and I am on any magento 2 page
160+
* @when I open the account menu
161+
* @and I click on the 'My orders' button
162+
* @then I should be navigated to the page with my order history
163+
*/
164+
test('Navigate_to_orders', { tag: ['@mainmenu', '@hot'] }, async ({page}) => {
165+
const mainMenu = new MainMenuPage(page);
166+
await mainMenu.goToOrders();
167+
});
168+
169+
/**
170+
* @feature Navigate to address book
171+
* @scenario user navigates to their address book
172+
* @given I am logged in
173+
* @and I am on any Magento 2 page
174+
* @when I open the account menu
175+
* @and I click on the 'Address book' button
176+
* @then I should be navigated to the page with my order history
177+
* @and I should see an appropriate title based on whether an address has been added
178+
*/
179+
test('Navigate_to_address_book', { tag: ['@mainmenu', '@hot'] }, async ({page}) => {
180+
const mainMenu = new MainMenuPage(page);
181+
await mainMenu.goToAddressBook();
182+
});
51183
});
184+
185+
186+
187+
188+

0 commit comments

Comments
 (0)