mirror of
https://github.com/mileswolfallen2/miles-web.git
synced 2026-12-04 15:57:47 +00:00
Add comprehensive test suite for application functionality
- Implement tests for HTTP API endpoints, ensuring correct responses and security headers. - Create configuration tests to validate loading of defaults and environment overrides. - Add tests for FEDL service to verify data handling and snapshot functionality. - Introduce GitHub service tests to check API data normalization and caching behavior. - Develop monitor service tests for network checks and uptime calculations. - Implement persistence tests to ensure database migrations are idempotent and data persists across restarts. - Add vault service tests for session management and brute-force protection mechanisms. - Include helper functions for test context creation and JSON response handling.
This commit is contained in:
1 parent
84b7a7e302
commit
c250653961
55 files changed
+8174
-226
No files matched your search
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Privacy-friendly pageview beacon.
|
||||
* - no cookies
|
||||
* - no localStorage identifier
|
||||
* - no query strings or fragments
|
||||
* - never runs on private or operator pages
|
||||
* The backend hashes the request IP with a daily rotating secret and discards it.
|
||||
*/
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
if (window.__milesAnalyticsLoaded) return;
|
||||
window.__milesAnalyticsLoaded = true;
|
||||
|
||||
var path = window.location.pathname || '/';
|
||||
var skip = [
|
||||
/^\/dashboard(?:\.html)?\/?$/,
|
||||
/^\/vault\/?$/,
|
||||
/^\/moon-vault(?:\.html)?$/,
|
||||
/^\/games(?:\/|$)/,
|
||||
/^\/api(?:\/|$)/,
|
||||
/^\/404(?:\.html)?$/
|
||||
];
|
||||
if (skip.some(function (pattern) { return pattern.test(path); })) return;
|
||||
|
||||
var meta = document.querySelector('meta[name="miles-analytics-endpoint"]');
|
||||
var endpoint = (meta && meta.getAttribute('content')) || '/api/analytics/hit';
|
||||
|
||||
var payload = {
|
||||
path: path,
|
||||
referrer: document.referrer || null
|
||||
};
|
||||
|
||||
function send() {
|
||||
try {
|
||||
var body = JSON.stringify(payload);
|
||||
fetch(endpoint, {
|
||||
method: 'POST',
|
||||
mode: 'cors',
|
||||
credentials: 'same-origin',
|
||||
cache: 'no-store',
|
||||
keepalive: true,
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: body
|
||||
}).catch(function () {});
|
||||
} catch (err) {
|
||||
// Analytics must never break the page.
|
||||
}
|
||||
}
|
||||
|
||||
if (document.readyState === 'complete') send();
|
||||
else window.addEventListener('load', send, { once: true });
|
||||
})();
|
||||
Reference in new issue
Block a user