End to end tests

This commit is contained in:
MaddoScientisto 2026-04-12 19:31:12 +02:00
commit fed82d1ae8
26 changed files with 1016 additions and 37 deletions

View file

@ -39,6 +39,19 @@ try {
'token' => $token
));
$result = faceai_fetch_json($bridgeUrl);
$matches = is_array($result['matches'] ?? null) ? $result['matches'] : array();
$photos = array_map(static function ($match) {
$photoId = (string) ($match['photoId'] ?? ($match['id'] ?? ''));
return array(
'id' => $photoId,
'photoId' => $photoId,
'label' => (string) ($match['label'] ?? $photoId),
'checkpoint' => (string) ($match['checkpoint'] ?? '-'),
'previewUrl' => (string) ($match['previewUrl'] ?? ''),
'score' => $match['score'] ?? null,
);
}, $matches);
faceai_sim_render_page(array(
'raceId' => (string) ($result['raceId'] ?? ($payload['raceId'] ?? '')),
@ -46,9 +59,9 @@ try {
'raceSlug' => (string) ($result['raceId'] ?? ($payload['raceId'] ?? '')),
'raceName' => (string) ($result['raceName'] ?? ('Race ' . ($payload['raceId'] ?? ''))),
'returnUrl' => (string) ($result['returnUrl'] ?? 'faceai_simulator.php'),
'banner' => 'Vista filtrata da FaceAI. Sono state trovate <strong>' . count($result['matches'] ?? array()) . '</strong> foto corrispondenti per l utente corrente.',
'totalLabel' => count($result['matches'] ?? array()) . ' foto da FaceAI',
'photos' => is_array($result['matches'] ?? null) ? $result['matches'] : array(),
'banner' => 'Vista filtrata da FaceAI. Sono state trovate <strong>' . count($photos) . '</strong> foto corrispondenti per l utente corrente.',
'totalLabel' => count($photos) . ' foto da FaceAI',
'photos' => $photos,
'showSimulatorBootstrap' => false
));
} catch (Throwable $error) {

View file

@ -153,17 +153,24 @@ function faceai_sim_render_page(array $options)
<div class="gallery-grid">
<?php foreach ($photos as $photo): ?>
<?php
$photoId = (string) ($photo['id'] ?? ($photo['photoId'] ?? ''));
$photoLabel = (string) ($photo['label'] ?? ($photoId !== '' ? $photoId : ($photo['thumb'] ?? 'Foto senza etichetta')));
$photoPreviewUrl = (string) ($photo['previewUrl'] ?? '');
$photoThumb = (string) ($photo['thumb'] ?? $photoId);
$photoCheckpoint = (string) ($photo['checkpoint'] ?? '-');
?>
<div class="gallery-card">
<div class="gallery-thumb">
<?php if (!empty($photo['previewUrl'])): ?>
<img src="<?php echo faceai_sim_html($photo['previewUrl']); ?>" alt="<?php echo faceai_sim_html($photo['label']); ?>">
<?php if ($photoPreviewUrl !== ''): ?>
<img src="<?php echo faceai_sim_html($photoPreviewUrl); ?>" alt="<?php echo faceai_sim_html($photoLabel); ?>">
<?php else: ?>
<?php echo faceai_sim_html($photo['thumb'] ?? $photo['id']); ?>
<?php echo faceai_sim_html($photoThumb); ?>
<?php endif; ?>
</div>
<strong><?php echo faceai_sim_html($photo['label'] ?? $photo['id']); ?></strong><br>
<small>ID foto: <?php echo faceai_sim_html($photo['id'] ?? ''); ?></small><br>
<small>Punto foto: <?php echo faceai_sim_html($photo['checkpoint'] ?? '-'); ?></small>
<strong><?php echo faceai_sim_html($photoLabel); ?></strong><br>
<small>ID foto: <?php echo faceai_sim_html($photoId); ?></small><br>
<small>Punto foto: <?php echo faceai_sim_html($photoCheckpoint); ?></small>
</div>
<?php endforeach; ?>
</div>
@ -226,6 +233,7 @@ window.faceAiSimulator = {
</script>
<?php endif; ?>
<script src="vendor/jquery/jquery.min.js"></script>
<script src="vendor/popper/popper.min.js"></script>
<script src="vendor/bootstrap/js/bootstrap.min.js"></script>
<script src="_js/rus-ecom-240621.js"></script>
</body>