mirror of
https://github.com/NanmiCoder/cc-haha
synced 2026-07-16 13:03:31 +08:00
Feishu onboarding previously expected users to find the template bot flow in docs before the desktop form made sense. Surface the documented OpenClaw creation link and the two required setup steps directly in the unconfigured Feishu settings state, while hiding the prompt once saved credentials exist. Constraint: The documented one-click template URL is the source of truth for bot creation. Rejected: Add a full wizard | this flow only needs a short external creation link plus credential fields. Confidence: high Scope-risk: narrow Directive: Keep this prompt short; detailed Feishu menu setup belongs in docs, not the settings form. Tested: cd desktop && bunx vitest run src/pages/AdapterSettings.test.tsx src/i18n/index.test.tsx Tested: cd desktop && bun run lint Tested: git diff --check Tested: bun run check:desktop Not-tested: Live Feishu developer console account flow.
55 lines
2.0 KiB
TypeScript
55 lines
2.0 KiB
TypeScript
import { afterEach, describe, expect, it, vi } from 'vitest'
|
|
import { cleanup, render, screen } from '@testing-library/react'
|
|
import '@testing-library/jest-dom'
|
|
|
|
import { AdapterSettings } from './AdapterSettings'
|
|
import { useAdapterStore } from '../stores/adapterStore'
|
|
import { useSettingsStore } from '../stores/settingsStore'
|
|
import type { AdapterFileConfig } from '../types/adapter'
|
|
|
|
const FEISHU_CREATE_BOT_URL = 'https://open.feishu.cn/page/openclaw?form=multiAgent'
|
|
|
|
function renderAdapterSettings(config: AdapterFileConfig) {
|
|
useSettingsStore.setState({ locale: 'en' })
|
|
useAdapterStore.setState({
|
|
config,
|
|
isLoading: false,
|
|
fetchConfig: vi.fn(async () => {}),
|
|
} as Partial<ReturnType<typeof useAdapterStore.getState>>)
|
|
|
|
render(<AdapterSettings />)
|
|
}
|
|
|
|
afterEach(() => {
|
|
cleanup()
|
|
useAdapterStore.setState(useAdapterStore.getInitialState(), true)
|
|
useSettingsStore.setState(useSettingsStore.getInitialState(), true)
|
|
})
|
|
|
|
describe('AdapterSettings Feishu onboarding', () => {
|
|
it('shows the documented one-click Feishu bot link before credentials are configured', () => {
|
|
renderAdapterSettings({})
|
|
|
|
expect(screen.getByText('Need a Feishu bot?')).toBeInTheDocument()
|
|
expect(screen.getByText(/OpenClaw template/)).toBeInTheDocument()
|
|
expect(screen.getByText('1. Create the bot from the template.')).toBeInTheDocument()
|
|
expect(screen.getByText('2. Copy its App ID and App Secret, then fill them in here.')).toBeInTheDocument()
|
|
expect(screen.getByRole('link', { name: /create feishu bot/i })).toHaveAttribute(
|
|
'href',
|
|
FEISHU_CREATE_BOT_URL,
|
|
)
|
|
})
|
|
|
|
it('hides the one-click Feishu bot prompt once saved credentials exist', () => {
|
|
renderAdapterSettings({
|
|
feishu: {
|
|
appId: 'cli_existing',
|
|
appSecret: '****cret',
|
|
},
|
|
})
|
|
|
|
expect(screen.queryByRole('link', { name: /create feishu bot/i })).not.toBeInTheDocument()
|
|
expect(screen.queryByText('Need a Feishu bot?')).not.toBeInTheDocument()
|
|
})
|
|
})
|