test: retain created knowledge bindings across polling
Cross-platform packages / Validate source (push) Canceled after 0s
Cross-platform packages / macos arm64 (push) Canceled after 0s
Cross-platform packages / windows arm64 (push) Canceled after 0s
Cross-platform packages / linux x64 (push) Canceled after 0s
Cross-platform packages / macos x64 (push) Canceled after 0s
Cross-platform packages / windows x64 (push) Canceled after 0s
Cross-platform packages / Publish GitHub and OSS release (push) Canceled after 0s
Cross-platform packages / Authorize desktop packaging (push) Canceled after 0s
Cross-platform packages / linux arm64 (push) Canceled after 0s

Model persisted library state in the external-binding fixture instead of returning pre-creation data to background refreshes. Keep all selected and excluded library assertions, without assuming the last snapshot request belongs to the new library. Windows App: 300 passed; complete frozen Linux suite: 5371 passed, 51 skipped. Typecheck, lint and bilingual notes validation passed.
This commit is contained in:
mesalogo
2026-09-28 04:22:13 +08:00
parent 706726bad6
commit 65a21390de
2 changed files with 21 additions and 5 deletions
+11 -5
View File
@@ -7391,13 +7391,18 @@ describe("App", () => {
const created = { ...existing, id: '33333333-3333-4333-8333-333333333333', name: 'Remote handbook', external: { knowledgeBaseId: '33333333-3333-4333-8333-333333333333', instanceId: instance.id, provider: 'dify' as const, remoteKnowledgeBaseId: 'remote-1', remoteName: 'Remote handbook', commonConfig: { resultLimit: 6, requestTimeoutMs: 15000, maxSnippetCharacters: 4000 }, providerConfig: { provider: 'dify' as const, useDatasetDefaults: true as const }, lastVerifiedAt: '2026-09-12' } };
const initial = { libraries: [existing, excluded], selectedLibraryId: existing.id, sources: [], documents: [], graphNodes: [], graphRelations: [], evidence: [] };
const updated = { ...initial, libraries: [...initial.libraries, created], selectedLibraryId: created.id };
vi.mocked(api.knowledge.getSnapshot).mockImplementation(async (libraryId) =>
libraryId === created.id ? updated : initial
);
let persistedSnapshot = initial;
vi.mocked(api.knowledge.getSnapshot).mockImplementation(async (libraryId) => ({
...persistedSnapshot,
selectedLibraryId: libraryId ?? persistedSnapshot.selectedLibraryId,
}));
vi.mocked(api.knowledge.externalInstancesList).mockResolvedValue([instance]);
vi.mocked(api.knowledge.externalCatalogList).mockResolvedValueOnce({ items: [{ id: 'remote-1', name: 'Remote handbook' }], hasMore: false });
vi.mocked(api.knowledge.externalCatalogGet).mockResolvedValueOnce({ id: 'remote-1', name: 'Remote handbook' });
vi.mocked(api.knowledge.externalBindingsCreate).mockResolvedValueOnce(updated);
vi.mocked(api.knowledge.externalBindingsCreate).mockImplementationOnce(async () => {
persistedSnapshot = updated;
return updated;
});
vi.mocked(api.conversations.list).mockResolvedValueOnce([{ id: '44444444-4444-4444-8444-444444444444', projectId, title: 'External scope test', updatedAt: 200, messages: [], knowledgeLibraryIds: [existing.id] }]);
render(<App />);
await screen.findByRole('button', { name: /^External scope test/u });
@@ -7412,7 +7417,8 @@ describe("App", () => {
await waitFor(() => expect(screen.getByRole('button', { name: '添加知识库' })).toBeEnabled());
fireEvent.click(screen.getByRole('button', { name: '添加知识库' }));
await screen.findByRole('heading', { name: 'Remote handbook' }, { timeout: 5_000 });
await waitFor(() => expect(api.knowledge.getSnapshot).toHaveBeenLastCalledWith(created.id));
// Polling can also refresh another selection; every snapshot must retain the created binding.
await waitFor(() => expect(api.knowledge.getSnapshot).toHaveBeenCalledWith(created.id));
fireEvent.click(screen.getByRole('button', { name: /^External scope test/u }));
openComposerOptions();
fireEvent.click(await screen.findByRole('button', { name: '选择知识库,本次已启用 2 个' }));