-
-
Notifications
You must be signed in to change notification settings - Fork 217
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2239 from DamnClin/modules-cypress-test
Add cypress tests to modules page
- Loading branch information
Showing
4 changed files
with
139 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{ | ||
"categories": [ | ||
{ | ||
"name": "Spring", | ||
"modules": [ | ||
{ | ||
"slug": "spring-cucumber", | ||
"description": "Add cucumber to the application", | ||
"properties": { | ||
"definitions": [ | ||
{ | ||
"type": "STRING", | ||
"mandatory": true, | ||
"key": "baseName", | ||
"description": "Application base name", | ||
"example": "jhipster" | ||
}, | ||
{ | ||
"type": "BOOLEAN", | ||
"mandatory": false, | ||
"key": "optionalBoolean" | ||
}, | ||
{ | ||
"type": "INTEGER", | ||
"mandatory": false, | ||
"key": "optionalInteger" | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
"slug": "spring-test", | ||
"description": "Add spring test to the application" | ||
} | ||
] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,84 @@ | ||
import { dataSelector } from '../support/selector'; | ||
import { interceptForever } from '../support/Interceptor'; | ||
|
||
describe('Modules', () => { | ||
it('Should display modules', () => { | ||
cy.visit('/modules'); | ||
describe('E2E', () => { | ||
it('Should display modules', () => { | ||
cy.visit('/modules'); | ||
|
||
cy.get(dataSelector('modules-list')).should('be.visible'); | ||
cy.get(dataSelector('modules-list')).should('be.visible'); | ||
}); | ||
}); | ||
|
||
describe('Component', () => { | ||
it('Should display loader while loading modules', () => { | ||
const result = interceptForever({ path: '/api/modules' }, { fixture: 'modules.json' }); | ||
|
||
cy.visit('/modules'); | ||
|
||
cy.get(dataSelector('modules-loader')) | ||
.should('be.visible') | ||
.then(() => { | ||
result.send(); | ||
|
||
cy.get(dataSelector('modules-loader')).should('not.exist'); | ||
cy.get(dataSelector('modules-list')).should('be.visible'); | ||
cy.get(dataSelector('module-spring-test-application-button')).should('be.disabled'); | ||
cy.get(dataSelector('module-spring-cucumber-application-button')).should('be.disabled'); | ||
}); | ||
}); | ||
|
||
it('Should apply module without properties', () => { | ||
cy.intercept({ path: '/api/modules' }, { fixture: 'modules.json' }); | ||
|
||
cy.intercept({ | ||
path: '/api/modules/spring-test/apply', | ||
method: 'POST', | ||
}).as('spring-test-creation'); | ||
|
||
cy.visit('/modules'); | ||
cy.get(dataSelector('folder-path-field')).type('test'); | ||
cy.get(dataSelector('module-spring-test-application-button')).click(); | ||
|
||
cy.wait('@spring-test-creation').should(xhr => { | ||
const body = xhr.request.body; | ||
|
||
expect(body).to.deep.equal({ | ||
projectFolder: 'test', | ||
properties: {}, | ||
}); | ||
}); | ||
}); | ||
|
||
it('Should apply module with properties', () => { | ||
cy.intercept({ path: '/api/modules' }, { fixture: 'modules.json' }); | ||
|
||
cy.intercept({ | ||
path: '/api/modules/spring-cucumber/apply', | ||
method: 'POST', | ||
}).as('spring-cucumber-creation'); | ||
|
||
cy.visit('/modules'); | ||
|
||
cy.get(dataSelector('spring-cucumber-module-content')).click(); | ||
cy.get(dataSelector('folder-path-field')).type('test'); | ||
cy.get(dataSelector('property-baseName-field')).type('jhipster'); | ||
cy.get(dataSelector('property-optionalBoolean-field')).select('true'); | ||
cy.get(dataSelector('property-optionalInteger-field')).type('42'); | ||
cy.get(dataSelector('module-spring-cucumber-application-button')).click(); | ||
|
||
cy.wait('@spring-cucumber-creation').should(xhr => { | ||
const body = xhr.request.body; | ||
|
||
expect(body).to.deep.equal({ | ||
projectFolder: 'test', | ||
properties: { | ||
baseName: 'jhipster', | ||
optionalBoolean: true, | ||
optionalInteger: 42, | ||
}, | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { HttpResponseInterceptor, RouteMatcher, StaticResponse } from '../../../../../node_modules/cypress/types/net-stubbing'; | ||
|
||
type ResponseSender = { | ||
send: () => void; | ||
}; | ||
|
||
export const interceptForever = (requestMatcher: RouteMatcher, response?: StaticResponse | HttpResponseInterceptor): ResponseSender => { | ||
let send; | ||
|
||
const trigger = new Promise(resolve => { | ||
send = resolve; | ||
}); | ||
|
||
cy.intercept(requestMatcher, request => { | ||
return trigger.then(() => { | ||
request.reply(response); | ||
}); | ||
}); | ||
|
||
return { send }; | ||
}; |