Passed
Push — develop ( acc51d...b423f4 )
by Bastien
01:55
created

functionnal_tests/cypress/support/commands.js   A

Complexity

Total Complexity 15
Complexity/F 1.15

Size

Lines of Code 113
Function Count 13

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 0
wmc 15
eloc 87
nc 1
mnd 1
bc 14
fnc 13
dl 0
loc 113
rs 10
bpm 1.0769
cpm 1.1538
noi 12
c 1
b 0
f 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A commands.js ➔ ??? 0 2 1
1
let LOGIN_URL = '/api/v2/auth/login'
2
3
Cypress.Commands.add('create_file', () => {
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...
4
})
5
6
Cypress.Commands.add('create_thread', () => {
7
  cy.visit('/ui/workspaces/1/dashboard')
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
  cy.get('.dashboard__workspace__detail').should('be.visible')
9
  cy.get('.dashboard__calltoaction .fa-comments-o').should('be.visible')
10
  cy.get('.dashboard__calltoaction .fa-comments-o').click()
11
  var titre1 = 'createthread'
12
  cy.get('.cardPopup__container .createcontent .createcontent__contentname').should('be.visible')
13
  cy.get('.cardPopup__container .createcontent .createcontent__form__input').should('have.attr', 'placeholder')
14
  cy.get('.cardPopup__container .createcontent .createcontent__form__input').type(titre1)
15
  cy.get('.cardPopup__container .createcontent .createcontent__form__input').should('have.attr', 'value', titre1)
16
  cy.get('.cardPopup__container .createcontent button.createcontent__form__button').click()
17
  cy.get('.cardPopup__container .createcontent  .createcontent__contentname').should('not.be.visible')
18
  cy.get('.thread.visible').should('be.visible')
19
  cy.get('.thread.visible .wsContentGeneric__header__title').contains(titre1)
20
  cy.get('.thread.visible .thread__contentpage__header__close').click()
21
  cy.get('.thread.visible').should('not.be.visible')
22
})
23
24
Cypress.Commands.add('create_htmldocument', () => {
25
  cy.visit('/ui/workspaces/1/dashboard')
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...
26
  cy.get('.dashboard__workspace__detail').should('be.visible')
27
  cy.get('.dashboard__calltoaction .fa-file-text-o').should('be.visible')
28
  cy.get('.dashboard__calltoaction .fa-file-text-o').click()
29
  var titre1 = 'createhtml-document'
30
  cy.get('.cardPopup__container .createcontent .createcontent__contentname').should('be.visible')
31
  cy.get('.cardPopup__container .createcontent .createcontent__form__input').should('have.attr', 'placeholder')
32
  cy.get('.cardPopup__container .createcontent .createcontent__form__input').type(titre1)
33
  cy.get('.cardPopup__container .createcontent .createcontent__form__input').should('have.attr', 'value', titre1)
34
  cy.get('.cardPopup__container .createcontent .createcontent__form__button.btn-primary').click()
35
  cy.get('.cardPopup__container .createcontent .createcontent__contentname').should('not.be.visible')
36
  cy.get('.html-document.visible').should('be.visible')
37
  cy.get('.html-document.visible .html-document__contentpage__messagelist__version.revision').should('be.visible')
38
  cy.get('.html-document.visible .wsContentGeneric__header__title').contains(titre1)
39
  //        cy.get('iframe#wysiwygNewVersion_ifr').should('be.visible')
40
  //        const $tinymce = Cypress.$.event(document)
41
  cy.wait(2000)
42
  cy.get('.html-document.visible .wsContentGeneric__header__close.html-document__header__close').should('be.visible')
43
  cy.get('.html-document.visible .wsContentGeneric__header__close.html-document__header__close').click()
44
  cy.get('.html-document.visible').should('not.be.visible')
45
  cy.wait(2000)
46
  cy.get('.content__name').contains(titre1).should('be.visible')
47
})
48
49
Cypress.Commands.add('delete_file', () => {
50
})
51
52
Cypress.Commands.add('delete_thread', () => {
53
  cy.visit('/ui/workspaces/1/contents')
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...
54
  cy.get('.pageTitleGeneric__title__icon').should('be.visible')
55
  var titre1 = 'createthread'
56
  cy.get('.content__name').each(($elm) => {
57
    cy.wrap($elm).invoke('text').then((text) => {
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...
58
      if (text === titre1) {
59
        cy.get('.content__name').contains(titre1).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...
60
        cy.get('.thread.visible').should('be.visible')
61
        cy.get('.thread.visible .wsContentGeneric__header__title').contains(titre1)
62
        cy.get('.thread.visible .align-items-center button:nth-child(2)').click()
63
        cy.get('.thread.visible .timeline__info__btnrestore').should('be.visible')
64
        cy.get('.thread.visible .thread__contentpage__header__close').click()
65
        cy.get('.thread.visible').should('not.be.visible')
66
      }
67
    })
68
  })
69
})
70
71
Cypress.Commands.add('delete_htmldocument', () => {
72
  cy.visit('/ui/workspaces/1/contents')
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...
73
  cy.get('.pageTitleGeneric__title__icon').should('be.visible')
74
  var titre1 = 'createhtml-document'
75
  cy.get('.content__name').each(($elm) => {
76
    cy.wrap($elm).invoke('text').then((text) => {
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...
77
      if (text === titre1) {
78
        cy.get('.content__name').contains(titre1).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...
79
        cy.get('.html-document.visible').should('be.visible')
80
        cy.get('.html-document.visible .wsContentGeneric__header__title').contains(titre1)
81
        cy.wait(2000)
82
        cy.get('.align-items-center button:nth-child(2)').click()
83
        cy.get('.html-document__contentpage__textnote__state__btnrestore').should('be.visible')
84
        cy.get('.html-document__header__close').click()
85
        cy.get('.html-document.visible').should('not.be.visible')
86
        cy.wait(2000)
87
      }
88
    })
89
  })
90
})
91
92
Cypress.Commands.add('login', (role = 'administrators') => {
93
  const userFixtures = {
94
    'administrators': 'defaultAdmin',
95
    'trusted-users': '',
96
    'users': 'baseUser'
97
  }
98
99
  return cy
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...
100
    .fixture(userFixtures[role])
101
    .then(userJSON => cy.request({
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...
102
      method: 'POST',
103
      url: LOGIN_URL,
104
      body: {
105
        'email': userJSON.email,
106
        'password': userJSON.password
107
      }
108
    }))
109
})
110
111
Cypress.Commands.add('logout', () => {
112
  cy.request('POST', 'api/v2/auth/logout')
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...
113
})
114