Merge branch 'release/test' of http://git.buggoglobal.com/html/admin-web into release/test
This commit is contained in:
@@ -11,6 +11,7 @@ import {
|
|||||||
} from '@/modules/fba-pricing'
|
} from '@/modules/fba-pricing'
|
||||||
import { useAccessPreviewStore } from '@/core/access/accessPreview'
|
import { useAccessPreviewStore } from '@/core/access/accessPreview'
|
||||||
import { useAuthStore } from '@/core/auth/auth'
|
import { useAuthStore } from '@/core/auth/auth'
|
||||||
|
import AppDialog from '@/shared/components/AppDialog.vue'
|
||||||
import CustomerBillingRulesPanel from './CustomerBillingRulesPanel.vue'
|
import CustomerBillingRulesPanel from './CustomerBillingRulesPanel.vue'
|
||||||
|
|
||||||
vi.mock('@/modules/dimension-config', () => ({ getCustomerDimensionConfig: vi.fn(), updateCustomerDimensionConfig: vi.fn(), updateCustomerDimensionDefaultCalculationMode: vi.fn() }))
|
vi.mock('@/modules/dimension-config', () => ({ getCustomerDimensionConfig: vi.fn(), updateCustomerDimensionConfig: vi.fn(), updateCustomerDimensionDefaultCalculationMode: vi.fn() }))
|
||||||
@@ -93,7 +94,7 @@ describe('CustomerBillingRulesPanel', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('submits all four rows in one update request', async () => {
|
it('submits all four rows in one update request', async () => {
|
||||||
mount(CustomerBillingRulesPanel, { attachTo: document.body, props: { customerId: '8', customerName: '柏悦物流' }, global: { plugins: [ElementPlus] } })
|
const wrapper = mount(CustomerBillingRulesPanel, { attachTo: document.body, props: { customerId: '8', customerName: '柏悦物流' }, global: { plugins: [ElementPlus] } })
|
||||||
await flushPromises()
|
await flushPromises()
|
||||||
;[...document.querySelectorAll<HTMLButtonElement>('button')].find((button) => button.textContent?.trim() === '编辑规则')?.click()
|
;[...document.querySelectorAll<HTMLButtonElement>('button')].find((button) => button.textContent?.trim() === '编辑规则')?.click()
|
||||||
await flushPromises()
|
await flushPromises()
|
||||||
@@ -105,6 +106,7 @@ describe('CustomerBillingRulesPanel', () => {
|
|||||||
expect(Object.keys(submittedRules[0]).sort()).toEqual([
|
expect(Object.keys(submittedRules[0]).sort()).toEqual([
|
||||||
'boxType', 'edgeAdditionCm', 'innerHeightCm', 'innerLengthCm', 'innerWidthCm', 'remark', 'version',
|
'boxType', 'edgeAdditionCm', 'innerHeightCm', 'innerLengthCm', 'innerWidthCm', 'remark', 'version',
|
||||||
])
|
])
|
||||||
|
expect(wrapper.findComponent(AppDialog).props('modelValue')).toBe(false)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('keeps the editor open when the whole-set save fails', async () => {
|
it('keeps the editor open when the whole-set save fails', async () => {
|
||||||
@@ -125,7 +127,7 @@ describe('CustomerBillingRulesPanel', () => {
|
|||||||
...config,
|
...config,
|
||||||
defaultCalculationMode: 'MULTIPLY',
|
defaultCalculationMode: 'MULTIPLY',
|
||||||
})
|
})
|
||||||
mount(CustomerBillingRulesPanel, { attachTo: document.body, props: { customerId: '8', customerName: '柏悦物流' }, global: { plugins: [ElementPlus] } })
|
const wrapper = mount(CustomerBillingRulesPanel, { attachTo: document.body, props: { customerId: '8', customerName: '柏悦物流' }, global: { plugins: [ElementPlus] } })
|
||||||
await flushPromises()
|
await flushPromises()
|
||||||
|
|
||||||
;[...document.querySelectorAll<HTMLButtonElement>('button')].find((button) => button.textContent?.trim() === '编辑规则')?.click()
|
;[...document.querySelectorAll<HTMLButtonElement>('button')].find((button) => button.textContent?.trim() === '编辑规则')?.click()
|
||||||
@@ -139,6 +141,7 @@ describe('CustomerBillingRulesPanel', () => {
|
|||||||
remark: expect.stringMatching(/SMALL:30,20,20;系数:\d+(?:\.\d+)?/),
|
remark: expect.stringMatching(/SMALL:30,20,20;系数:\d+(?:\.\d+)?/),
|
||||||
}))
|
}))
|
||||||
expect(setCustomerChargeRuleDefault).toHaveBeenCalledWith('8', '201')
|
expect(setCustomerChargeRuleDefault).toHaveBeenCalledWith('8', '201')
|
||||||
|
expect(wrapper.findComponent(AppDialog).props('modelValue')).toBe(false)
|
||||||
|
|
||||||
const defaultRuleCheckboxes = [...document.querySelectorAll<HTMLInputElement>('input[type="checkbox"]')]
|
const defaultRuleCheckboxes = [...document.querySelectorAll<HTMLInputElement>('input[type="checkbox"]')]
|
||||||
defaultRuleCheckboxes[1]?.click()
|
defaultRuleCheckboxes[1]?.click()
|
||||||
|
|||||||
@@ -193,8 +193,8 @@ async function saveConfig() {
|
|||||||
}))
|
}))
|
||||||
config.value = await updateCustomerDimensionConfig(props.customerId, { rules })
|
config.value = await updateCustomerDimensionConfig(props.customerId, { rules })
|
||||||
config.value.rules = sortRules(config.value.rules)
|
config.value.rules = sortRules(config.value.rules)
|
||||||
form.rules = cloneRules(config.value.rules)
|
|
||||||
editorDirty.value = false
|
editorDirty.value = false
|
||||||
|
editorVisible.value = false
|
||||||
ElMessage.success('箱规尺寸规则已保存')
|
ElMessage.success('箱规尺寸规则已保存')
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
ElMessage.error(getApiErrorDetails(error, '箱规尺寸规则保存失败,请刷新后重试').message)
|
ElMessage.error(getApiErrorDetails(error, '箱规尺寸规则保存失败,请刷新后重试').message)
|
||||||
@@ -240,6 +240,8 @@ async function saveChargeConfig() {
|
|||||||
const created = await createCustomerChargeRule(props.customerId, { ...chargeForm, ruleCode: `RULE-${Date.now()}`, lengthFactor: coefficient, widthFactor: coefficient, heightFactor: coefficient, defaultRule: false, remark: chargeRows.map((row) => `${row.boxType}:${row.length},${row.width},${row.height};系数:${row.coefficient};${BOX_NAMES[row.boxType]}:${row.remark || '—'}`).join(';') })
|
const created = await createCustomerChargeRule(props.customerId, { ...chargeForm, ruleCode: `RULE-${Date.now()}`, lengthFactor: coefficient, widthFactor: coefficient, heightFactor: coefficient, defaultRule: false, remark: chargeRows.map((row) => `${row.boxType}:${row.length},${row.width},${row.height};系数:${row.coefficient};${BOX_NAMES[row.boxType]}:${row.remark || '—'}`).join(';') })
|
||||||
await setCustomerChargeRuleDefault(props.customerId, created.id)
|
await setCustomerChargeRuleDefault(props.customerId, created.id)
|
||||||
await loadChargeRules()
|
await loadChargeRules()
|
||||||
|
editorDirty.value = false
|
||||||
|
editorVisible.value = false
|
||||||
ElMessage.success('权重系数规则已保存')
|
ElMessage.success('权重系数规则已保存')
|
||||||
} catch (error) { ElMessage.error(getApiErrorDetails(error, '权重系数规则保存失败').message) }
|
} catch (error) { ElMessage.error(getApiErrorDetails(error, '权重系数规则保存失败').message) }
|
||||||
finally { chargeSaving.value = false }
|
finally { chargeSaving.value = false }
|
||||||
|
|||||||
Reference in New Issue
Block a user