This commit is contained in:
2026-08-04 09:05:19 +08:00
parent fa922ca96f
commit 815d4e8daf
21 changed files with 994 additions and 128 deletions
@@ -5,6 +5,8 @@ import { afterAll, afterEach, beforeEach, describe, expect, it, vi } from 'vites
import { listPlatformExpressCompanies, type PlatformExpressCompanyResource } from '@/modules/master-data/express-companies/api/platformExpressCompanies'
import { useAccessPreviewStore } from '@/core/access/accessPreview'
import { useAuthStore } from '@/core/auth/auth'
import { listPlatformTenants, type PlatformTenantResource } from '../../../iam/api/platformIam'
import PlatformTenantSelector from '../../../iam/components/PlatformTenantSelector.vue'
import ExpressCompaniesView from './ExpressCompaniesView.vue'
vi.mock('@/modules/master-data/express-companies/api/platformExpressCompanies', () => ({
@@ -14,6 +16,8 @@ vi.mock('@/modules/master-data/express-companies/api/platformExpressCompanies',
changePlatformExpressCompanyStatus: vi.fn(),
}))
vi.mock('../../../iam/api/platformIam', () => ({ listPlatformTenants: vi.fn() }))
class ResizeObserverStub implements ResizeObserver {
observe() {}
unobserve() {}
@@ -45,6 +49,16 @@ const company: PlatformExpressCompanyResource = {
updatedAt: '2026-07-31T10:20:00',
}
const tenant = (id: number | string, tenantName: string): PlatformTenantResource => ({
id, tenantCode: String(id), tenantName, status: 'ACTIVE', legalName: tenantName,
legalRepresentative: null, unifiedSocialCreditCode: null, contactName: null,
contactPhone: null, contactEmail: null, servicePackage: null, contactWechat: null,
salesOwnerName: null, paymentTermDays: null, enterpriseType: null, establishedDate: null,
registeredCapital: null, registeredCapitalCurrency: null, registeredAddress: null,
internalRemark: null, createdAt: null, approvedAt: null,
})
const snowflakeTenantId = '9223372036854775806'
async function mountView() {
vi.stubGlobal('localStorage', createMemoryStorage())
vi.stubGlobal('sessionStorage', createMemoryStorage())
@@ -69,6 +83,9 @@ describe('ExpressCompaniesView query and table migration', () => {
beforeEach(() => {
vi.stubGlobal('ResizeObserver', ResizeObserverStub)
document.body.innerHTML = ''
vi.mocked(listPlatformTenants).mockReset().mockResolvedValue({
records: [tenant(10001, '默认企业'), tenant(snowflakeTenantId, '雪花企业')], page: 1, size: 200, total: 2, pages: 1,
})
vi.mocked(listPlatformExpressCompanies).mockReset().mockResolvedValue({
records: [company], page: 1, size: 20, total: 1, pages: 1,
})
@@ -95,4 +112,13 @@ describe('ExpressCompaniesView query and table migration', () => {
expect(listPlatformExpressCompanies).toHaveBeenLastCalledWith(10001, 1, 20, '顺丰', '')
})
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)
await flushPromises()
expect(listPlatformExpressCompanies).toHaveBeenLastCalledWith(snowflakeTenantId, 1, 20, '', '')
})
})