mirror of
https://github.com/inventree/InvenTree.git
synced 2026-04-10 05:21:07 +00:00
Fix complete_sales_order_shipment task (#11525)
* Fix complete_sales_order_shipment task - Perform allocation *before* marking shipment as complete - Ensure task is not marked as complete before it is actually done * Add unit test * Provide task status tracking for shipment completion * Add integration testing * Address unit test issues * Bump API version * Enhance playwright test
This commit is contained in:
@@ -5,6 +5,7 @@ import {
|
||||
clickOnRowMenu,
|
||||
globalSearch,
|
||||
loadTab,
|
||||
navigate,
|
||||
setTableChoiceFilter,
|
||||
showCalendarView,
|
||||
showParametricView,
|
||||
@@ -238,6 +239,77 @@ test('Sales Orders - Shipments', async ({ browser }) => {
|
||||
.click();
|
||||
});
|
||||
|
||||
// Complete a shipment against a sales order
|
||||
test('Sales Orders - Complete Shipment', async ({ browser }) => {
|
||||
const page = await doCachedLogin(browser, {
|
||||
url: 'part/113/stock'
|
||||
});
|
||||
|
||||
const serialNumber = `SN${Math.floor(Math.random() * 100000)}`;
|
||||
const shipmentReference = `SHIP-${Math.floor(Math.random() * 100000)}`;
|
||||
|
||||
// First create some stock to allocate
|
||||
await page
|
||||
.getByRole('button', { name: 'action-button-add-stock-item' })
|
||||
.click();
|
||||
await page
|
||||
.getByRole('textbox', { name: 'text-field-serial_numbers' })
|
||||
.fill(serialNumber);
|
||||
await page.getByRole('button', { name: 'Submit' }).click();
|
||||
await page.getByText('Stock item created').first().waitFor();
|
||||
|
||||
// Navigate to the sales order and create a new shipment
|
||||
await navigate(page, '/sales/sales-order/7/shipments');
|
||||
await page
|
||||
.getByRole('button', { name: 'action-button-add-shipment' })
|
||||
.click();
|
||||
await page
|
||||
.getByLabel('text-field-reference', { exact: true })
|
||||
.fill(shipmentReference);
|
||||
await page.getByRole('button', { name: 'Submit' }).click();
|
||||
await page.getByText('Shipment created').first().waitFor();
|
||||
|
||||
// Back to the "line items" tab to allocate stock
|
||||
await loadTab(page, 'Line Items');
|
||||
const cell = await page.getByRole('cell', { name: 'MAST', exact: true });
|
||||
await clickOnRowMenu(cell);
|
||||
|
||||
// Allocate 1 item based on serial number
|
||||
await page.getByRole('menuitem', { name: 'Allocate serials' }).click();
|
||||
await page.getByRole('textbox', { name: 'number-field-quantity' }).fill('1');
|
||||
await page
|
||||
.getByRole('textbox', { name: 'text-field-serial_numbers' })
|
||||
.fill(serialNumber);
|
||||
await page.getByLabel('related-field-shipment').fill(shipmentReference);
|
||||
await page.getByText(`SO0007Shipment ${shipmentReference}`).click();
|
||||
await page.getByRole('button', { name: 'Submit' }).click();
|
||||
await page.getByText('Stock allocated successfully').first().waitFor();
|
||||
|
||||
// Navigate to the shipment and mark it as "shipped"
|
||||
await loadTab(page, 'Shipments');
|
||||
await page.getByRole('cell', { name: shipmentReference }).click();
|
||||
await page.getByText(shipmentReference).first().waitFor();
|
||||
await page.getByText('Pending').first().waitFor();
|
||||
await loadTab(page, 'Allocated Stock');
|
||||
|
||||
// Check that the serial number is allocated as expected
|
||||
await page.getByRole('cell', { name: serialNumber }).waitFor();
|
||||
await page.getByRole('button', { name: 'Send Shipment' }).click();
|
||||
await page.getByRole('button', { name: 'Submit' }).click();
|
||||
|
||||
await page.getByText('Completing shipment').first().waitFor();
|
||||
await page.getByText('Shipment completed').first().waitFor();
|
||||
|
||||
await page.getByText('Shipped', { exact: true }).first().waitFor();
|
||||
|
||||
// Finally, navigate to the stock item and check it has been allocated to the customer
|
||||
await page.getByRole('cell', { name: serialNumber }).click();
|
||||
await page.waitForLoadState('networkidle');
|
||||
await page.getByText('Unavailable').first().waitFor();
|
||||
await page.getByRole('link', { name: 'SO0007' }).waitFor();
|
||||
await page.getByRole('cell', { name: 'Customer D' }).waitFor();
|
||||
});
|
||||
|
||||
test('Sales Orders - Duplicate', async ({ browser }) => {
|
||||
const page = await doCachedLogin(browser, {
|
||||
url: 'sales/sales-order/14/detail'
|
||||
|
||||
Reference in New Issue
Block a user