Skip to content
Snippets Groups Projects
Commit d027e5fd authored by Embruch, Gerd's avatar Embruch, Gerd
Browse files

fixed tests by adding findRecordByID

parent f505bb7a
No related branches found
No related tags found
No related merge requests found
......@@ -35,6 +35,12 @@ exports[`ai chat with model > given a chatId was sended > should respond with a
}
`;
exports[`ai chat with model > given invalid chatId sended > should respond with a proper body 1`] = `
{
"message": "No chat history with ID 66a2af22df510b35b401f5ba found.",
}
`;
exports[`ai chat with model > given no chatId sended > should respond with a proper body 1`] = `
{
"answer": "It seems you're asking when the pain of mocking (in the context of software development) subsides. Well, with practice and experience, you'll find that your code becomes more robust, and the process of writing unit tests using mocking libraries becomes more natural. The initial discomfort will give way to a sense of confidence and efficiency as you master the art of mocking.",
......@@ -96,9 +102,3 @@ exports[`ai chat with model > given required fields are missing > should respond
},
}
`;
exports[`ai chat with model > given valid chatId sended > should respond with a proper body 1`] = `
{
"message": "No chat history with ID 66a2af22df510b35b401f5ba found.",
}
`;
......@@ -123,6 +123,7 @@ vi.mock('../../utils/handleDB.js', async (importOriginal) => {
...await importOriginal(),
dbConnection: vi.fn(() => 'mocked'),
findOneRecord: vi.fn(() => mockedVals.foundUser),
findRecordByID: vi.fn(() => mockedVals.filledChatRecord),
createRecord: vi.fn(() => mockedVals.emptyChatRecord),
};
});
......@@ -152,7 +153,7 @@ describe('ai chat with model', () => {
describe('given a chatId was sended', () => {
beforeAll(async () => {
dbService.findOneRecord.mockImplementationOnce(() => mockedVals.filledChatRecord);
// dbService.findOneRecord.mockImplementationOnce(() => mockedVals.filledChatRecord);
response = await supertest(app)
.post(ROUTE)
......@@ -170,10 +171,10 @@ describe('ai chat with model', () => {
// ############################
describe('given valid chatId sended', () => {
describe('given invalid chatId sended', () => {
beforeAll(async () => {
dbService.findOneRecord.mockImplementationOnce(() => null);
dbService.findRecordByID.mockImplementationOnce(() => null);
response = await supertest(app)
.post(ROUTE)
......
......@@ -99,7 +99,6 @@ export const getChat = async (req, res, next) => {
try {
// fetch chat record
const record = await findRecordByID(Chat, req.body.chatId);
if (!record) {
return res.status(404).json({ message: `No chat history with ID ${req.body.chatId} found.` });
}
......
......@@ -8,7 +8,7 @@ import { prefillDocumentObject, hideConfidentialFields } from '../utils/handleSc
export const createUser = async (req, res, next) => {
try {
// autoverify if user-agent is Artillery
const isArtilleryAgent = req.get('user-agent').includes('Artillery');
const isArtilleryAgent = (req.get('user-agent') && req.get('user-agent').includes('Artillery') ? true : false);
if (isArtilleryAgent) {
req.body.verified = true;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment