This commit is contained in:
2026-08-04 21:01:39 +08:00
parent 88bd939170
commit 5cb1ca307d
77 changed files with 9914 additions and 131 deletions
@@ -8,8 +8,8 @@ import {
} from '@/modules/master-data/counterparties/api/platformPartners'
import { useAccessPreviewStore } from '@/core/access/accessPreview'
import { useAuthStore } from '@/core/auth/auth'
import QueryToolbar from '@/shared/components/QueryToolbar.vue'
import { listPlatformTenants, type PlatformTenantResource } from '../../../iam/api/platformIam'
import PlatformTenantSelector from '../../../iam/components/PlatformTenantSelector.vue'
import PartnersView from './PartnersView.vue'
vi.mock('@/modules/master-data/counterparties/api/platformPartners', () => ({
@@ -111,12 +111,14 @@ describe('PartnersView real API integration', () => {
})
})
it('loads the fixed tenant page and renders the real partner fields', async () => {
it('loads all enterprises by default and renders the real partner fields', async () => {
const wrapper = await mountView()
expect(listPlatformPartners).toHaveBeenCalledWith(10001, {
expect(listPlatformPartners).toHaveBeenCalledWith(undefined, {
page: 1, size: 20, keyword: undefined, type: undefined, status: undefined,
})
expect(wrapper.find('input[aria-label="所属企业"]').exists()).toBe(true)
expect(wrapper.text()).toContain('全部企业 · 共 1 个往来单位')
expect(wrapper.text()).toContain('深圳示例贸易有限公司')
expect(wrapper.text()).toContain('CUS-001')
expect(wrapper.text()).toContain('contact@example.com')
@@ -131,7 +133,10 @@ describe('PartnersView real API integration', () => {
it('preserves a snowflake tenant id as a string when switching enterprises', async () => {
const wrapper = await mountView()
wrapper.findComponent(PlatformTenantSelector).vm.$emit('update:modelValue', snowflakeTenantId)
const toolbar = wrapper.findComponent(QueryToolbar)
const model = { tenantId: snowflakeTenantId, keyword: '', type: '', status: '' }
toolbar.vm.$emit('update:modelValue', model)
toolbar.vm.$emit('search', model)
await flushPromises()
expect(listPlatformPartners).toHaveBeenLastCalledWith(snowflakeTenantId, {
@@ -153,13 +158,18 @@ describe('PartnersView real API integration', () => {
await flushPromises()
expect(listPlatformPartners).toHaveBeenCalledTimes(2)
expect(listPlatformPartners).toHaveBeenLastCalledWith(10001, {
expect(listPlatformPartners).toHaveBeenLastCalledWith(undefined, {
page: 1, size: 20, keyword: '深圳', type: undefined, status: undefined,
})
})
it('shows useful placeholders and visible required markers in the create form', async () => {
const wrapper = await mountView()
const toolbar = wrapper.findComponent(QueryToolbar)
const model = { tenantId: '10001', keyword: '', type: '', status: '' }
toolbar.vm.$emit('update:modelValue', model)
toolbar.vm.$emit('search', model)
await flushPromises()
const createButton = wrapper.findAll('button').find((button) => button.text().trim() === '新增往来单位')
expect(createButton).toBeDefined()
await createButton?.trigger('click')