Passed
Push — master ( 7e874c...f67e1e )
by Christian
14:45 queued 02:54
created

src/Administration/Resources/app/administration/test/e2e/cypress/integration/media-marketing/sw-promotion-v2/codes.spec.js   A

Complexity

Total Complexity 8
Complexity/F 1

Size

Lines of Code 42
Function Count 8

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 26
c 0
b 0
f 0
dl 0
loc 42
rs 10
wmc 8
mnd 0
bc 0
fnc 8
bpm 0
cpm 1
noi 7
1
/// <reference types="Cypress" />
2
3
const promotionCodeFixedSelector = '#sw-field--promotion-code';
4
5
describe('Promotion v2: Test crud operations', () => {
6
    before(() => {
7
        cy.onlyOnFeature('FEATURE_NEXT_12016');
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
    });
9
10
    beforeEach(() => {
11
        cy.setToInitialState().then(() => {
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
            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...
13
        }).then(() => {
14
            return cy.createDefaultFixture('promotion');
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...
15
        }).then(() => {
16
            cy.openInitialPage(`${Cypress.env('admin')}#/sw/promotion/v2/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...
17
        });
18
    });
19
20
    it('@base @marketing: generate and save a fixed promotion code', () => {
21
        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...
22
        cy.get('.sw-data-grid__cell--name > .sw-data-grid__cell-content > a').click();
23
24
        const testPromoCode = 'WelcomeIAmAPromotionCode';
25
26
        // Select fixed code type and edit manually
27
        cy.get(promotionCodeFixedSelector).should('not.be.visible');
28
        cy.get('#sw-field--selectedCodeType').select('Fixed promotion code');
29
        cy.get(promotionCodeFixedSelector).should('be.visible');
30
        cy.get(promotionCodeFixedSelector).type(testPromoCode);
31
32
        // Save
33
        cy.get('.sw-promotion-v2-detail__save-action').click();
34
        cy.get('.sw-loader').should('not.be.visible');
35
36
        // Generate and check code
37
        cy.get(promotionCodeFixedSelector).should('contain.value', testPromoCode);
38
        cy.get('.sw-promotion-v2-detail-base__button-generate-fixed').click();
39
        cy.get(promotionCodeFixedSelector).should('not.contain.value', testPromoCode);
40
        cy.get(promotionCodeFixedSelector).should((code) => {
41
            expect(code[0].value).to.have.length(8);
42
        });
43
    });
44
});
45