Skip to content
Open
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
21 changes: 11 additions & 10 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const compat = new FlatCompat({
});

export default defineConfig([
globalIgnores(['**/*/coverage/*', '**/.build', '**/node_modules', '**/dist']),
globalIgnores(['**/*/coverage/*', '**/.build', '**/node_modules', '**/dist', '**/test-results', '**/playwright-report']),

//imports
importX.flatConfigs.recommended,
Expand Down Expand Up @@ -63,6 +63,7 @@ export default defineConfig([
// ],
projectService: true,
tsconfigRootDir: import.meta.dirname,
extraFileExtensions: ['.json']
},
},
},
Expand Down Expand Up @@ -251,17 +252,17 @@ export default defineConfig([
},
},
{
files: ['**/utils/**'],
//files: ['**/utils/**'],
rules: {
'import-x/prefer-default-export': 0,
},
},
{
plugins: {
'no-relative-import-paths': noRelativeImportPaths,
},
rules: {
'no-relative-import-paths/no-relative-import-paths': 2,
},
},
//{
// plugins: {
// 'no-relative-import-paths': noRelativeImportPaths,
// },
// rules: {
// 'no-relative-import-paths/no-relative-import-paths': 2,
// },
//},
]);
4 changes: 2 additions & 2 deletions frontend/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ const config: Config = {
],

// Set the absolute path for imports
moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths, {
moduleNameMapper: { '@amplify_outputs': '<rootDir>/jestamplify_outputs.json', ...pathsToModuleNameMapper(compilerOptions.paths, {
prefix: '<rootDir>/',
}),
}) },

setupFilesAfterEnv: ['<rootDir>/jest.setup.ts'],
};
Expand Down
1 change: 1 addition & 0 deletions frontend/jestamplify_outputs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
3 changes: 2 additions & 1 deletion frontend/src/__tests__/app/inactive/page.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import { ReadonlyURLSearchParams, useSearchParams } from 'next/navigation';
import InactivePage from '@/app/inactive/page';

jest.mock('@/components/molecules/SignOut/SignOut', () => ({
SignOut: ({ children }: { children: React.ReactNode }) => children,
__esModule: true,
default: ({ children }: { children: React.ReactNode }) => children,
}));

jest.mock('next/navigation', () => ({
Expand Down
13 changes: 9 additions & 4 deletions frontend/src/__tests__/app/page.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,18 @@ jest.mock('@aws-amplify/ui-react', () => ({
),
}));

jest.mock('@/components/CIS2SignInButton/CIS2SignInButton', () => ({
CIS2SignInButton: ({ onClick }: { onClick: () => void }) => (
function mockCIS2SignInButton({ onClick }: { onClick: () => void }) {
return (
<button type='button' data-testid='mock-cis2-button' onClick={onClick}>
Mock CIS2 Sign In Button
</button>
),
}));
);
}

jest.mock(
'@/components/CIS2SignInButton/CIS2SignInButton',
() => mockCIS2SignInButton
);

jest.mock('@/utils/federated-sign-in');

Expand Down
3 changes: 2 additions & 1 deletion frontend/src/__tests__/app/signout/page.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { render, screen, waitFor } from '@testing-library/react';
import SignOutPage from '@/app/signout/page';

jest.mock('@/components/molecules/SignOut/SignOut', () => ({
SignOut: ({ children }: { children: React.ReactNode }) => children,
__esModule: true,
default: ({ children }: { children: React.ReactNode }) => children,
}));

describe('Signout Page', () => {
Expand Down
8 changes: 5 additions & 3 deletions frontend/src/__tests__/components/Header.test.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { render } from '@testing-library/react';
import NHSNotifyHeader from '@/components/molecules/Header/Header';

jest.mock('@/components/molecules/AuthLink/AuthLink', () => ({
AuthLink: () => <div data-testid='auth-link' />,
}));
function mockAuthLink() {
return <div data-testid='auth-link' />;
}

jest.mock('@/components/molecules/AuthLink/AuthLink', () => mockAuthLink);

describe('Header component', () => {
it('renders component correctly', async () => {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/__tests__/utils/amplify-utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jest.mock('next/headers', () => ({
getAll: jest.fn(),
}),
}));
jest.mock('@/amplify_outputs.json', () => ({
jest.mock('@amplify_outputs', () => ({
name: 'mockConfig',
}));

Expand Down
4 changes: 2 additions & 2 deletions frontend/src/__tests__/utils/federated-sign-in.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { signInWithRedirect } from '@aws-amplify/auth';
import { federatedSignIn } from '@/utils/federated-sign-in';

jest.mock('@/amplify_outputs.json', () => ({
jest.mock('@amplify_outputs', () => ({
version: '1.3',
}));

Expand All @@ -12,7 +12,7 @@ jest.mock('@aws-amplify/auth', () => ({

const signInWithRedirectMock = jest.mocked(signInWithRedirect);
// eslint-disable-next-line @typescript-eslint/no-require-imports, unicorn/prefer-module, import-x/no-unresolved
const mockedAmplifyOutputs = jest.mocked(require('@/amplify_outputs.json'));
const mockedAmplifyOutputs = jest.mocked(require('@amplify_outputs'));

describe('federated-sign-in', () => {
beforeEach(() => {
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import React, { Suspense, useEffect } from 'react';
import { RedirectType, redirect, useSearchParams } from 'next/navigation';
import { Authenticator, useAuthenticator } from '@aws-amplify/ui-react';
import JsCookie from 'js-cookie';
import path from 'node:path';
// this is not node:path, this is an npm module
import path from 'path'; // eslint-disable-line unicorn/prefer-node-protocol
import { authenticatorSelector } from '@/utils/authenticator-selector';
import { federatedSignIn } from '@/utils/federated-sign-in';
import CIS2SignInButton from '@/components/CIS2SignInButton/CIS2SignInButton';
Expand Down
1 change: 0 additions & 1 deletion frontend/src/app/signin/route.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable import-x/prefer-default-export */
'use server';

import { cookies } from 'next/headers';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import NHSNotifyContainer from '@/components/layouts/container/container';
import NHSNotifyHeader from '@/components/molecules/Header/Header';
import NHSNotifyFooter from '@/components/molecules/Footer/Footer';

// eslint-disable-next-line import-x/no-unresolved
import amplifyConfig from '@/amplify_outputs.json';
// eslint-disable-next-line @typescript-eslint/no-require-imports, unicorn/prefer-module, import-x/no-unresolved, import-x/no-unresolved
const amplifyConfig = require('@amplify_outputs');

Amplify.configure(amplifyConfig, { ssr: true });

Expand Down
4 changes: 2 additions & 2 deletions frontend/src/utils/amplify-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { fetchAuthSession } from 'aws-amplify/auth/server';
import { FetchAuthSessionOptions, JWT } from '@aws-amplify/auth';
import { jwtDecode } from 'jwt-decode';

// eslint-disable-next-line @typescript-eslint/no-require-imports, import-x/no-unresolved, unicorn/prefer-module
const config = require('@/amplify_outputs.json');
// eslint-disable-next-line @typescript-eslint/no-require-imports, unicorn/prefer-module, import-x/no-unresolved
const config = require('@amplify_outputs');

export const { runWithAmplifyServerContext } = createServerRunner({
config,
Expand Down
5 changes: 3 additions & 2 deletions frontend/src/utils/federated-sign-in.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { signInWithRedirect } from '@aws-amplify/auth';
// eslint-disable-next-line import-x/no-unresolved
import amplifyOutputs from '@/amplify_outputs.json';

// eslint-disable-next-line @typescript-eslint/no-require-imports, unicorn/prefer-module, import-x/no-unresolved
const amplifyOutputs = require('@amplify_outputs');

export type State = {
redirectPath: string;
Expand Down
4 changes: 2 additions & 2 deletions frontend/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"compilerOptions": {
"baseUrl": ".",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
Expand All @@ -19,7 +18,8 @@
}
],
"paths": {
"@/*": ["./src/*"]
"@/*": ["./src/*"],
"@amplify_outputs": ["./amplify_outputs.json"]
},
"target": "ES6"
},
Expand Down
7 changes: 7 additions & 0 deletions lambdas/cis2-api/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,17 @@
*/

import type { Config } from 'jest';
import { pathsToModuleNameMapper } from 'ts-jest';
import { compilerOptions } from './tsconfig.json';

const config: Config = {
preset: 'ts-jest',

// Set the absolute path for imports
moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths, {
prefix: '<rootDir>/',
}),

// Automatically clear mock calls, instances, contexts and results before every test
clearMocks: true,

Expand Down
3 changes: 2 additions & 1 deletion lambdas/cis2-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"jest": "^29.7.0",
"jest-html-reporter": "^3.10.2",
"jest-mock-extended": "^3.0.7",
"jsonwebtoken": "^9.0.2"
"jsonwebtoken": "^9.0.2",
"ts-jest": "^29.3.0"
},
"dependencies": {
"axios": "^1.8.4",
Expand Down
1 change: 0 additions & 1 deletion lambdas/cis2-api/src/authorize-handler.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable import-x/prefer-default-export */
import type { APIGatewayProxyHandler } from 'aws-lambda';
import { extractStringRecord } from '@/src/utils/extract-string-record';

Expand Down
5 changes: 3 additions & 2 deletions lambdas/cis2-api/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"extends": "@tsconfig/node20/tsconfig.json",
"include": ["**/*.ts"],
"include": ["**/*.ts", "*.json"],
"compilerOptions": {
"paths": {
"@/*": ["./*"]
}
},
"resolveJsonModule": true
}
}
1 change: 0 additions & 1 deletion lambdas/jwks-key-rotation/src/handler.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable import-x/prefer-default-export */
import type { ScheduledHandler } from 'aws-lambda';
import {
SigningKeyDirectory,
Expand Down
2 changes: 1 addition & 1 deletion lambdas/jwks-key-rotation/src/utils/aws/kms-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import {
CreateKeyCommand,
DescribeKeyCommand,
GetPublicKeyCommand,
KeyState,
KMSClient,
KeyState,
ScheduleKeyDeletionCommand,
} from '@aws-sdk/client-kms';
import { logger } from '@/src/utils/logger';
Expand Down
3 changes: 2 additions & 1 deletion lambdas/jwks-key-rotation/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"extends": "@tsconfig/node20/tsconfig.json",
"include": [
"**/*.ts"
"**/*.ts",
"**/*.json"
],
"compilerOptions": {
"paths": {
Expand Down
Loading
Loading