-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheckout-flow.spec.ts
More file actions
104 lines (81 loc) · 3.36 KB
/
checkout-flow.spec.ts
File metadata and controls
104 lines (81 loc) · 3.36 KB
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
import { test, expect } from '../fixtures/test-setup.fixture';
import { HomePage } from '../page-objects/home-page';
import { ProductPage } from '../page-objects/product-page';
import { CartDrawer } from '../page-objects/cart-drawer';
import { CheckoutPage } from '../page-objects/checkout-page';
test.describe('Complete Checkout Flow', () => {
test('should complete a purchase with test payment', async ({ page }) => {
// Initialize page objects
const homePage = new HomePage(page);
const productPage = new ProductPage(page);
const cartDrawer = new CartDrawer(page);
const checkoutPage = new CheckoutPage(page);
// Step 1: Visit the home page
await homePage.goto();
// Step 2: Add a product to cart from home page
await homePage.addToCart();
// Step 3: Open the cart drawer
await homePage.openCartDrawer();
// Step 4: Verify cart drawer is open and has items
await cartDrawer.waitForDrawerOpen();
await cartDrawer.verifyItemInCart();
// Step 5: Proceed to checkout
await cartDrawer.proceedToCheckout();
// Step 6: Verify we're on the checkout page
await expect(page).toHaveURL(/\/checkout/);
// Step 7: Fill in the address form
await checkoutPage.fillAddressForm({
email: 'test@example.com',
firstName: 'Test',
lastName: 'User',
address: '123 Test St',
city: 'Test City',
state: 'TX',
zip: '12345',
phone: '555-123-4567'
});
// Step 8: Select test payment option
await checkoutPage.selectTestPayment();
// Step 9: Complete checkout with test payment
await checkoutPage.completeCheckout();
// Step 10: Verify successful checkout (this will depend on your app's behavior)
// For example, you might check for a success message or redirection to a confirmation page
await expect(page).toHaveURL(/\/confirmation|\/success|\/thank-you/);
});
test('should add product from PDP and complete checkout', async ({ page }) => {
// Initialize page objects
const productPage = new ProductPage(page);
const cartDrawer = new CartDrawer(page);
const checkoutPage = new CheckoutPage(page);
// Step 1: Visit a product detail page (replace with an actual product handle)
await productPage.goto('sample-product');
// Step 2: Add the product to cart
await productPage.addToCart();
// Step 3: Open the cart drawer
await productPage.openCartDrawer();
// Step 4: Verify cart drawer is open and has items
await cartDrawer.waitForDrawerOpen();
await cartDrawer.verifyItemInCart();
// Step 5: Proceed to checkout
await cartDrawer.proceedToCheckout();
// Step 6: Verify we're on the checkout page
await expect(page).toHaveURL(/\/checkout/);
// Step 7: Fill in the address form
await checkoutPage.fillAddressForm({
email: 'test@example.com',
firstName: 'Test',
lastName: 'User',
address: '123 Test St',
city: 'Test City',
state: 'TX',
zip: '12345',
phone: '555-123-4567'
});
// Step 8: Select test payment option
await checkoutPage.selectTestPayment();
// Step 9: Complete checkout with test payment
await checkoutPage.completeCheckout();
// Step 10: Verify successful checkout
await expect(page).toHaveURL(/\/confirmation|\/success|\/thank-you/);
});
});