Add E2E tests and harness for customer assignment modal:
- Implemented end-to-end test cases for validating `AssignDraftOrderCustomerModal` workflows, including error handling and behavior consistency. - Introduced test harness in `change-customer-modal.html` and `change-customer-modal.ts` to facilitate testing of modal interactions. - Added supporting unit tests for modal behavior and integration with session data.
This commit is contained in:
@@ -1194,42 +1194,70 @@ function processPendingEdgeGatewayClaims(edgeGatewayFixture) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const gatewayId = edgeGatewayFixture.nextGatewayId++;
|
||||
const gatewayId = Number(claim.reuse_gateway_id || 0);
|
||||
const claimedAt = toSqlDateTime();
|
||||
const auditLog = {
|
||||
id: Date.now(),
|
||||
created_at: claimedAt,
|
||||
action: "GATEWAY_CLAIMED",
|
||||
actor_type: "USER",
|
||||
};
|
||||
const metadata = {
|
||||
broker_connected: true,
|
||||
system_metrics: {
|
||||
latency_ms: 73,
|
||||
cpu_usage_pct: 19,
|
||||
memory_usage_pct: 44,
|
||||
disk_usage_pct: 52,
|
||||
},
|
||||
};
|
||||
const existingGateway =
|
||||
gatewayId > 0 ? edgeGatewayFixture.gateways.find((gateway) => Number(gateway.id) === gatewayId) || null : null;
|
||||
|
||||
if (existingGateway) {
|
||||
Object.assign(existingGateway, {
|
||||
department_id: Number(claim.department_id || existingGateway.department_id || 1),
|
||||
label: claim.label || existingGateway.label || `Gateway ${gatewayId}`,
|
||||
hostname: existingGateway.hostname || `edge-${gatewayId}`,
|
||||
is_primary: true,
|
||||
status: "ONLINE",
|
||||
transport_mode: "gateway",
|
||||
department_transport_mode: "gateway",
|
||||
installed_version: existingGateway.installed_version || "php-agent-v1",
|
||||
target_version: existingGateway.target_version || existingGateway.installed_version || "php-agent-v1",
|
||||
last_heartbeat_at: claimedAt,
|
||||
last_seen_ip: "10.9.0.14",
|
||||
discovery_status: existingGateway.discovery_status || "READY",
|
||||
metadata: {
|
||||
...(existingGateway.metadata || {}),
|
||||
...metadata,
|
||||
},
|
||||
audit_logs: [auditLog, ...(existingGateway.audit_logs || [])],
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
const newGatewayId = edgeGatewayFixture.nextGatewayId++;
|
||||
edgeGatewayFixture.gateways.push({
|
||||
id: gatewayId,
|
||||
id: newGatewayId,
|
||||
department_id: Number(claim.department_id || 1),
|
||||
label: claim.label || `Gateway ${gatewayId}`,
|
||||
hostname: `edge-${gatewayId}`,
|
||||
label: claim.label || `Gateway ${newGatewayId}`,
|
||||
hostname: `edge-${newGatewayId}`,
|
||||
is_primary: true,
|
||||
status: "ONLINE",
|
||||
transport_mode: "gateway",
|
||||
department_transport_mode: "gateway",
|
||||
installed_version: "php-agent-v1",
|
||||
target_version: "php-agent-v1",
|
||||
last_heartbeat_at: toSqlDateTime(),
|
||||
last_heartbeat_at: claimedAt,
|
||||
last_seen_ip: "10.9.0.14",
|
||||
discovery_status: "READY",
|
||||
metadata: {
|
||||
broker_connected: true,
|
||||
system_metrics: {
|
||||
latency_ms: 73,
|
||||
cpu_usage_pct: 19,
|
||||
memory_usage_pct: 44,
|
||||
disk_usage_pct: 52,
|
||||
},
|
||||
},
|
||||
metadata,
|
||||
inventory: [],
|
||||
bindings: [],
|
||||
recent_commands: [],
|
||||
operations: [],
|
||||
audit_logs: [
|
||||
{
|
||||
id: Date.now(),
|
||||
created_at: toSqlDateTime(),
|
||||
action: "GATEWAY_CLAIMED",
|
||||
actor_type: "USER",
|
||||
},
|
||||
],
|
||||
audit_logs: [auditLog],
|
||||
});
|
||||
|
||||
return false;
|
||||
@@ -1329,6 +1357,7 @@ function createHttpEdgeGatewayFixture(options = {}) {
|
||||
nextOperationId: 9901,
|
||||
nextOperationEventId: 19901,
|
||||
claimPollsRemaining: Number(options.claimPollsRemaining || 2),
|
||||
reuseClaimGatewayId: Number(options.reuseClaimGatewayId || 0),
|
||||
pendingClaims: [],
|
||||
pendingDiscoveryByGatewayId: {},
|
||||
gateways: baseGateways,
|
||||
@@ -2913,6 +2942,7 @@ async function handleEdgeGatewayRoute({
|
||||
department_id: Number(body.department_id || 1),
|
||||
label: String(body.label || "").trim(),
|
||||
pollsRemaining: edgeGatewayFixture.claimPollsRemaining,
|
||||
reuse_gateway_id: edgeGatewayFixture.reuseClaimGatewayId,
|
||||
});
|
||||
await route.fulfill(
|
||||
json(
|
||||
|
||||
Reference in New Issue
Block a user