Skip to content

Commit

Permalink
Update test
Browse files Browse the repository at this point in the history
  • Loading branch information
heatherlogan-scottlogic committed Aug 1, 2023
1 parent 160414d commit 35c8b38
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 21 deletions.
30 changes: 15 additions & 15 deletions backend/src/openai.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,21 @@ const chatGptFunctions = [
parameters: {
type: "object",
properties: {}
}
},
{
name: "askQuestion",
description: "Ask a question about the documents with company information. ",
parameters: {
type: "object",
properties: {
question: {
type: "string",
description: "The question asked about the documents",
}
}
},
{
name: "askQuestion",
description: "Ask a question about the documents with company information. ",
parameters: {
type: "object",
properties: {
question: {
type: "string",
description: "The question asked about the documents",
}
}
},
}
},
];

function initOpenAi() {
Expand Down Expand Up @@ -104,12 +104,12 @@ async function chatGptCallFunction(functionCall, defenceInfo, session) {
session
);
}

} else if (functionName == "getEmailWhitelist") {
response = getEmailWhitelist(isDefenceActive("EMAIL_WHITELIST", session.activeDefences));
}

if (functionName === "askQuestion"){
if (functionName === "askQuestion") {
console.debug("Asking question: " + params.question);
// if asking a question, call the queryDocuments
response = await queryDocuments(params.question);
Expand Down
13 changes: 7 additions & 6 deletions backend/test/unit/email.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@ test("GIVEN email is ready to be sent WHEN email is sent THEN session list is up
};
const response = sendEmail(address, subject, body, session);
// check the response
expect(response).toBe(JSON.stringify({ isEmailSent: true }));
// check the sent email has been added to the session
expect(session.sentEmails.length).toBe(1);
expect(session.sentEmails[0].address).toBe(address);
expect(session.sentEmails[0].subject).toBe(subject);
expect(session.sentEmails[0].content).toBe(body);
expect(response).toBe("Email sent to " + address + " with subject " +
subject + " and body " + body);
// check the sent email has been added to the session
expect(session.sentEmails.length).toBe(1);
expect(session.sentEmails[0].address).toBe(address);
expect(session.sentEmails[0].subject).toBe(subject);
expect(session.sentEmails[0].content).toBe(body);
});

test("GIVEN EMAIL_WHITELIST envionrment variable is set WHEN getting whitelist AND whitelist defense on THEN list is returned", () => {
Expand Down

0 comments on commit 35c8b38

Please sign in to comment.