Skip to content

Commit

Permalink
Fixed issues with price check tests
Browse files Browse the repository at this point in the history
  • Loading branch information
shayfaber committed Jan 13, 2025
1 parent 4680eec commit 864b4c2
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
5 changes: 1 addition & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@ bypass-captcha.config.ts
package-lock.json
/tests/base/config/test-toggles.json
/tests/custom/config/test-toggles.json
/tests/base/updated-account.spec.ts
/tests/base/utils/AccountPage.ts
.env
.vscode
/tests/.auth/
/tests/base/fixtures/devtools.page.ts
/test/base/devtools.spec.ts
/tests/.auth/
4 changes: 2 additions & 2 deletions tests/base/cart.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,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('Quantity').fill('2');
await page.getByLabel(selectors.productPage.quantityFieldLabel).fill('2');

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

});

Expand Down
12 changes: 5 additions & 7 deletions tests/base/config/selectors/selectors.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,11 @@
"discountInputFieldLabel": "Enter discount code",
"continueShoppingLabel": "Continue Shopping",
"applyDiscountCodeLabel": "Apply Discount Code",
"remove": "Remove"
"remove": "Remove",
"openCartButtonLabel": "Cart",
"openCartButtonLabelCont": "item",
"openCartButtonLabelContMultiple": "items",
"cartDetailsLocator": "#checkout-cart-details div"
},
"miniCart": {
"checkOutButtonLabel": "Checkout",
Expand All @@ -92,12 +96,6 @@
"minicartPriceFieldClass": ".price-excluding-tax .minicart-price .price",
"minicartAmountBubbleLocator": "#menu-cart-icon > span"
},
"checkout": {
"openCartButtonLabel": "Cart",
"openCartButtonLabelCont": "item",
"openCartButtonLabelContMultiple": "items",
"cartDetailsLocator": "#checkout-cart-details div"
},
"contactPage": {
"messageFieldLabel": "What’s on your mind?"
},
Expand Down
7 changes: 6 additions & 1 deletion tests/base/fixtures/product.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,17 @@ export class ProductPage {
this.simpleProductAddToCartButon = page.getByRole('button', { name: 'shopping-cart Add to Cart' });
}

async addSimpleProductToCart(product: string, url: string){
async addSimpleProductToCart(product: string, url: string, quantity?: string) {
await this.page.goto(url);
this.simpleProductTitle = this.page.getByRole('heading', {name: product, exact:true});
let productAddedNotification = `${verify.productPage.simpleProductAddedNotification} ${product}`;

await expect(this.simpleProductTitle.locator('span')).toBeVisible();

if(quantity){
// set quantity
await this.page.getByLabel(selectors.productPage.quantityFieldLabel).fill('2');
}

await this.simpleProductAddToCartButon.click();
await expect(this.page.getByText(productAddedNotification)).toBeVisible();
Expand Down

0 comments on commit 864b4c2

Please sign in to comment.