You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
2.0 KiB
55 lines
2.0 KiB
jest.mock('@/api/budget/budgetCollectionYear.js', () => ({}))
|
|
jest.mock('@/api/budget/leadDepartment.js', () => ({}))
|
|
jest.mock('@/views/budget/collection/components/SplitPackageForm.vue', () => ({}))
|
|
jest.mock('@/views/budget/collection/components/ProjectDetailsView.vue', () => ({}))
|
|
jest.mock('@/views/budget/collection/components/LeadDepartmentSummaryForm.vue', () => ({}))
|
|
jest.mock('@/views/budget/collection/components/BudgetSubmissionForm.vue', () => ({}))
|
|
|
|
import LeadDepartmentPage from '@/views/budget/collection/leadDepartment.vue'
|
|
|
|
function createContext() {
|
|
const methods = LeadDepartmentPage.methods
|
|
const context = {
|
|
currentSummaryPackage: null,
|
|
summaryMode: null,
|
|
summarySubmitVisible: false
|
|
}
|
|
context.getLeadSubmission = methods.getLeadSubmission.bind(context)
|
|
context.hasStartedLeadSummary = methods.hasStartedLeadSummary.bind(context)
|
|
context.getSummaryMode = methods.getSummaryMode.bind(context)
|
|
return context
|
|
}
|
|
|
|
describe('LeadDepartmentPage summary action', () => {
|
|
const draftSummary = {
|
|
status: 'draft',
|
|
summary_started_at: '2026-08-14 10:00:00'
|
|
}
|
|
|
|
it('opens an active-year draft summary in edit mode when labelled 修改汇总', () => {
|
|
const context = createContext()
|
|
const row = {
|
|
budget_year: { status: 'ACTIVE' },
|
|
lead_submission: draftSummary
|
|
}
|
|
|
|
expect(LeadDepartmentPage.methods.summaryActionLabel.call(context, row)).toBe('修改汇总')
|
|
LeadDepartmentPage.methods.openSummarySubmit.call(context, row)
|
|
|
|
expect(context.summaryMode).toBe('edit')
|
|
})
|
|
|
|
it('uses 查看汇总 rather than 修改汇总 when a draft belongs to an inactive year', () => {
|
|
const context = createContext()
|
|
const row = {
|
|
budget_year: { status: 'INACTIVE' },
|
|
lead_submission: draftSummary
|
|
}
|
|
|
|
expect(LeadDepartmentPage.methods.summaryActionLabel.call(context, row)).toBe('查看汇总')
|
|
LeadDepartmentPage.methods.openSummarySubmit.call(context, row)
|
|
|
|
expect(context.summaryMode).toBe('view')
|
|
})
|
|
})
|