Skip to content

Commit

Permalink
removes redundant LevelState declaration from session module declaration
Browse files Browse the repository at this point in the history
  • Loading branch information
pmarsh-scottlogic committed Feb 27, 2024
1 parent 14119c2 commit 5e3301b
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 73 deletions.
11 changes: 10 additions & 1 deletion backend/src/controller/startController.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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;

Expand Down
6 changes: 0 additions & 6 deletions backend/test/integration/chatController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 0 additions & 6 deletions backend/test/unit/controller/chatController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
8 changes: 1 addition & 7 deletions backend/test/unit/controller/defenceController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,14 @@ 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 {
initialised: boolean;
chatModel: ChatModel;
levelState: LevelState[];
}
interface LevelState {
level: LEVEL_NAMES;
chatHistory: ChatMessage[];
defences: Defence[];
sentEmails: EmailInfo[];
}
}

jest.mock('@src/defence');
Expand Down
10 changes: 1 addition & 9 deletions backend/test/unit/controller/emailController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,15 @@ 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 {
initialised: boolean;
chatModel: ChatModel;
levelState: LevelState[];
}
interface LevelState {
level: LEVEL_NAMES;
chatHistory: ChatMessage[];
defences: Defence[];
sentEmails: EmailInfo[];
}
}

function responseMock() {
Expand Down
19 changes: 0 additions & 19 deletions backend/test/unit/controller/levelController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
7 changes: 1 addition & 6 deletions backend/test/unit/controller/resetController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
19 changes: 0 additions & 19 deletions backend/test/unit/controller/startController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit 5e3301b

Please sign in to comment.