Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ntrnl 331 add start page with overview and login button #28

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ export const PATH_SSL_CERTIFICATE = process.env['PATH_SSL_CERTIFICATE'] || '';
export const SERVICE_NAME = 'GitHub Requests Application ';

// Template
export const LANDING = 'landing-page';
export const START = 'start';
export const HOME = 'home';
export const ADD_MEMBER = 'add-member';
export const REMOVE_MEMBER = 'remove-member';
export const MEMBER_REQUST = 'member-request';
Expand All @@ -27,7 +28,8 @@ export const REPO_REQUEST = 'repo-request';

// Routing paths

export const LANDING_URL = '/landing-page';
export const START_URL = '/start';
export const HOME_URL = '/home';
export const ADD_MEMBER_URL = '/add-member';
export const REMOVE_MEMBER_URL = '/remove-member';
export const MEMBER_REQUST_URL = '/member-request';
Expand Down
2 changes: 1 addition & 1 deletion src/controller/add-member.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ export const post = (req: Request, res: Response) => {

log.info(`first_name: ${firstName}, last_name: ${lastName}, github_handle: ${gitHubHandle}, email_address: ${emailAddress}, contract_type: ${contractType}`);

return res.redirect(config.LANDING);
return res.redirect(config.HOME);
};
2 changes: 1 addition & 1 deletion src/controller/add-repo.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ export const post = (req: Request, res: Response) => {

log.info(`Repository Name: ${repoName}, Visibility: ${visibility}`);

return res.redirect(config.LANDING);
return res.redirect(config.HOME);
};
2 changes: 1 addition & 1 deletion src/controller/add-team-member.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ export const post = (req: Request, res: Response) => {

log.info(`Team Name: ${teamName}, Team Member GitHub Handle: ${teamMemberGithubHandle}`);

return res.redirect(config.LANDING);
return res.redirect(config.HOME);
};
2 changes: 1 addition & 1 deletion src/controller/add-team.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ export const post = (req: Request, res: Response) => {

log.info(`Team Name: ${teamName}, Team Maintainer GitHub Handle: ${teamMaintainerGithubHandle}`);

return res.redirect(config.LANDING);
return res.redirect(config.HOME);
};
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ import { Request, Response } from 'express';
import * as config from '../config';

export const get = (_req: Request, res: Response) => {
return res.render(config.LANDING);
return res.render(config.HOME);
};
2 changes: 1 addition & 1 deletion src/controller/member-request.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ export const post = (req: Request, res: Response) => {

log.info(`GitHub Handle: ${githubHandle}`);

return res.redirect(config.LANDING);
return res.redirect(config.HOME);
};
2 changes: 1 addition & 1 deletion src/controller/remove-member.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ export const post = (req: Request, res: Response) => {

log.info(`Github Handle: ${githubHandle}`);

return res.redirect(config.LANDING);
return res.redirect(config.HOME);
};
2 changes: 1 addition & 1 deletion src/controller/repo-request.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ export const post = (req: Request, res: Response) => {

log.info(`Repository Name: ${repoName}`);

return res.redirect(config.LANDING);
return res.redirect(config.HOME);
};
6 changes: 6 additions & 0 deletions src/controller/start.controller.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { Request, Response } from 'express';
import * as config from '../config';

export const get = (_req: Request, res: Response) => {
return res.render(config.START);
};
2 changes: 1 addition & 1 deletion src/controller/team-request.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ export const post = (req: Request, res: Response) => {

log.info(`Team Name: ${teamName}`);

return res.redirect(config.LANDING);
return res.redirect(config.HOME);
};
12 changes: 12 additions & 0 deletions src/routes/home.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Router } from 'express';

import { authentication } from '../middleware/authentication.middleware';

import { get } from '../controller/home.controller';
import * as config from '../config';

const homePageRouter = Router();

homePageRouter.get(config.HOME_URL, authentication, get);

export default homePageRouter;
6 changes: 4 additions & 2 deletions src/routes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { Router } from 'express';

import { logger } from '../middleware/logger.middleware';

import landingPageRouter from './landing-page';
import startPageRouter from './start';
import homePageRouter from './home';
import healthcheckRouter from './healthcheck';
import confirmationRouter from './confirmation';
import addRepoRouter from './add-repo';
Expand All @@ -20,7 +21,8 @@ const router = Router();
router.use(logger);

// Routes
router.use(landingPageRouter);
router.use(startPageRouter);
router.use(homePageRouter);
router.use(addMemberRouter);
router.use(confirmationRouter);
router.use(healthcheckRouter);
Expand Down
12 changes: 0 additions & 12 deletions src/routes/landing-page.ts

This file was deleted.

10 changes: 10 additions & 0 deletions src/routes/start.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Router } from 'express';

import { get } from '../controller/start.controller';
import * as config from '../config';

const startPageRouter = Router();

startPageRouter.get(config.START_URL, get);

export default startPageRouter;
2 changes: 1 addition & 1 deletion src/views/add-team-member.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{% block beforeContent %}
{{ govukBackLink({
text: "Back",
href: "/landing-page"
href: "/home"
}) }}
{% endblock %}

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/views/include/back-link.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{ govukBackLink({
text: "Back",
href: "/landing-page"
href: "/home"
}) }}
19 changes: 19 additions & 0 deletions src/views/start.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{% extends "layout.html" %}

{% block content %}
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<h1 class="govuk-heading-xl">GitHub Requests</h1>

<p class="govuk-body-l">Use this service to make member, team, and repository related requests to the cabinetoffice GitHub organisation.</p>

<a href="https://cola.service.cabinetoffice.gov.uk/v2/github-requests/login" role="button" draggable="false" class="govuk-button govuk-button--start" data-module="govuk-button">
Start now
<svg class="govuk-button__start-icon" xmlns="http://www.w3.org/2000/svg" width="17.5" height="19"
viewBox="0 0 33 40" aria-hidden="true" focusable="false">
<path fill="currentColor" d="M0 0h13l20 20-20 20H0l20-20z" />
</svg>
</a>
</div>
</div>
{% endblock %}
2 changes: 1 addition & 1 deletion test/integration/routes/add-member.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe('Add-member endpoint integration tests', () => {
});
});
describe('Add member POST tests', () => {
test('Should redirect to landing page after POST request', async () => {
test('Should redirect to home page after POST request', async () => {
const res = await request(app).post(config.ADD_MEMBER_URL).send(MOCK_POST_ADD_MEMBER);

expect(res.status).toEqual(302);
Expand Down
2 changes: 1 addition & 1 deletion test/integration/routes/add-repo.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe('add-repo endpoint integration tests', () => {
});
});
describe('POST tests', () => {
test('Should redirect to landing page after POST request', async () => {
test('Should redirect to home page after POST request', async () => {
const res = await request(app).post(config.ADD_REPO_URL).send(MOCK_POST_ADD_REPO);

expect(res.status).toEqual(302);
Expand Down
2 changes: 1 addition & 1 deletion test/integration/routes/add-team-member.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe('add-team-member endpoint integration tests', () => {
});
});
describe('POST tests', () => {
test('Should redirect to landing page after POST request', async () => {
test('Should redirect to home page after POST request', async () => {
const res = await request(app).post(config.ADD_TEAM_MEMBER_URL).send(MOCK_POST_ADD_TEAM_MEMBER);

expect(res.status).toEqual(302);
Expand Down
2 changes: 1 addition & 1 deletion test/integration/routes/add-team.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe('add-team endpoint integration tests', () => {
});
});
describe('POST tests', () => {
test('Should redirect to landing page after POST request', async () => {
test('Should redirect to home page after POST request', async () => {
const res = await request(app).post(config.ADD_TEAM_URL).send(MOCK_POST_ADD_TEAM);

expect(res.status).toEqual(302);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,24 @@ import * as config from '../../../src/config';
import { logger } from '../../../src/middleware/logger.middleware';
import { authentication } from '../../../src/middleware/authentication.middleware';

import { MOCK_GET_LANDING_RESPONSE } from '../../mock/text.mock';
import { MOCK_GET_HOME_RESPONSE } from '../../mock/text.mock';

const mockedLogger = logger as jest.Mock<typeof logger>;
mockedLogger.mockImplementation((req: Request, res: Response, next: NextFunction) => next());
mockedLogger.mockImplementation((_req: Request, _res: Response, next: NextFunction) => next());
const mockedAuth = authentication as jest.Mock<typeof authentication>;
mockedAuth.mockImplementation((_req: Request, _res: Response, next: NextFunction) => next());

describe('Confirmation endpoint integration tests', () => {
describe('Home endpoint integration tests', () => {
beforeEach(() => {
jest.clearAllMocks();
});

describe('GET tests', () => {
test('should render confirmation template', async () => {
const res = await request(app).get(config.LANDING_URL);
test('should render home template', async () => {
const res = await request(app).get(config.HOME_URL);

expect(res.status).toEqual(200);
expect(res.text).toContain(MOCK_GET_LANDING_RESPONSE);
expect(res.text).toContain(MOCK_GET_HOME_RESPONSE);
expect(mockedLogger).toHaveBeenCalledTimes(1);
expect(mockedAuth).toHaveBeenCalledTimes(1);
});
Expand Down
2 changes: 1 addition & 1 deletion test/integration/routes/member-request.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe('Member-request endpoint integration tests', () => {
});
});
describe('POST tests', () => {
test('Should redirect to landing page after POST request', async () => {
test('Should redirect to home page after POST request', async () => {
const res = await request(app).post(config.MEMBER_REQUST_URL).send(MOCK_POST_MEMBER_REQUEST);

expect(res.status).toEqual(302);
Expand Down
2 changes: 1 addition & 1 deletion test/integration/routes/remove-member.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ describe('Remove-member endpoint integration tests', () => {
});

describe('POST tests', () => {
test('Should redirect to landing page after POST request', async () => {
test('Should redirect to home page after POST request', async () => {
const res = await request(app).post(config.REMOVE_MEMBER_URL).send(MOCK_POST_REMOVE_MEMBER);

expect(res.status).toEqual(302);
Expand Down
2 changes: 1 addition & 1 deletion test/integration/routes/repo-request.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe('repo-request endpoint integration tests', () => {
});
});
describe('POST tests', () => {
test('Should redirect to landing page after POST request', async () => {
test('Should redirect to home page after POST request', async () => {
const res = await request(app).post(config.REPO_REQUEST_URL).send(MOCK_POST_REPO_REQUEST);

expect(res.status).toEqual(302);
Expand Down
32 changes: 32 additions & 0 deletions test/integration/routes/start.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
jest.mock('../../../src/middleware/logger.middleware');
jest.mock('../../../src/utils/logger');

import { jest, beforeEach, describe, expect, test } from '@jest/globals';
import { Request, Response, NextFunction } from 'express';
import request from 'supertest';

import app from '../../../src/app';
import * as config from '../../../src/config';

import { logger } from '../../../src/middleware/logger.middleware';

import { MOCK_GET_START_RESPONSE } from '../../mock/text.mock';

const mockedLogger = logger as jest.Mock<typeof logger>;
mockedLogger.mockImplementation((_req: Request, _res: Response, next: NextFunction) => next());

describe('Start endpoint integration tests', () => {
beforeEach(() => {
jest.clearAllMocks();
});

describe('GET tests', () => {
test('should render start template', async () => {
const res = await request(app).get(config.START_URL);

expect(res.status).toEqual(200);
expect(res.text).toContain(MOCK_GET_START_RESPONSE);
expect(mockedLogger).toHaveBeenCalledTimes(1);
});
});
});
2 changes: 1 addition & 1 deletion test/integration/routes/team-request.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe('Team-request endpoint integration tests', () => {
});
});
describe('POST tests', () => {
test('Should redirect to landing page after POST request', async () => {
test('Should redirect to home page after POST request', async () => {
const res = await request(app).post(config.TEAM_REQUEST_URL).send(MOCK_POST_TEAM_REQUEST);

expect(res.status).toEqual(302);
Expand Down
5 changes: 3 additions & 2 deletions test/mock/text.mock.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export const MOCK_OK_RESPONSE = 'OK';
export const MOCK_GET_CONFIRMATION_RESPONSE = 'GitHub request complete';
export const MOCK_GET_LANDING_RESPONSE = 'GitHub request application';
export const MOCK_GET_START_RESPONSE = 'GitHub Requests';
export const MOCK_GET_HOME_RESPONSE = 'GitHub request application';

export const MOCK_GET_ADD_REPO_RESPONSE = 'Add a GitHub Repository';
export const MOCK_POST_ADD_REPO_RESPONSE = 'Repository Name: repo1, Visibility: public';
Expand Down Expand Up @@ -31,4 +32,4 @@ export const MOCK_SERVICE_UNAVAILABLE = 'Sorry, there is a problem with the serv
export const MOCK_SERVER_ERROR = 'Pipe 3000 requires elevated privileges';
export const MOCK_ERROR_MESSAGE = 'Something has went wrong';
export const MOCK_WRONG_URL = '/infooo';
export const MOCK_REDIRECT_MESSAGE = 'Found. Redirecting to landing-page';
export const MOCK_REDIRECT_MESSAGE = 'Found. Redirecting to home';
4 changes: 2 additions & 2 deletions test/unit/controller/add-member.controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ describe('add member controller test suites', () => {

describe('add-member POST tests', () => {

test('should redirect to landing-page on POST request', () => {
test('should redirect to home page on POST request', () => {
const res = mockResponse();

post(req, res);

expect(res.redirect).toBeCalledWith(config.LANDING);
expect(res.redirect).toBeCalledWith(config.HOME);
});
test('should log add-member details on POST request', () => {
const res = mockResponse();
Expand Down
4 changes: 2 additions & 2 deletions test/unit/controller/add-repo.controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ describe('Add-repo controller test suites', () => {

describe('add-repo POST tests', () => {

test('should redirect to landing-page on POST request', () => {
test('should redirect to home page on POST request', () => {
const res = mockResponse();

post(req, res);

expect(res.redirect).toBeCalledWith(config.LANDING);
expect(res.redirect).toBeCalledWith(config.HOME);
});
test('should log Repository Name, Visibility and Description on POST request', () => {
const res = mockResponse();
Expand Down
4 changes: 2 additions & 2 deletions test/unit/controller/add-team-member.controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ describe('add-team-member controller test suites', () => {

describe('add-team-member POST tests', () => {

test('should redirect to landing-page on POST request', () => {
test('should redirect to home page on POST request', () => {
const res = mockResponse();

post(req, res);

expect(res.redirect).toBeCalledWith(config.LANDING);
expect(res.redirect).toBeCalledWith(config.HOME);
});
test('should log Team Name, Team Member GitHub handle on POST request', () => {
const res = mockResponse();
Expand Down
4 changes: 2 additions & 2 deletions test/unit/controller/add-team.controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ describe('add-team controller test suites', () => {

describe('add-team POST tests', () => {

test('should redirect to landing-page on POST request', () => {
test('should redirect to home page on POST request', () => {
const res = mockResponse();

post(req, res);

expect(res.redirect).toBeCalledWith(config.LANDING);
expect(res.redirect).toBeCalledWith(config.HOME);
});
test('should log Team Name and Team Maintainer GitHub handle on POST request', () => {
const res = mockResponse();
Expand Down
Loading
Loading