1
|
|
|
/// <reference types="Cypress" /> |
2
|
|
|
|
3
|
|
View Code Duplication |
describe('CMS: Check usage and editing of cross selling element', () => { |
|
|
|
|
4
|
|
|
beforeEach(() => { |
5
|
|
|
cy.setToInitialState() |
|
|
|
|
6
|
|
|
.then(() => { |
7
|
|
|
cy.loginViaApi(); |
|
|
|
|
8
|
|
|
}) |
9
|
|
|
.then(() => { |
10
|
|
|
return cy.createCmsFixture(); |
|
|
|
|
11
|
|
|
}) |
12
|
|
|
.then(() => { |
13
|
|
|
return cy.createProductFixture({ |
|
|
|
|
14
|
|
|
name: 'First product', |
15
|
|
|
productNumber: 'RS-11111', |
16
|
|
|
description: 'Pudding wafer apple pie fruitcake cupcake. Biscuit cotton candy gingerbread liquorice tootsie roll caramels soufflé. Wafer gummies chocolate cake soufflé.', |
17
|
|
|
crossSellings: [ |
18
|
|
|
{ |
19
|
|
|
name: "You may like it", |
20
|
|
|
active: true |
21
|
|
|
} |
22
|
|
|
] |
23
|
|
|
}); |
24
|
|
|
}) |
25
|
|
|
.then(() => { |
26
|
|
|
return cy.createProductFixture({ |
|
|
|
|
27
|
|
|
name: 'Second product', |
28
|
|
|
productNumber: 'RS-22222', |
29
|
|
|
description: 'Jelly beans jelly-o toffee I love jelly pie tart cupcake topping. Cotton candy jelly beans tootsie roll pie tootsie roll chocolate cake brownie. I love pudding brownie I love.' |
30
|
|
|
}); |
31
|
|
|
}) |
32
|
|
|
.then(() => { |
33
|
|
|
return cy.createProductFixture({ |
|
|
|
|
34
|
|
|
name: 'Third product', |
35
|
|
|
productNumber: 'RS-33333', |
36
|
|
|
description: 'Cookie bonbon tootsie roll lemon drops soufflé powder gummies bonbon. Jelly-o lemon drops cheesecake. I love carrot cake I love toffee jelly beans I love jelly.' |
37
|
|
|
}); |
38
|
|
|
}) |
39
|
|
|
.then(() => { |
40
|
|
|
cy.viewport(1920, 1080); |
|
|
|
|
41
|
|
|
cy.openInitialPage(`${Cypress.env('admin')}#/sw/product/index`); |
|
|
|
|
42
|
|
|
}); |
43
|
|
|
}); |
44
|
|
|
|
45
|
|
|
it('@content: use cross selling element in another block', () => { |
46
|
|
|
cy.window().then((win) => { |
|
|
|
|
47
|
|
|
if (!win.Shopware.Feature.isActive('FEATURE_NEXT_10078')) { |
48
|
|
|
cy.log('Skipping test of deactivated feature \'FEATURE_NEXT_10078\' flag'); |
|
|
|
|
49
|
|
|
return; |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
cy.server(); |
53
|
|
|
cy.route({ |
54
|
|
|
url: `${Cypress.env('apiPath')}/cms-page/*`, |
|
|
|
|
55
|
|
|
method: 'patch' |
56
|
|
|
}).as('saveData'); |
57
|
|
|
|
58
|
|
|
cy.route({ |
59
|
|
|
url: `${Cypress.env('apiPath')}/category/*`, |
60
|
|
|
method: 'patch' |
61
|
|
|
}).as('saveCategory'); |
62
|
|
|
|
63
|
|
|
cy.route({ |
64
|
|
|
url: `${Cypress.env('apiPath')}/search/product-cross-selling/**/assigned-products`, |
65
|
|
|
method: 'post' |
66
|
|
|
}).as('assignProduct'); |
67
|
|
|
|
68
|
|
|
cy.route({ |
69
|
|
|
url: `${Cypress.env('apiPath')}/product/*`, |
70
|
|
|
method: 'patch' |
71
|
|
|
}).as('saveProductData'); |
72
|
|
|
|
73
|
|
|
// Open product and add cross selling |
74
|
|
|
cy.visit(`${Cypress.env('admin')}#/sw/product/index`); |
75
|
|
|
cy.contains('First product').click(); |
76
|
|
|
|
77
|
|
|
cy.get('.sw-product-detail__tab-cross-selling').click(); |
78
|
|
|
cy.get('input[name="sw-field--crossSelling-active"]').click(); |
79
|
|
|
|
80
|
|
|
// Fill in cross selling form |
81
|
|
|
cy.get('#sw-field--crossSelling-type').select('Manual selection'); |
82
|
|
|
cy.get('input[name="sw-field--crossSelling-active"]').click(); |
83
|
|
|
|
84
|
|
|
// Save and verify cross selling |
85
|
|
|
cy.get('.sw-button-process').click(); |
86
|
|
|
cy.wait('@saveProductData').then((xhr) => { |
87
|
|
|
expect(xhr).to.have.property('status', 204); |
88
|
|
|
}); |
89
|
|
|
|
90
|
|
|
// Add products to cross selling |
91
|
|
|
cy.get('.sw-product-cross-selling-assignment__select-container .sw-entity-single-select__selection').type('Second'); |
92
|
|
|
cy.get('.sw-select-result').should('be.visible'); |
93
|
|
|
cy.get('.sw-select-option--1').should('not.exist'); |
94
|
|
|
cy.contains('.sw-select-option--0', 'Second product').click(); |
95
|
|
|
cy.get('.sw-card__title').click(); |
96
|
|
|
cy.get('.sw-data-grid__cell--product-translated-name').contains('Second product'); |
97
|
|
|
|
98
|
|
|
// Add more products to cross selling |
99
|
|
|
cy.get('.sw-product-cross-selling-assignment__select-container .sw-entity-single-select__selection').type('Third'); |
100
|
|
|
cy.get('.sw-select-result').should('be.visible'); |
101
|
|
|
cy.get('.sw-select-option--1').should('not.exist'); |
102
|
|
|
cy.contains('.sw-select-option--0', 'Third product').click(); |
103
|
|
|
cy.get('.sw-card__title').click(); |
104
|
|
|
cy.get('.sw-data-grid__cell--product-translated-name').contains('Third product'); |
105
|
|
|
|
106
|
|
|
// Save and verify cross selling |
107
|
|
|
cy.get('.sw-button-process').click(); |
108
|
|
|
cy.wait('@saveProductData').then((xhr) => { |
109
|
|
|
expect(xhr).to.have.property('status', 204); |
110
|
|
|
}); |
111
|
|
|
|
112
|
|
|
cy.visit(`${Cypress.env('admin')}#/sw/cms/index`); |
113
|
|
|
|
114
|
|
|
cy.get('.sw-cms-list-item--0').click(); |
115
|
|
|
|
116
|
|
|
// Add text block |
117
|
|
|
cy.get('.sw-cms-section__empty-stage').click(); |
118
|
|
|
cy.get('#sw-field--currentBlockCategory').select('Text'); |
119
|
|
|
cy.get('.sw-cms-preview-text').should('be.visible'); |
120
|
|
|
cy.get('.sw-cms-preview-text').dragTo('.sw-cms-section__empty-stage'); |
121
|
|
|
|
122
|
|
|
cy.get('.sw-cms-block__config-overlay').invoke('show'); |
123
|
|
|
cy.get('.sw-cms-block__config-overlay').should('be.visible'); |
124
|
|
|
cy.get('.sw-cms-block__config-overlay').click(); |
125
|
|
|
cy.get('.sw-cms-block__config-overlay.is--active').should('be.visible'); |
126
|
|
|
cy.get('.sw-cms-slot .sw-cms-slot__overlay').invoke('show'); |
127
|
|
|
|
128
|
|
|
// Replace text element with cross selling element |
129
|
|
|
cy.get('.sw-cms-slot .sw-cms-slot__element-action').click(); |
130
|
|
|
cy.get('.sw-cms-slot__element-selection').should('be.visible'); |
131
|
|
|
|
132
|
|
|
cy.get('.sw-cms-el-preview-cross-selling').click(); |
133
|
|
|
|
134
|
|
|
// Select a product with cross selling data |
135
|
|
|
cy.get('.sw-cms-slot .sw-cms-slot__settings-action').first().click(); |
136
|
|
|
cy.get('.sw-cms-el-config-cross-selling .sw-entity-single-select') |
137
|
|
|
.typeSingleSelectAndCheck('First product', '.sw-cms-el-config-cross-selling .sw-entity-single-select'); |
138
|
|
|
cy.get('.sw-cms-slot__config-modal .sw-button--primary').click(); |
139
|
|
|
|
140
|
|
|
// Save new page layout |
141
|
|
|
cy.get('.sw-cms-detail__save-action').click(); |
142
|
|
|
cy.wait('@saveData').then(() => { |
143
|
|
|
cy.get('.sw-cms-detail__back-btn').click(); |
|
|
|
|
144
|
|
|
}); |
145
|
|
|
|
146
|
|
|
// Assign layout to root category |
147
|
|
|
cy.visit(`${Cypress.env('admin')}#/sw/category/index`); |
148
|
|
|
cy.get('.sw-tree-item__element').contains('Home').click(); |
149
|
|
|
cy.get('.sw-card.sw-category-layout-card').scrollIntoView(); |
150
|
|
|
cy.get('.sw-category-detail-layout__change-layout-action').click(); |
151
|
|
|
cy.get('.sw-modal__dialog').should('be.visible'); |
152
|
|
|
cy.get('.sw-cms-layout-modal__content-item--0 .sw-field--checkbox').click(); |
153
|
|
|
cy.get('.sw-modal .sw-button--primary').click(); |
154
|
|
|
cy.get('.sw-card.sw-category-layout-card .sw-category-layout-card__desc-headline').contains('Vierte Wand'); |
155
|
|
|
cy.get('.sw-category-detail__save-action').click(); |
156
|
|
|
|
157
|
|
|
cy.wait('@saveCategory').then((response) => { |
158
|
|
|
expect(response).to.have.property('status', 204); |
159
|
|
|
}); |
160
|
|
|
|
161
|
|
|
// Verify layout in Storefront |
162
|
|
|
cy.visit('/'); |
163
|
|
|
cy.get('.product-cross-selling-tab-navigation') |
164
|
|
|
.scrollIntoView() |
165
|
|
|
.should('be.visible'); |
166
|
|
|
cy.get('.product-detail-tab-navigation-link.active').contains('You may like it'); |
167
|
|
|
cy.get('.product-slider-item .product-name[title="Second product"]') |
168
|
|
|
.should('be.visible'); |
169
|
|
|
cy.get('.product-slider-item .product-name[title="Third product"]') |
170
|
|
|
.should('be.visible'); |
171
|
|
|
}); |
172
|
|
|
}); |
173
|
|
|
}); |
174
|
|
|
|