Skip to content

Commit 882a8c3

Browse files
authored
Merge pull request #56 from elgentos/alpha-release-fixes
Renamed selectors.json and verify.json, removed console.logs where test annotation is more appropriate
2 parents e39558c + a3a68c8 commit 882a8c3

21 files changed

+226
-230
lines changed

tests/base/account.spec.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import {NewsletterSubscriptionPage} from './fixtures/newsletter.page';
77

88
import slugs from './config/slugs.json';
99
import inputvalues from './config/input-values/input-values.json';
10-
import selectors from './config/selectors/selectors.json';
11-
import verify from './config/expected/expected.json';
10+
import UIReference from './config/element-identifiers/element-identifiers.json';
11+
import outcomeMarker from './config/outcome-markers/outcome-markers.json';
1212

1313
// Before each test, log in
1414
test.beforeEach(async ({ page, browserName }) => {
@@ -43,7 +43,7 @@ test.describe('Account information actions', {annotation: {type: 'Account Dashbo
4343
* @then I should see a notification that my password has been updated
4444
* @and I should be able to login with my new credentials.
4545
*/
46-
test('I can change my password',{ tag: '@account-credentials', }, async ({page, browserName}) => {
46+
test('I can change my password',{ tag: '@account-credentials', }, async ({page, browserName}, testInfo) => {
4747

4848
// Create instances and set variables
4949
const mainMenu = new MainMenuPage(page);
@@ -58,7 +58,7 @@ test.describe('Account information actions', {annotation: {type: 'Account Dashbo
5858
let changedPasswordValue = process.env.MAGENTO_EXISTING_ACCOUNT_CHANGED_PASSWORD;
5959

6060
// Log out of current account
61-
if(await page.getByRole('link', { name: selectors.mainMenu.myAccountLogoutItem }).isVisible()){
61+
if(await page.getByRole('link', { name: UIReference.mainMenu.myAccountLogoutItem }).isVisible()){
6262
await mainMenu.logout();
6363
}
6464

@@ -108,7 +108,7 @@ test.describe.serial('Account address book actions', { annotation: {type: 'Accou
108108

109109
test('I can add my first address',{ tag: '@address-actions', }, async ({page}, testInfo) => {
110110
const accountPage = new AccountPage(page);
111-
let addNewAddressTitle = page.getByRole('heading', {level: 1, name: selectors.newAddress.addNewAddressTitle});
111+
let addNewAddressTitle = page.getByRole('heading', {level: 1, name: UIReference.newAddress.addNewAddressTitle});
112112

113113
if(await addNewAddressTitle.isHidden()) {
114114
await accountPage.deleteAllAddresses();
@@ -150,7 +150,7 @@ test.describe.serial('Account address book actions', { annotation: {type: 'Accou
150150
test('I can edit an existing address',{ tag: '@address-actions', }, async ({page}) => {
151151
const accountPage = new AccountPage(page);
152152
await page.goto(slugs.account.addressNewSlug);
153-
let editAddressButton = page.getByRole('link', {name: selectors.accountDashboard.editAddressIconButton}).first();
153+
let editAddressButton = page.getByRole('link', {name: UIReference.accountDashboard.editAddressIconButton}).first();
154154

155155
if(await editAddressButton.isHidden()){
156156
// The edit address button was not found, add another address first.
@@ -175,11 +175,11 @@ test.describe.serial('Account address book actions', { annotation: {type: 'Accou
175175
test('I can delete an address',{ tag: '@address-actions', }, async ({page}, testInfo) => {
176176
const accountPage = new AccountPage(page);
177177

178-
let deleteAddressButton = page.getByRole('link', {name: selectors.accountDashboard.addressDeleteIconButton}).first();
178+
let deleteAddressButton = page.getByRole('link', {name: UIReference.accountDashboard.addressDeleteIconButton}).first();
179179

180180
if(await deleteAddressButton.isHidden()) {
181181
await page.goto(slugs.account.addressNewSlug);
182-
await accountPage.addNewAddress(inputvalues.firstAddress.firstPhoneNumberValue, inputvalues.firstAddress.firstStreetAddressValue, inputvalues.firstAddress.firstZipCodeValue, inputvalues.firstAddress.firstCityValue, inputvalues.firstAddress.firstProvinceValue);
182+
await accountPage.addNewAddress();
183183
}
184184
await accountPage.deleteFirstAddressFromAddressBook();
185185
});
@@ -204,11 +204,11 @@ test.describe('Newsletter actions', { annotation: {type: 'Account Dashboard', de
204204
test('I can update my newsletter subscription',{ tag: '@newsletter-actions', }, async ({page, browserName}) => {
205205
test.skip(browserName === 'webkit', '.click() does not work, still searching for a workaround');
206206
const newsletterPage = new NewsletterSubscriptionPage(page);
207-
let newsletterLink = page.getByRole('link', { name: selectors.accountDashboard.links.newsletterLink });
208-
const newsletterCheckElement = page.getByLabel(selectors.newsletterSubscriptions.generalSubscriptionCheckLabel);
207+
let newsletterLink = page.getByRole('link', { name: UIReference.accountDashboard.links.newsletterLink });
208+
const newsletterCheckElement = page.getByLabel(UIReference.newsletterSubscriptions.generalSubscriptionCheckLabel);
209209

210210
await newsletterLink.click();
211-
await expect(page.getByText(verify.account.newsletterSubscriptionTitle, { exact: true })).toBeVisible();
211+
await expect(page.getByText(outcomeMarker.account.newsletterSubscriptionTitle, { exact: true })).toBeVisible();
212212

213213
let updateSubscription = await newsletterPage.updateNewsletterSubscription();
214214

tests/base/cart.spec.ts

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import {LoginPage} from './fixtures/login.page';
55
import { CartPage } from './fixtures/cart.page';
66

77
import slugs from './config/slugs.json';
8-
import selectors from './config/selectors/selectors.json';
9-
import verify from './config/expected/expected.json';
8+
import UIReference from './config/element-identifiers/element-identifiers.json';
9+
import outcomeMarker from './config/outcome-markers/outcome-markers.json';
1010

1111
test.describe('Cart functionalities (guest)', () => {
1212
/**
@@ -25,14 +25,14 @@ test.describe('Cart functionalities (guest)', () => {
2525
const productPage = new ProductPage(page);
2626

2727
await page.goto(slugs.productpage.simpleProductSlug);
28-
await productPage.addSimpleProductToCart(selectors.productPage.simpleProductTitle, slugs.productpage.simpleProductSlug);
28+
await productPage.addSimpleProductToCart(UIReference.productPage.simpleProductTitle, slugs.productpage.simpleProductSlug);
2929
await mainMenu.openMiniCart();
30-
await expect(page.getByText(verify.miniCart.simpleProductInCartTitle)).toBeVisible();
30+
await expect(page.getByText(outcomeMarker.miniCart.simpleProductInCartTitle)).toBeVisible();
3131
await page.goto(slugs.cartSlug);
3232
});
3333

3434
test('Product can be added to cart',{ tag: '@cart',}, async ({page}) => {
35-
await expect(page.getByRole('strong').getByRole('link', {name: selectors.productPage.simpleProductTitle}), `Product is visible in cart`).toBeVisible();
35+
await expect(page.getByRole('strong').getByRole('link', {name: UIReference.productPage.simpleProductTitle}), `Product is visible in cart`).toBeVisible();
3636
});
3737

3838
/**
@@ -46,7 +46,7 @@ test.describe('Cart functionalities (guest)', () => {
4646
await test.step('Add another product to cart', async () =>{
4747
const productpage = new ProductPage(page);
4848
await page.goto(slugs.productpage.secondSimpleProductSlug);
49-
await productpage.addSimpleProductToCart(selectors.productPage.secondSimpleProducTitle, slugs.productpage.secondSimpleProductSlug);
49+
await productpage.addSimpleProductToCart(UIReference.productPage.secondSimpleProducTitle, slugs.productpage.secondSimpleProductSlug);
5050
});
5151

5252
await test.step('Log in with account', async () =>{
@@ -63,8 +63,8 @@ test.describe('Cart functionalities (guest)', () => {
6363
});
6464

6565
await page.goto(slugs.cartSlug);
66-
await expect(page.getByRole('strong').getByRole('link', { name: selectors.productPage.simpleProductTitle }),`${selectors.productPage.simpleProductTitle} should still be in cart`).toBeVisible();
67-
await expect(page.getByRole('strong').getByRole('link', { name: selectors.productPage.secondSimpleProducTitle }),`${selectors.productPage.secondSimpleProducTitle} should still be in cart`).toBeVisible();
66+
await expect(page.getByRole('strong').getByRole('link', { name: UIReference.productPage.simpleProductTitle }),`${UIReference.productPage.simpleProductTitle} should still be in cart`).toBeVisible();
67+
await expect(page.getByRole('strong').getByRole('link', { name: UIReference.productPage.secondSimpleProducTitle }),`${UIReference.productPage.secondSimpleProducTitle} should still be in cart`).toBeVisible();
6868
});
6969

7070
/** @feature Remove product from cart
@@ -77,7 +77,7 @@ test.describe('Cart functionalities (guest)', () => {
7777
*/
7878
test('Remove product from cart',{ tag: '@cart',}, async ({page}) => {
7979
const cart = new CartPage(page);
80-
await cart.removeProduct(selectors.productPage.simpleProductTitle);
80+
await cart.removeProduct(UIReference.productPage.simpleProductTitle);
8181
});
8282

8383
/**
@@ -172,11 +172,11 @@ test.describe('Price checking tests', () => {
172172
const productPage = new ProductPage(page);
173173
await page.goto(slugs.productpage.simpleProductSlug);
174174
// set quantity to 2 so we can see that the math works
175-
await page.getByLabel(selectors.productPage.quantityFieldLabel).fill('2');
175+
await page.getByLabel(UIReference.productPage.quantityFieldLabel).fill('2');
176176

177-
productPagePrice = await page.locator(selectors.productPage.simpleProductPrice).innerText();
178-
productPageAmount = await page.getByLabel(selectors.productPage.quantityFieldLabel).inputValue();
179-
await productPage.addSimpleProductToCart(selectors.productPage.simpleProductTitle, slugs.productpage.simpleProductSlug, '2');
177+
productPagePrice = await page.locator(UIReference.productPage.simpleProductPrice).innerText();
178+
productPageAmount = await page.getByLabel(UIReference.productPage.quantityFieldLabel).inputValue();
179+
await productPage.addSimpleProductToCart(UIReference.productPage.simpleProductTitle, slugs.productpage.simpleProductSlug, '2');
180180

181181
});
182182

@@ -185,7 +185,7 @@ test.describe('Price checking tests', () => {
185185
await page.waitForLoadState();
186186

187187
// returns productPriceInCheckout and productQuantityInCheckout
188-
checkoutProductDetails = await cart.getCheckoutValues(selectors.productPage.simpleProductTitle, productPagePrice, productPageAmount);
188+
checkoutProductDetails = await cart.getCheckoutValues(UIReference.productPage.simpleProductTitle, productPagePrice, productPageAmount);
189189
});
190190

191191
await test.step('Step: Calculate and check expectations', async () =>{
@@ -216,8 +216,8 @@ test.describe('Price checking tests', () => {
216216
// set quantity to 2 so we can see that the math works
217217
await page.getByLabel('Quantity').fill('2');
218218

219-
productPagePrice = await page.locator(selectors.productPage.simpleProductPrice).innerText();
220-
productPageAmount = await page.getByLabel(selectors.productPage.quantityFieldLabel).inputValue();
219+
productPagePrice = await page.locator(UIReference.productPage.simpleProductPrice).innerText();
220+
productPageAmount = await page.getByLabel(UIReference.productPage.quantityFieldLabel).inputValue();
221221
await productPage.addConfigurableProductToCart();
222222

223223
});
@@ -227,7 +227,7 @@ test.describe('Price checking tests', () => {
227227
await page.waitForLoadState();
228228

229229
// returns productPriceInCheckout and productQuantityInCheckout
230-
checkoutProductDetails = await cart.getCheckoutValues(selectors.productPage.configurableProductTitle, productPagePrice, productPageAmount);
230+
checkoutProductDetails = await cart.getCheckoutValues(UIReference.productPage.configurableProductTitle, productPagePrice, productPageAmount);
231231
});
232232

233233
await test.step('Step: Calculate and check expectations', async () =>{

tests/base/checkout.spec.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ import {AccountPage} from './fixtures/account.page';
55
import { CheckoutPage } from './fixtures/checkout.page';
66

77
import slugs from './config/slugs.json';
8-
import inputvalues from './config/input-values/input-values.json';
9-
import selectors from './config/selectors/selectors.json';
8+
import UIReference from './config/element-identifiers/element-identifiers.json';
109

1110

1211
/**
@@ -24,7 +23,7 @@ test.beforeEach(async ({ page }) => {
2423
const productPage = new ProductPage(page);
2524

2625
await page.goto(slugs.productpage.simpleProductSlug);
27-
await productPage.addSimpleProductToCart(selectors.productPage.simpleProductTitle, slugs.productpage.simpleProductSlug);
26+
await productPage.addSimpleProductToCart(UIReference.productPage.simpleProductTitle, slugs.productpage.simpleProductSlug);
2827
await page.goto(slugs.checkoutSlug);
2928
});
3029

@@ -54,16 +53,16 @@ test.describe('Checkout (login required)', () => {
5453
* @then My name and address should already be filled in
5554
*/
5655
test('My address should be already filled in at the checkout',{ tag: '@checkout',}, async ({page}) => {
57-
let signInLink = page.getByRole('link', { name: selectors.credentials.loginButtonLabel });
58-
let addressField = page.getByLabel(selectors.newAddress.streetAddressLabel);
56+
let signInLink = page.getByRole('link', { name: UIReference.credentials.loginButtonLabel });
57+
let addressField = page.getByLabel(UIReference.newAddress.streetAddressLabel);
5958
let addressAlreadyAdded = false;
6059

6160
if(await signInLink.isVisible()) {
6261
throw new Error(`Sign in link found, user is not logged in. Please check the test setup.`);
6362
}
6463

6564
// name field should NOT be on the page
66-
await expect(page.getByLabel(selectors.personalInformation.firstNameLabel)).toBeHidden();
65+
await expect(page.getByLabel(UIReference.personalInformation.firstNameLabel)).toBeHidden();
6766

6867
if(await addressField.isVisible()) {
6968
if(!addressAlreadyAdded){
@@ -76,7 +75,7 @@ test.describe('Checkout (login required)', () => {
7675
}
7776

7877
// expect to see radio button to select existing address
79-
let shippingRadioButton = page.locator(selectors.checkout.shippingAddressRadioLocator).first();
78+
let shippingRadioButton = page.locator(UIReference.checkout.shippingAddressRadioLocator).first();
8079
await expect(shippingRadioButton, 'Radio button to select address should be visible').toBeVisible();
8180

8281
});
File renamed without changes.
File renamed without changes.

tests/base/contact.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {test, expect} from '@playwright/test';
1+
import {test} from '@playwright/test';
22
import { ContactPage } from './fixtures/contact.page';
33

44
/**

0 commit comments

Comments
 (0)