This repository has been archived by the owner on May 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 215
/
cart.content.spec.js
80 lines (58 loc) · 2.73 KB
/
cart.content.spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import { languageSelectors, openDeepLinkUrl, restartApp } from '../../helpers/utils';
import LoginScreen from '../../screenObjects/#';
import InventoryListScreen from '../../screenObjects/inventoryList';
import CartContent from '../../screenObjects/cart';
import AppHeader from '../../screenObjects/appHeader';
import CheckoutPageOne from '../../screenObjects/checkoutPageOne';
import { LOGIN_USERS } from '../../helpers/e2eConstants';
describe('Cart Content Page', () => {
const SELECTORS = languageSelectors();
beforeEach(() => {
// Restart the app before each session, only not for the first session
restartApp();
LoginScreen.waitForIsShown();
});
it('should show 2 items in the cart added in the normal flow', () => {
LoginScreen.signIn(LOGIN_USERS.STANDARD);
// Add some items to the cart
InventoryListScreen.waitForIsShown();
InventoryListScreen.addSwagItemToCart(SELECTORS.products.backpack.name);
InventoryListScreen.addSwagItemToCart(SELECTORS.products.bikeLight.name);
// Open the cart
AppHeader.openCart();
CartContent.waitForIsShown();
expect(CartContent.swagItems.length).toEqual(2, 'The amount of items in the cart is not correct.');
});
it('should show the items page if continue shopping is selected', () => {
openDeepLinkUrl('cart/0,1');
CartContent.waitForIsShown();
CartContent.continueShopping();
InventoryListScreen.waitForIsShown();
expect(CartContent.isShown()).toEqual(false, 'The car content page is still visible');
});
it('should update the cart if an item is removed', () => {
openDeepLinkUrl('cart/0,1');
CartContent.waitForIsShown();
expect(AppHeader.getCartAmount()).toContain(2, 'Cart amount is not correct');
CartContent.removeSwagItem();
expect(AppHeader.getCartAmount()).toContain(1, 'The amount if items in the cart is not correct.');
CartContent.removeSwagItem();
expect(AppHeader.getCartAmount()).not.toContain(1, 'The amount if items in the cart is not correct.');
});
it('should update the cart if an item is removed by swiping', () => {
openDeepLinkUrl('cart/0,1');
CartContent.waitForIsShown();
expect(AppHeader.getCartAmount()).toContain(2, 'Cart amount is not correct');
CartContent.swipeToOpenDeleteButton();
CartContent.deleteSwagItem();
expect(AppHeader.getCartAmount()).toContain(1, 'The amount if items in the cart is not correct.');
});
it('should open the checkout page one page if checkout is clicked', () => {
openDeepLinkUrl('cart/0,1');
CartContent.waitForIsShown();
CartContent.goToCheckout();
CheckoutPageOne.waitForIsShown();
expect(CartContent.isShown()).toEqual(false, 'The cart content page is still visible');
expect(CheckoutPageOne.isShown()).toEqual(true, 'The checkout page one is not visible');
});
});