Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gitlab 10: An error message should show in cart/checkout if an incorrect coupon code has been entered #32

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

shayfaber
Copy link
Contributor

No description provided.

*/
test('Add coupon code in cart',{ tag: ['@cart', '@coupon-code']}, async ({page}) => {
const cart = new CartPage(page);
let discountCode = process.env.DISCOUNT_CODE;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shayfaber Should be MAGENTO_COUPON_CODE

let discountCode = process.env.DISCOUNT_CODE;

if(!discountCode) {
throw new Error(`discountCode appears to not be set in .env file. Value reported: ${discountCode}`);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shayfaber The discountCode is the var for this function but it's more clear to report the env variable which is MAGENTO_COUPON_CODE

*/
test('Remove coupon code from cart',{ tag: ['@cart', '@coupon-code'] }, async ({page}) => {
const cart = new CartPage(page);
let discountCode = process.env.DISCOUNT_CODE;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shayfaber See comments above. Same for this code, maybe also an idea to move this code to a function, because you have the same code twice now.

let discountCode = process.env.DISCOUNT_CODE;

if(!discountCode) {
throw new Error(`discountCode appears to not be set in .env file. Value reported: ${discountCode}`);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shayfaber See comments above.

* @then I should get a notification that the code did not work.
*/

test('Using an invalid discountcode should give an error',{ tag: ['@cart', '@coupon-code'] }, async ({page}) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shayfaber For naming better to call if coupon code.


if(!discountCode) {
throw new Error(`discountCode appears to not be set in .env file. Value reported: ${discountCode}`);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shayfaber See above.

*/

test('Using an invalid discountcode should give an error',{ tag: ['@checkout', '@coupon-code'] }, async ({page}) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shayfaber See above.

test('Using an invalid discountcode should give an error',{ tag: ['@checkout', '@coupon-code'] }, async ({page}) => {
const checkout = new CheckoutPage(page);
let wrongDiscountCode = "incorrect discount code";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shayfaber When used once, you don't have to push it to a var.

@@ -1,18 +1,63 @@
import {expect, type Locator, type Page} from '@playwright/test';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shayfaber Let's keep the naming everywhere 'coupon code' as Magento is also naming it that way.

@@ -51,4 +56,53 @@ export class CheckoutPage {
await expect(this.continueShoppingButton, `Your order number is: ${orderNumber}`).toBeVisible();
return orderNumber;
}

async applyDiscountCodeCheckout(code: string){
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shayfaber Is there a reason this needs to be *Checkout? Or can we remove Checkout from this function name? Because it is already called exported as CheckoutPage. So then it will be CheckoutPage->applyCouponCode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants