Files
shopdb/tests/test_savemachine.html
cproudlock 65b622c361 Add USB checkout system and SSO profile page
New Features:
- USB Device checkout/check-in system with barcode scanning
  - displayusb.asp: List all USB devices with status
  - addusb.asp: Add new USB devices via barcode scan
  - checkout_usb.asp/savecheckout_usb.asp: Check out USB to SSO
  - checkin_usb.asp/savecheckin_usb.asp: Check in with wipe confirmation
  - usb_history.asp: Full checkout history with filters
  - api_usb.asp: JSON API for AJAX lookups
- displayprofile.asp: SSO profile page showing user info and USB history
- Date/time format changed to 12-hour (MM/DD/YYYY h:mm AM/PM)
- SSO links in USB history now link to profile page via search

Database:
- New machinetypeid 44 for USB devices
- New usb_checkouts table for tracking checkouts

Cleanup:
- Removed v2 folder (duplicate/old files)
- Removed old debug/test files
- Removed completed migration documentation

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-07 11:16:14 -05:00

351 lines
12 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Test savemachine_direct.asp</title>
<style>
body {
font-family: Arial, sans-serif;
max-width: 900px;
margin: 50px auto;
padding: 20px;
background-color: #f5f5f5;
}
.test-form {
background: white;
padding: 30px;
border-radius: 8px;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
margin-bottom: 20px;
}
h1 {
color: #333;
margin-bottom: 20px;
}
h2 {
color: #666;
font-size: 18px;
margin-top: 0;
border-bottom: 1px solid #eee;
padding-bottom: 10px;
}
.form-group {
margin-bottom: 15px;
}
label {
display: block;
margin-bottom: 5px;
font-weight: bold;
color: #555;
}
input[type="text"],
select {
width: 100%;
padding: 10px;
border: 1px solid #ddd;
border-radius: 4px;
box-sizing: border-box;
}
.highlight {
background-color: #fff3cd;
border-color: #ffc107;
}
.note {
font-size: 12px;
color: #888;
margin-top: 3px;
}
button {
background-color: #007bff;
color: white;
padding: 12px 24px;
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 16px;
margin-right: 10px;
}
button:hover {
background-color: #0056b3;
}
button.secondary {
background-color: #6c757d;
}
button.secondary:hover {
background-color: #545b62;
}
button.success {
background-color: #28a745;
}
button.success:hover {
background-color: #1e7e34;
}
.info-box {
background-color: #e7f3ff;
border: 1px solid #b3d4fc;
padding: 15px;
border-radius: 4px;
margin-bottom: 20px;
}
.warning-box {
background-color: #fff3cd;
border: 1px solid #ffc107;
padding: 15px;
border-radius: 4px;
margin-bottom: 20px;
}
.error-box {
background-color: #f8d7da;
border: 1px solid #f5c6cb;
padding: 15px;
border-radius: 4px;
margin-bottom: 20px;
}
code {
background-color: #f4f4f4;
padding: 2px 6px;
border-radius: 3px;
font-family: monospace;
}
.test-cases {
background: #f8f9fa;
padding: 20px;
border-radius: 8px;
margin-top: 20px;
}
.test-cases h3 {
margin-top: 0;
}
.test-case {
margin-bottom: 15px;
padding: 10px;
background: white;
border-radius: 4px;
border-left: 4px solid #007bff;
}
.test-case.error-test {
border-left-color: #dc3545;
}
.test-case strong {
display: block;
margin-bottom: 5px;
}
#result {
margin-top: 20px;
padding: 15px;
border-radius: 4px;
display: none;
}
#result.show {
display: block;
}
#result.success {
background-color: #d4edda;
border: 1px solid #c3e6cb;
}
#result.error {
background-color: #f8d7da;
border: 1px solid #f5c6cb;
}
#result pre {
white-space: pre-wrap;
word-wrap: break-word;
max-height: 400px;
overflow-y: auto;
background: #f4f4f4;
padding: 10px;
border-radius: 4px;
font-size: 12px;
}
.form-row {
display: flex;
gap: 15px;
}
.form-row .form-group {
flex: 1;
}
iframe {
width: 100%;
height: 500px;
border: 1px solid #ddd;
border-radius: 4px;
margin-top: 20px;
}
</style>
</head>
<body>
<h1>Test: savemachine_direct.asp</h1>
<div class="info-box">
<strong>Purpose:</strong> Test the machine creation form with nested entity creation (new vendor, new model).
<br><br>
<strong>Expected Bug:</strong> When <code>newmodelmachinetypeid</code> is empty, the page should show
"Machine type is required for new model" error, but may return a 500 error instead.
<br><br>
<strong>Note:</strong> 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.
</div>
<form class="test-form" action="http://192.168.122.151:8080/savemachine_direct.asp" method="POST" id="testForm" target="resultFrame">
<h2>Test Case: New Model with Missing Machine Type</h2>
<div class="form-row">
<div class="form-group">
<label>Machine Number (required)</label>
<input type="text" name="machinenumber" value="TEST-001" id="machinenumber" required>
</div>
<div class="form-group">
<label>Business Unit ID</label>
<input type="text" name="businessunitid" value="1">
</div>
</div>
<div class="form-row">
<div class="form-group">
<label>Model ID</label>
<input type="text" name="modelid" value="new">
<div class="note">Set to "new" to trigger new model creation</div>
</div>
<div class="form-group">
<label>New Model Number</label>
<input type="text" name="newmodelnumber" value="TestModel">
</div>
</div>
<div class="form-row">
<div class="form-group">
<label>New Vendor ID</label>
<input type="text" name="newvendorid" value="new">
<div class="note">Set to "new" to trigger new vendor creation</div>
</div>
<div class="form-group">
<label>New Vendor Name</label>
<input type="text" name="newvendorname" value="TestVendor">
</div>
</div>
<div class="form-group highlight">
<label>New Model Machine Type ID (BUG TRIGGER FIELD)</label>
<input type="text" name="newmodelmachinetypeid" value="" id="machinetypeid">
<div class="note"><strong>BUG TEST:</strong> Leave empty to test validation error handling.
Should show "Machine type is required" but may cause 500 error.</div>
</div>
<div class="form-row">
<div class="form-group">
<label>Alias (optional)</label>
<input type="text" name="alias" value="">
</div>
<div class="form-group">
<label>Machine Notes (optional)</label>
<input type="text" name="machinenotes" value="">
</div>
</div>
<div class="form-row">
<div class="form-group">
<label>Map Left (optional)</label>
<input type="text" name="mapleft" value="">
</div>
<div class="form-group">
<label>Map Top (optional)</label>
<input type="text" name="maptop" value="">
</div>
</div>
<hr style="margin: 20px 0;">
<button type="submit">Submit Test (Expect Error)</button>
<button type="button" class="secondary" onclick="fillValidData()">Fill Valid Data</button>
<button type="button" class="success" onclick="randomizeMachineNumber()">Randomize Machine #</button>
</form>
<h3>Response:</h3>
<iframe name="resultFrame" id="resultFrame"></iframe>
<div class="test-cases">
<h3>Quick Test Scenarios</h3>
<div class="test-case error-test">
<strong>Test 1: Empty Machine Type (Current)</strong>
Submit with empty <code>newmodelmachinetypeid</code>.
<br>Expected: "Machine type is required for new model" error message.
<br>Possible Bug: 500 Internal Server Error if validation fails improperly.
</div>
<div class="test-case">
<strong>Test 2: Valid Machine Type</strong>
Click "Fill Valid Data" button, then submit.
This should create the machine successfully (if the machine number doesn't exist).
</div>
<div class="test-case error-test">
<strong>Test 3: Duplicate Machine Number</strong>
If the machine number already exists, submit should show "Machine number already exists" error.
</div>
<div class="test-case">
<strong>Test 4: Use Existing Model</strong>
Change <code>modelid</code> from "new" to a valid model ID (e.g., 1, 2, 3).
This bypasses new model creation entirely.
</div>
</div>
<div class="test-form" style="margin-top: 20px;">
<h2>Quick Database Check (Run on Server)</h2>
<p>After testing, run this SQL to verify the data:</p>
<pre>
-- 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;"
</pre>
</div>
<script>
function fillValidData() {
// Set a valid machine type ID (1 is typically CNC Machine or similar)
document.getElementById('machinetypeid').value = '1';
randomizeMachineNumber();
alert('Set machine type ID to 1 and randomized machine number. Form should now submit successfully.');
}
function randomizeMachineNumber() {
const random = Math.floor(Math.random() * 10000);
const timestamp = Date.now().toString().slice(-6);
document.getElementById('machinenumber').value = 'TEST-' + timestamp + '-' + random;
}
// Log form submission
document.getElementById('testForm').addEventListener('submit', function(e) {
const formData = new FormData(this);
let data = 'Submitting to: ' + this.action + '\n\nForm Data:\n';
for (let [key, value] of formData.entries()) {
data += ` ${key}: "${value}"\n`;
}
console.log(data);
});
</script>
</body>
</html>