diff --git a/backend/src/controller/startController.ts b/backend/src/controller/startController.ts index 7198d900f..a2994f9d4 100644 --- a/backend/src/controller/startController.ts +++ b/backend/src/controller/startController.ts @@ -1,7 +1,8 @@ import { Response } from 'express'; import { StartGetRequest } from '@src/models/api/StartGetRequest'; -import { LEVEL_NAMES } from '@src/models/level'; +import { ChatModel } from '@src/models/chat'; +import { LEVEL_NAMES, LevelState } from '@src/models/level'; import { getValidOpenAIModels } from '@src/openai'; import { systemRoleLevel1, @@ -11,6 +12,14 @@ import { import { sendErrorResponse } from './handleError'; +declare module 'express-session' { + interface Session { + initialised: boolean; + chatModel: ChatModel; + levelState: LevelState[]; + } +} + function handleStart(req: StartGetRequest, res: Response) { const { level } = req.query; diff --git a/backend/test/integration/chatController.test.ts b/backend/test/integration/chatController.test.ts index 51f582eaf..d01cd7594 100644 --- a/backend/test/integration/chatController.test.ts +++ b/backend/test/integration/chatController.test.ts @@ -16,12 +16,6 @@ declare module 'express-session' { chatModel: ChatModel; levelState: LevelState[]; } - interface LevelState { - level: LEVEL_NAMES; - chatHistory: ChatMessage[]; - defences: Defence[]; - sentEmails: EmailInfo[]; - } } // mock the api call diff --git a/backend/test/unit/controller/chatController.test.ts b/backend/test/unit/controller/chatController.test.ts index a0a44b62d..8bbe67ed0 100644 --- a/backend/test/unit/controller/chatController.test.ts +++ b/backend/test/unit/controller/chatController.test.ts @@ -32,12 +32,6 @@ declare module 'express-session' { chatModel: ChatModel; levelState: LevelState[]; } - interface LevelState { - level: LEVEL_NAMES; - chatHistory: ChatMessage[]; - defences: Defence[]; - sentEmails: EmailInfo[]; - } } jest.mock('@src/openai'); diff --git a/backend/test/unit/controller/defenceController.test.ts b/backend/test/unit/controller/defenceController.test.ts index 5ed392cf9..ccbb16641 100644 --- a/backend/test/unit/controller/defenceController.test.ts +++ b/backend/test/unit/controller/defenceController.test.ts @@ -8,7 +8,7 @@ import { ChatModel } from '@src/models/chat'; import { ChatMessage } from '@src/models/chatMessage'; import { DEFENCE_ID, Defence } from '@src/models/defence'; import { EmailInfo } from '@src/models/email'; -import { LEVEL_NAMES } from '@src/models/level'; +import { LEVEL_NAMES, LevelState } from '@src/models/level'; declare module 'express-session' { interface Session { @@ -16,12 +16,6 @@ declare module 'express-session' { chatModel: ChatModel; levelState: LevelState[]; } - interface LevelState { - level: LEVEL_NAMES; - chatHistory: ChatMessage[]; - defences: Defence[]; - sentEmails: EmailInfo[]; - } } jest.mock('@src/defence'); diff --git a/backend/test/unit/controller/emailController.test.ts b/backend/test/unit/controller/emailController.test.ts index 6c44a4d84..ec6db1b35 100644 --- a/backend/test/unit/controller/emailController.test.ts +++ b/backend/test/unit/controller/emailController.test.ts @@ -4,10 +4,8 @@ import { Response } from 'express'; import { handleClearEmails } from '@src/controller/emailController'; import { EmailClearRequest } from '@src/models/api/EmailClearRequest'; import { ChatModel } from '@src/models/chat'; -import { ChatMessage } from '@src/models/chatMessage'; -import { Defence } from '@src/models/defence'; import { EmailInfo } from '@src/models/email'; -import { LEVEL_NAMES } from '@src/models/level'; +import { LevelState } from '@src/models/level'; declare module 'express-session' { interface Session { @@ -15,12 +13,6 @@ declare module 'express-session' { chatModel: ChatModel; levelState: LevelState[]; } - interface LevelState { - level: LEVEL_NAMES; - chatHistory: ChatMessage[]; - defences: Defence[]; - sentEmails: EmailInfo[]; - } } function responseMock() { diff --git a/backend/test/unit/controller/levelController.test.ts b/backend/test/unit/controller/levelController.test.ts index 636dfbb91..3d2df5d41 100644 --- a/backend/test/unit/controller/levelController.test.ts +++ b/backend/test/unit/controller/levelController.test.ts @@ -3,25 +3,6 @@ import { Response } from 'express'; import { handleLoadLevel } from '@src/controller/levelController'; import { LevelGetRequest } from '@src/models/api/LevelGetRequest'; -import { ChatModel } from '@src/models/chat'; -import { ChatMessage } from '@src/models/chatMessage'; -import { Defence } from '@src/models/defence'; -import { EmailInfo } from '@src/models/email'; -import { LEVEL_NAMES } from '@src/models/level'; - -declare module 'express-session' { - interface Session { - initialised: boolean; - chatModel: ChatModel; - levelState: LevelState[]; - } - interface LevelState { - level: LEVEL_NAMES; - chatHistory: ChatMessage[]; - defences: Defence[]; - sentEmails: EmailInfo[]; - } -} jest.mock('@src/promptTemplates', () => ({ systemRoleLevel1: 'systemRoleLevel1', diff --git a/backend/test/unit/controller/resetController.test.ts b/backend/test/unit/controller/resetController.test.ts index 6a5807f4e..69902b805 100644 --- a/backend/test/unit/controller/resetController.test.ts +++ b/backend/test/unit/controller/resetController.test.ts @@ -19,13 +19,8 @@ declare module 'express-session' { chatModel: ChatModel; levelState: LevelState[]; } - interface LevelState { - level: LEVEL_NAMES; - chatHistory: ChatMessage[]; - defences: Defence[]; - sentEmails: EmailInfo[]; - } } + function responseMock() { return { send: jest.fn(), diff --git a/backend/test/unit/controller/startController.test.ts b/backend/test/unit/controller/startController.test.ts index 77751f15d..eb5204f20 100644 --- a/backend/test/unit/controller/startController.test.ts +++ b/backend/test/unit/controller/startController.test.ts @@ -3,25 +3,6 @@ import { Response } from 'express'; import { handleStart } from '@src/controller/startController'; import { StartGetRequest } from '@src/models/api/StartGetRequest'; -import { ChatModel } from '@src/models/chat'; -import { ChatMessage } from '@src/models/chatMessage'; -import { Defence } from '@src/models/defence'; -import { EmailInfo } from '@src/models/email'; -import { LEVEL_NAMES } from '@src/models/level'; - -declare module 'express-session' { - interface Session { - initialised: boolean; - chatModel: ChatModel; - levelState: LevelState[]; - } - interface LevelState { - level: LEVEL_NAMES; - chatHistory: ChatMessage[]; - defences: Defence[]; - sentEmails: EmailInfo[]; - } -} jest.mock('@src/promptTemplates', () => ({ systemRoleLevel1: 'systemRoleLevel1',