diff --git a/assets/src/bundles/add_forge/add-request-history-item.ejs b/assets/src/bundles/add_forge/add-request-history-item.ejs --- a/assets/src/bundles/add_forge/add-request-history-item.ejs +++ b/assets/src/bundles/add_forge/add-request-history-item.ejs @@ -6,7 +6,7 @@ %>
-
+

-
+

<%= event.text %>

<%if (event.new_status !== null) { %> diff --git a/cypress/fixtures/add-forge-now-request.json b/cypress/fixtures/add-forge-now-request.json --- a/cypress/fixtures/add-forge-now-request.json +++ b/cypress/fixtures/add-forge-now-request.json @@ -3,18 +3,19 @@ "id":1, "status":"PENDING", "submission_date":"2022-03-17T13:35:24.324848Z", - "submitter_name":"admin", - "submitter_email":"admin@swh-web.org", + "submitter_name":"submitter", + "submitter_email":"submitter@example.com", "forge_type":"bitbucket", "forge_url":"test.com", "forge_contact_email":"test@example.com", "forge_contact_name":"test user", + "submitter_forward_username":true, "forge_contact_comment":"test comment" },"history":[ { "id":1, "text":"", - "actor":"admin", + "actor":"submitter", "actor_role":"SUBMITTER", "date":"2022-03-17T13:35:24.326190Z", "new_status":"PENDING" diff --git a/cypress/integration/add-forge-now-request-dashboard.spec.js b/cypress/integration/add-forge-now-request-dashboard.spec.js --- a/cypress/integration/add-forge-now-request-dashboard.spec.js +++ b/cypress/integration/add-forge-now-request-dashboard.spec.js @@ -34,6 +34,24 @@ cy.get('#requestContactName') .should('contain', 'test user'); + cy.get('#requestContactEmail') + .should('contain', 'test@example.com'); + + cy.get('#requestContactConsent') + .should('contain', 'true'); + + cy.get('#submitterMessage') + .should('contain', 'test comment'); + }); + + it('should show send message link', function() { + cy.get('#contactForgeAdmin') + .should('have.attr', 'emailto') + .and('include', 'test@example.com'); + + cy.get('#contactForgeAdmin') + .should('have.attr', 'emailsubject') + .and('include', '[swh-add_forge_now] Request 1'); }); it('should not show any error message', function() { @@ -66,6 +84,9 @@ cy.get('#requestHistory') .children() .should('contain', 'New status: Pending'); + + cy.get('#requestHistory') + .should('contain', 'From submitter (SUBMITTER)'); }); it('should load possible next status', function() { @@ -75,3 +96,48 @@ .should('have.length', 4); }); }); + +describe('Test forge now request update', function() { + + beforeEach(function() { + const url = this.Urls.add_forge_now_request_dashboard(requestId); + cy.adminLogin(); + + cy.intercept(`${this.Urls.api_1_add_forge_request_get(requestId)}**`, + {fixture: 'add-forge-now-request'}).as('forgeAddRequest'); + cy.intercept('POST', `${this.Urls.api_1_add_forge_request_update(requestId)}**`, + {fixture: 'add-forge-now-request'}).as('updateRequest'); + cy.visit(url); + }); + + it('should post data on submit', function() { + cy.get('#decisionOptions').select('WAITING_FOR_FEEDBACK'); + cy.get('#updateComment').type('This is an update comment'); + cy.get('#updateRequestForm').submit(); + + cy.wait('@updateRequest').its('request.body') + .should('include', 'new_status') + .should('include', 'text') + .should('include', 'WAITING_FOR_FEEDBACK'); + cy.get('#userMessage') + .should('contain', 'The request status has been updated') + .should('not.have.class', 'badge-danger') + .should('have.class', 'badge-success'); + }); + + it('should show an error on API failiure', function() { + cy.intercept('POST', + `${this.Urls.api_1_add_forge_request_update(requestId)}**`, + {forceNetworkError: true}) + .as('updateFailedRequest'); + cy.get('#decisionOptions').select('WAITING_FOR_FEEDBACK'); + cy.get('#updateComment').type('This is an update comment'); + cy.get('#updateRequestForm').submit(); + + cy.wait('@updateFailedRequest'); + cy.get('#userMessage') + .should('contain', 'Sorry; Updating the request failed') + .should('have.class', 'badge-danger') + .should('not.have.class', 'badge-success'); + }); +});