Skip to content

Commit

Permalink
TMI2-353|fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ConorFayleAND committed Oct 13, 2023
1 parent bf4df2f commit 44a3655
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 39 deletions.
28 changes: 14 additions & 14 deletions packages/applicant/src/pages/api/redirect-from-find.page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,20 @@ export default async function handler(
grantSchemeId,
} = await getAdvertBySlug(getJwtFromCookies(req), slug);

// if (version === 1) {
// const redirectUrl = isInternal
// ? `${process.env.HOST}${routes.applications}/${grantApplicationId}`
// : externalSubmissionUrl;
// res.redirect(redirectUrl);
// }
//
// if (version === 2) {
res.redirect(
`${process.env.HOST}${routes.mandatoryQuestions.startPage(
grantSchemeId.toString()
)}`
);
// }
if (version === 1) {
const redirectUrl = isInternal
? `${process.env.HOST}${routes.applications}/${grantApplicationId}`
: externalSubmissionUrl;
res.redirect(redirectUrl);
}

if (version === 2) {
res.redirect(
`${process.env.HOST}${routes.mandatoryQuestions.startPage(
grantSchemeId.toString()
)}`
);
}
} catch (e) {
const serviceErrorProps = {
errorInformation: 'There was an error in the service',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import MandatoryQuestionsBeforeYouStart, {
MandatoryQuestionsProps,
} from './start.page';
import { getProps } from 'gap-web-ui';
import { RouterContext } from 'next/dist/shared/lib/router-context';
import { createMockRouter } from '../../testUtils/createMockRouter';

function getDefaultProps(): MandatoryQuestionsProps {
return {
Expand All @@ -13,33 +15,37 @@ function getDefaultProps(): MandatoryQuestionsProps {

describe('Mandatory Questions Start', () => {
test('should render page', () => {
render(<MandatoryQuestionsBeforeYouStart {...getProps(getDefaultProps)} />);
render(
<RouterContext.Provider
value={createMockRouter({
pathname: `/applications`,
})}
>
<MandatoryQuestionsBeforeYouStart {...getProps(getDefaultProps)} />
</RouterContext.Provider>
);

screen.getByRole('heading', {
name: 'Before you start',
});
screen.getByRole('paragraph', {
name: 'Before you start, we’d like to ask you a few questions.',
});
screen.getByRole('paragraph', {
name:
'These questions will be used by the grant’s administrators to prevent fraud ' +
'and help Find a grant understand the demand for this grant.',
});
screen.getByRole('paragraph', {
name: 'You will need:',
});
screen.getByRole('listitem', {
name: 'your organisation’s address',
});
screen.getByRole('listitem', {
name: 'your Companies House number (if you have one)',
});
screen.getByRole('listitem', {
name: 'your Charity Commission number (if you have one)',
});
name: /Before you start/i,
});
screen.getByRole(
(role, element) =>
role === 'listitem' &&
element.textContent === 'your organisation’s address'
);
screen.getByRole(
(role, element) =>
role === 'listitem' &&
element.textContent === 'your Companies House number (if you have one)'
);
screen.getByRole(
(role, element) =>
role === 'listitem' &&
element.textContent ===
'your Charity Commission number (if you have one)'
);
screen.getByRole('button', {
name: 'Continue',
name: /Continue/i,
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const MandatoryQuestionsBeforeYouStart: FC<MandatoryQuestionsProps> = ({
return (
<>
<Meta title="Before you start" />
<Layout backBtnUrl={routes.organisation.index}>
<Layout>
<h1 className="govuk-heading-l">Before you start</h1>
<p className="govuk-body">
Before you start, we’d like to ask you a few questions.
Expand Down

0 comments on commit 44a3655

Please sign in to comment.