1
|
|
|
/// <reference types="Cypress" /> |
2
|
|
|
|
3
|
|
|
import ProductPageObject from '../../../support/pages/module/sw-product.page-object'; |
4
|
|
|
|
5
|
|
|
describe('Review: Test ACL privileges', () => { |
6
|
|
|
beforeEach(() => { |
7
|
|
|
cy.setToInitialState() |
|
|
|
|
8
|
|
|
.then(() => { |
9
|
|
|
cy.loginViaApi(); |
|
|
|
|
10
|
|
|
}) |
11
|
|
|
.then(() => { |
12
|
|
|
cy.openInitialPage(`${Cypress.env('admin')}#/sw/profile/index`); |
|
|
|
|
13
|
|
|
}); |
14
|
|
|
}); |
15
|
|
|
|
16
|
|
|
it('@general: has no access to sw-profile module', () => { |
17
|
|
|
cy.window().then((win) => { |
|
|
|
|
18
|
|
|
if (!win.Shopware.Feature.isActive('FEATURE_NEXT_3722')) { |
19
|
|
|
return; |
20
|
|
|
} |
21
|
|
|
|
22
|
|
|
cy.loginAsUserWithPermissions([ |
|
|
|
|
23
|
|
|
{ |
24
|
|
|
key: 'sales_channel', |
25
|
|
|
role: 'viewer' |
26
|
|
|
} |
27
|
|
|
]).then(() => { |
28
|
|
|
cy.openInitialPage(`${Cypress.env('admin')}#/sw/profile/index`); |
|
|
|
|
29
|
|
|
}); |
30
|
|
|
|
31
|
|
|
// open review without permissions |
32
|
|
|
cy.get('.sw-privilege-error__access-denied-image').should('be.visible'); |
33
|
|
|
cy.get('h1').contains('Access denied'); |
34
|
|
|
cy.get('.sw-review-list').should('not.exist'); |
35
|
|
|
|
36
|
|
|
// see menu without review menu item |
37
|
|
|
cy.get('.sw-admin-menu__user-actions-toggle').should('be.visible'); |
38
|
|
|
cy.get('.sw-admin-menu__profile-item').should('not.be.visible'); |
39
|
|
|
cy.get('.sw-admin-menu__user-actions-toggle').click(); |
40
|
|
|
cy.get('.sw-admin-menu__logout-action').should('be.visible'); |
41
|
|
|
cy.get('.sw-admin-menu__profile-item').should('not.be.visible'); |
42
|
|
|
}); |
43
|
|
|
}); |
44
|
|
|
|
45
|
|
|
it('@general: can edit own user', () => { |
46
|
|
|
cy.window().then((win) => { |
|
|
|
|
47
|
|
|
if (!win.Shopware.Feature.isActive('FEATURE_NEXT_3722')) { |
48
|
|
|
return; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
cy.loginAsUserWithPermissions([ |
|
|
|
|
52
|
|
|
{ |
53
|
|
|
key: 'user', |
54
|
|
|
role: 'update_profile' |
55
|
|
|
} |
56
|
|
|
]).then(() => { |
57
|
|
|
cy.openInitialPage(`${Cypress.env('admin')}#/sw/profile/index`); |
|
|
|
|
58
|
|
|
}); |
59
|
|
|
|
60
|
|
|
cy.get('#sw-field--email') |
61
|
|
|
.should('be.visible') |
62
|
|
|
.click() |
63
|
|
|
.clear() |
64
|
|
|
.type('[email protected]'); |
65
|
|
|
|
66
|
|
|
cy.get('.sw-profile__save-action') |
67
|
|
|
.should('be.visible') |
68
|
|
|
.click(); |
69
|
|
|
|
70
|
|
|
// expect modal to be open |
71
|
|
|
cy.get('.sw-modal') |
72
|
|
|
.should('be.visible'); |
73
|
|
|
cy.get('.sw-modal__title') |
74
|
|
|
.contains('Enter your current password to confirm'); |
75
|
|
|
|
76
|
|
|
cy.get('.sw-modal__footer > .sw-button--primary') |
77
|
|
|
.should('be.disabled'); |
78
|
|
|
|
79
|
|
|
cy.get('.sw-modal__body input[name="sw-field--confirm-password"]') |
80
|
|
|
.should('be.visible') |
81
|
|
|
.typeAndCheck('Passw0rd!'); |
82
|
|
|
|
83
|
|
|
cy.get('.sw-modal__footer > .sw-button--primary > .sw-button__content') |
84
|
|
|
.should('not.be.disabled') |
85
|
|
|
.click() |
86
|
|
|
.then(() => { |
87
|
|
|
cy.get('.sw-modal') |
|
|
|
|
88
|
|
|
.should('not.be.visible'); |
89
|
|
|
|
90
|
|
|
cy.get('#sw-field--email') |
91
|
|
|
.should('be.visible') |
92
|
|
|
.should('have.value', '[email protected]'); |
93
|
|
|
}); |
94
|
|
|
}); |
95
|
|
|
}); |
96
|
|
|
}); |
97
|
|
|
|
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.