1
|
|
|
// / <reference types="Cypress" /> |
2
|
|
|
|
3
|
|
|
import SettingsPageObject from '../../../support/pages/module/sw-settings.page-object'; |
4
|
|
|
|
5
|
|
|
describe('Integration: Test acl privileges', () => { |
6
|
|
|
beforeEach(() => { |
7
|
|
|
cy.setToInitialState() |
|
|
|
|
8
|
|
|
.then(() => { |
9
|
|
|
cy.loginViaApi(); |
|
|
|
|
10
|
|
|
}) |
11
|
|
|
.then(() => { |
12
|
|
|
cy.openInitialPage(`${Cypress.env('admin')}#/sw/dashboard/index`); |
|
|
|
|
13
|
|
|
}); |
14
|
|
|
}); |
15
|
|
|
|
16
|
|
|
it('@settings: can view a list of integration', () => { |
17
|
|
|
cy.window().then((win) => { |
|
|
|
|
18
|
|
|
if (!win.Shopware.Feature.isActive('FEATURE_NEXT_3722')) { |
19
|
|
|
return; |
20
|
|
|
} |
21
|
|
|
|
22
|
|
|
const page = new SettingsPageObject(); |
23
|
|
|
|
24
|
|
|
cy.loginAsUserWithPermissions([ |
|
|
|
|
25
|
|
|
{ |
26
|
|
|
key: 'integration', |
27
|
|
|
role: 'viewer' |
28
|
|
|
} |
29
|
|
|
]); |
30
|
|
|
|
31
|
|
|
// go to integration module |
32
|
|
|
cy.get('.sw-admin-menu__item--sw-settings').click(); |
33
|
|
|
cy.get('.sw-settings__tab-system').click(); |
34
|
|
|
cy.get('#sw-integration').click(); |
35
|
|
|
|
36
|
|
|
// assert that there is an available list of integration |
37
|
|
|
cy.get(`${page.elements.integrationListConent}`).should('be.visible'); |
38
|
|
|
}); |
39
|
|
|
}); |
40
|
|
|
|
41
|
|
|
it('@settings: can create a integration', () => { |
42
|
|
|
cy.window().then((win) => { |
|
|
|
|
43
|
|
|
if (!win.Shopware.Feature.isActive('FEATURE_NEXT_3722')) { |
44
|
|
|
return; |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
cy.loginAsUserWithPermissions([ |
|
|
|
|
48
|
|
|
{ |
49
|
|
|
key: 'integration', |
50
|
|
|
role: 'viewer' |
51
|
|
|
}, |
52
|
|
|
{ |
53
|
|
|
key: 'integration', |
54
|
|
|
role: 'creator' |
55
|
|
|
} |
56
|
|
|
]); |
57
|
|
|
|
58
|
|
|
// Request we want to wait for later |
59
|
|
|
cy.server(); |
60
|
|
|
cy.route({ |
61
|
|
|
url: '/api/v*/integration', |
62
|
|
|
method: 'post' |
63
|
|
|
}).as('createIntegration'); |
64
|
|
|
|
65
|
|
|
// go to integration module |
66
|
|
|
cy.get('.sw-admin-menu__item--sw-settings').click(); |
67
|
|
|
cy.get('.sw-settings__tab-system').click(); |
68
|
|
|
cy.get('#sw-integration').click(); |
69
|
|
|
|
70
|
|
|
// go to create page |
71
|
|
|
cy.get('.sw-integration-list__add-integration-action').click(); |
72
|
|
|
|
73
|
|
|
// clear old data and type another one in name field |
74
|
|
|
cy.get('#sw-field--currentIntegration-label') |
75
|
|
|
.clear() |
76
|
|
|
.type('chat-key'); |
77
|
|
|
cy.get('.sw-field__checkbox input[type="checkbox"]').check(); |
78
|
|
|
|
79
|
|
|
cy.get('.sw-integration-detail-modal__save-action').click(); |
80
|
|
|
|
81
|
|
|
// Verify create a integration |
82
|
|
|
cy.wait('@createIntegration').then((xhr) => { |
83
|
|
|
expect(xhr).to.have.property('status', 204); |
84
|
|
|
}); |
85
|
|
|
|
86
|
|
|
cy.get('.sw-data-grid__cell-content a[href="#"]').contains('chat-key'); |
87
|
|
|
}); |
88
|
|
|
}); |
89
|
|
|
|
90
|
|
|
it('@settings: can edit a integration', () => { |
91
|
|
|
cy.window().then((win) => { |
|
|
|
|
92
|
|
|
if (!win.Shopware.Feature.isActive('FEATURE_NEXT_3722')) { |
93
|
|
|
return; |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
const page = new SettingsPageObject(); |
97
|
|
|
|
98
|
|
|
cy.loginAsUserWithPermissions([ |
|
|
|
|
99
|
|
|
{ |
100
|
|
|
key: 'integration', |
101
|
|
|
role: 'viewer' |
102
|
|
|
}, |
103
|
|
|
{ |
104
|
|
|
key: 'integration', |
105
|
|
|
role: 'creator' |
106
|
|
|
}, |
107
|
|
|
{ |
108
|
|
|
key: 'integration', |
109
|
|
|
role: 'editor' |
110
|
|
|
} |
111
|
|
|
]); |
112
|
|
|
|
113
|
|
|
// Request we want to wait for later |
114
|
|
|
cy.server(); |
115
|
|
|
cy.route({ |
116
|
|
|
url: '/api/v*/integration', |
117
|
|
|
method: 'post' |
118
|
|
|
}).as('createIntegration'); |
119
|
|
|
cy.route({ |
120
|
|
|
url: '/api/v*/integration/*', |
121
|
|
|
method: 'patch' |
122
|
|
|
}).as('editIntegration'); |
123
|
|
|
|
124
|
|
|
// go to integration module |
125
|
|
|
cy.get('.sw-admin-menu__item--sw-settings').click(); |
126
|
|
|
cy.get('.sw-settings__tab-system').click(); |
127
|
|
|
cy.get('#sw-integration').click(); |
128
|
|
|
|
129
|
|
|
// go to create page |
130
|
|
|
cy.get('.sw-integration-list__add-integration-action').click(); |
131
|
|
|
|
132
|
|
|
// clear old data and type another one in name field |
133
|
|
|
cy.get('#sw-field--currentIntegration-label') |
134
|
|
|
.clear() |
135
|
|
|
.type('chat-key'); |
136
|
|
|
cy.get('.sw-field__checkbox input[type="checkbox"]').check(); |
137
|
|
|
|
138
|
|
|
cy.get('.sw-integration-detail-modal__save-action').click(); |
139
|
|
|
|
140
|
|
|
// Verify create a integration |
141
|
|
|
cy.wait('@createIntegration').then((xhr) => { |
142
|
|
|
expect(xhr).to.have.property('status', 204); |
143
|
|
|
}); |
144
|
|
|
|
145
|
|
|
// click on the first element in grid |
146
|
|
|
cy.get(`${page.elements.dataGridRow}--0`).contains('chat-key').click(); |
147
|
|
|
|
148
|
|
|
cy.get('#sw-field--currentIntegration-label') |
149
|
|
|
.clear() |
150
|
|
|
.type('chat-key-edited'); |
151
|
|
|
|
152
|
|
|
cy.get('.sw-button--danger').click(); |
153
|
|
|
|
154
|
|
|
cy.get('.sw-integration-detail-modal__save-action').click(); |
155
|
|
|
|
156
|
|
|
// Verify edit a integration |
157
|
|
|
cy.wait('@editIntegration').then((xhr) => { |
158
|
|
|
expect(xhr).to.have.property('status', 204); |
159
|
|
|
}); |
160
|
|
|
cy.get('.sw-data-grid__cell-content a[href="#"]').contains('chat-key-edited'); |
161
|
|
|
}); |
162
|
|
|
}); |
163
|
|
|
|
164
|
|
|
it('@settings: can delete a integration', () => { |
165
|
|
|
cy.window().then((win) => { |
|
|
|
|
166
|
|
|
if (!win.Shopware.Feature.isActive('FEATURE_NEXT_3722')) { |
167
|
|
|
return; |
168
|
|
|
} |
169
|
|
|
|
170
|
|
|
const page = new SettingsPageObject(); |
171
|
|
|
|
172
|
|
|
cy.loginAsUserWithPermissions([ |
|
|
|
|
173
|
|
|
{ |
174
|
|
|
key: 'integration', |
175
|
|
|
role: 'viewer' |
176
|
|
|
}, |
177
|
|
|
{ |
178
|
|
|
key: 'integration', |
179
|
|
|
role: 'creator' |
180
|
|
|
}, |
181
|
|
|
{ |
182
|
|
|
key: 'integration', |
183
|
|
|
role: 'deleter' |
184
|
|
|
} |
185
|
|
|
]); |
186
|
|
|
|
187
|
|
|
// Request we want to wait for later |
188
|
|
|
cy.server(); |
189
|
|
|
cy.route({ |
190
|
|
|
url: '/api/v*/integration', |
191
|
|
|
method: 'post' |
192
|
|
|
}).as('createIntegration'); |
193
|
|
|
cy.route({ |
194
|
|
|
url: '/api/v*/integration/*', |
195
|
|
|
method: 'delete' |
196
|
|
|
}).as('deleteIntegration'); |
197
|
|
|
|
198
|
|
|
// go to integration module |
199
|
|
|
cy.get('.sw-admin-menu__item--sw-settings').click(); |
200
|
|
|
cy.get('.sw-settings__tab-system').click(); |
201
|
|
|
cy.get('#sw-integration').click(); |
202
|
|
|
|
203
|
|
|
// go to create page |
204
|
|
|
cy.get('.sw-integration-list__add-integration-action').click(); |
205
|
|
|
|
206
|
|
|
// clear old data and type another one in name field |
207
|
|
|
cy.get('#sw-field--currentIntegration-label') |
208
|
|
|
.clear() |
209
|
|
|
.type('chat-key'); |
210
|
|
|
cy.get('.sw-field__checkbox input[type="checkbox"]').check(); |
211
|
|
|
|
212
|
|
|
cy.get('.sw-integration-detail-modal__save-action').click(); |
213
|
|
|
|
214
|
|
|
// Verify create a integration |
215
|
|
|
cy.wait('@createIntegration').then((xhr) => { |
216
|
|
|
expect(xhr).to.have.property('status', 204); |
217
|
|
|
}); |
218
|
|
|
cy.clickContextMenuItem( |
219
|
|
|
`${page.elements.contextMenu}-item--danger`, |
220
|
|
|
page.elements.contextMenuButton, |
221
|
|
|
`${page.elements.dataGridRow}--0` |
222
|
|
|
); |
223
|
|
|
|
224
|
|
|
cy.get('.sw-button--primary.sw-button--small span.sw-button__content').contains('Delete').click(); |
225
|
|
|
// Verify delete a integration |
226
|
|
|
cy.wait('@deleteIntegration').then((xhr) => { |
227
|
|
|
expect(xhr).to.have.property('status', 204); |
228
|
|
|
}); |
229
|
|
|
}); |
230
|
|
|
}); |
231
|
|
|
}); |
232
|
|
|
|
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.
To learn more about declaring variables in Javascript, see the MDN.