test(auth): cover sample editor permission scope
This commit is contained in:
parent
336b47a5fc
commit
42e4503ce6
@ -101,6 +101,83 @@ describe('SampleProgressEditorDrawer', () => {
|
||||
await waitFor(() => expect(onSaved).toHaveBeenCalledWith(item))
|
||||
})
|
||||
|
||||
it('passes the supply-chain permission scope when editing and creating records', async () => {
|
||||
fetchMock.mockResolvedValue({
|
||||
ok: true,
|
||||
json: async () => ({ data: item }),
|
||||
} as Response)
|
||||
|
||||
const editView = render(
|
||||
<SampleProgressEditorDrawer
|
||||
item={item}
|
||||
permissionScope="supply-chain"
|
||||
onClose={jest.fn()}
|
||||
onSaved={jest.fn()}
|
||||
/>,
|
||||
)
|
||||
|
||||
fireEvent.change(screen.getByLabelText('颜色'), { target: { value: '黑色' } })
|
||||
fireEvent.click(screen.getByRole('button', { name: '保存' }))
|
||||
|
||||
await waitFor(() => expect(fetchMock).toHaveBeenCalledWith(
|
||||
'/api/intake/sample-progress/sample-1?permissionScope=supply-chain',
|
||||
expect.objectContaining({ method: 'PUT' }),
|
||||
))
|
||||
|
||||
editView.unmount()
|
||||
fetchMock.mockClear()
|
||||
|
||||
render(
|
||||
<SampleProgressEditorDrawer
|
||||
item={null}
|
||||
permissionScope="supply-chain"
|
||||
onClose={jest.fn()}
|
||||
onSaved={jest.fn()}
|
||||
/>,
|
||||
)
|
||||
|
||||
fireEvent.change(screen.getByLabelText('开款编号'), { target: { value: 'KY20260802' } })
|
||||
fireEvent.click(screen.getByRole('button', { name: '保存' }))
|
||||
|
||||
await waitFor(() => expect(fetchMock).toHaveBeenCalledWith(
|
||||
'/api/intake/sample-progress?permissionScope=supply-chain',
|
||||
expect.objectContaining({ method: 'POST' }),
|
||||
))
|
||||
})
|
||||
|
||||
it('passes the supply-chain permission scope when loading OA prefill data', async () => {
|
||||
fetchMock.mockResolvedValue({
|
||||
ok: true,
|
||||
json: async () => ({
|
||||
data: {
|
||||
brand: '测试品牌',
|
||||
designer: '设计师甲',
|
||||
imageUrl: null,
|
||||
oaReachedAt: null,
|
||||
purchaseOwner: '采购甲',
|
||||
merchandiserOwner: '跟单甲',
|
||||
},
|
||||
}),
|
||||
} as Response)
|
||||
|
||||
render(
|
||||
<SampleProgressEditorDrawer
|
||||
item={null}
|
||||
permissionScope="supply-chain"
|
||||
onClose={jest.fn()}
|
||||
onSaved={jest.fn()}
|
||||
/>,
|
||||
)
|
||||
|
||||
const openingCode = screen.getByLabelText('开款编号')
|
||||
fireEvent.change(openingCode, { target: { value: 'KY20260803' } })
|
||||
fireEvent.blur(openingCode)
|
||||
|
||||
await waitFor(() => expect(fetchMock).toHaveBeenCalledWith(
|
||||
'/api/intake/sample-progress/oa-prefill?openingCode=KY20260803&permissionScope=supply-chain',
|
||||
))
|
||||
})
|
||||
|
||||
it('requires a reason before saving a changed due date', () => {
|
||||
render(<SampleProgressEditorDrawer item={item} onClose={jest.fn()} onSaved={jest.fn()}/>)
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user