Passed
Push — master ( 4af871...65c09b )
by Christian
23:24 queued 11:17
created

src/Administration/Resources/app/administration/test/e2e/cypress/integration/settings/sw-integration/acl.spec.js   A

Complexity

Total Complexity 21
Complexity/F 1.24

Size

Lines of Code 229
Function Count 17

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 21
eloc 135
mnd 4
bc 4
fnc 17
dl 0
loc 229
rs 10
bpm 0.2352
cpm 1.2352
noi 12
c 0
b 0
f 0
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()
0 ignored issues
show
Bug introduced by
The variable cy seems to be never declared. If this is a global, consider adding a /** global: cy */ comment.

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.

Loading history...
8
            .then(() => {
9
                cy.loginViaApi();
0 ignored issues
show
Bug introduced by
The variable cy seems to be never declared. If this is a global, consider adding a /** global: cy */ comment.

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.

Loading history...
10
            })
11
            .then(() => {
12
                cy.openInitialPage(`${Cypress.env('admin')}#/sw/dashboard/index`);
0 ignored issues
show
Bug introduced by
The variable Cypress seems to be never declared. If this is a global, consider adding a /** global: Cypress */ comment.

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.

Loading history...
Bug introduced by
The variable cy seems to be never declared. If this is a global, consider adding a /** global: cy */ comment.

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.

Loading history...
13
            });
14
    });
15
16
    it('@settings: can view a list of integration', () => {
17
        cy.window().then((win) => {
0 ignored issues
show
Bug introduced by
The variable cy seems to be never declared. If this is a global, consider adding a /** global: cy */ comment.

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.

Loading history...
18
            if (!win.Shopware.Feature.isActive('FEATURE_NEXT_3722')) {
19
                return;
20
            }
21
22
            const page = new SettingsPageObject();
23
24
            cy.loginAsUserWithPermissions([
0 ignored issues
show
Bug introduced by
The variable cy seems to be never declared. If this is a global, consider adding a /** global: cy */ comment.

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.

Loading history...
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) => {
0 ignored issues
show
Bug introduced by
The variable cy seems to be never declared. If this is a global, consider adding a /** global: cy */ comment.

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.

Loading history...
43
            if (!win.Shopware.Feature.isActive('FEATURE_NEXT_3722')) {
44
                return;
45
            }
46
47
            cy.loginAsUserWithPermissions([
0 ignored issues
show
Bug introduced by
The variable cy seems to be never declared. If this is a global, consider adding a /** global: cy */ comment.

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.

Loading history...
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) => {
0 ignored issues
show
Bug introduced by
The variable cy seems to be never declared. If this is a global, consider adding a /** global: cy */ comment.

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.

Loading history...
92
            if (!win.Shopware.Feature.isActive('FEATURE_NEXT_3722')) {
93
                return;
94
            }
95
96
            const page = new SettingsPageObject();
97
98
            cy.loginAsUserWithPermissions([
0 ignored issues
show
Bug introduced by
The variable cy seems to be never declared. If this is a global, consider adding a /** global: cy */ comment.

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.

Loading history...
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) => {
0 ignored issues
show
Bug introduced by
The variable cy seems to be never declared. If this is a global, consider adding a /** global: cy */ comment.

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.

Loading history...
166
            if (!win.Shopware.Feature.isActive('FEATURE_NEXT_3722')) {
167
                return;
168
            }
169
170
            const page = new SettingsPageObject();
171
172
            cy.loginAsUserWithPermissions([
0 ignored issues
show
Bug introduced by
The variable cy seems to be never declared. If this is a global, consider adding a /** global: cy */ comment.

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.

Loading history...
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