mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-09-22 19:53:48 +08:00
@@ -290,6 +290,7 @@ test('should fork session correctly', async t => {
|
|||||||
|
|
||||||
const assertForkSession = async (
|
const assertForkSession = async (
|
||||||
workspaceId: string,
|
workspaceId: string,
|
||||||
|
docId: string,
|
||||||
sessionId: string,
|
sessionId: string,
|
||||||
lastMessageId: string | undefined,
|
lastMessageId: string | undefined,
|
||||||
error: string,
|
error: string,
|
||||||
@@ -300,13 +301,7 @@ test('should fork session correctly', async t => {
|
|||||||
}
|
}
|
||||||
) =>
|
) =>
|
||||||
await asserter(
|
await asserter(
|
||||||
forkCopilotSession(
|
forkCopilotSession(app, workspaceId, docId, sessionId, lastMessageId)
|
||||||
app,
|
|
||||||
workspaceId,
|
|
||||||
randomUUID(),
|
|
||||||
sessionId,
|
|
||||||
lastMessageId
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// prepare session
|
// prepare session
|
||||||
@@ -330,6 +325,7 @@ test('should fork session correctly', async t => {
|
|||||||
// should be able to fork session
|
// should be able to fork session
|
||||||
forkedSessionId = await assertForkSession(
|
forkedSessionId = await assertForkSession(
|
||||||
id,
|
id,
|
||||||
|
docId,
|
||||||
sessionId,
|
sessionId,
|
||||||
latestMessageId!,
|
latestMessageId!,
|
||||||
'should be able to fork session with cloud workspace that user can access'
|
'should be able to fork session with cloud workspace that user can access'
|
||||||
@@ -340,6 +336,7 @@ test('should fork session correctly', async t => {
|
|||||||
{
|
{
|
||||||
forkedSessionId = await assertForkSession(
|
forkedSessionId = await assertForkSession(
|
||||||
id,
|
id,
|
||||||
|
docId,
|
||||||
sessionId,
|
sessionId,
|
||||||
undefined,
|
undefined,
|
||||||
'should be able to fork session without latestMessageId'
|
'should be able to fork session without latestMessageId'
|
||||||
@@ -348,18 +345,25 @@ test('should fork session correctly', async t => {
|
|||||||
|
|
||||||
// should not be able to fork session with wrong latestMessageId
|
// should not be able to fork session with wrong latestMessageId
|
||||||
{
|
{
|
||||||
await assertForkSession(id, sessionId, 'wrong-message-id', '', async x => {
|
await assertForkSession(
|
||||||
await t.throwsAsync(
|
id,
|
||||||
x,
|
docId,
|
||||||
{ instanceOf: Error },
|
sessionId,
|
||||||
'should not able to fork session with wrong latestMessageId'
|
'wrong-message-id',
|
||||||
);
|
'',
|
||||||
});
|
async x => {
|
||||||
|
await t.throwsAsync(
|
||||||
|
x,
|
||||||
|
{ instanceOf: Error },
|
||||||
|
'should not able to fork session with wrong latestMessageId'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
const u2 = await app.signupV1();
|
const u2 = await app.signupV1();
|
||||||
await assertForkSession(id, sessionId, randomUUID(), '', async x => {
|
await assertForkSession(id, docId, sessionId, randomUUID(), '', async x => {
|
||||||
await t.throwsAsync(
|
await t.throwsAsync(
|
||||||
x,
|
x,
|
||||||
{ instanceOf: Error },
|
{ instanceOf: Error },
|
||||||
@@ -371,7 +375,7 @@ test('should fork session correctly', async t => {
|
|||||||
const inviteId = await inviteUser(app, id, u2.email);
|
const inviteId = await inviteUser(app, id, u2.email);
|
||||||
await app.switchUser(u2);
|
await app.switchUser(u2);
|
||||||
await acceptInviteById(app, id, inviteId, false);
|
await acceptInviteById(app, id, inviteId, false);
|
||||||
await assertForkSession(id, sessionId, randomUUID(), '', async x => {
|
await assertForkSession(id, docId, sessionId, randomUUID(), '', async x => {
|
||||||
await t.throwsAsync(
|
await t.throwsAsync(
|
||||||
x,
|
x,
|
||||||
{ instanceOf: Error },
|
{ instanceOf: Error },
|
||||||
@@ -389,6 +393,7 @@ test('should fork session correctly', async t => {
|
|||||||
await app.switchUser(u2);
|
await app.switchUser(u2);
|
||||||
await assertForkSession(
|
await assertForkSession(
|
||||||
id,
|
id,
|
||||||
|
docId,
|
||||||
forkedSessionId,
|
forkedSessionId,
|
||||||
latestMessageId!,
|
latestMessageId!,
|
||||||
'should able to fork a forked session created by other user'
|
'should able to fork a forked session created by other user'
|
||||||
|
|||||||
@@ -507,6 +507,8 @@ export class ChatSessionService {
|
|||||||
return await this.models.copilotSession.fork({
|
return await this.models.copilotSession.fork({
|
||||||
...session,
|
...session,
|
||||||
userId: options.userId,
|
userId: options.userId,
|
||||||
|
// docId can be changed in fork
|
||||||
|
docId: options.docId,
|
||||||
sessionId: randomUUID(),
|
sessionId: randomUUID(),
|
||||||
parentSessionId: options.sessionId,
|
parentSessionId: options.sessionId,
|
||||||
messages,
|
messages,
|
||||||
|
|||||||
Reference in New Issue
Block a user