fix(admin): load picker warehouses from domestic master
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import { http } from '@/shared/api/http'
|
||||
import { overseasHttp } from '@/shared/api/overseasHttp'
|
||||
import {
|
||||
approveEnterpriseReview,
|
||||
archivePlatformTenant,
|
||||
@@ -51,10 +50,6 @@ 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,
|
||||
@@ -123,7 +118,6 @@ 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 () => {
|
||||
@@ -218,9 +212,13 @@ describe('platform IAM roles', () => {
|
||||
})
|
||||
|
||||
it('maintains paginated platform users through the unified user contract', async () => {
|
||||
const userOptions = {
|
||||
const userOptionsPayload = {
|
||||
tenants: [{ id: '0', name: '平台', status: 'ACTIVE' }],
|
||||
roles: [{ id: '40001', tenantId: '0', roleCode: 'PLATFORM_OPERATOR', name: '运营管理员', status: 'ACTIVE' }],
|
||||
roles: [{ id: '40001', tenantId: '0', name: '运营管理员', status: 'ACTIVE' }],
|
||||
}
|
||||
const userOptions = {
|
||||
...userOptionsPayload,
|
||||
roles: [{ ...userOptionsPayload.roles[0], roleCode: 'PLATFORM_OPERATOR' }],
|
||||
}
|
||||
const create = {
|
||||
username: 'zhangwei', displayName: '张伟', phone: '13800138000', email: 'zhangwei@example.com',
|
||||
@@ -234,7 +232,11 @@ describe('platform IAM roles', () => {
|
||||
vi.mocked(http.get).mockResolvedValueOnce({
|
||||
code: '200', message: 'success', data: { ...userPage, page: '2', size: '10', total: '11', pages: '2' },
|
||||
})
|
||||
.mockResolvedValueOnce({ code: '200', message: 'success', data: userOptions })
|
||||
.mockResolvedValueOnce({ code: '200', message: 'success', data: userOptionsPayload })
|
||||
.mockResolvedValueOnce({
|
||||
code: '200', message: 'success',
|
||||
data: [{ ...role, id: '40001', roleCode: 'PLATFORM_OPERATOR' }],
|
||||
})
|
||||
vi.mocked(http.post).mockResolvedValue({ code: '200', message: 'success', data: managedUser })
|
||||
vi.mocked(http.put).mockResolvedValue({ code: '200', message: 'success', data: managedUser })
|
||||
|
||||
@@ -249,28 +251,36 @@ describe('platform IAM roles', () => {
|
||||
params: { page: 2, size: 10, keyword: '张伟', status: 'ACTIVE' },
|
||||
})
|
||||
expect(http.get).toHaveBeenNthCalledWith(2, '/platform/v1/iam/users/options')
|
||||
expect(http.get).toHaveBeenNthCalledWith(3, '/platform/v1/iam/roles')
|
||||
expect(http.post).toHaveBeenCalledWith('/platform/v1/iam/users', create)
|
||||
expect(http.put).toHaveBeenNthCalledWith(1, `/platform/v1/iam/users/${managedUser.membershipId}`, update)
|
||||
expect(http.put).toHaveBeenNthCalledWith(2, `/platform/v1/iam/users/${managedUser.membershipId}/status`, { status: 'DISABLED' })
|
||||
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({
|
||||
it('loads only active shared receiving overseas warehouses from domestic warehouse master data', async () => {
|
||||
vi.mocked(http.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,
|
||||
{ id: '90071992547409931', tenantId: '0', warehouseCode: 'LAX-01', warehouseName: '洛杉矶收货仓', warehouseType: 'OVERSEAS', countryCode: 'US', status: 'ACTIVE' },
|
||||
{ id: '90071992547409932', tenantId: '0', warehouseCode: 'NYC-01', warehouseName: '纽约收货仓', warehouseType: 'OVERSEAS', countryCode: 'US', status: 'ACTIVE' },
|
||||
{ id: '2', tenantId: '100', warehouseCode: 'CUST', warehouseName: '客户仓', warehouseType: 'OVERSEAS', countryCode: 'US', status: 'ACTIVE' },
|
||||
{ id: '3', tenantId: '0', warehouseCode: 'PARTNER', warehouseName: '合作仓', warehouseType: 'OVERSEAS_PARTNER', countryCode: 'US', status: 'ACTIVE' },
|
||||
{ id: '4', tenantId: '0', warehouseCode: 'ONT8', warehouseName: 'ONT8', warehouseType: 'FBA', countryCode: 'US', status: 'ACTIVE' },
|
||||
{ id: '5', tenantId: '0', warehouseCode: 'SEA-INACTIVE', warehouseName: '西雅图停用仓', warehouseType: 'OVERSEAS', countryCode: 'US', status: 'INACTIVE' },
|
||||
], page: 1, size: 200, total: 6, pages: 1,
|
||||
},
|
||||
})
|
||||
|
||||
await expect(listSharedReceivingOverseasWarehouseOptions()).resolves.toEqual([
|
||||
{ id: '90071992547409931', warehouseCode: 'LAX-01', warehouseName: '洛杉矶收货仓', countryCode: 'US' },
|
||||
{ id: '90071992547409932', warehouseCode: 'NYC-01', warehouseName: '纽约收货仓', countryCode: 'US' },
|
||||
])
|
||||
expect(overseasHttp.get).toHaveBeenCalledWith('/platform/v1/warehouse-admin', {
|
||||
params: { customerId: '0', page: 1, size: 200, capabilityCode: 'RECEIVING', status: 'ACTIVE' },
|
||||
expect(http.get).toHaveBeenCalledWith('/platform/v1/warehouse-admin', {
|
||||
params: {
|
||||
tenantId: '0', page: 1, size: 200, capabilityCode: 'RECEIVING',
|
||||
warehouseType: 'OVERSEAS', status: 'ACTIVE',
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user