fix(agents): surface unapplied draft changes and publish action
This commit is contained in:
@@ -3,7 +3,14 @@ import { act, cleanup, fireEvent, render, screen, waitFor } from '@testing-libra
|
||||
import { afterEach, beforeEach, expect, it, vi } from 'vitest';
|
||||
import { CloudApproval, CloudChat } from '@/pages/CloudAgents/CloudChat';
|
||||
import { AgentRequirements } from '@/pages/CloudAgents/AgentRequirements';
|
||||
import { CloudAccessPanel } from '@/pages/CloudAgents/CloudAccess';
|
||||
import { CloudAccessPanel as AccessPanel } from '@/pages/CloudAgents/CloudAccess';
|
||||
|
||||
import { useCloudPublication } from '@/pages/CloudAgents/useCloudPublication';
|
||||
|
||||
function CloudAccessPanel(props: { slug: string; revision: number; onPublished: () => void }) {
|
||||
const publication = useCloudPublication(props.slug, props.revision, props.onPublished);
|
||||
return <AccessPanel slug={props.slug} revision={props.revision} publication={publication} />;
|
||||
}
|
||||
|
||||
const api = vi.hoisted(() => ({ call: vi.fn(), events: vi.fn(), download: vi.fn(), recovery: vi.fn(), remember: vi.fn() }));
|
||||
vi.mock('@/lib/cloud-agents-api', () => ({ cloudAgentsApi: api }));
|
||||
@@ -36,7 +43,7 @@ it('starts private use through the existing publication action and retains its i
|
||||
let attempts = 0;
|
||||
api.call.mockImplementation(async (operation, input) => {
|
||||
if (operation === 'access') return { published_version: published ? 1 : null, enabled: true, versions: [], grants: [], applications: [] };
|
||||
if (operation === 'publish') { if (++attempts === 1) throw new Error('连接中断'); published = true; return { version: 1 }; }
|
||||
if (operation === 'publish') { if (++attempts === 1) throw new Error('连接中断'); published = true; return { version: 1, draft_revision: input.expected_revision }; }
|
||||
if (operation === 'costs') return { items: [], next_offset: null, summary: {} };
|
||||
if (operation === 'channelBindings') return { items: [] };
|
||||
return base(operation, input);
|
||||
|
||||
Reference in New Issue
Block a user