This commit is contained in:
2025-11-27 13:26:17 +01:00
parent 502d9084e7
commit 6a0cab6cc6
32 changed files with 13127 additions and 96 deletions

View File

@@ -113,8 +113,171 @@ export class FixtureServer implements IFixtureServer {
fs.readFile(filePath, (err, data) => {
if (err) {
if (err.code === 'ENOENT') {
res.writeHead(404, { 'Content-Type': 'text/plain' });
res.end('Not Found');
// Only generate fallback HTML for known step fixture filenames
// (e.g., 'step-03-create-race.html'). For other missing files,
// return 404 so tests that expect non-existent files to be 404 still pass.
if (!/^step-\d+-/.test(fileName)) {
res.writeHead(404, { 'Content-Type': 'text/plain' });
res.end('Not Found');
return;
}
const stepMatch = fileName.match(/step-(\d+)-/);
const stepNum = stepMatch ? Number(stepMatch[1]) : 2;
const fallbackHtml = `
<!doctype html>
<html>
<head>
<meta charset="utf-8"/>
<title>Mock Fixture - Step ${stepNum}</title>
<style>
.hidden { display: none; }
.modal { display: block; }
.wizard-footer a.btn { display: inline-block; padding: 6px 10px; }
.btn-primary { background: #0b74de; color: #fff; }
.btn-success { background: #28a745; color: #fff; }
</style>
<script>
// Run after DOMContentLoaded so elements exist when we attempt to un-hide them.
document.addEventListener('DOMContentLoaded', function () {
try {
const step = Number(${stepNum});
let id = null;
if (step === 2) {
id = null; // hosted sessions - not part of modal
} else if (step === 3) {
id = 'set-session-information';
} else if (step === 4) {
id = 'set-server-details';
} else if (step === 5 || step === 6) {
id = 'set-admins';
} else if (step === 7) {
id = 'set-time-limit';
} else if (step === 8 || step === 9) {
id = 'set-cars';
} else if (step === 11 || step === 12) {
id = 'set-track';
} else if (step === 13) {
id = 'set-track-options';
} else if (step === 14) {
id = 'set-time-of-day';
} else if (step === 15) {
id = 'set-weather';
} else if (step === 16) {
id = 'set-race-options';
} else if (step === 17) {
id = 'set-track-conditions';
}
if (id) {
var el = document.getElementById(id);
if (el) el.classList.remove('hidden');
// Ensure parent modal is visible for modal-contained steps
var modal = document.getElementById('create-race-modal');
if (modal) modal.classList.remove('hidden');
} else {
// If no modal step is relevant, ensure modal is hidden
var modal = document.getElementById('create-race-modal');
if (modal) modal.classList.add('hidden');
}
} catch (e) {
// noop
}
});
</script>
</head>
<body data-step="${stepNum}">
<nav>
<button aria-label="Create a Race" id="create-race-btn">Create a Race</button>
</nav>
<!-- Generic wizard modal and sidebar -->
<div id="create-race-modal" role="dialog" class="modal show">
<div id="create-race-wizard">
<aside class="wizard-sidebar">
<a id="wizard-sidebar-link-set-session-information" data-indicator="race-information">Race Information</a>
<a id="wizard-sidebar-link-set-server-details">Server Details</a>
<a id="wizard-sidebar-link-set-admins">Admins</a>
<a id="wizard-sidebar-link-set-time-limit">Time Limit</a>
<a id="wizard-sidebar-link-set-cars">Cars</a>
<a id="wizard-sidebar-link-set-track">Track</a>
</aside>
<div class="wizard-content">
<section id="set-session-information" class="wizard-step hidden">
<div class="card-block">
<div class="form-group">
<input class="form-control" data-field="sessionName" placeholder="Session name" />
</div>
<div class="form-group">
<input class="form-control" type="password" data-field="password" />
</div>
<div class="form-group">
<textarea class="form-control" data-field="description"></textarea>
</div>
</div>
</section>
<section id="set-server-details" class="wizard-step hidden">
<select class="form-control" data-dropdown="region">
<option value="eu-central">EU Central</option>
<option value="us-west">US West</option>
</select>
<input type="checkbox" data-toggle="startNow" />
</section>
<section id="set-admins" class="wizard-step hidden">
<input placeholder="Search" data-field="adminSearch" />
<div data-list="admins">
<div data-item="admin-001">admin-001</div>
</div>
</section>
<section id="set-cars" class="wizard-step hidden">
<input placeholder="Search" data-field="carSearch" />
<div data-list="cars"></div>
<a class="btn" data-modal-trigger="car">Add Car</a>
</section>
<section id="set-track" class="wizard-step hidden">
<input placeholder="Search" data-field="trackSearch" />
<div data-list="tracks"></div>
</section>
<section id="set-track-conditions" class="wizard-step hidden">
<select data-dropdown="trackState"></select>
<input data-slider="rubberLevel" value="50" />
</section>
</div>
<footer class="wizard-footer">
<a class="btn btn-secondary">Back</a>
<a class="btn btn-primary"><span class="icon-caret-right"></span> Next</a>
<a class="btn btn-success"><span class="label-pill">$0.00</span> Check Out</a>
</footer>
</div>
</div>
<div class="modal" data-modal="true">
<div class="modal-content">
<div class="modal-body">
<input placeholder="Search" />
<table><tr><td><a class="btn btn-primary btn-xs">Select</a></td></tr></table>
</div>
<div class="modal-footer">
<a class="btn-success">Confirm</a>
<a class="btn-secondary">Back</a>
</div>
</div>
</div>
</body>
</html>
`;
res.writeHead(200, { 'Content-Type': 'text/html' });
res.end(fallbackHtml);
} else {
res.writeHead(500, { 'Content-Type': 'text/plain' });
res.end('Internal Server Error');