Passed
Push — master ( 6c0bd9...a700df )
by Christian
12:08 queued 43s
created

src/Administration/Resources/app/administration/test/e2e/cypress/integration/content/sw-cms/gdpr-compliant-video-elements.spec.js   A

Complexity

Total Complexity 10
Complexity/F 1

Size

Lines of Code 121
Function Count 10

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 81
c 0
b 0
f 0
dl 0
loc 121
rs 10
wmc 10
mnd 0
bc 0
fnc 10
bpm 0
cpm 1
noi 9
1
const platforms = [{
2
    name: 'youtube',
3
    videoId: 'https://www.youtube.com/watch?v=Ds7c_AKSk7s'
4
}, {
5
    name: 'vimeo',
6
    videoId: 'https://vimeo.com/68765485'
7
}];
8
9
describe('CMS: Check GDPR compliant video elements', () => {
10
    beforeEach(() => {
11
        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...
12
            .then(() => {
13
                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...
14
            })
15
            .then(() => {
16
                return cy.createCmsFixture();
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...
17
            })
18
            .then(() => {
19
                cy.viewport(1920, 1080);
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...
20
                cy.openInitialPage(`${Cypress.env('admin')}#/sw/cms/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...
21
            });
22
    });
23
24
    platforms.forEach(({ name, videoId }) => {
25
        it(`use ${name} element with GDPR compliant options`, () => {
26
            cy.server();
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...
27
            cy.route({
28
                url: `${Cypress.env('apiPath')}/cms-page/*`,
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...
29
                method: 'patch'
30
            }).as('saveData');
31
32
            cy.route({
33
                url: `${Cypress.env('apiPath')}/category/*`,
34
                method: 'patch'
35
            }).as('saveCategory');
36
37
            cy.get('.sw-cms-list-item--0').click();
38
            cy.get('.sw-cms-section__empty-stage').should('be.visible');
39
40
            // Add simple image block
41
            cy.get('.sw-cms-section__empty-stage').click();
42
            cy.get('#sw-field--currentBlockCategory').select('Video');
43
            cy.get(`.sw-cms-preview-${name}-video`).should('be.visible');
44
            cy.get(`.sw-cms-preview-${name}-video`).closest('.sw-cms-sidebar__block-preview')
45
                .dragTo('.sw-cms-section__empty-stage');
46
            cy.get('.sw-cms-block').should('be.visible');
47
            cy.get('.sw-cms-block__config-overlay').invoke('show');
48
            cy.get('.sw-cms-block__config-overlay').should('be.visible');
49
            cy.get('.sw-cms-block__config-overlay').click();
50
            cy.get('.sw-cms-block__config-overlay.is--active').should('be.visible');
51
            cy.get('.sw-cms-slot .sw-cms-slot__overlay').invoke('show');
52
            cy.get('.sw-cms-slot .sw-cms-slot__settings-action').click();
53
            cy.get('.sw-cms-slot__config-modal').should('be.visible');
54
55
            // Fill out config modal form
56
            cy.get('input[name="sw-field--videoID"]').type(videoId);
57
            cy.get(`.sw-cms-el-config-${name}-video__confirmation label`).click();
58
59
            // Upload preview image
60
            cy.get('.sw-media-upload-v2__dropzone.is--droppable').should('be.visible');
61
            cy.fixture('img/sw-login-background.png').then(fileContent => {
62
                cy.get('.sw-cms-slot__config-modal #files').upload(
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...
63
                    {
64
                        fileContent,
65
                        fileName: 'sw-login-background.png',
66
                        mimeType: 'image/png'
67
                    }, {
68
                        subjectType: 'input'
69
                    }
70
                );
71
            });
72
            cy.awaitAndCheckNotification('File has been saved.');
73
74
            // Close config modal
75
            cy.get('.sw-cms-slot__config-modal .sw-modal__footer .sw-button--primary').click();
76
77
            // Save new page layout
78
            cy.get('.sw-cms-detail__save-action').click();
79
            cy.wait('@saveData').then(() => {
80
                cy.get('.sw-cms-detail__back-btn').click();
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...
81
            });
82
83
            // Assign layout to root category
84
            cy.visit(`${Cypress.env('admin')}#/sw/category/index`);
85
            cy.get('.sw-tree-item__element').contains('Home').click();
86
            cy.get('.sw-card.sw-category-layout-card').scrollIntoView();
87
            cy.get('.sw-category-detail-layout__change-layout-action').click();
88
            cy.get('.sw-modal__dialog').should('be.visible');
89
            cy.get('.sw-cms-layout-modal__content-item--0 .sw-field--checkbox').click();
90
            cy.get('.sw-modal .sw-button--primary').click();
91
            cy.get('.sw-card.sw-category-layout-card .sw-cms-list-item__title').contains('Vierte Wand');
92
            cy.get('.sw-category-detail__save-action').click();
93
94
            cy.wait('@saveCategory').then((response) => {
95
                expect(response).to.have.property('status', 204);
96
            });
97
98
            // Verify layout in Storefront
99
            cy.visit('/');
100
101
            cy.get(`.cms-element-${name}-video__backdrop`).should('be.visible');
102
103
            // Check the privacy notice modal
104
            cy.get(`.cms-element-${name}-video__backdrop a[data-toggle="modal"]`).click();
105
            cy.get('.js-pseudo-modal .modal').should('exist');
106
            cy.get('.js-pseudo-modal .modal .cms-element-text h2').contains('Privacy');
107
108
            cy.get('.js-pseudo-modal').invoke('hide');
109
            cy.get('.modal-backdrop').invoke('hide');
110
111
            // Click agree button
112
            cy.get(`.cms-element-${name}-video__backdrop .btn-outline-secondary`)
113
                .contains('Accept')
114
                .click();
115
116
            // Check if the video iframe will be displayed
117
            cy.get(`.cms-element-${name}-video__backdrop`).should('not.exist');
118
            cy.get(`.cms-element-${name}-video__video`).should('exist');
119
        });
120
    });
121
});
122