Changeset View
Changeset View
Standalone View
Standalone View
cypress/integration/add-forge-now-request-create.spec.js
Show First 20 Lines • Show All 128 Lines • ▼ Show 20 Lines | it('should show error message on conflict', function() { | ||||
cy.visit(this.addForgeNowUrl); | cy.visit(this.addForgeNowUrl); | ||||
populateForm('bitbucket', 'gitlab.com', 'test', 'test@example.com', 'on', 'test comment'); | populateForm('bitbucket', 'gitlab.com', 'test', 'test@example.com', 'on', 'test comment'); | ||||
cy.get('#requestCreateForm').submit(); | cy.get('#requestCreateForm').submit(); | ||||
cy.get('#requestCreateForm').submit(); // Submitting the same data again | cy.get('#requestCreateForm').submit(); // Submitting the same data again | ||||
cy.get('#userMessage') | cy.get('#userMessage') | ||||
.should('have.class', 'badge-danger') | .should('have.class', 'badge-danger') | ||||
.should('contain', 'Sorry; an error occurred'); | .should('contain', 'already exists'); | ||||
}); | }); | ||||
it('should show error message', function() { | |||||
cy.userLogin(); | |||||
cy.intercept('POST', `${this.Urls.api_1_add_forge_request_create()}**`, | |||||
{ | |||||
body: { | |||||
'exception': 'BadInputExc', | |||||
'reason': '{"add-forge-comment": ["This field is required"]}' | |||||
}, | |||||
statusCode: 400 | |||||
}).as('errorRequest'); | |||||
cy.visit(this.addForgeNowUrl); | |||||
populateForm( | |||||
'bitbucket', 'gitlab.com', 'test', 'test@example.com', 'on', 'comment' | |||||
); | |||||
cy.get('#requestCreateForm').submit(); | |||||
cy.wait('@errorRequest').then((xhr) => { | |||||
cy.get('#userMessage') | |||||
.should('have.class', 'badge-danger') | |||||
.should('contain', 'field is required'); | |||||
}); | |||||
}); | |||||
}); | }); |