mirror of
https://github.com/inventree/InvenTree.git
synced 2025-08-06 12:01:41 +00:00
Updated playwright testing
This commit is contained in:
@@ -574,7 +574,9 @@ class BuildOutputCompleteSerializer(serializers.Serializer):
|
||||
)
|
||||
|
||||
status_custom_key = serializers.ChoiceField(
|
||||
choices=StockStatus.items(), default=StockStatus.OK.value, label=_('Status')
|
||||
choices=StockStatus.items(custom=True),
|
||||
default=StockStatus.OK.value,
|
||||
label=_('Status'),
|
||||
)
|
||||
|
||||
accept_incomplete_allocation = serializers.BooleanField(
|
||||
|
@@ -158,7 +158,7 @@ class StatusCode(BaseEnum):
|
||||
return re.sub(r'(?<!^)(?=[A-Z])', '_', ref_name).lower()
|
||||
|
||||
@classmethod
|
||||
def items(cls, custom=True):
|
||||
def items(cls, custom=False):
|
||||
"""All status code items."""
|
||||
data = [(x.value, x.label) for x in cls.values()]
|
||||
|
||||
|
@@ -769,7 +769,9 @@ class PurchaseOrderLineItemReceiveSerializer(serializers.Serializer):
|
||||
)
|
||||
|
||||
status = serializers.ChoiceField(
|
||||
choices=StockStatus.items(), default=StockStatus.OK.value, label=_('Status')
|
||||
choices=StockStatus.items(custom=True),
|
||||
default=StockStatus.OK.value,
|
||||
label=_('Status'),
|
||||
)
|
||||
|
||||
packaging = serializers.CharField(
|
||||
@@ -1935,7 +1937,7 @@ class ReturnOrderLineItemReceiveSerializer(serializers.Serializer):
|
||||
)
|
||||
|
||||
status = serializers.ChoiceField(
|
||||
choices=stock.status_codes.StockStatus.items(),
|
||||
choices=stock.status_codes.StockStatus.items(custom=True),
|
||||
default=None,
|
||||
label=_('Status'),
|
||||
help_text=_('Stock item status code'),
|
||||
|
@@ -980,7 +980,7 @@ class ReturnStockItemSerializer(serializers.Serializer):
|
||||
)
|
||||
|
||||
status = serializers.ChoiceField(
|
||||
choices=stock.status_codes.StockStatus.items(),
|
||||
choices=stock.status_codes.StockStatus.items(custom=True),
|
||||
default=None,
|
||||
label=_('Status'),
|
||||
help_text=_('Stock item status code'),
|
||||
@@ -996,7 +996,7 @@ class ReturnStockItemSerializer(serializers.Serializer):
|
||||
)
|
||||
|
||||
def save(self):
|
||||
"""Save the serialzier to return the item into stock."""
|
||||
"""Save the serializer to return the item into stock."""
|
||||
item = self.context['item']
|
||||
request = self.context['request']
|
||||
|
||||
@@ -1037,7 +1037,7 @@ class StockChangeStatusSerializer(serializers.Serializer):
|
||||
return items
|
||||
|
||||
status = serializers.ChoiceField(
|
||||
choices=stock.status_codes.StockStatus.items(),
|
||||
choices=stock.status_codes.StockStatus.items(custom=True),
|
||||
default=stock.status_codes.StockStatus.OK.value,
|
||||
label=_('Status'),
|
||||
)
|
||||
@@ -1533,11 +1533,11 @@ def stock_item_adjust_status_options():
|
||||
|
||||
In particular, include a Null option for the status field.
|
||||
"""
|
||||
return [(None, _('No Change')), *stock.status_codes.StockStatus.items()]
|
||||
return [(None, _('No Change')), *stock.status_codes.StockStatus.items(custom=True)]
|
||||
|
||||
|
||||
class StockAdjustmentItemSerializer(serializers.Serializer):
|
||||
"""Serializer for a single StockItem within a stock adjument request.
|
||||
"""Serializer for a single StockItem within a stock adjustment request.
|
||||
|
||||
Required Fields:
|
||||
- item: StockItem object
|
||||
|
@@ -113,8 +113,6 @@ export default function StockDetail() {
|
||||
|
||||
data.available_stock = Math.max(0, data.quantity - data.allocated);
|
||||
|
||||
data.stock_status = data.status_custom_key || data.status;
|
||||
|
||||
if (instanceQuery.isFetching) {
|
||||
return <Skeleton />;
|
||||
}
|
||||
@@ -136,12 +134,22 @@ export default function StockDetail() {
|
||||
hidden: !part.IPN
|
||||
},
|
||||
{
|
||||
name: 'status_custom_key',
|
||||
name: 'status',
|
||||
type: 'status',
|
||||
label: t`Stock Status`,
|
||||
label: t`Status`,
|
||||
model: ModelType.stockitem,
|
||||
icon: 'status'
|
||||
},
|
||||
{
|
||||
name: 'status_custom_key',
|
||||
type: 'status',
|
||||
label: t`Custom Status`,
|
||||
model: ModelType.stockitem,
|
||||
icon: 'status',
|
||||
hidden:
|
||||
!stockitem.status_custom_key ||
|
||||
stockitem.status_custom_key == stockitem.status
|
||||
},
|
||||
{
|
||||
type: 'text',
|
||||
name: 'tests',
|
||||
|
@@ -169,56 +169,58 @@ test('Stock - Serial Numbers', async ({ page }) => {
|
||||
test('Stock - Stock Actions', async ({ page }) => {
|
||||
await doQuickLogin(page);
|
||||
|
||||
// Find an in-stock, untracked item
|
||||
await page.goto(
|
||||
`${baseUrl}/stock/location/index/stock-items?in_stock=1&serialized=0`
|
||||
);
|
||||
await page.getByText('530470210').first().click();
|
||||
await page.goto(`${baseUrl}/stock/item/1225/details`);
|
||||
|
||||
// Helper function to launch a stock action
|
||||
const launchStockAction = async (action: string) => {
|
||||
await page.getByLabel('action-menu-stock-operations').click();
|
||||
await page.getByLabel(`action-menu-stock-operations-${action}`).click();
|
||||
};
|
||||
|
||||
const setStockStatus = async (status: string) => {
|
||||
await page.getByLabel('action-button-change-status').click();
|
||||
await page.getByLabel('choice-field-status').click();
|
||||
await page.getByRole('option', { name: status }).click();
|
||||
};
|
||||
|
||||
// Check for required values
|
||||
await page.getByText('Status', { exact: true }).waitFor();
|
||||
await page.getByText('Custom Status', { exact: true }).waitFor();
|
||||
await page.getByText('Attention needed').waitFor();
|
||||
await page
|
||||
.locator('div')
|
||||
.filter({ hasText: /^Quantity: 270$/ })
|
||||
.first()
|
||||
.getByLabel('Stock Details')
|
||||
.getByText('Incoming goods inspection')
|
||||
.waitFor();
|
||||
await page.getByText('123').first().waitFor();
|
||||
|
||||
// Check for expected action sections
|
||||
await page.getByLabel('action-menu-barcode-actions').click();
|
||||
await page.getByLabel('action-menu-barcode-actions-link-barcode').click();
|
||||
await page.getByRole('banner').getByRole('button').click();
|
||||
|
||||
await page.getByLabel('action-menu-printing-actions').click();
|
||||
await page.getByLabel('action-menu-printing-actions-print-labels').click();
|
||||
await page.getByRole('button', { name: 'Cancel' }).click();
|
||||
|
||||
await page.getByLabel('action-menu-stock-operations').click();
|
||||
await page.getByLabel('action-menu-stock-operations-count').waitFor();
|
||||
await page.getByLabel('action-menu-stock-operations-add').waitFor();
|
||||
await page.getByLabel('action-menu-stock-operations-remove').waitFor();
|
||||
|
||||
await page.getByLabel('action-menu-stock-operations-transfer').click();
|
||||
await page.getByLabel('text-field-notes').fill('test notes');
|
||||
// Add stock, and change status
|
||||
await launchStockAction('add');
|
||||
await page.getByLabel('number-field-quantity').fill('12');
|
||||
await setStockStatus('Lost');
|
||||
await page.getByRole('button', { name: 'Submit' }).click();
|
||||
await page.getByText('This field is required.').first().waitFor();
|
||||
|
||||
// Set the status field
|
||||
await page.getByLabel('action-button-change-status').click();
|
||||
await page.getByLabel('choice-field-status').click();
|
||||
await page.getByText('Attention needed').click();
|
||||
await page.getByText('Lost').first().waitFor();
|
||||
await page.getByText('Unavailable').first().waitFor();
|
||||
await page.getByText('135').first().waitFor();
|
||||
|
||||
// Set the packaging field
|
||||
await page.getByLabel('action-button-adjust-packaging').click();
|
||||
await page.getByLabel('text-field-packaging').fill('test packaging');
|
||||
// Remove stock, and change status
|
||||
await launchStockAction('remove');
|
||||
await page.getByLabel('number-field-quantity').fill('99');
|
||||
await setStockStatus('Damaged');
|
||||
await page.getByRole('button', { name: 'Submit' }).click();
|
||||
|
||||
// Close the dialog
|
||||
await page.getByRole('button', { name: 'Cancel' }).click();
|
||||
await page.getByText('36').first().waitFor();
|
||||
await page.getByText('Damaged').first().waitFor();
|
||||
|
||||
// Find an item which has been sent to a customer
|
||||
await page.goto(`${baseUrl}/stock/item/1014/details`);
|
||||
await page.getByText('Batch Code: 2022-11-12').waitFor();
|
||||
await page.getByText('Unavailable').waitFor();
|
||||
await page.getByLabel('action-menu-stock-operations').click();
|
||||
await page.getByLabel('action-menu-stock-operations-return').click();
|
||||
// Count stock and change status (reverting to original value)
|
||||
await launchStockAction('count');
|
||||
await page.getByLabel('number-field-quantity').fill('123');
|
||||
await setStockStatus('Incoming goods inspection');
|
||||
await page.getByRole('button', { name: 'Submit' }).click();
|
||||
|
||||
await page.waitForTimeout(2500);
|
||||
await page.getByText('123').first().waitFor();
|
||||
await page.getByText('Custom Status').first().waitFor();
|
||||
await page.getByText('Incoming goods inspection').first().waitFor();
|
||||
});
|
||||
|
||||
test('Stock - Tracking', async ({ page }) => {
|
||||
@@ -233,7 +235,4 @@ test('Stock - Tracking', async ({ page }) => {
|
||||
await page.getByText('- - Factory/Office Block/Room').first().waitFor();
|
||||
await page.getByRole('link', { name: 'Widget Assembly' }).waitFor();
|
||||
await page.getByRole('cell', { name: 'Installed into assembly' }).waitFor();
|
||||
|
||||
await page.waitForTimeout(1500);
|
||||
return;
|
||||
});
|
||||
|
@@ -153,7 +153,7 @@ test('Settings - Admin - Barcode History', async ({ page, request }) => {
|
||||
await page.getByRole('menuitem', { name: 'Admin Center' }).click();
|
||||
await page.getByRole('tab', { name: 'Barcode Scans' }).click();
|
||||
|
||||
await page.waitForTimeout(2000);
|
||||
await page.waitForTimeout(500);
|
||||
|
||||
// Barcode history is displayed in table
|
||||
barcodes.forEach(async (barcode) => {
|
||||
|
Reference in New Issue
Block a user