Skip to content

Commit

Permalink
Merge pull request #56 from elgentos/alpha-release-fixes
Browse files Browse the repository at this point in the history
Renamed selectors.json and verify.json, removed console.logs where test annotation is more appropriate
  • Loading branch information
dheesen authored Jan 29, 2025
2 parents e39558c + a3a68c8 commit 882a8c3
Show file tree
Hide file tree
Showing 21 changed files with 226 additions and 230 deletions.
22 changes: 11 additions & 11 deletions tests/base/account.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import {NewsletterSubscriptionPage} from './fixtures/newsletter.page';

import slugs from './config/slugs.json';
import inputvalues from './config/input-values/input-values.json';
import selectors from './config/selectors/selectors.json';
import verify from './config/expected/expected.json';
import UIReference from './config/element-identifiers/element-identifiers.json';
import outcomeMarker from './config/outcome-markers/outcome-markers.json';

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

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

// Log out of current account
if(await page.getByRole('link', { name: selectors.mainMenu.myAccountLogoutItem }).isVisible()){
if(await page.getByRole('link', { name: UIReference.mainMenu.myAccountLogoutItem }).isVisible()){
await mainMenu.logout();
}

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

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

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

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

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

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

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

let updateSubscription = await newsletterPage.updateNewsletterSubscription();

Expand Down
34 changes: 17 additions & 17 deletions tests/base/cart.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import {LoginPage} from './fixtures/login.page';
import { CartPage } from './fixtures/cart.page';

import slugs from './config/slugs.json';
import selectors from './config/selectors/selectors.json';
import verify from './config/expected/expected.json';
import UIReference from './config/element-identifiers/element-identifiers.json';
import outcomeMarker from './config/outcome-markers/outcome-markers.json';

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

await page.goto(slugs.productpage.simpleProductSlug);
await productPage.addSimpleProductToCart(selectors.productPage.simpleProductTitle, slugs.productpage.simpleProductSlug);
await productPage.addSimpleProductToCart(UIReference.productPage.simpleProductTitle, slugs.productpage.simpleProductSlug);
await mainMenu.openMiniCart();
await expect(page.getByText(verify.miniCart.simpleProductInCartTitle)).toBeVisible();
await expect(page.getByText(outcomeMarker.miniCart.simpleProductInCartTitle)).toBeVisible();
await page.goto(slugs.cartSlug);
});

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

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

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

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

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

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

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

});

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

// returns productPriceInCheckout and productQuantityInCheckout
checkoutProductDetails = await cart.getCheckoutValues(selectors.productPage.simpleProductTitle, productPagePrice, productPageAmount);
checkoutProductDetails = await cart.getCheckoutValues(UIReference.productPage.simpleProductTitle, productPagePrice, productPageAmount);
});

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

productPagePrice = await page.locator(selectors.productPage.simpleProductPrice).innerText();
productPageAmount = await page.getByLabel(selectors.productPage.quantityFieldLabel).inputValue();
productPagePrice = await page.locator(UIReference.productPage.simpleProductPrice).innerText();
productPageAmount = await page.getByLabel(UIReference.productPage.quantityFieldLabel).inputValue();
await productPage.addConfigurableProductToCart();

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

// returns productPriceInCheckout and productQuantityInCheckout
checkoutProductDetails = await cart.getCheckoutValues(selectors.productPage.configurableProductTitle, productPagePrice, productPageAmount);
checkoutProductDetails = await cart.getCheckoutValues(UIReference.productPage.configurableProductTitle, productPagePrice, productPageAmount);
});

await test.step('Step: Calculate and check expectations', async () =>{
Expand Down
13 changes: 6 additions & 7 deletions tests/base/checkout.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import {AccountPage} from './fixtures/account.page';
import { CheckoutPage } from './fixtures/checkout.page';

import slugs from './config/slugs.json';
import inputvalues from './config/input-values/input-values.json';
import selectors from './config/selectors/selectors.json';
import UIReference from './config/element-identifiers/element-identifiers.json';


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

await page.goto(slugs.productpage.simpleProductSlug);
await productPage.addSimpleProductToCart(selectors.productPage.simpleProductTitle, slugs.productpage.simpleProductSlug);
await productPage.addSimpleProductToCart(UIReference.productPage.simpleProductTitle, slugs.productpage.simpleProductSlug);
await page.goto(slugs.checkoutSlug);
});

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

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

// name field should NOT be on the page
await expect(page.getByLabel(selectors.personalInformation.firstNameLabel)).toBeHidden();
await expect(page.getByLabel(UIReference.personalInformation.firstNameLabel)).toBeHidden();

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

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

});
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion tests/base/contact.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {test, expect} from '@playwright/test';
import {test} from '@playwright/test';
import { ContactPage } from './fixtures/contact.page';

/**
Expand Down
Loading

0 comments on commit 882a8c3

Please sign in to comment.