test(ios-test-app): add invalid data test buttons and improve error detection
Add three test buttons (Empty, Invalid, Negative) below the "Test Notification"
button to test invalid time format handling. Each button attempts to schedule
a notification with invalid values: empty string, "25:00" (invalid hour), and
"-1:30" (negative time).
Improve TEST 3 error detection in test-phase1.sh by:
- Making grep case-insensitive to catch ERROR/invalid patterns
- Adding DNP-* error prefix patterns for plugin error logs
- Documenting that Capacitor bridge errors (⚡️ logs) appear in Xcode console
but not in system logs captured by xcrun simctl
This commit is contained in:
@@ -40,6 +40,17 @@
|
||||
background: rgba(255, 255, 255, 0.3);
|
||||
transform: translateY(-2px);
|
||||
}
|
||||
.button-row {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
gap: 10px;
|
||||
margin: 10px 0;
|
||||
}
|
||||
.button-row .button {
|
||||
margin: 0;
|
||||
padding: 10px 15px;
|
||||
font-size: 14px;
|
||||
}
|
||||
.status {
|
||||
margin-top: 30px;
|
||||
padding: 20px;
|
||||
@@ -73,6 +84,11 @@
|
||||
<button class="button" onclick="configurePlugin()">Configure Plugin</button>
|
||||
<button class="button" onclick="requestPermissions()">Request Permissions</button>
|
||||
<button class="button" onclick="testNotification()">Test Notification</button>
|
||||
<div class="button-row">
|
||||
<button class="button" onclick="testEmptyNotification()">Empty</button>
|
||||
<button class="button" onclick="testInvalidNotification()">Invalid</button>
|
||||
<button class="button" onclick="testNegativeNotification()">Negative</button>
|
||||
</div>
|
||||
<button class="button" onclick="checkComprehensiveStatus()">Full System Status</button>
|
||||
|
||||
<div id="status" class="status">
|
||||
@@ -394,9 +410,118 @@
|
||||
}
|
||||
}
|
||||
|
||||
// Invalid data test functions
|
||||
function testEmptyNotification() {
|
||||
console.log('testEmptyNotification called');
|
||||
const status = document.getElementById('status');
|
||||
status.innerHTML = 'Testing with empty time string...';
|
||||
status.style.background = 'rgba(255, 255, 0, 0.3)'; // Yellow background
|
||||
|
||||
try {
|
||||
if (!window.DailyNotification) {
|
||||
status.innerHTML = 'DailyNotification plugin not available';
|
||||
status.style.background = 'rgba(255, 0, 0, 0.3)'; // Red background
|
||||
return;
|
||||
}
|
||||
|
||||
window.DailyNotification.scheduleDailyNotification({
|
||||
time: '', // Empty string
|
||||
title: 'Test Empty',
|
||||
body: 'This should fail gracefully',
|
||||
sound: true,
|
||||
priority: 'high'
|
||||
})
|
||||
.then(() => {
|
||||
status.innerHTML = '⚠️ Unexpected: Empty time was accepted (should have been rejected)';
|
||||
status.style.background = 'rgba(255, 165, 0, 0.3)'; // Orange background
|
||||
})
|
||||
.catch(error => {
|
||||
status.innerHTML = '✅ Empty time rejected as expected<br>' +
|
||||
`Error: ${error.message}`;
|
||||
status.style.background = 'rgba(0, 255, 0, 0.3)'; // Green background
|
||||
});
|
||||
} catch (error) {
|
||||
status.innerHTML = `Error: ${error.message}`;
|
||||
status.style.background = 'rgba(255, 0, 0, 0.3)'; // Red background
|
||||
}
|
||||
}
|
||||
|
||||
function testInvalidNotification() {
|
||||
console.log('testInvalidNotification called');
|
||||
const status = document.getElementById('status');
|
||||
status.innerHTML = 'Testing with invalid time format (25:00)...';
|
||||
status.style.background = 'rgba(255, 255, 0, 0.3)'; // Yellow background
|
||||
|
||||
try {
|
||||
if (!window.DailyNotification) {
|
||||
status.innerHTML = 'DailyNotification plugin not available';
|
||||
status.style.background = 'rgba(255, 0, 0, 0.3)'; // Red background
|
||||
return;
|
||||
}
|
||||
|
||||
window.DailyNotification.scheduleDailyNotification({
|
||||
time: '25:00', // Invalid time (hour > 23)
|
||||
title: 'Test Invalid',
|
||||
body: 'This should fail gracefully',
|
||||
sound: true,
|
||||
priority: 'high'
|
||||
})
|
||||
.then(() => {
|
||||
status.innerHTML = '⚠️ Unexpected: Invalid time was accepted (should have been rejected)';
|
||||
status.style.background = 'rgba(255, 165, 0, 0.3)'; // Orange background
|
||||
})
|
||||
.catch(error => {
|
||||
status.innerHTML = '✅ Invalid time rejected as expected<br>' +
|
||||
`Error: ${error.message}`;
|
||||
status.style.background = 'rgba(0, 255, 0, 0.3)'; // Green background
|
||||
});
|
||||
} catch (error) {
|
||||
status.innerHTML = `Error: ${error.message}`;
|
||||
status.style.background = 'rgba(255, 0, 0, 0.3)'; // Red background
|
||||
}
|
||||
}
|
||||
|
||||
function testNegativeNotification() {
|
||||
console.log('testNegativeNotification called');
|
||||
const status = document.getElementById('status');
|
||||
status.innerHTML = 'Testing with negative time (-1:30)...';
|
||||
status.style.background = 'rgba(255, 255, 0, 0.3)'; // Yellow background
|
||||
|
||||
try {
|
||||
if (!window.DailyNotification) {
|
||||
status.innerHTML = 'DailyNotification plugin not available';
|
||||
status.style.background = 'rgba(255, 0, 0, 0.3)'; // Red background
|
||||
return;
|
||||
}
|
||||
|
||||
window.DailyNotification.scheduleDailyNotification({
|
||||
time: '-1:30', // Negative time
|
||||
title: 'Test Negative',
|
||||
body: 'This should fail gracefully',
|
||||
sound: true,
|
||||
priority: 'high'
|
||||
})
|
||||
.then(() => {
|
||||
status.innerHTML = '⚠️ Unexpected: Negative time was accepted (should have been rejected)';
|
||||
status.style.background = 'rgba(255, 165, 0, 0.3)'; // Orange background
|
||||
})
|
||||
.catch(error => {
|
||||
status.innerHTML = '✅ Negative time rejected as expected<br>' +
|
||||
`Error: ${error.message}`;
|
||||
status.style.background = 'rgba(0, 255, 0, 0.3)'; // Green background
|
||||
});
|
||||
} catch (error) {
|
||||
status.innerHTML = `Error: ${error.message}`;
|
||||
status.style.background = 'rgba(255, 0, 0, 0.3)'; // Red background
|
||||
}
|
||||
}
|
||||
|
||||
// Attach to window object
|
||||
window.configurePlugin = configurePlugin;
|
||||
window.testNotification = testNotification;
|
||||
window.testEmptyNotification = testEmptyNotification;
|
||||
window.testInvalidNotification = testInvalidNotification;
|
||||
window.testNegativeNotification = testNegativeNotification;
|
||||
window.requestPermissions = requestPermissions;
|
||||
window.checkComprehensiveStatus = checkComprehensiveStatus;
|
||||
|
||||
|
||||
@@ -517,10 +517,25 @@ The app should show an error message and NOT crash."
|
||||
device_id=$(get_simulator_id)
|
||||
logs=$(get_app_logs "${device_id}" 50)
|
||||
|
||||
if echo "${logs}" | grep -q "error\|invalid\|Error"; then
|
||||
# Debug: Show captured logs if verbose (uncomment to debug)
|
||||
# echo "DEBUG: Captured logs:"
|
||||
# echo "${logs}"
|
||||
|
||||
# Check for error patterns (case-insensitive):
|
||||
# - error/invalid keywords
|
||||
# - DNP-* error prefixes (plugin error logs)
|
||||
# - invalid_time_format (error code)
|
||||
# - ERROR MESSAGE (Capacitor bridge prefix, if it appears in system logs)
|
||||
if echo "${logs}" | grep -qiE "error|invalid|DNP-.*(error|fail|reject)|invalid_time_format|ERROR MESSAGE"; then
|
||||
print_success "Error handling detected in logs"
|
||||
else
|
||||
print_info "No errors in recent logs (may indicate graceful handling)"
|
||||
print_info "No errors in recent system logs (may indicate graceful handling)"
|
||||
print_warn "Note: Capacitor bridge errors (⚡️ logs in Xcode console) may not appear in system logs."
|
||||
print_info "The plugin uses call.reject() which logs to Xcode console, not system logs."
|
||||
print_info "Verify error handling by checking:"
|
||||
print_info " 1. Xcode console for ⚡️ ERROR MESSAGE logs"
|
||||
print_info " 2. App UI shows error messages (not crashes)"
|
||||
print_info " 3. Valid notifications still work after errors"
|
||||
fi
|
||||
|
||||
wait_for_ui_action "Verify that:
|
||||
|
||||
Reference in New Issue
Block a user