mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-11 20:08:37 +00:00
feat: improve query performence (#6764)
This commit is contained in:
@@ -336,6 +336,32 @@ test('should be able to generate with message id', async t => {
|
||||
}
|
||||
});
|
||||
|
||||
test('should save message correctly', async t => {
|
||||
const { prompt, session } = t.context;
|
||||
|
||||
await prompt.set('prompt', 'model', [
|
||||
{ role: 'system', content: 'hello {{word}}' },
|
||||
]);
|
||||
|
||||
const sessionId = await session.create({
|
||||
docId: 'test',
|
||||
workspaceId: 'test',
|
||||
userId,
|
||||
promptName: 'prompt',
|
||||
});
|
||||
const s = (await session.get(sessionId))!;
|
||||
|
||||
const message = (await session.createMessage({
|
||||
sessionId,
|
||||
content: 'hello',
|
||||
}))!;
|
||||
|
||||
await s.pushByMessageId(message);
|
||||
t.is(s.stashMessages.length, 1, 'should get stash messages');
|
||||
await s.save();
|
||||
t.is(s.stashMessages.length, 0, 'should empty stash messages after save');
|
||||
});
|
||||
|
||||
// ==================== provider ====================
|
||||
|
||||
test('should be able to get provider', async t => {
|
||||
|
||||
@@ -29,11 +29,7 @@ class WorkspaceResolverMock {
|
||||
permissions: {
|
||||
create: {
|
||||
type: Permission.Owner,
|
||||
user: {
|
||||
connect: {
|
||||
id: user.id,
|
||||
},
|
||||
},
|
||||
userId: user.id,
|
||||
accepted: true,
|
||||
},
|
||||
},
|
||||
@@ -163,7 +159,7 @@ test('should be able to set workspace feature', async t => {
|
||||
const f1 = await feature.getWorkspaceFeatures(w1.id);
|
||||
t.is(f1.length, 0, 'should be empty');
|
||||
|
||||
await feature.addWorkspaceFeature(w1.id, FeatureType.Copilot, 1, 'test');
|
||||
await feature.addWorkspaceFeature(w1.id, FeatureType.Copilot, 'test');
|
||||
|
||||
const f2 = await feature.getWorkspaceFeatures(w1.id);
|
||||
t.is(f2.length, 1, 'should have 1 feature');
|
||||
@@ -178,7 +174,7 @@ test('should be able to check workspace feature', async t => {
|
||||
const f1 = await management.hasWorkspaceFeature(w1.id, FeatureType.Copilot);
|
||||
t.false(f1, 'should not have copilot');
|
||||
|
||||
await management.addWorkspaceFeatures(w1.id, FeatureType.Copilot, 1, 'test');
|
||||
await management.addWorkspaceFeatures(w1.id, FeatureType.Copilot, 'test');
|
||||
const f2 = await management.hasWorkspaceFeature(w1.id, FeatureType.Copilot);
|
||||
t.true(f2, 'should have copilot');
|
||||
|
||||
@@ -195,7 +191,7 @@ test('should be able revert workspace feature', async t => {
|
||||
const f1 = await management.hasWorkspaceFeature(w1.id, FeatureType.Copilot);
|
||||
t.false(f1, 'should not have feature');
|
||||
|
||||
await management.addWorkspaceFeatures(w1.id, FeatureType.Copilot, 1, 'test');
|
||||
await management.addWorkspaceFeatures(w1.id, FeatureType.Copilot, 'test');
|
||||
const f2 = await management.hasWorkspaceFeature(w1.id, FeatureType.Copilot);
|
||||
t.true(f2, 'should have feature');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user