Remove selected-user sharing from cloud agent access UI

This commit is contained in:
2026-09-19 08:52:04 +08:00
parent 7fb4c60492
commit e04787763b
8 changed files with 94 additions and 31 deletions

View File

@@ -118,7 +118,7 @@ it('shares the original failed publication between the header and access page',
fireEvent.click(screen.getByRole('button', { name: '应用最新修改', exact: true }));
await screen.findByText(/连接中断/);
expect(screen.getByRole('button', { name: '重试本次应用' })).toBeEnabled();
fireEvent.click(screen.getByRole('button', { name: '使用与分享' }));
fireEvent.click(screen.getByRole('button', { name: '使用与接入' }));
fireEvent.click(await screen.findByRole('button', { name: '重试本次发布' }));
await waitFor(() => expect(screen.getByRole('button', { name: '已应用', exact: true })).toBeDisabled());
const calls = api.call.mock.calls.filter(([operation]) => operation === 'publish');

View File

@@ -187,6 +187,33 @@ it('restores a durable question and follows the new resume run', async () => {
expect(api.call.mock.calls.find(call => call[0] === 'resume')?.[1].decision).toEqual({ direction: '海洋' });
});
it('keeps channel and application access without offering selected-user sharing', async () => {
const base = api.call.getMockImplementation()!;
api.call.mockImplementation(async (operation, input) => {
if (operation === 'access') return {
published_version: 1, enabled: true, share_url: 'niancode://agents/' + slug,
versions: [], grants: [{ account_id: 'previously-shared-user', enabled: true }], applications: [],
};
if (operation === 'costs') return { items: [], next_offset: null, unit: '词元点数', summary: { count: 0, settled_points: '0.00', pending_points: '0.00' } };
if (operation === 'createApplication') return { id: 'application-1', name: input.name, enabled: true };
return base(operation, input);
});
render(<CloudAccessPanel slug={slug} revision={2} onPublished={() => undefined} />);
expect(await screen.findByRole('heading', { name: '应用与 API' })).toBeVisible();
expect(screen.getByRole('button', { name: '打开渠道' })).toBeEnabled();
expect(screen.getByRole('button', { name: '停用智能体' })).toBeEnabled();
expect(screen.queryByRole('heading', { name: '分享给指定用户' })).not.toBeInTheDocument();
expect(screen.queryByLabelText('查找分享用户')).not.toBeInTheDocument();
expect(screen.queryByRole('button', { name: '复制分享链接' })).not.toBeInTheDocument();
expect(screen.queryByText('previously-shared-user')).not.toBeInTheDocument();
expect(screen.queryByText('niancode://agents/' + slug)).not.toBeInTheDocument();
fireEvent.change(screen.getByLabelText('应用名称'), { target: { value: '我的网站' } });
fireEvent.click(screen.getByRole('button', { name: '创建应用' }));
await screen.findByText('应用已创建,可为它生成 API 凭据');
expect(api.call).toHaveBeenCalledWith('createApplication', expect.objectContaining({ slug, name: '我的网站' }));
expect(api.call.mock.calls.some(([operation]) => operation === 'users' || operation === 'share')).toBe(false);
});
it('keeps publication and access controls usable when cost history is unavailable', async () => {
api.call.mockImplementation(async (operation) => {
if (operation === 'access') return { published_version: 1, enabled: true, share_url: 'niancode://agents/' + slug, versions: [], grants: [], applications: [] };