Test: savemachine_direct.asp

Purpose: Test the machine creation form with nested entity creation (new vendor, new model).

Expected Bug: When newmodelmachinetypeid is empty, the page should show "Machine type is required for new model" error, but may return a 500 error instead.

Note: IIS is configured to require authentication for POST requests. If you get a 401 error from curl, use this HTML form from a browser instead.

Test Case: New Model with Missing Machine Type

Set to "new" to trigger new model creation
Set to "new" to trigger new vendor creation
BUG TEST: Leave empty to test validation error handling. Should show "Machine type is required" but may cause 500 error.

Response:

Quick Test Scenarios

Test 1: Empty Machine Type (Current) Submit with empty newmodelmachinetypeid.
Expected: "Machine type is required for new model" error message.
Possible Bug: 500 Internal Server Error if validation fails improperly.
Test 2: Valid Machine Type Click "Fill Valid Data" button, then submit. This should create the machine successfully (if the machine number doesn't exist).
Test 3: Duplicate Machine Number If the machine number already exists, submit should show "Machine number already exists" error.
Test 4: Use Existing Model Change modelid from "new" to a valid model ID (e.g., 1, 2, 3). This bypasses new model creation entirely.

Quick Database Check (Run on Server)

After testing, run this SQL to verify the data:

-- Check if machine was created
SELECT machineid, machinenumber, modelnumberid, machinetypeid, businessunitid, lastupdated
FROM machines
WHERE machinenumber LIKE 'TEST%'
ORDER BY machineid DESC
LIMIT 5;

-- Check if vendor was created
SELECT vendorid, vendor
FROM vendors
WHERE vendor LIKE 'Test%'
ORDER BY vendorid DESC
LIMIT 5;

-- Check if model was created
SELECT modelnumberid, modelnumber, vendorid, machinetypeid
FROM models
WHERE modelnumber LIKE 'Test%'
ORDER BY modelnumberid DESC
LIMIT 5;

-- Docker command:
-- docker exec -it dev-mysql mysql -u root -prootpassword shopdb -e "SELECT * FROM machines WHERE machinenumber LIKE 'TEST%' ORDER BY machineid DESC LIMIT 5;"