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

functionnal_tests/cypress/integration/helpers/index.js   A

Complexity

Total Complexity 15
Complexity/F 1.15

Size

Lines of Code 111
Function Count 13

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 0
wmc 15
eloc 87
nc 1
mnd 1
bc 15
fnc 13
dl 0
loc 111
rs 10
bpm 1.1538
cpm 1.1538
noi 2
c 0
b 0
f 0

8 Functions

Rating   Name   Duplication   Size   Complexity  
A index.js ➔ create_thread 0 17 1
A index.js ➔ loginAsAdmin 0 7 1
A index.js ➔ delete_htmldocument 0 20 1
A index.js ➔ logout 0 4 1
A index.js ➔ create_file 0 2 1
A index.js ➔ create_htmldocument 0 24 1
A index.js ➔ delete_file 0 2 1
A index.js ➔ delete_thread 0 18 1
1
export function login (cy) {
2
  cy.visit('/login')
3
  cy.get('input[type=email]').should('be.visible')
4
  cy.get('input[type=email]').type('[email protected]')
5
  cy.get('input[type=password]').should('be.visible')
6
  cy.get('input[type=password]').type('[email protected]')
7
  cy.get('.connection__form__btnsubmit').should('be.visible')
8
  cy.get('.connection__form__btnsubmit').click()
9
}
10
11
export function logout (cy) {
12
  cy.get('#dropdownMenuButton.profilgroup__name.btn').click()
13
  cy.get('div.setting__link .fa-sign-out').click()
14
}
15
16
export function create_file (cy) {
0 ignored issues
show
Unused Code introduced by
The parameter cy is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
17
}
18
19
export function create_thread (cy) {
20
  cy.visit('/workspaces/1/dashboard')
21
  cy.get('.dashboard__workspace__detail').should('be.visible')
22
  cy.get('.dashboard__calltoaction .fa-comments-o').should('be.visible')
23
  cy.get('.dashboard__calltoaction .fa-comments-o').click()
24
  var titre1 = 'createthread'
25
  cy.get('.cardPopup__container .createcontent .createcontent__contentname').should('be.visible')
26
  cy.get('.cardPopup__container .createcontent .createcontent__form__input').should('have.attr', 'placeholder')
27
  cy.get('.cardPopup__container .createcontent .createcontent__form__input').type(titre1)
28
  cy.get('.cardPopup__container .createcontent .createcontent__form__input').should('have.attr', 'value', titre1)
29
  cy.get('.cardPopup__container .createcontent button.createcontent__form__button').click()
30
  cy.get('.cardPopup__container .createcontent  .createcontent__contentname').should('not.be.visible')
31
  cy.get('.thread.visible').should('be.visible')
32
  cy.get('.thread.visible .wsContentGeneric__header__title').contains(titre1)
33
  cy.get('.thread.visible .thread__contentpage__header__close').click()
34
  cy.get('.thread.visible').should('not.be.visible')
35
}
36
37
export function create_htmldocument (cy) {
38
  cy.visit('/workspaces/1/dashboard')
39
  cy.get('.dashboard__workspace__detail').should('be.visible')
40
  cy.get('.dashboard__calltoaction .fa-file-text-o').should('be.visible')
41
  cy.get('.dashboard__calltoaction .fa-file-text-o').click()
42
  var titre1 = 'createhtml-document'
43
  cy.get('.cardPopup__container .createcontent .createcontent__contentname').should('be.visible')
44
  cy.get('.cardPopup__container .createcontent .createcontent__form__input').should('have.attr', 'placeholder')
45
  cy.get('.cardPopup__container .createcontent .createcontent__form__input').type(titre1)
46
  cy.get('.cardPopup__container .createcontent .createcontent__form__input').should('have.attr', 'value', titre1)
47
  cy.get('.cardPopup__container .createcontent .createcontent__form__button.btn-primary').click()
48
  cy.get('.cardPopup__container .createcontent .createcontent__contentname').should('not.be.visible')
49
  cy.get('.html-document.visible').should('be.visible')
50
  cy.get('.html-document.visible .html-document__contentpage__messagelist__version.revision').should('be.visible')
51
  cy.get('.html-document.visible .wsContentGeneric__header__title').contains(titre1)
52
  //        cy.get('iframe#wysiwygNewVersion_ifr').should('be.visible')
53
  //        const $tinymce = Cypress.$.event(document)
54
  cy.wait(2000)
55
  cy.get('.html-document.visible .wsContentGeneric__header__close.html-document__header__close').should('be.visible')
56
  cy.get('.html-document.visible .wsContentGeneric__header__close.html-document__header__close').click()
57
  cy.get('.html-document.visible').should('not.be.visible')
58
  cy.wait(2000)
59
  cy.get('.content__name').contains(titre1).should('be.visible')
60
}
61
62
export function delete_file (cy) {
0 ignored issues
show
Unused Code introduced by
The parameter cy is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
63
}
64
65
export function delete_thread (cy) {
66
  cy.visit('/workspaces/1/contents')
67
  cy.get('.pageTitleGeneric__title__icon').should('be.visible')
68
  var titre1 = 'createthread'
69
  cy.get('.content__name').each(($elm) => {
70
    cy.wrap($elm).invoke('text').then((text) => {
71
      if (text === titre1) {
72
        cy.get('.content__name').contains(titre1).click()
73
        cy.get('.thread.visible').should('be.visible')
74
        cy.get('.thread.visible .wsContentGeneric__header__title').contains(titre1)
75
        cy.get('.thread.visible .align-items-center button:nth-child(2)').click()
76
        cy.get('.thread.visible .timeline__info__btnrestore').should('be.visible')
77
        cy.get('.thread.visible .thread__contentpage__header__close').click()
78
        cy.get('.thread.visible').should('not.be.visible')
79
      }
80
    })
81
  })
82
}
83
84
export function delete_htmldocument (cy) {
85
  cy.visit('/workspaces/1/contents')
86
  cy.get('.pageTitleGeneric__title__icon').should('be.visible')
87
  var titre1 = 'createhtml-document'
88
  cy.get('.content__name').each(($elm) => {
89
    cy.wrap($elm).invoke('text').then((text) => {
90
      if (text === titre1) {
91
        cy.get('.content__name').contains(titre1).click()
92
        cy.get('.html-document.visible').should('be.visible')
93
        cy.get('.html-document.visible .wsContentGeneric__header__title').contains(titre1)
94
        cy.wait(2000)
95
        cy.get('.align-items-center button:nth-child(2)').click()
96
        cy.get('.html-document__contentpage__textnote__state__btnrestore').should('be.visible')
97
        cy.get('.html-document__header__close').click()
98
        cy.get('.html-document.visible').should('not.be.visible')
99
        cy.wait(2000)
100
      }
101
    })
102
  })
103
}
104
105
export function loginAsAdmin (cy) {
106
  var body = {
107
    'email': '[email protected]',
108
    'password': '[email protected]'
109
  }
110
  cy.request('POST', '/api/v2/sessions/login', body)
111
}
112