feat(db & e2e): Enhance DB Schemas/Controllers and Improve E2E Tests (#966)

* feat: add global teardown to remove test data and add registration/log-out to auth flow

* refactor(models/Conversation): index user field and add JSDoc to deleteConvos

* refactor: add user index to message schema and ensure user is saved to each Message

* refactor: add user to each saveMessage call

* fix: handle case where title is null in zod schema

* feat(e2e): ensure messages are deleted on cleanUp

* fix: set last convo for all endpoints on conversation update

* fix: enable registration for CI env
This commit is contained in:
Danny Avila 2023-09-18 15:19:50 -04:00 committed by GitHub
parent fd70e21732
commit 6358383001
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
28 changed files with 229 additions and 72 deletions

View file

@ -75,6 +75,7 @@ router.post('/', validateEndpoint, buildEndpointOption, setHeaders, async (req,
cancelled: false,
isEdited: true,
error: false,
user,
});
}
@ -89,7 +90,7 @@ router.post('/', validateEndpoint, buildEndpointOption, setHeaders, async (req,
plugin.inputs.push(formattedAction);
plugin.latest = formattedAction.plugin;
if (!start) {
saveMessage(userMessage);
saveMessage({ ...userMessage, user });
}
sendIntermediateMessage(res, { plugin });
// console.log('PLUGIN ACTION', formattedAction);
@ -99,7 +100,7 @@ router.post('/', validateEndpoint, buildEndpointOption, setHeaders, async (req,
let { intermediateSteps: steps } = data;
plugin.outputs = steps && steps[0].action ? formatSteps(steps) : 'An error occurred.';
plugin.loading = false;
saveMessage(userMessage);
saveMessage({ ...userMessage, user });
sendIntermediateMessage(res, { plugin });
// console.log('CHAIN END', plugin.outputs);
};
@ -154,12 +155,12 @@ router.post('/', validateEndpoint, buildEndpointOption, setHeaders, async (req,
console.log('CLIENT RESPONSE');
console.dir(response, { depth: null });
response.plugin = { ...plugin, loading: false };
await saveMessage(response);
await saveMessage({ ...response, user });
sendMessage(res, {
title: await getConvoTitle(req.user.id, conversationId),
title: await getConvoTitle(user, conversationId),
final: true,
conversation: await getConvo(req.user.id, conversationId),
conversation: await getConvo(user, conversationId),
requestMessage: userMessage,
responseMessage: response,
});