feat: add pagination support for workspace config (#11859)

fix AI-78
This commit is contained in:
darkskygit
2025-04-23 11:25:41 +00:00
parent 5397fba897
commit ddb739fa13
13 changed files with 460 additions and 113 deletions
@@ -0,0 +1,56 @@
# Snapshot report for `src/__tests__/models/copilot-workspace.spec.ts`
The actual snapshot is saved in `copilot-workspace.spec.ts.snap`.
Generated by [AVA](https://avajs.dev).
## should manage copilot workspace ignored docs
> should add ignored doc
1
> should return added doc
[
{
docId: 'doc1',
},
]
> should return ignored docs in workspace
[
'doc1',
]
> should not add ignored doc again
[
{
docId: 'doc1',
},
]
> should add new ignored doc
2
> should add ignored doc
[
{
docId: 'new_doc',
},
{
docId: 'doc1',
},
]
> should remove ignored doc
[
{
docId: 'new_doc',
},
]
@@ -6,6 +6,7 @@ import { CopilotWorkspaceConfigModel } from '../../models/copilot-workspace';
import { UserModel } from '../../models/user';
import { WorkspaceModel } from '../../models/workspace';
import { createTestingModule, type TestingModule } from '../utils';
import { cleanObject } from '../utils/copilot';
interface Context {
config: Config;
@@ -56,16 +57,16 @@ test('should manage copilot workspace ignored docs', async t => {
workspace.id,
[docId]
);
t.is(count, 1, 'should add ignored doc');
t.snapshot(count, 'should add ignored doc');
const ret = await t.context.copilotWorkspace.listIgnoredDocs(workspace.id);
t.deepEqual(ret, [docId], 'should return added doc');
t.snapshot(cleanObject(ret), 'should return added doc');
const check = await t.context.copilotWorkspace.checkIgnoredDocs(
workspace.id,
[docId]
);
t.deepEqual(check, [docId], 'should return ignored docs in workspace');
t.snapshot(check, 'should return ignored docs in workspace');
}
{
@@ -76,7 +77,7 @@ test('should manage copilot workspace ignored docs', async t => {
t.is(count, 1, 'should not add ignored doc again');
const ret = await t.context.copilotWorkspace.listIgnoredDocs(workspace.id);
t.deepEqual(ret, [docId], 'should not add ignored doc again');
t.snapshot(cleanObject(ret), 'should not add ignored doc again');
}
{
@@ -84,10 +85,10 @@ test('should manage copilot workspace ignored docs', async t => {
workspace.id,
['new_doc']
);
t.is(count, 2, 'should add new ignored doc');
t.snapshot(count, 'should add new ignored doc');
const ret = await t.context.copilotWorkspace.listIgnoredDocs(workspace.id);
t.deepEqual(ret, [docId, 'new_doc'], 'should add ignored doc');
t.snapshot(cleanObject(ret), 'should add ignored doc');
}
{
@@ -98,7 +99,7 @@ test('should manage copilot workspace ignored docs', async t => {
);
const ret = await t.context.copilotWorkspace.listIgnoredDocs(workspace.id);
t.deepEqual(ret, ['new_doc'], 'should remove ignored doc');
t.snapshot(cleanObject(ret), 'should remove ignored doc');
}
});