-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproduct-detail-extended.spec.ts
More file actions
270 lines (234 loc) · 8.56 KB
/
product-detail-extended.spec.ts
File metadata and controls
270 lines (234 loc) · 8.56 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
import { test, expect } from '../../fixtures/test-base';
import { PRODUCTS } from '../../data/products.data';
test.describe('Product Detail — Extended @regression', () => {
const product = PRODUCTS.microFreak;
const secondProduct = PRODUCTS.studioMonitors;
test.describe('Technical Specifications', () => {
test('Specifications table renders for synthesizer product', async ({
productDetailPage,
}) => {
await test.step('Navigate to product detail page', async () => {
await productDetailPage.goto(product.id);
});
await test.step('Verify specification terms are displayed', async () => {
await expect(productDetailPage.specTerms.first()).toBeVisible();
const count = await productDetailPage.specTerms.count();
expect(count).toBeGreaterThan(0);
});
await test.step('Verify specification definitions match terms', async () => {
const termsCount = await productDetailPage.specTerms.count();
const defsCount = await productDetailPage.specDefinitions.count();
expect(defsCount).toBe(termsCount);
});
});
test('Specifications table renders for studio recording product', async ({
productDetailPage,
}) => {
await test.step('Navigate to different product type', async () => {
await productDetailPage.goto(secondProduct.id);
});
await test.step('Verify specifications are present', async () => {
await expect(productDetailPage.specTerms.first()).toBeVisible();
});
});
});
test.describe('Customer Reviews', () => {
test('Reviews section displays reviewer info and ratings', async ({
productDetailPage,
}) => {
await test.step('Navigate to product detail page', async () => {
await productDetailPage.goto(product.id);
});
await test.step('Verify reviews section is visible', async () => {
await expect(productDetailPage.reviewsRegion).toBeVisible();
});
await test.step('Verify review articles exist', async () => {
const reviewCount =
await productDetailPage.reviewArticles.count();
expect(reviewCount).toBeGreaterThan(0);
});
await test.step('Verify first review contains text content', async () => {
const firstReview = productDetailPage.reviewArticles.first();
const text = await firstReview.textContent();
expect(text).toBeTruthy();
expect(text!.length).toBeGreaterThan(10);
});
});
});
test.describe('Share Buttons', () => {
test.beforeEach(async ({ productDetailPage }) => {
await productDetailPage.goto(product.id);
});
test('Facebook share button is visible', async ({
productDetailPage,
}) => {
await test.step('Verify Facebook share button', async () => {
await expect(
productDetailPage.shareFacebookButton,
).toBeVisible();
});
});
test('Twitter share button is visible', async ({
productDetailPage,
}) => {
await test.step('Verify Twitter share button', async () => {
await expect(
productDetailPage.shareTwitterButton,
).toBeVisible();
});
});
test('LinkedIn share button is visible', async ({
productDetailPage,
}) => {
await test.step('Verify LinkedIn share button', async () => {
await expect(
productDetailPage.shareLinkedInButton,
).toBeVisible();
});
});
test('WhatsApp share button is visible', async ({
productDetailPage,
}) => {
await test.step('Verify WhatsApp share button', async () => {
await expect(
productDetailPage.shareWhatsAppButton,
).toBeVisible();
});
});
test('Copy Link button is visible and functional', async ({
productDetailPage,
}) => {
await test.step('Verify Copy Link button is visible', async () => {
await expect(productDetailPage.copyLinkButton).toBeVisible();
});
await test.step('Click Copy Link button', async () => {
await productDetailPage.copyLinkButton.click();
});
await test.step('Verify button interaction completed without error', async () => {
// The copy action may show a brief toast or change button text
// Verify the button is still visible after clicking (no crash)
await expect(productDetailPage.copyLinkButton).toBeVisible();
});
});
});
test.describe('Favorites Button', () => {
test('Add to favorites button is visible and clickable', async ({
productDetailPage,
}) => {
await test.step('Navigate to product detail page', async () => {
await productDetailPage.goto(product.id);
});
await test.step('Verify add to favorites button is visible', async () => {
await expect(
productDetailPage.addToFavoritesButton.first(),
).toBeVisible();
});
await test.step('Click add to favorites', async () => {
await productDetailPage.addToFavoritesButton.first().click();
});
await test.step('Verify favorites interaction completed', async () => {
// After clicking, the button may toggle state or show notification
// Verify the page remains functional
await expect(
productDetailPage.addToFavoritesButton.first(),
).toBeVisible();
});
});
});
test.describe('Quantity Boundaries', () => {
test.beforeEach(async ({ productDetailPage }) => {
await productDetailPage.goto(product.id);
});
test('Quantity starts at 1 and decrease button is disabled at minimum', async ({
productDetailPage,
}) => {
await test.step('Verify initial quantity is 1', async () => {
await expect(productDetailPage.quantityInput).toHaveAttribute(
'aria-valuenow',
'1',
);
});
await test.step('Verify decrease button is disabled at quantity 1', async () => {
await expect(
productDetailPage.decreaseQuantityButton,
).toBeDisabled();
});
await test.step('Verify quantity remains at 1', async () => {
await expect(productDetailPage.quantityInput).toHaveAttribute(
'aria-valuenow',
'1',
);
});
});
test('Quantity can be increased to a high value', async ({
productDetailPage,
}) => {
await test.step('Increase quantity to 5', async () => {
for (let i = 0; i < 4; i++) {
await productDetailPage.increaseQuantityButton.click();
}
});
await test.step('Verify quantity is 5', async () => {
await expect(productDetailPage.quantityInput).toHaveAttribute(
'aria-valuenow',
'5',
);
});
});
test('Increase then decrease returns to original value', async ({
productDetailPage,
}) => {
await test.step('Increase quantity by 3', async () => {
for (let i = 0; i < 3; i++) {
await productDetailPage.increaseQuantityButton.click();
}
await expect(productDetailPage.quantityInput).toHaveAttribute(
'aria-valuenow',
'4',
);
});
await test.step('Decrease quantity by 3', async () => {
for (let i = 0; i < 3; i++) {
await productDetailPage.decreaseQuantityButton.click();
}
});
await test.step('Verify quantity is back to 1', async () => {
await expect(productDetailPage.quantityInput).toHaveAttribute(
'aria-valuenow',
'1',
);
});
});
});
test.describe('Continue Shopping', () => {
test('"Continue Shopping" navigates back to products page', async ({
productDetailPage,
page,
}) => {
await test.step('Navigate to product detail page', async () => {
await productDetailPage.goto(product.id);
});
await test.step('Click "Continue Shopping" button', async () => {
await productDetailPage.continueShoppingButton.click();
});
await test.step('Verify navigation to products page', async () => {
await expect(page).toHaveURL(/\/products/);
});
});
});
test.describe('Product Image', () => {
test('Product detail page shows correct product image', async ({
productDetailPage,
}) => {
await test.step('Navigate to product page', async () => {
await productDetailPage.goto(product.id);
});
await test.step('Verify product image is present with alt text', async () => {
const img = productDetailPage.page.getByRole('img', {
name: product.name,
});
await expect(img).toBeVisible();
});
});
});
});