Passed
Push — master ( 8dcbad...e6bdec )
by Christian
12:34 queued 12s
created

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

Complexity

Total Complexity 13
Complexity/F 1.18

Size

Lines of Code 94
Function Count 11

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 62
c 0
b 0
f 0
dl 0
loc 94
rs 10
wmc 13
mnd 2
bc 2
fnc 11
bpm 0.1818
cpm 1.1818
noi 13
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()
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/profile/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('@general: has no access to sw-profile module', () => {
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
            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...
23
                {
24
                    key: 'sales_channel',
25
                    role: 'viewer'
26
                }
27
            ]).then(() => {
28
                cy.openInitialPage(`${Cypress.env('admin')}#/sw/profile/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...
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) => {
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...
47
            if (!win.Shopware.Feature.isActive('FEATURE_NEXT_3722')) {
48
                return;
49
            }
50
51
            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...
52
                {
53
                    key: 'user',
54
                    role: 'update_profile'
55
                }
56
            ]).then(() => {
57
                cy.openInitialPage(`${Cypress.env('admin')}#/sw/profile/index`);
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...
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...
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')
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...
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