/
task3.spec.js
99 lines (91 loc) · 2.25 KB
/
task3.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/// <reference types="cypress" />
import { sizes, viewports } from '../../../utils/device-utils';
const allViewports = [viewports.DESKTOP, viewports.TABLET, viewports.MOBILE];
const elements = [
{
name: 'Wishlist Icon',
id: '#A__wishlist__52',
isDisplayedOn: [...allViewports],
},
{
name: 'Basket Count',
id: '#A__cartbt__49 strong',
isDisplayedOn: [...allViewports],
},
{
name: 'Shoe Name',
id: '#shoe_name',
isDisplayedOn: [...allViewports],
},
{
name: 'Shoe Image',
id: '#shoe_img',
isDisplayedOn: [...allViewports],
},
{
name: 'Shoe Rating',
id: '#SPAN__rating__76',
isDisplayedOn: [...allViewports],
},
{
name: 'Shoe Description',
id: '#P____83',
isDisplayedOn: [...allViewports],
},
{
name: 'Shoe Size',
id: '.nice-select.wide > .current',
isDisplayedOn: [...allViewports],
},
{
name: 'Shoe Quantity',
id: '#quantity_1',
isDisplayedOn: [...allViewports],
},
{
name: 'Shoe Old Price',
id: '#old_price',
isDisplayedOn: [...allViewports],
},
{
name: 'Shoe New Price',
id: '#new_price',
isDisplayedOn: [...allViewports],
},
{
name: 'Shoe Discount',
id: '#discount',
isDisplayedOn: [...allViewports],
},
{
name: 'Add to Cart Button',
id: '#DIV__btnaddtoca__113',
isDisplayedOn: [...allViewports],
},
];
describe(`AppliFashion V${Cypress.env(
'VERSION'
)} Task 3 - Product Details Test`, () => {
sizes.forEach((size) => {
const { viewport, device } = size;
before(() => {
cy.visitViewport(device, Cypress.env('APP_NAME'));
cy.get('#product_1').click();
cy.url().should('contain', Cypress.env('PRODUCT_DETAILS_URL'));
});
elements.forEach((element) => {
const { name, id, isDisplayedOn } = element;
it(`should display ${name} appropriately on product details page on ${viewport} - ${device} device - ${Cypress.env(
'BROWSER'
)} browser`, () => {
const assertionString = isDisplayedOn.includes(viewport)
? 'be.visible'
: 'not.be.visible';
cy.get(id).should(assertionString);
if (name === 'Shoe Size') {
cy.get(id).should('have.text', 'Small (S)');
}
});
});
});
});