Skip to content

Commit e88ef66

Browse files
committed
Add system hook creation test
1 parent cfea9f4 commit e88ef66

File tree

3 files changed

+46
-0
lines changed

3 files changed

+46
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
describe('System hooks', () => {
2+
beforeEach(() => {
3+
cy.api_deleteSystemHooks()
4+
cy.sessionLogin()
5+
})
6+
7+
it('creates a system hook', () => {
8+
// Arrange
9+
cy.visit('admin/hooks')
10+
11+
// Act
12+
cy.get('#hook_url').type('http://example.com')
13+
cy.get('input[type="submit"][value="Add system hook"]').click()
14+
15+
// Assert
16+
cy.contains('.flash-notice', 'Hook was successfully created.').should('be.visible')
17+
cy.contains('.card-header', 'System hooks (1)')
18+
.should('be.visible')
19+
.next()
20+
.should('contain', 'http://example.com')
21+
.and('be.visible')
22+
})
23+
})

cypress/e2e/gui/allButProject.cy.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import '../gui/profile/createAccessToken.cy'
33

44
// GUI tests (all but project)
55
import './admin/broadcastMessage.cy'
6+
import './admin/systemHooks.cy'
67
// The below test destroys the user session. The next one recreates it.
78
import './admin/impersonateUser.cy'
89
import './group/createGroup.cy'

cypress/support/commands/api_commands.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,3 +235,25 @@ Cypress.Commands.add('api_deleteSnippets', () => {
235235
})
236236
})
237237
})
238+
239+
Cypress.Commands.add('api_getAllSystemHooks', () => {
240+
setAccessTokenIfNotYetSet()
241+
cy.request({
242+
method: 'GET',
243+
url: '/api/v4/hooks',
244+
headers: { 'Private-Token': accessToken }
245+
})
246+
})
247+
248+
Cypress.Commands.add('api_deleteSystemHooks', () => {
249+
setAccessTokenIfNotYetSet()
250+
cy.api_getAllSystemHooks()
251+
.its('body')
252+
.each(({ id }) => {
253+
cy.request({
254+
method: 'DELETE',
255+
url: `/api/v4/hooks/${id}`,
256+
headers: { 'Private-Token': accessToken }
257+
})
258+
})
259+
})

0 commit comments

Comments
 (0)