new file cypress/fixtures/add-forge-now-create-request-fail.json @@ -0,0 +1,8 @@ +{ + "status": 400, + "ok": false, + "data": { + "exception": "BadInputExc", + "reason": "{\"add-forge-comment\": [\"This field is required\"]}" + } +} \ No newline at end of file modified cypress/integration/add-forge-now-request-create.spec.js @@ -136,4 +136,30 @@ describe('Test add-forge-request creation', function() { .should('have.class', 'badge-danger') .should('contain', 'already exists'); }); + + it('should show error message', function() { + cy.userLogin(); + + cy.intercept(`${this.Urls.api_1_add_forge_request_create()}**`, + {fixture: 'add-forge-now-create-request-fail'}).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.log('response:', xhr.response); + cy.log(xhr.response.body); + const requests = xhr.response.body.data; + cy.log('Requests: ', requests); + + cy.get('#userMessage') + .should('have.class', 'badge-danger') + .should('contain', 'field is required'); + }); + }); + });