diff --git a/app/containers/Organisations/Organisations.tsx b/app/containers/Organisations/Organisations.tsx index 4998e27a33..db1d0ca228 100644 --- a/app/containers/Organisations/Organisations.tsx +++ b/app/containers/Organisations/Organisations.tsx @@ -20,6 +20,7 @@ import Help from 'components/helpers/Help'; interface Props { query: Organisations_query; relay: RelayProp; + flagCertRequests: boolean; orgInput: string; selectedOrg: number; confirmOrg: boolean; @@ -72,6 +73,15 @@ export const OrganisationsComponent: React.FunctionComponent = ( const {edges} = session.ciipUserBySub.ciipUserOrganisationsByUserId; return ( <> + {props.flagCertRequests && ( + + One or more reporting operations has requested that you certify an + application.{' '} + + View all certification requests. + + + )} {edges.length === 0 ? ( <> diff --git a/app/cypress/integration/email.spec.js b/app/cypress/integration/email.spec.js index a4ceee38fb..69b1dec217 100644 --- a/app/cypress/integration/email.spec.js +++ b/app/cypress/integration/email.spec.js @@ -61,6 +61,8 @@ if (Cypress.env('NO_MAIL')) { expect(response.body[0].Content.Body).to.contain( 'has requested that you review' ); + // eslint-disable-next-line jest/valid-expect + expect(response.body[0].Content.Body).to.contain('/certifier/requests'); cy.request('DELETE', 'localhost:8025/api/v1/messages'); cy.get('input') .invoke('val') diff --git a/app/cypress/integration/reporter-certifier-access.spec.js b/app/cypress/integration/reporter-certifier-access.spec.js index 2f782a849b..972ff86034 100644 --- a/app/cypress/integration/reporter-certifier-access.spec.js +++ b/app/cypress/integration/reporter-certifier-access.spec.js @@ -37,5 +37,8 @@ describe('When logged in as a certifier(reporter)', () => { cy.get('#page-content'); cy.contains('View').click(); cy.url().should('include', '/certifier/certify'); + cy.visit('/reporter/user-dashboard'); + cy.get('.alert-link').contains('View all certification requests.').click(); + cy.url().should('include', '/certifier/requests'); }); }); diff --git a/app/pages/reporter/user-dashboard.tsx b/app/pages/reporter/user-dashboard.tsx index 46680770ec..fd2a10c3dd 100644 --- a/app/pages/reporter/user-dashboard.tsx +++ b/app/pages/reporter/user-dashboard.tsx @@ -25,6 +25,13 @@ export default class UserDashBoard extends Component { ciipUserBySub { id rowId + certificationRequests { + edges { + node { + id + } + } + } } } } @@ -73,6 +80,8 @@ export default class UserDashBoard extends Component { render() { const {query} = this.props; const {session} = query || {}; + const hasCertificationRequests = + session.ciipUserBySub.certificationRequests.edges.length > 0; const helpDetails = { title: 'What is an Operator', helpMessage: 'An operator is an organisation' @@ -89,6 +98,7 @@ export default class UserDashBoard extends Component { { return ` @@ -24,7 +25,10 @@ const createCertificationRequestMail = ({ a summary of the data.


- CIIP Application +

+ CIIP Application +

+

Or, view all certification requests.

diff --git a/app/server/tasks/sendMail.js b/app/server/tasks/sendMail.js index 04c15e236f..b3a976282f 100644 --- a/app/server/tasks/sendMail.js +++ b/app/server/tasks/sendMail.js @@ -76,7 +76,8 @@ module.exports = async ({ facilityName, operatorName, reporterEmail, - certifierUrl + certifierUrl, + host: process.env.HOST }); break; // Certifier signs application diff --git a/app/tests/integration/__snapshots__/Storyshots.test.ts.snap b/app/tests/integration/__snapshots__/Storyshots.test.ts.snap index 147deb2c9b..bfcebe14c9 100644 --- a/app/tests/integration/__snapshots__/Storyshots.test.ts.snap +++ b/app/tests/integration/__snapshots__/Storyshots.test.ts.snap @@ -1400,6 +1400,21 @@ Array [
+
+ One or more reporting operations has requested that you certify an application. + + + View all certification requests. + +
{ it('should render no organisations if the user has not requested any access', async () => { - const query: Organisations_query = { - ' $refType': 'Organisations_query', - session: { - ciipUserBySub: { - id: '', - ciipUserOrganisationsByUserId: {edges: []} - } - }, - allOrganisations: {edges: []} - }; const r = shallow( { expect(r).toMatchSnapshot(); }); it("should render the user's requested organisations", async () => { - const query: Organisations_query = { - ' $refType': 'Organisations_query', - session: { - ciipUserBySub: { - id: '', - ciipUserOrganisationsByUserId: { - edges: [ - { - node: { - id: 'OrgId', - ' $fragmentRefs': {UserOrganisation_userOrganisation: true} - } - } - ] - } - } - }, - allOrganisations: { - edges: [] - } - }; const r = shallow( { expect( r.find('Relay(UserOrganisationComponent)').prop('userOrganisation') ).toBe( - query.session.ciipUserBySub.ciipUserOrganisationsByUserId.edges[0].node + queryWithOrganisations.session.ciipUserBySub.ciipUserOrganisationsByUserId + .edges[0].node ); }); + + it('should announce there are certification requests to view', async () => { + const r = shallow( + + ); + expect(r).toMatchSnapshot(); + }); }); diff --git a/app/tests/unit/containers/Organisation/__snapshots__/Organisations.test.tsx.snap b/app/tests/unit/containers/Organisation/__snapshots__/Organisations.test.tsx.snap index 157ae15870..016d93f969 100644 --- a/app/tests/unit/containers/Organisation/__snapshots__/Organisations.test.tsx.snap +++ b/app/tests/unit/containers/Organisation/__snapshots__/Organisations.test.tsx.snap @@ -1,5 +1,188 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`Organisations should announce there are certification requests to view 1`] = ` + + + One or more reporting operations has requested that you certify an application. + + + View all certification requests. + + + + Once your access to the requested operators is approved you can view their facilities and apply for CIIP for each. + + +
+ + + + + + + + + + + th.jsx-130150550{padding:20px;font-weight:500;} + + +
+ + +
+ Add operators you represent +
+ +
+ + + + Request access to an Operator: + + + (You can search to narrow the results in the dropdown) + + + Select Operator + + + +
+ + +
+ + + .org-scroll.jsx-3491480756{max-height:250px;overflow:hidden;overflow-y:scroll;} + + + +
+ +`; + exports[`Organisations should render no organisations if the user has not requested any access 1`] = ` + +
+ + + +
+ How to apply for CIIP +
+
+ + + + Step 1: + +
+ Request access to one or more Operators. +
+ + + Step 2: + +
+ CIIP administrators will approve your request. + +
+ + + Step 3: + +
+ Once approved, you can view all the facilities for the Operator. +
+ + + Step 4: + +
+ You can apply for CIIP for each facility. +
+
+
+ + + +`; + +exports[`Reporter Dashboard Reporter with no certification requests 1`] = ` + @@ -28,11 +195,31 @@ exports[`landingIndustryUser It matches the last accepted Snapshot 1`] = ` > diff --git a/app/tests/unit/pages/user-dashboard.test.tsx b/app/tests/unit/pages/user-dashboard.test.tsx index 72a9f954a8..3d22d0034b 100644 --- a/app/tests/unit/pages/user-dashboard.test.tsx +++ b/app/tests/unit/pages/user-dashboard.test.tsx @@ -1,10 +1,65 @@ import React from 'react'; import {shallow} from 'enzyme'; import UserDashboard from 'pages/reporter/user-dashboard'; +import {userDashboardQueryResponse} from 'userDashboardQuery.graphql'; -describe('landingIndustryUser', () => { - it('It matches the last accepted Snapshot', () => { - const wrapper = shallow(); +const query = { + session: { + ciipUserBySub: { + id: 'ciip-reporter@mailinator.com', + rowId: 6, + certificationRequests: { + edges: [] + } + }, + ' $fragmentRefs': { + defaultLayout_session: true + } + }, + ' $fragmentRefs': { + Organisations_query: true + } +}; + +const queryWithCertRequests: userDashboardQueryResponse['query'] = { + session: { + ciipUserBySub: { + id: 'ciip-reporter@mailinator.com', + rowId: 6, + certificationRequests: { + edges: [ + { + node: { + id: '1' + } + } + ] + } + }, + ' $fragmentRefs': { + defaultLayout_session: true + } + }, + ' $fragmentRefs': { + Organisations_query: true + } +}; + +describe('Reporter Dashboard', () => { + it('Reporter with no certification requests', () => { + const wrapper = shallow(); + expect(wrapper).toMatchSnapshot(); + expect( + wrapper.find('Relay(OrganisationsComponent)').prop('flagCertRequests') + ).toBe(false); + }); + it('Reporter with certification requests', () => { + const wrapper = shallow( + + ); expect(wrapper).toMatchSnapshot(); + expect( + wrapper.find('Relay(OrganisationsComponent)').prop('flagCertRequests') + ).toBe(true); }); });
+ Operator + + Access Status + + Operations/Facilities +