Skip to content

Commit

Permalink
Adding UI test for discount behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
porgabi committed Aug 2, 2023
1 parent f78e3c0 commit 6ef3a24
Showing 1 changed file with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Lombiq.Tests.UI.Extensions;
using Lombiq.Tests.UI.Services;
using OpenQA.Selenium;
using Shouldly;
using Xunit;
using Xunit.Abstractions;
using static OrchardCore.Commerce.Tests.UI.Constants.ContentItemIds;
Expand Down Expand Up @@ -35,4 +36,33 @@ async Task CheckDiscountPresenceAsync(bool hasNewPrice)
await CheckDiscountPresenceAsync(hasNewPrice: true);
},
browser);

[Theory, Chrome]
public Task DiscountShouldProperlyAppearOnDiscountedProduct(Browser browser) =>
ExecuteTestAfterSetupAsync(
async context =>
{
// Discount should appear on discounted product's page.
await context.GoToRelativeUrlAsync("/testdiscountedproduct");
context.Get(By.CssSelector(".price-part-price-field-value > del")).Text.ShouldBe("$5.00");
context.Get(By.CssSelector(".price-part-price-field-value > span")).Text.ShouldBe("$3.00");
await context.ClickReliablyOnSubmitAsync();
// Discount should appear in cart when discounted product is the only item in the cart.
context.Get(By.CssSelector(".shopping-cart-table-unit-price")).Text.ShouldBe("$3.00");
// Discount should appear in cart when discounted product is not the only item in the cart.
await context.GoToRelativeUrlAsync("/testproduct");
await context.ClickReliablyOnSubmitAsync();
context.Get(By.CssSelector(".shopping-cart-table-unit-price")).Text.ShouldBe("$3.00");
// Total should reflect discount as well.
context.Get(By.CssSelector(".shopping-cart-table-totals > div")).Text.ShouldBe("$8.00");
// Discount should still appear on discounted product's page when the cart contains a full-price item.
await context.GoToRelativeUrlAsync("/testdiscountedproduct");
context.Get(By.CssSelector(".price-part-price-field-value > del")).Text.ShouldBe("$5.00");
context.Get(By.CssSelector(".price-part-price-field-value > span")).Text.ShouldBe("$3.00");
},
browser);
}

0 comments on commit 6ef3a24

Please sign in to comment.