This commit is contained in:
2026-09-11 16:17:21 +08:00
parent 80a4b3ab5e
commit 737dd41ff1
24 changed files with 202 additions and 229 deletions
@@ -263,7 +263,7 @@ describe('CustomersView', () => {
await wrapper.get('input[placeholder="请输入工商登记公司名称"]').setValue(fullTenant.tenantName)
await wrapper.get('input[placeholder="请输入营业执照上的企业名称"]').setValue(fullTenant.legalName)
await wrapper.get('input[placeholder="请输入法定代表人姓名"]').setValue(fullTenant.legalRepresentative)
expect(wrapper.get('input[placeholder="请输入法定代表人姓名(选填)"]').attributes('aria-required')).not.toBe('true')
await wrapper.get('input[placeholder="请输入主要联系人姓名"]').setValue(fullTenant.contactName)
await wrapper.get('input[placeholder="请输入公司联系电话"]').setValue(fullTenant.contactPhone)
await wrapper.get('input[placeholder="请输入18位大写字母或数字"]').setValue(fullTenant.unifiedSocialCreditCode)
@@ -277,6 +277,7 @@ describe('CustomersView', () => {
expect(createPlatformTenant).toHaveBeenCalledWith(expect.objectContaining({
tenantName: fullTenant.tenantName,
contactPhone: fullTenant.contactPhone,
legalRepresentative: '',
}))
expect(createPlatformTenant).toHaveBeenCalledWith(expect.not.objectContaining({ unifiedSocialCreditCode: expect.anything() }))
expect(uploadPlatformTenantRequiredQualificationPackage).toHaveBeenCalledWith(
@@ -710,6 +711,9 @@ describe('CustomersView', () => {
auth.permissions = [...auth.permissions, 'platform:customer:delete']
useAccessPreviewStore().initializeAfterLogin()
vi.mocked(archivePlatformTenant).mockResolvedValue({ ...fullTenant, status: 'ARCHIVED' })
vi.mocked(listPlatformTenants)
.mockResolvedValueOnce({ records: [fullTenant], page: 1, size: 10, total: 1, pages: 1 })
.mockResolvedValueOnce({ records: [], page: 1, size: 10, total: 0, pages: 0 })
mount(CustomersView, { attachTo: document.body, global: { plugins: [pinia, ElementPlus] } })
await flushPromises()
@@ -730,6 +734,7 @@ describe('CustomersView', () => {
await flushPromises()
expect(archivePlatformTenant).toHaveBeenCalledWith(fullTenant.id)
expect(document.body.textContent).not.toContain(fullTenant.tenantName)
})
it('keeps the first operation column unfixed so it cannot cover a 320px table viewport', async () => {
@@ -757,24 +762,6 @@ describe('CustomersView', () => {
expect(document.body.textContent).toContain('代登录原因')
})
it('treats archived customers as read-only and terminal', async () => {
const auth = useAuthStore()
auth.permissions = [...auth.permissions, 'platform:customer:edit', 'platform:customer:status', 'platform:customer:delete']
useAccessPreviewStore().initializeAfterLogin()
vi.mocked(listPlatformTenants).mockResolvedValue({
records: [{ ...fullTenant, status: 'ARCHIVED' }], page: 1, size: 10, total: 1, pages: 1,
})
mount(CustomersView, { attachTo: document.body, global: { plugins: [pinia, ElementPlus] } })
await flushPromises()
expect(document.body.textContent).toContain('已归档')
expect(tableButtonByText('编辑')).toBeUndefined()
expect(tableButtonByText('启用')).toBeUndefined()
expect(tableButtonByText('停用')).toBeUndefined()
expect(tableButtonByText('删除')).toBeUndefined()
})
it('renders one overflow menu per customer when permitted actions exceed three', async () => {
const auth = useAuthStore()
auth.permissions = [...auth.permissions, 'platform:customer:reset-password', 'platform:customer:impersonate', 'platform:customer:status', 'platform:customer:delete']