Skip to content

Commit

Permalink
feat: Link to batch certify page from dash + email
Browse files Browse the repository at this point in the history
  • Loading branch information
kriscooke committed May 21, 2020
1 parent 6e0820c commit 4e9c250
Show file tree
Hide file tree
Showing 11 changed files with 534 additions and 41 deletions.
10 changes: 10 additions & 0 deletions app/containers/Organisations/Organisations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -72,6 +73,15 @@ export const OrganisationsComponent: React.FunctionComponent<Props> = (
const {edges} = session.ciipUserBySub.ciipUserOrganisationsByUserId;
return (
<>
{props.flagCertRequests && (
<Alert variant="info">
One or more reporting operations has requested that you certify an
application.{' '}
<Alert.Link href="/certifier/requests">
View all certification requests.
</Alert.Link>
</Alert>
)}
{edges.length === 0 ? (
<>
<Alert variant="warning">
Expand Down
2 changes: 2 additions & 0 deletions app/cypress/integration/email.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
3 changes: 3 additions & 0 deletions app/cypress/integration/reporter-certifier-access.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
});
10 changes: 10 additions & 0 deletions app/pages/reporter/user-dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ export default class UserDashBoard extends Component<Props> {
ciipUserBySub {
id
rowId
certificationRequests {
edges {
node {
id
}
}
}
}
}
}
Expand Down Expand Up @@ -73,6 +80,8 @@ export default class UserDashBoard extends Component<Props> {
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'
Expand All @@ -89,6 +98,7 @@ export default class UserDashBoard extends Component<Props> {
<Col md={{span: 8}}>
<Organisations
query={query}
flagCertRequests={hasCertificationRequests}
orgInput={this.state.orgInput}
selectedOrg={this.state.selectedOrg}
confirmOrg={this.state.confirmOrg}
Expand Down
8 changes: 6 additions & 2 deletions app/server/emailTemplates/certificationRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ const createCertificationRequestMail = ({
facilityName,
operatorName,
reporterEmail,
certifierUrl
certifierUrl,
host
}) => {
return `
<table align="center" border="1" cellpadding="0" cellspacing="0" width="600">
Expand All @@ -24,7 +25,10 @@ const createCertificationRequestMail = ({
a summary of the data.
</p>
<br/>
<a href=${certifierUrl}>CIIP Application</a>
<p>
<a href=${certifierUrl}>CIIP Application</a>
</p>
<p>Or, <a href="${host}/certifier/requests">view all certification requests</a>.</p>
</td>
</tr>
<tr>
Expand Down
3 changes: 2 additions & 1 deletion app/server/tasks/sendMail.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ module.exports = async ({
facilityName,
operatorName,
reporterEmail,
certifierUrl
certifierUrl,
host: process.env.HOST
});
break;
// Certifier signs application
Expand Down
15 changes: 15 additions & 0 deletions app/tests/integration/__snapshots__/Storyshots.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1400,6 +1400,21 @@ Array [
<div
className="col-md-8"
>
<div
className="fade alert alert-info show"
role="alert"
>
One or more reporting operations has requested that you certify an application.
<a
className="alert-link"
href="/certifier/requests"
onClick={[Function]}
onKeyDown={[Function]}
>
View all certification requests.
</a>
</div>
<div
className="fade alert alert-info show"
role="alert"
Expand Down
91 changes: 57 additions & 34 deletions app/tests/unit/containers/Organisation/Organisations.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,46 @@ import {shallow} from 'enzyme';
import {Organisations_query} from 'Organisations_query.graphql';
import {OrganisationsComponent} from 'containers/Organisations/Organisations';

const queryWithoutOrganisations: Organisations_query = {
' $refType': 'Organisations_query',
session: {
ciipUserBySub: {
id: '',
ciipUserOrganisationsByUserId: {edges: []}
}
},
allOrganisations: {edges: []}
};

const queryWithOrganisations: Organisations_query = {
' $refType': 'Organisations_query',
session: {
ciipUserBySub: {
id: '',
ciipUserOrganisationsByUserId: {
edges: [
{
node: {
id: 'OrgId',
' $fragmentRefs': {UserOrganisation_userOrganisation: true}
}
}
]
}
}
},
allOrganisations: {
edges: []
}
};

describe('Organisations', () => {
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(
<OrganisationsComponent
query={query}
query={queryWithoutOrganisations}
relay={null}
flagCertRequests={false}
orgInput={null}
selectedOrg={null}
confirmOrg={null}
Expand All @@ -31,31 +55,11 @@ describe('Organisations', () => {
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(
<OrganisationsComponent
query={query}
query={queryWithOrganisations}
relay={null}
flagCertRequests={false}
orgInput={null}
selectedOrg={null}
confirmOrg={null}
Expand All @@ -69,7 +73,26 @@ describe('Organisations', () => {
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(
<OrganisationsComponent
flagCertRequests
query={queryWithOrganisations}
relay={null}
orgInput={null}
selectedOrg={null}
confirmOrg={null}
handleInputChange={null}
handleContextChange={null}
handleOrgChange={null}
handleOrgConfirm={null}
/>
);
expect(r).toMatchSnapshot();
});
});
Loading

0 comments on commit 4e9c250

Please sign in to comment.