|
|
@@ -8,6 +8,14 @@ jest.mock("@/api/admin", () => ({
|
|
|
getFamilyTasks: jest.fn().mockResolvedValue({ data: { records: [], total: 0 } }),
|
|
|
getFamilyOverview: jest.fn().mockResolvedValue({ data: { reports: [], plans: [] } })
|
|
|
}))
|
|
|
+// FamilyCouponPanel 引入真实 @/api/coupon → @/utils/request → @/router → Vue.use(VueRouter) 安装只读 $route,
|
|
|
+// 导致 $route/$router mock 无法覆盖;此处同样 mock,阻断副作用(面板组件在 shallowMount 下不触发调用)。
|
|
|
+jest.mock("@/api/coupon", () => ({
|
|
|
+ getCouponList: jest.fn(),
|
|
|
+ issueFamilyCoupon: jest.fn(),
|
|
|
+ getFamilyCoupons: jest.fn(),
|
|
|
+ getFamilyCouponUsage: jest.fn()
|
|
|
+}))
|
|
|
jest.mock("echarts", () => ({
|
|
|
init: jest.fn(() => ({ setOption: jest.fn(), dispose: jest.fn(), resize: jest.fn() }))
|
|
|
}))
|
|
|
@@ -72,4 +80,27 @@ describe("FamilyWorkbench 单家庭工作台", () => {
|
|
|
)
|
|
|
wrapper.destroy()
|
|
|
})
|
|
|
-})
|
|
|
+
|
|
|
+ it("渲染 6 个家庭级 tab 面板且 familyId 均锁定为当前家庭", async () => {
|
|
|
+ const wrapper = mountPage()
|
|
|
+ await wrapper.vm.$nextTick()
|
|
|
+ await wrapper.vm.$nextTick()
|
|
|
+ const panelNames = [
|
|
|
+ "ChildrenPanel",
|
|
|
+ "PointsPanel",
|
|
|
+ "WishesPanel",
|
|
|
+ "RewardsPanel",
|
|
|
+ "FamilyCouponPanel",
|
|
|
+ "FamilyEarningsPanel"
|
|
|
+ ]
|
|
|
+ panelNames.forEach((name) => {
|
|
|
+ const found = wrapper.findAllComponents({ name })
|
|
|
+ expect(found.length).toBe(1)
|
|
|
+ if (found.length) {
|
|
|
+ expect(found.at(0).props("familyId")).toBe(5)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ expect(wrapper.vm.activeTab).toBe("children")
|
|
|
+ wrapper.destroy()
|
|
|
+ })
|
|
|
+})
|