diff --git a/src/modules/customers/components/CustomerBillingRulesPanel.test.ts b/src/modules/customers/components/CustomerBillingRulesPanel.test.ts index 62ab5d2d..32cd0e73 100644 --- a/src/modules/customers/components/CustomerBillingRulesPanel.test.ts +++ b/src/modules/customers/components/CustomerBillingRulesPanel.test.ts @@ -13,6 +13,7 @@ import { useAccessPreviewStore } from '@/core/access/accessPreview' import { useAuthStore } from '@/core/auth/auth' import AppDialog from '@/shared/components/AppDialog.vue' import CustomerBillingRulesPanel from './CustomerBillingRulesPanel.vue' +import { getPlatformTenantDimensionInitializationStatus } from '@/modules/iam' vi.mock('@/modules/dimension-config', () => ({ getCustomerDimensionConfig: vi.fn(), updateCustomerDimensionConfig: vi.fn(), updateCustomerDimensionDefaultCalculationMode: vi.fn() })) vi.mock('@/modules/fba-pricing', () => ({ @@ -21,6 +22,7 @@ vi.mock('@/modules/fba-pricing', () => ({ retireCustomerChargeRule: vi.fn(), setCustomerChargeRuleDefault: vi.fn(), })) +vi.mock('@/modules/iam', () => ({ getPlatformTenantDimensionInitializationStatus: vi.fn() })) const boxes = [ ['SMALL', '小箱', 30, 20, 20, '标准小箱'], @@ -64,6 +66,10 @@ describe('CustomerBillingRulesPanel', () => { vi.mocked(updateCustomerDimensionDefaultCalculationMode).mockResolvedValue(config) vi.mocked(listCustomerChargeRules).mockResolvedValue([chargeRule]) vi.mocked(createCustomerChargeRule).mockResolvedValue(chargeRule) + vi.mocked(getPlatformTenantDimensionInitializationStatus).mockResolvedValue({ + tenantId: '8', status: 'PENDING', attemptCount: 0, nextRetryAt: null, + lastErrorCode: null, lastErrorMessage: null, updatedAt: null, + }) }) it('renders the four fixed carton dimension rows and calculated values', async () => { @@ -111,6 +117,24 @@ describe('CustomerBillingRulesPanel', () => { expect(listCustomerChargeRules).not.toHaveBeenCalled() }) + it('loads billing rules automatically when asynchronous initialization becomes ready', async () => { + vi.mocked(getPlatformTenantDimensionInitializationStatus).mockResolvedValueOnce({ + tenantId: '8', status: 'READY', attemptCount: 1, nextRetryAt: null, + lastErrorCode: null, lastErrorMessage: null, updatedAt: '2026-09-10T20:04:06', + }) + mount(CustomerBillingRulesPanel, { + attachTo: document.body, + props: { customerId: '8', customerName: '柏悦物流', dimensionInitializationStatus: 'PENDING' }, + global: { plugins: [ElementPlus] }, + }) + await flushPromises() + + expect(getPlatformTenantDimensionInitializationStatus).toHaveBeenCalledWith('8') + expect(getCustomerDimensionConfig).toHaveBeenCalledWith('8') + expect(listCustomerChargeRules).toHaveBeenCalledWith('8') + expect(document.body.textContent).not.toContain('箱规尺寸规则加载失败') + }) + it('submits all four rows in one update request', async () => { const wrapper = mount(CustomerBillingRulesPanel, { attachTo: document.body, props: { customerId: '8', customerName: '柏悦物流' }, global: { plugins: [ElementPlus] } }) await flushPromises() diff --git a/src/modules/customers/components/CustomerBillingRulesPanel.vue b/src/modules/customers/components/CustomerBillingRulesPanel.vue index c8ba7178..4deb67d3 100644 --- a/src/modules/customers/components/CustomerBillingRulesPanel.vue +++ b/src/modules/customers/components/CustomerBillingRulesPanel.vue @@ -1,5 +1,5 @@