1
|
|
|
// / <reference types="Cypress" /> |
2
|
|
|
|
3
|
|
|
import SettingsPageObject from '../../../support/pages/module/sw-settings.page-object'; |
4
|
|
|
|
5
|
|
|
describe('Integration: crud integrations', () => { |
6
|
|
|
beforeEach(() => { |
7
|
|
|
cy.setToInitialState() |
|
|
|
|
8
|
|
|
.then(() => { |
9
|
|
|
cy.loginViaApi(); |
|
|
|
|
10
|
|
|
}) |
11
|
|
|
.then(() => { |
12
|
|
|
cy.openInitialPage(`${Cypress.env('admin')}#/sw/dashboard/index`); |
|
|
|
|
13
|
|
|
}); |
14
|
|
|
}); |
15
|
|
|
|
16
|
|
|
it('@settings: can create a new integration', () => { |
17
|
|
|
// Request we want to wait for later |
18
|
|
|
cy.server(); |
|
|
|
|
19
|
|
|
cy.route({ |
20
|
|
|
url: '/api/v*/integration', |
21
|
|
|
method: 'post' |
22
|
|
|
}).as('createIntegration'); |
23
|
|
|
|
24
|
|
|
// go to integration module |
25
|
|
|
cy.get('.sw-admin-menu__item--sw-settings').click(); |
26
|
|
|
cy.get('.sw-settings__tab-system').click(); |
27
|
|
|
cy.get('#sw-integration').click(); |
28
|
|
|
|
29
|
|
|
// go to create page |
30
|
|
|
cy.get('.sw-integration-list__add-integration-action').click(); |
31
|
|
|
|
32
|
|
|
// clear old data and type another one in name field |
33
|
|
|
cy.get('#sw-field--currentIntegration-label') |
34
|
|
|
.clear() |
35
|
|
|
.type('chat-key'); |
36
|
|
|
cy.get('.sw-field__checkbox input[type="checkbox"]').check(); |
37
|
|
|
|
38
|
|
|
cy.get('.sw-integration-detail-modal__save-action').click(); |
39
|
|
|
|
40
|
|
|
// Verify create a integration |
41
|
|
|
cy.wait('@createIntegration').then((xhr) => { |
42
|
|
|
expect(xhr).to.have.property('status', 204); |
43
|
|
|
}); |
44
|
|
|
|
45
|
|
|
cy.get('.sw-data-grid__cell-content a[href="#"]').contains('chat-key'); |
46
|
|
|
}); |
47
|
|
|
|
48
|
|
|
it('@settings: can edit a integration', () => { |
49
|
|
|
const page = new SettingsPageObject(); |
50
|
|
|
// Request we want to wait for later |
51
|
|
|
cy.server(); |
|
|
|
|
52
|
|
|
cy.route({ |
53
|
|
|
url: '/api/v*/integration', |
54
|
|
|
method: 'post' |
55
|
|
|
}).as('createIntegration'); |
56
|
|
|
cy.route({ |
57
|
|
|
url: '/api/v*/integration/*', |
58
|
|
|
method: 'patch' |
59
|
|
|
}).as('editIntegration'); |
60
|
|
|
|
61
|
|
|
// go to integration module |
62
|
|
|
cy.get('.sw-admin-menu__item--sw-settings').click(); |
63
|
|
|
cy.get('.sw-settings__tab-system').click(); |
64
|
|
|
cy.get('#sw-integration').click(); |
65
|
|
|
|
66
|
|
|
// go to create page |
67
|
|
|
cy.get('.sw-integration-list__add-integration-action').click(); |
68
|
|
|
|
69
|
|
|
// clear old data and type another one in name field |
70
|
|
|
cy.get('#sw-field--currentIntegration-label') |
71
|
|
|
.clear() |
72
|
|
|
.type('chat-key'); |
73
|
|
|
cy.get('.sw-field__checkbox input[type="checkbox"]').check(); |
74
|
|
|
|
75
|
|
|
cy.get('.sw-integration-detail-modal__save-action').click(); |
76
|
|
|
|
77
|
|
|
// Verify create a integration |
78
|
|
|
cy.wait('@createIntegration').then((xhr) => { |
79
|
|
|
expect(xhr).to.have.property('status', 204); |
80
|
|
|
}); |
81
|
|
|
|
82
|
|
|
// click on the first element in grid |
83
|
|
|
cy.get(`${page.elements.dataGridRow}--0`).contains('chat-key').click(); |
84
|
|
|
|
85
|
|
|
cy.get('#sw-field--currentIntegration-label') |
86
|
|
|
.clear() |
87
|
|
|
.type('chat-key-edited'); |
88
|
|
|
|
89
|
|
|
cy.get('.sw-button--danger').click(); |
90
|
|
|
|
91
|
|
|
cy.get('.sw-integration-detail-modal__save-action').click(); |
92
|
|
|
|
93
|
|
|
// Verify edit a integration |
94
|
|
|
cy.wait('@editIntegration').then((xhr) => { |
95
|
|
|
expect(xhr).to.have.property('status', 204); |
96
|
|
|
}); |
97
|
|
|
}); |
98
|
|
|
|
99
|
|
|
it('@settings: can delete a integration', () => { |
100
|
|
|
const page = new SettingsPageObject(); |
101
|
|
|
// Request we want to wait for later |
102
|
|
|
cy.server(); |
|
|
|
|
103
|
|
|
cy.route({ |
104
|
|
|
url: '/api/v*/integration', |
105
|
|
|
method: 'post' |
106
|
|
|
}).as('createIntegration'); |
107
|
|
|
cy.route({ |
108
|
|
|
url: '/api/v*/integration/*', |
109
|
|
|
method: 'delete' |
110
|
|
|
}).as('deleteIntegration'); |
111
|
|
|
|
112
|
|
|
// go to integration module |
113
|
|
|
cy.get('.sw-admin-menu__item--sw-settings').click(); |
114
|
|
|
cy.get('.sw-settings__tab-system').click(); |
115
|
|
|
cy.get('#sw-integration').click(); |
116
|
|
|
|
117
|
|
|
// go to create page |
118
|
|
|
cy.get('.sw-integration-list__add-integration-action').click(); |
119
|
|
|
|
120
|
|
|
// clear old data and type another one in name field |
121
|
|
|
cy.get('#sw-field--currentIntegration-label') |
122
|
|
|
.clear() |
123
|
|
|
.type('chat-key'); |
124
|
|
|
cy.get('.sw-field__checkbox input[type="checkbox"]').check(); |
125
|
|
|
|
126
|
|
|
cy.get('.sw-integration-detail-modal__save-action').click(); |
127
|
|
|
|
128
|
|
|
// Verify create a integration |
129
|
|
|
cy.wait('@createIntegration').then((xhr) => { |
130
|
|
|
expect(xhr).to.have.property('status', 204); |
131
|
|
|
}); |
132
|
|
|
cy.clickContextMenuItem( |
133
|
|
|
`${page.elements.contextMenu}-item--danger`, |
134
|
|
|
page.elements.contextMenuButton, |
135
|
|
|
`${page.elements.dataGridRow}--0` |
136
|
|
|
); |
137
|
|
|
|
138
|
|
|
cy.get('.sw-button--primary.sw-button--small span.sw-button__content').contains('Delete').click(); |
139
|
|
|
// Verify delete a integration |
140
|
|
|
cy.wait('@deleteIntegration').then((xhr) => { |
141
|
|
|
expect(xhr).to.have.property('status', 204); |
142
|
|
|
}); |
143
|
|
|
}); |
144
|
|
|
}); |
145
|
|
|
|
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.