Skip to content

Commit

Permalink
feat: the application view page redirects to 404 if no application
Browse files Browse the repository at this point in the history
  • Loading branch information
matthieu-foucault committed Apr 7, 2021
1 parent ddef660 commit 28d531c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@ class ViewApplication extends Component<Props> {
);
const status =
application?.applicationRevisionStatus?.applicationRevisionStatus;

if (!status) {
router.push('/404');
return null;
}

const changesRequested = status === 'REQUESTED_CHANGES';
const hasBeenReviewed = status !== 'SUBMITTED' && status !== 'DRAFT';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ const router: any = {
query: {
applicationId: 'testing',
versionNumber: '1'
}
},
push: jest.fn()
};

describe('View submitted application page', () => {
Expand All @@ -51,6 +52,14 @@ describe('View submitted application page', () => {
).toBe(query);
});

it('redirects to the 404 page if the application is missing', () => {
const r = shallow(
<ViewApplication query={{...query, application: null}} router={router} />
);
expect(r).toBeEmpty();
expect(router.push).toBeCalledWith('/404');
});

it('does not show an application decision when unreviewed', () => {
const r = shallow(
<ViewApplication
Expand Down

0 comments on commit 28d531c

Please sign in to comment.