This commit is contained in:
2026-08-25 09:52:45 +08:00
parent e9b6979a82
commit 5641545fd5
4 changed files with 208 additions and 6 deletions
+30 -3
View File
@@ -1,5 +1,6 @@
import { beforeEach, describe, expect, it, vi } from 'vitest'
import { http } from '@/shared/api/http'
import { overseasHttp } from '@/shared/api/overseasHttp'
import {
approveEnterpriseReview,
archivePlatformTenant,
@@ -24,6 +25,7 @@ import {
listPlatformRoles,
listPlatformInternalUsers,
listPlatformManagedUsers,
listSharedReceivingOverseasWarehouseOptions,
getPlatformUserOptions,
qualificationFileName,
replacePlatformRolePermissions,
@@ -49,6 +51,10 @@ vi.mock('@/shared/api/http', () => ({
unwrapApiResponse: <T>(response: { data: T }) => response.data,
}))
vi.mock('@/shared/api/overseasHttp', () => ({
overseasHttp: { get: vi.fn() },
}))
const role: PlatformRoleResource = {
id: 4000002,
tenantId: 0,
@@ -108,6 +114,7 @@ const managedUser: PlatformManagedUser = {
roleNames: ['运营管理员'],
lastLoginAt: '2026-06-01T10:30:00',
protectedAccount: false,
overseasWarehouseId: null,
}
describe('platform IAM roles', () => {
@@ -116,6 +123,7 @@ describe('platform IAM roles', () => {
vi.mocked(http.post).mockReset()
vi.mocked(http.put).mockReset()
vi.mocked(http.delete).mockReset()
vi.mocked(overseasHttp.get).mockReset()
})
it('loads roles from the platform IAM prefix', async () => {
@@ -212,15 +220,15 @@ describe('platform IAM roles', () => {
it('maintains paginated platform users through the unified user contract', async () => {
const userOptions = {
tenants: [{ id: '0', name: '平台', status: 'ACTIVE' }],
roles: [{ id: '40001', tenantId: '0', name: '运营管理员', status: 'ACTIVE' }],
roles: [{ id: '40001', tenantId: '0', roleCode: 'PLATFORM_OPERATOR', name: '运营管理员', status: 'ACTIVE' }],
}
const create = {
username: 'zhangwei', displayName: '张伟', phone: '13800138000', email: 'zhangwei@example.com',
tenantId: '0', roleIds: ['40001'], password: 'Password1', status: 'ACTIVE' as const,
tenantId: '0', roleIds: ['40001'], overseasWarehouseId: null, password: 'Password1', status: 'ACTIVE' as const,
}
const update = {
displayName: '张伟', phone: '13800138000', email: 'zhangwei@example.com',
tenantId: '0', roleIds: ['40001'],
tenantId: '0', roleIds: ['40001'], overseasWarehouseId: null,
}
const userPage = { records: [managedUser], page: 2, size: 10, total: 11, pages: 2 }
vi.mocked(http.get).mockResolvedValueOnce({
@@ -247,6 +255,25 @@ describe('platform IAM roles', () => {
expect(http.put).toHaveBeenNthCalledWith(3, `/platform/v1/iam/users/${managedUser.membershipId}/password`, { newPassword: 'ChangeMe123' })
})
it('loads only active shared receiving overseas warehouses through the overseas gateway', async () => {
vi.mocked(overseasHttp.get).mockResolvedValue({
code: '200', message: 'success', data: {
records: [
{ id: '90071992547409931', customerId: '0', warehouseCode: 'LAX-01', warehouseName: '洛杉矶收货仓', warehouseType: 'OVERSEAS', countryCode: 'US', status: 'ACTIVE' },
{ id: '2', customerId: '100', warehouseCode: 'CUST', warehouseName: '客户仓', warehouseType: 'OVERSEAS', countryCode: 'US', status: 'ACTIVE' },
{ id: '3', customerId: '0', warehouseCode: 'PARTNER', warehouseName: '合作仓', warehouseType: 'OVERSEAS_PARTNER', countryCode: 'US', status: 'ACTIVE' },
], page: 1, size: 200, total: 3, pages: 1,
},
})
await expect(listSharedReceivingOverseasWarehouseOptions()).resolves.toEqual([
{ id: '90071992547409931', warehouseCode: 'LAX-01', warehouseName: '洛杉矶收货仓', countryCode: 'US' },
])
expect(overseasHttp.get).toHaveBeenCalledWith('/platform/v1/warehouse-admin', {
params: { customerId: '0', page: 1, size: 200, capabilityCode: 'RECEIVING', status: 'ACTIVE' },
})
})
it('loads qualifications for the selected tenant', async () => {
const qualification = {
id: 12,