Skip to content

Commit

Permalink
Merge pull request #48 from elgentos/todo-comments
Browse files Browse the repository at this point in the history
Removed TODO comments (tickets created)
  • Loading branch information
dheesen authored Jan 22, 2025
2 parents 3aa2374 + cfbaa80 commit 58fb7e8
Show file tree
Hide file tree
Showing 17 changed files with 21 additions and 115 deletions.
1 change: 0 additions & 1 deletion bypass-captcha.config.example.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* It will set the global cookie to bypass CAPTCHA for Magento 2.
* See: https://github.com/elgentos/magento2-bypass-captcha-cookie
*
* //TODO The extension is WIP. Currently being developed.
*/
import { FullConfig } from '@playwright/test';
import * as playwright from 'playwright';
Expand Down
2 changes: 0 additions & 2 deletions playwright.config.example.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,10 @@ export default defineConfig({

/* Configure projects for major browsers */
projects: [
// TODO: uncomment the setup line once authentication works!
// Import our auth.setup.ts file
//{ name: 'setup', testMatch: /.*\.setup\.ts/ },

{
// TODO: uncomment dependency and storage state once authentication works!
name: 'chromium',
testMatch: testFiles,
use: {
Expand Down
10 changes: 0 additions & 10 deletions tests/base/account.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ import inputvalues from './config/input-values/input-values.json';
import selectors from './config/selectors/selectors.json';
import verify from './config/expected/expected.json';

// no resetting storageState, mainmenu has more functionalities when logged in.
// TODO: remove this beforeEach() once authentication as project set-up/fixture works.

// Before each test, log in
test.beforeEach(async ({ page, browserName }) => {
const browserEngine = browserName?.toUpperCase() || "UNKNOWN";
Expand All @@ -34,8 +31,6 @@ test.describe('Account information actions', {annotation: {type: 'Account Dashbo
await page.waitForLoadState();
});

// TODO: add test to update e-mail address

/**
* @feature Magento 2 Change Password
* @scenario User changes their password
Expand Down Expand Up @@ -93,8 +88,6 @@ test.describe('Account information actions', {annotation: {type: 'Account Dashbo
});


// TODO: Add tests to check address can't be added/updated if the supplied information is incorrect
// TODO: Add tests to check address can't be deleted if it's the last/only one.
test.describe('Account address book actions', { annotation: {type: 'Account Dashboard', description: 'Tests for the Address Book'},}, () => {
test.beforeEach(async ({page}) => {
// go to the Adress Book page
Expand Down Expand Up @@ -206,15 +199,12 @@ test.describe('Account address book actions', { annotation: {type: 'Account Dash
});
});

// TODO: move this to new spec file.
test.describe('Newsletter actions', { annotation: {type: 'Account Dashboard', description: 'Newsletter tests'},}, () => {
test.beforeEach(async ({page}) => {
// go to the Dashboard page
await page.goto(slugs.account.accountOverviewSlug);
});

// TODO: What if website offers multiple subscriptions?

/**
* @feature Magento 2 newsletter subscriptions
* @scenario User (un)subscribes from a newsletter
Expand Down
2 changes: 0 additions & 2 deletions tests/base/cart.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ test.describe('Cart functionalities (guest)', () => {
const mainMenu = new MainMenuPage(page);
const productPage = new ProductPage(page);

//TODO: Use a storagestate or API call to add product to the cart so shorten test time
await page.goto(slugs.productpage.simpleProductSlug);
await productPage.addSimpleProductToCart(selectors.productPage.simpleProductTitle, slugs.productpage.simpleProductSlug);
await mainMenu.openMiniCart();
Expand Down Expand Up @@ -127,7 +126,6 @@ test.describe('Cart functionalities (guest)', () => {
throw new Error(`MAGENTO_COUPON_CODE_${browserEngine} appears to not be set in .env file. Value reported: ${discountCode}`);
}

// TODO: create API call to quickly add discount code rather than run a test again.
await cart.applyDiscountCode(discountCode);
await cart.removeDiscountCode();
});
Expand Down
24 changes: 12 additions & 12 deletions tests/base/checkout.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import inputvalues from './config/input-values/input-values.json';
import selectors from './config/selectors/selectors.json';


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

/**
* @feature BeforeEach runs before each test in this group.
* @scenario Add product to the cart, confirm it's there, then move to checkout.
Expand All @@ -25,7 +23,6 @@ import selectors from './config/selectors/selectors.json';
test.beforeEach(async ({ page }) => {
const productPage = new ProductPage(page);

//TODO: Use a storagestate or API call to add product to the cart so shorten test time
await page.goto(slugs.productpage.simpleProductSlug);
await productPage.addSimpleProductToCart(selectors.productPage.simpleProductTitle, slugs.productpage.simpleProductSlug);
await page.goto(slugs.checkoutSlug);
Expand All @@ -34,7 +31,6 @@ test.beforeEach(async ({ page }) => {

test.describe('Checkout (login required)', () => {
// Before each test, log in
// TODO: remove this beforeEach() once authentication as project set-up/fixture works.
test.beforeEach(async ({ page, browserName }) => {
const browserEngine = browserName?.toUpperCase() || "UNKNOWN";
let emailInputValue = process.env[`MAGENTO_EXISTING_ACCOUNT_EMAIL_${browserEngine}`];
Expand Down Expand Up @@ -86,20 +82,26 @@ test.describe('Checkout (login required)', () => {
}
});

//TODO: Add Gherkin feature description

/**
* @feature Place order for simple product
* @scenario User places an order for a simple product
* @given I have a product in my cart
* @and I am on any page
* @when I navigate to the checkout
* @and I fill in the required fields
* @and I click the button to place my order
* @then I should see a confirmation that my order has been placed
* @and a order number should be created and show to me
*/
test('Place order for simple product',{ tag: '@simple-product-order',}, async ({page}) => {
const checkoutPage = new CheckoutPage(page);
await checkoutPage.placeOrder();
});



});

test.describe('Checkout (guest)', () => {
// TODO: Write test to confirm order can be placed without an account
// TODO: Write test for logged-in user who hasn't added an address yet.

/**
* @feature Discount Code
* @scenario User adds a discount code to their cart
Expand All @@ -113,7 +115,6 @@ test.describe('Checkout (guest)', () => {
* @and a discount should be applied to the product
*/
test('Add coupon code in checkout',{ tag: ['@checkout', '@coupon-code']}, async ({page, browserName}) => {
//TODO: Write tests to ensure code also works if user is NOT logged in.
const checkout = new CheckoutPage(page);
const browserEngine = browserName?.toUpperCase() || "UNKNOWN";
let discountCode = process.env[`MAGENTO_COUPON_CODE_${browserEngine}`];
Expand Down Expand Up @@ -148,7 +149,6 @@ test.describe('Checkout (guest)', () => {
throw new Error(`MAGENTO_COUPON_CODE appears to not be set in .env file. Value reported: ${discountCode}`);
}

// TODO: create API call to quickly add discount code rather than run a test again.
await checkout.applyDiscountCodeCheckout(discountCode);
await checkout.removeDiscountCode();
});
Expand Down
5 changes: 4 additions & 1 deletion tests/base/config/selectors/selectors.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@
"nameFieldLabel": "Name",
"emailFieldLabel": "Email",
"passwordFieldLabel": "Password",
"newPasswordFieldLabel": "New Password",
"passwordConfirmFieldLabel": "Confirm Password",
"loginButtonLabel": "Sign In"
"newPasswordConfirmFieldLabel": "Confirm New Password",
"loginButtonLabel": "Sign In",
"currentPasswordFieldLabel": "Current Password"
},
"personalInformation": {
"firstNameLabel": "First Name",
Expand Down
28 changes: 4 additions & 24 deletions tests/base/fixtures/account.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,6 @@ export class AccountPage {
readonly accountCreationPasswordRepeatField: Locator;
readonly accountCreationConfirmButton: Locator;

// fields below are not required when adding an address.
/*
readonly companyField: Locator;
readonly streetAddressFieldTwo: Locator;
readonly streetAddressFieldThree: Locator;
*/

// TODO: Update these functionalities to be able to take in non-required fields.

constructor(page: Page){
this.page = page;
Expand All @@ -49,20 +41,15 @@ export class AccountPage {
this.streetAddressField = page.getByLabel(selectors.newAddress.streetAddressLabel, {exact:true});
this.zipCodeField = page.getByLabel(selectors.newAddress.zipCodeLabel);
this.cityField = page.getByLabel(selectors.newAddress.cityNameLabel);
//TODO: countrySelect is used to change the country so it's not US.
//TODO: provinceSelect should be provinceField if country is, for example, Netherlands.
this.countrySelectorField = page.getByLabel(selectors.newAddress.countryLabel);
this.stateSelectorField = page.getByLabel(selectors.newAddress.provinceSelectLabel).filter({hasText: selectors.newAddress.provinceSelectFilterLabel});
this.saveAddressButton = page.getByRole('button',{name: selectors.newAddress.saveAdressButton});
//unrequired fields
// this.companyField = page.getByLabel(selectors.newAddress.companyNameLabel);

// Account Information elements
this.changePasswordCheck = page.getByRole('checkbox', {name: selectors.personalInformation.changePasswordCheckLabel});
//TODO: Fix these once I can log in again
this.currentPasswordField = page.getByLabel('Current Password');
this.newPasswordField = page.getByLabel('New Password', {exact:true});
this.confirmNewPasswordField = page.getByLabel('Confirm New Password')
this.currentPasswordField = page.getByLabel(selectors.credentials.currentPasswordFieldLabel);
this.newPasswordField = page.getByLabel(selectors.credentials.newPasswordFieldLabel, {exact:true});
this.confirmNewPasswordField = page.getByLabel(selectors.credentials.newPasswordConfirmFieldLabel);
this.genericSaveButton = page.getByRole('button', { name: selectors.general.genericSaveButtonLabel });

// Account Creation elements
Expand All @@ -79,11 +66,9 @@ export class AccountPage {
this.editAddressButton = page.getByRole('link', {name: selectors.accountDashboard.editAddressIconButton}).first();
}

//TODO: Add ability to choose different country other than US
async addNewAddress(phonenumber: string,streetName: string, zipCode: string, cityName: string, state: string){
let addressAddedNotification = verify.address.newAddressAddedNotifcation;


// Name should be filled in automatically.
await expect(this.firstNameField).not.toBeEmpty();
await expect(this.lastNameField).not.toBeEmpty();
Expand All @@ -104,7 +89,6 @@ export class AccountPage {
// the notification for a modified address is the same as the notification for a new address.
let addressModifiedNotification = verify.address.newAddressAddedNotifcation;

// .click() replaced by .press("Enter") as a workaround for webkit issues
await this.editAddressButton.click();

// Name should be filled in automatically, but editable.
Expand All @@ -117,7 +101,7 @@ export class AccountPage {
await this.zipCodeField.fill(zipCode);
await this.cityField.fill(cityName);
await this.stateSelectorField.selectOption(state);
// .click() replaced by .press("Enter") as a workaround for webkit issues

await this.saveAddressButton.click();
await this.page.waitForLoadState();

Expand All @@ -126,8 +110,6 @@ export class AccountPage {
}


// TODO: Update function to remove random address from address book?
// deleteAddressButton is currently the first instance it finds.
async deleteFirstAddressFromAddressBook(){
let addressDeletedNotification = verify.address.addressDeletedNotification;
// Dialog function to click confirm
Expand All @@ -137,7 +119,6 @@ export class AccountPage {
}
});

// .click() replaced by .press("Enter") as a workaround for webkit issues
await this.deleteAddressButton.click();
await this.page.waitForLoadState();
await expect(this.page.getByText(addressDeletedNotification)).toBeVisible();
Expand All @@ -151,7 +132,6 @@ export class AccountPage {
await this.newPasswordField.fill(newPassword);
await this.confirmNewPasswordField.fill(newPassword);

// .click() replaced by .press("Enter") as a workaround for webkit issues
await this.genericSaveButton.click();
await this.page.waitForLoadState();

Expand Down
3 changes: 0 additions & 3 deletions tests/base/fixtures/checkout.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import slugs from '../config/slugs.json';

export class CheckoutPage {

//TODO: Expand with fields for when user is not logged in or has not provided an address
readonly page: Page;
readonly shippingMethodOptionFixed: Locator;
readonly paymentMethodOptionCheck: Locator;
Expand Down Expand Up @@ -53,8 +52,6 @@ export class CheckoutPage {
let orderNumber = await this.page.locator('p').filter({ hasText: 'Your order number is:' }).getByRole('link').innerText();
console.log(`Your ordernumer is: ${orderNumber}`);

// This await only exists to report order number to the HTML reporter.
// TODO: replace this with a proper way to write something to the HTML reporter.
await expect(this.continueShoppingButton, `Your order number is: ${orderNumber}`).toBeVisible();
return orderNumber;
}
Expand Down
4 changes: 0 additions & 4 deletions tests/base/fixtures/login.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,13 @@ export class LoginPage {
this.loginButton = page.getByRole('button', { name: selectors.credentials.loginButtonLabel });
}

// Note: this login function is simply written to quickly log in for tests which require you to be logged in.
// TODO: this login function should be moved to an auth file. see login.spec.ts line 15 and 16 for more info.
async login(email: string, password: string){
await this.page.goto(slugs.account.loginSlug);
await this.loginEmailField.fill(email);
await this.loginPasswordField.fill(password);
// usage of .press("Enter") to prevent webkit issues with button.click();
await this.loginButton.press("Enter");

// this element cannot be defined in the constructor, since the sign out button only appears after logging in.
// Using a selector rather than expected, since it's we're locating a button rather than an expected notification.
await expect(this.page.getByRole('link', { name: selectors.mainMenu.myAccountLogoutItem })).toBeVisible();
}
}
2 changes: 1 addition & 1 deletion tests/base/fixtures/mainmenu.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class MainMenuPage {
}

async gotoAddressBook() {
// TODO: create function to navigate to Address Book through the header menu links
// create function to navigate to Address Book through the header menu links
}

async openMiniCart() {
Expand Down
2 changes: 0 additions & 2 deletions tests/base/fixtures/newsletter.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ export class NewsletterSubscriptionPage {
this.saveSubscriptionsButton = page.getByRole('button', {name:selectors.newsletterSubscriptions.saveSubscriptionsButton});
}

//TODO: the text of the notification can differ sometimes. Update this function to take this into account.
// newsletterRemovedNotification should sometimes be newsletterUpdatedNotification.
async updateNewsletterSubscription(){

if(await this.newsletterCheckElement.isChecked()) {
Expand Down
1 change: 0 additions & 1 deletion tests/base/fixtures/product.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,5 @@ export class ProductPage {

await this.simpleProductAddToCartButon.click();
await this.page.waitForLoadState();
//TODO: add notification check to ensure product has been added.
}
}
1 change: 0 additions & 1 deletion tests/base/home.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ test('Add product on homepage to cart',{ tag: '@homepage',}, async ({page}) => {
const homepage = new HomePage(page);
const mainmenu = new MainMenuPage(page);

// TODO: rework adding product to cart into API call function to reduce test time
await page.goto('');
await homepage.addHomepageProductToCart();
await mainmenu.openMiniCart();
Expand Down
25 changes: 0 additions & 25 deletions tests/base/login.spec.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,6 @@
import {test as base} from '@playwright/test';
import {LoginPage} from './fixtures/login.page';

/*
const test = base.extend<{ loginPage:LoginPage }>({
loginPage: async ({ page }, use) => {
const loginPage = new LoginPage(page);
await loginPage.login();
}
});
*/

//TODO: create an auth.setup.ts file to handle authentication (see login function on login.page.ts)
//TODO: link that setup file in project dependencies to be logged for all tests.
// See: https://playwright.dev/docs/auth#basic-shared-account-in-all-tests

//TODO: login.spec.ts can be removed when storageState functionality has been implemented. Relevant functions should be moved to mainmenu, footer, search, or other page spec files.

// Reset storageState to ensure we're not logged in before running these tests.
base.use({ storageState: { cookies: [], origins: [] } });

base('User can log in with valid credentials', async ({page, browserName}) => {
const browserEngine = browserName?.toUpperCase() || "UNKNOWN";
let emailInputValue = process.env[`MAGENTO_EXISTING_ACCOUNT_EMAIL_${browserEngine}`];
Expand All @@ -31,10 +13,3 @@ base('User can log in with valid credentials', async ({page, browserName}) => {
const loginPage = new LoginPage(page);
await loginPage.login(emailInputValue, passwordInputValue);
});

//TODO: Add test to ensure user cannot log in with invalid credentials.
// Basically, we log in with wrong credentials, then expect a failure message.
// These tests should have a specific "error checker" tag.


//TODO: Add test to test 'Forgot your Password' functionality
1 change: 0 additions & 1 deletion tests/base/mainmenu.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {MainMenuPage} from './fixtures/mainmenu.page';

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

// TODO: remove this beforeEach() once authentication as project set-up/fixture works.
// Before each test, log in
test.beforeEach(async ({ page, browserName }) => {
const browserEngine = browserName?.toUpperCase() || "UNKNOWN";
Expand Down
2 changes: 0 additions & 2 deletions tests/base/minicart.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ test.describe('Minicart Actions', {annotation: {type: 'Minicart', description: '
const mainMenu = new MainMenuPage(page);
const productPage = new ProductPage(page);

//TODO: Use a storagestate or API call to add product to the cart so shorten test time
await page.goto(slugs.productpage.simpleProductSlug);
await productPage.addSimpleProductToCart(selectors.productPage.simpleProductTitle, slugs.productpage.simpleProductSlug);
await mainMenu.openMiniCart();
Expand Down Expand Up @@ -115,7 +114,6 @@ test.describe('Minicart Actions', {annotation: {type: 'Minicart', description: '
const mainMenu = new MainMenuPage(page);
const productPage = new ProductPage(page);

//TODO: Use a storagestate or API call to add product to the cart so shorten test time
await page.goto(slugs.productpage.configurableProductSlug);
await productPage.addConfigurableProductToCart();
await mainMenu.openMiniCart();
Expand Down
Loading

0 comments on commit 58fb7e8

Please sign in to comment.