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

CCM-6833: Add place holder stage to auth #75

Merged
merged 6 commits into from
Oct 21, 2024
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
11 changes: 6 additions & 5 deletions infrastructure/terraform/components/app/amplify_app.tf
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@ resource "aws_amplify_app" "main" {
]

environment_variables = {
USER_POOL_ID = aws_cognito_user_pool.main.id
HOSTED_LOGIN_DOMAIN = local.auth_domain_name
NOTIFY_GROUP = var.group
NOTIFY_ENVIRONMENT = var.environment
NOTIFY_DOMAIN_NAME = local.root_domain_name
USER_POOL_ID = aws_cognito_user_pool.main.id
HOSTED_LOGIN_DOMAIN = local.auth_domain_name
NOTIFY_GROUP = var.group
NOTIFY_ENVIRONMENT = var.environment
NOTIFY_DOMAIN_NAME = local.root_domain_name
NEXT_PUBLIC_DISABLE_CONTENT = var.disable_content
}
}
6 changes: 6 additions & 0 deletions infrastructure/terraform/components/app/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,9 @@ variable "branch_name" {
description = "The branch name to deploy"
default = "main"
}

variable "disable_content" {
type = string
description = "Value for turning switching disable conten true/false"
default = "false"
}
17 changes: 17 additions & 0 deletions src/__tests__/components/Header.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,28 @@ import { render, screen } from '@testing-library/react';
import { NHSNotifyHeader } from '@/src/components/molecules/Header/Header';

describe('Header component', () => {
const ENV = process.env;

beforeEach(() => {
jest.resetModules();
process.env = { ...ENV };
});

afterAll(() => {
process.env = ENV;
});
it('renders component correctly', () => {
render(<NHSNotifyHeader />);

expect(screen.getByTestId('page-header')).toBeInTheDocument();
expect(screen.getByTestId('page-header-logo')).toBeInTheDocument();
expect(screen.getByTestId('login-link')).toBeInTheDocument();
});

it('should not render login link', () => {
process.env.NEXT_PUBLIC_DISABLE_CONTENT = 'true';
render(<NHSNotifyHeader />);

expect(screen.queryByTestId('login-link')).not.toBeInTheDocument();
});
});
6 changes: 5 additions & 1 deletion src/components/layouts/container/container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ export async function NHSNotifyContainer({
return (
<div className='nhsuk-width-container'>
<main className='nhsuk-main-wrapper nhsuk-u-padding-top-4' role='main'>
{children}
{process.env.NEXT_PUBLIC_DISABLE_CONTENT === 'true' ? (
<h1>Coming soon</h1>
) : (
children
)}
</main>
</div>
);
Expand Down
18 changes: 12 additions & 6 deletions src/components/molecules/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ export function NHSNotifyHeader({ className, dataTestId }: HeaderType) {
<div className='nhsuk-header__logo'>
<Link
className='nhsuk-header__link nhsuk-header__link--service'
href='/'
href={
process.env.NEXT_PUBLIC_DISABLE_CONTENT === 'true'
? '/'
: '/create-and-submit-templates'
}
aria-label='NHS homepage'
>
<svg
Expand Down Expand Up @@ -51,11 +55,13 @@ export function NHSNotifyHeader({ className, dataTestId }: HeaderType) {
id='content-header'
>
{/* I am currently testing the link wrapper, this will change later when we implement auth as the link will change based on auth state */}
<div className='nhsuk-account__login' data-testid='login-link'>
<Link className='nhsuk-account__login--link' href='/'>
{content.components.headerComponent.links.logIn}
</Link>
</div>
{process.env.NEXT_PUBLIC_DISABLE_CONTENT === 'true' ? undefined : (
<div className='nhsuk-account__login' data-testid='login-link'>
<Link className='nhsuk-account__login--link' href='/'>
{content.components.headerComponent.links.logIn}
</Link>
</div>
)}
</div>
</div>
</header>
Expand Down
Loading